SANMUGAPIRIYA/Sentimentanalysis
0
1import gradio as gr2from transformers import pipeline3 4# Load Sentiment Analysis model5sentiment_pipeline = pipeline("sentiment-analysis")6 7def analyze_sentiment(text):8 result = sentiment_pipeline(text)[0]9 return f"Sentiment: {result['label']} (Confidence: {result['score']:.2f})"10 11# Create Gradio Interface12iface = gr.Interface(13 fn=analyze_sentiment,14 inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),15 outputs="text",16 title="Sentiment Analysis API",17 description="Enter a sentence, and the model will predict if it's POSITIVE or NEGATIVE."18)19 20# Launch the Gradio app21iface.launch()