Spaces:
Sleeping
Sleeping
File size: 547 Bytes
40bac30 c52adb8 40bac30 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import gradio as gr
from transformers import pipeline
def analyze_sentiment(text):
classifier = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english")
result = classifier(text)
return {
"label": result[0]["label"],
"score": result[0]["score"]
}
demo = gr.Interface(
fn=analyze_sentiment,
inputs="textbox",
outputs="json",
title="Sentiment Analysis",
description="Enter text to analyze its sentiment using DistilBERT."
)
demo.queue(api_open=True)
demo.launch() |