import torch from transformers import pipeline import gradio as gr import pandas as pd from datasets import Dataset # Enable SafeTensors if available if torch.__version__ >= "1.10": torch.set_safety_enabled(True) # Load the model model_nm = 'microsoft/deberta-v3-small' classifier = pipeline("text-classification", model=model_nm) # Read and preprocess data df = pd.read_csv("path/to/train.csv") # Replace "path/to/train.csv" with the actual path df.describe(include='object') df['input'] = 'TEXT1: ' + df.context + '; TEXT2: ' + df.target + '; ANC1: ' + df.anchor ds = Dataset.from_pandas(df) # Define prediction function def predict_text(input_text): prediction = classifier(input_text) return prediction # Define Gradio interface text_input = gr.inputs.Textbox(lines=7, label="Unesite tekst") output_text = gr.outputs.Textbox(label="Predikcija") gr.Interface(predict_text, inputs=text_input, outputs=output_text).launch()