import gradio as gr | |
from transformers import pipeline | |
classifier = pipeline('text-classification', model="abhi227070/distilbert-base-uncased-finetuned-imdb") | |
def sentiment_analysis(text): | |
result = classifier(text) | |
return result[0]['label'], result[0]['score'] | |
iface = gr.Interface( | |
fn = sentiment_analysis, | |
inputs = gr.Textbox(label="Context", placeholder="Enter your text here...", lines = 5), | |
outputs = [gr.Textbox(label="Result"), gr.Textbox(label="Accuracy")] | |
) | |
iface.launch() |