Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # Load sentiment analysis model | |
| sentiment = pipeline("sentiment-analysis") | |
| # Function to analyze text | |
| def analyze_sentiment(text): | |
| if not text.strip(): | |
| return "Please enter some text!" | |
| result = sentiment(text)[0] | |
| return f"Label: {result['label']}, Score: {round(result['score'], 2)}" | |
| # Gradio interface | |
| iface = gr.Interface( | |
| fn=analyze_sentiment, | |
| inputs=gr.Textbox(lines=5, placeholder="Type your text here..."), | |
| outputs="text", | |
| title="๐ Sentiment Analyzer", | |
| description="Type any text and see if it is Positive, Negative, or Neutral!" | |
| ) | |
| iface.launch() |