Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| def sentiment_analysis(text): | |
| # Placeholder for sentiment analysis logic | |
| sentiment_analysis = pipeline("sentiment-analysis") | |
| result = sentiment_analysis(text) | |
| sentiment = result[0]['label'] | |
| score = result[0]['score'] | |
| if sentiment == "POSITIVE": | |
| return f"Positive sentiment with score: {score:.2f}" | |
| else: | |
| return f"Negative sentiment with score: {score:.2f}" | |
| with gr.Blocks() as demo: | |
| gr.Markdown("## Sentiment Analysis App") | |
| with gr.Column(): | |
| text_input = gr.Textbox(label="Enter text for sentiment analysis") | |
| sentiment_output = gr.Textbox(label="Sentiment Result") | |
| submit_btn = gr.Button("Analyze Sentiment") | |
| submit_btn.click(sentiment_analysis, inputs=text_input, outputs=sentiment_output) | |
| demo.launch() |