chat / app.py
Joe7oo7's picture
Update app.py
884c2a2 verified
import gradio as gr
from transformers import pipeline
# Load a sentiment analysis model
classifier = pipeline("sentiment-analysis")
# Define the function for sentiment analysis
def analyze_sentiment(text):
result = classifier(text)
return result
# Create a Gradio interface
iface = gr.Interface(
fn=analyze_sentiment,
inputs=gr.inputs.Textbox(lines=2, placeholder="Type your text here..."),
outputs=gr.outputs.Label(num_top_classes=1),
title="Sentiment Analysis",
description="Enter a sentence to analyze its sentiment."
)
# Launch the Gradio app
iface.launch()