Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| sentiment_pipeline = pipeline( | |
| "sentiment-analysis", | |
| model="distilbert-base-uncased-finetuned-sst-2-english" | |
| ) | |
| def analyze(text): | |
| result = sentiment_pipeline(text)[0] | |
| label = result["label"] | |
| score = result["score"] | |
| return f"{label} ({score:.2%} confidence)" | |
| demo = gr.Interface( | |
| fn=analyze, | |
| inputs=gr.Textbox(placeholder="Type something..."), | |
| outputs=gr.Textbox(label="Result"), | |
| title="Sentiment Analyzer" | |
| ) | |
| demo.launch() | |