File size: 507 Bytes
4a2a22b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
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() |