Spaces:
Sleeping
Sleeping
Download app.py from llamalib/sentiment_analysis: direct link, hf CLI and curl.
- Browser
- Download file 847 Bytes
-
https://huggingface.co/spaces/llamalib/sentiment_analysis/resolve/main/app.py
- Command line
-
hf download hf://spaces/llamalib/sentiment_analysis/app.py
-
curl -L -o app.py https://huggingface.co/spaces/llamalib/sentiment_analysis/resolve/main/app.py
847 Bytes
| 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() |