Spaces:
Sleeping
Sleeping
Download app.py from keerthii05/Sentiment-Analysis: direct link, hf CLI and curl.
- Browser
- Download file 534 Bytes
-
https://huggingface.co/spaces/keerthii05/Sentiment-Analysis/resolve/main/app.py
- Command line
-
hf download hf://spaces/keerthii05/Sentiment-Analysis/app.py
-
curl -L -o app.py https://huggingface.co/spaces/keerthii05/Sentiment-Analysis/resolve/main/app.py
534 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| # Load pre-trained sentiment-analysis pipeline | |
| model = pipeline("sentiment-analysis", model="distilbert-base-uncased") | |
| # Function to classify sentiment | |
| def analyze_sentiment(feedback_text): | |
| result = model(feedback_text) | |
| return result[0]['label'], result[0]['score'] # returns label and confidence score | |
| # Gradio interface | |
| iface = gr.Interface(fn=analyze_sentiment, | |
| inputs="text", | |
| outputs=["text", "number"]) | |
| iface.launch() | |