AhsanSaghir / app.py
AhsanSaghir's picture
Update app.py
ef37f64 verified
raw
history blame
551 Bytes
import gradio as gr
from transformers import pipeline
# Load a simple sentiment analysis model
classifier = pipeline("sentiment-analysis")
def analyze_text(text):
result = classifier(text)[0]
return f"Label: {result['label']}, Confidence: {result['score']:.2f}"
# Create the Gradio interface
demo = gr.Interface(
fn=analyze_text,
inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
outputs="text",
title="Text Sentiment Analysis",
description="Enter some text and I'll analyze its sentiment.",
)
demo.launch()