Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # Load sentiment analysis pipeline | |
| sentiment_pipeline = pipeline("sentiment-analysis") | |
| # Function for Gradio | |
| def analyze_sentiment(text): | |
| result = sentiment_pipeline(text) | |
| return f"{result[0]['label']} ({result[0]['score']:.2f})" | |
| # Gradio interface | |
| iface = gr.Interface( | |
| fn=analyze_sentiment, | |
| inputs="text", | |
| outputs="text", | |
| title="Sentiment Analysis App", | |
| description="Enter text to see if the sentiment is positive, negative, or neutral." | |
| ) | |
| iface.launch() | |