jems9376's picture
Create app.py
f5875c8 verified
Raw
History Blame Contribute Delete
563 Bytes
import gradio as gr
from transformers import pipeline
classifier = pipeline(
"sentiment-analysis",
model="distilbert-base-uncased-finetuned-sst-2-english"
)
def analyze_sentiment(text):
result = classifier(text)[0]
return f"Sentiment: {result['label']}\nConfidence: {result['score']:.2%}"
app = gr.Interface(
fn=analyze_sentiment,
inputs=gr.Textbox(lines=4, placeholder="Enter text here..."),
outputs=gr.Textbox(),
title="Sentiment Analysis App",
description="Analyze whether a text is Positive or Negative."
)
app.launch()