import gradio as gr from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline id2label = {0: "Negative", 1: "Positive"} label2id = {"Negative":0, "Positive":1} # Load the tokenizer and model tokenizer = AutoTokenizer.from_pretrained('distilbert/distilbert-base-uncased', add_prefix_space=True) model = AutoModelForSequenceClassification.from_pretrained('AmirRghp/distilbert-base-uncasedimdb-text-classification') # Create the pipeline classifier = pipeline('text-classification', model=model, tokenizer=tokenizer) def classify_text(text): result = classifier(text) return result gr.Interface(fn=classify_text, inputs="text", outputs="json").launch()