Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,17 @@
|
|
| 1 |
-
import torch
|
| 2 |
-
from transformers import pipeline
|
| 3 |
-
import gradio as gr
|
| 4 |
import pandas as pd
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
torch.set_safety_enabled(True)
|
| 10 |
|
| 11 |
-
# Load the model
|
| 12 |
model_nm = 'microsoft/deberta-v3-small'
|
| 13 |
classifier = pipeline("text-classification", model=model_nm)
|
| 14 |
|
| 15 |
-
# Read and preprocess data
|
| 16 |
-
df = pd.read_csv("path/to/train.csv") # Replace "path/to/train.csv" with the actual path
|
| 17 |
-
df.describe(include='object')
|
| 18 |
-
df['input'] = 'TEXT1: ' + df.context + '; TEXT2: ' + df.target + '; ANC1: ' + df.anchor
|
| 19 |
-
ds = Dataset.from_pandas(df)
|
| 20 |
-
|
| 21 |
# Define prediction function
|
| 22 |
def predict_text(input_text):
|
| 23 |
prediction = classifier(input_text)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import pandas as pd
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from transformers import pipeline
|
| 4 |
+
|
| 5 |
+
# URL of the CSV file
|
| 6 |
+
csv_url = "https://huggingface.co/spaces/kataniccc/tekst/blob/main/submission.csv"
|
| 7 |
|
| 8 |
+
# Read the CSV file into a pandas DataFrame
|
| 9 |
+
df = pd.read_csv(csv_url)
|
|
|
|
| 10 |
|
| 11 |
+
# Load the model for text classification
|
| 12 |
model_nm = 'microsoft/deberta-v3-small'
|
| 13 |
classifier = pipeline("text-classification", model=model_nm)
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
# Define prediction function
|
| 16 |
def predict_text(input_text):
|
| 17 |
prediction = classifier(input_text)
|