Spaces:
Runtime error
Runtime error
| from transformers import pipeline | |
| import gradio as gr | |
| # Load sentiment analysis pipeline | |
| sentiment_pipeline = pipeline("sentiment-analysis") | |
| # Define function for prediction | |
| def analyze_sentiment(text): | |
| result = sentiment_pipeline(text)[0] | |
| label = result['label'] | |
| score = result['score'] | |
| return f"{label} ({score:.2f})" | |
| # Create Gradio interface | |
| interface = gr.Interface(fn=analyze_sentiment, | |
| inputs="text", | |
| outputs="text", | |
| title="Sentiment Analyzer", | |
| description="Type a sentence to see if it's Positive or Negative") | |
| # Launch the app | |
| interface.launch() |