Spaces:
Sleeping
Sleeping
| from transformers import pipeline | |
| import gradio as gr | |
| # Load the model | |
| sentiment_model = pipeline("sentiment-analysis") | |
| # Define the app's logic | |
| def analyze_sentiment(text): | |
| result = sentiment_model(text)[0] # Get the first result | |
| label = result['label'] # Extract label (e.g., "POSITIVE" or "NEGATIVE") | |
| return label | |
| # Gradio interface | |
| interface = gr.Interface( | |
| fn=analyze_sentiment, | |
| inputs="text", | |
| outputs="text", | |
| ) | |
| interface.launch() | |