Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # Load pre-trained sentiment-analysis pipeline | |
| classifier = pipeline("sentiment-analysis") | |
| # Define the function for prediction | |
| def analyze_sentiment(text): | |
| result = classifier(text)[0] | |
| return f"Label: {result['label']} (Score: {result['score']:.2f})" | |
| # Create a Gradio interface | |
| app = gr.Interface( | |
| fn=analyze_sentiment, | |
| inputs=gr.Textbox(label="Enter a sentence"), | |
| outputs=gr.Textbox(label="Sentiment") | |
| ) | |
| app.launch() | |