Spaces:
Build error
Build error
Download app.py from keerthii05/Analysis: direct link, hf CLI and curl.
- Browser
- Download file 808 Bytes
-
https://huggingface.co/spaces/keerthii05/Analysis/resolve/main/app.py
- Command line
-
hf download hf://spaces/keerthii05/Analysis/app.py
-
curl -L -o app.py https://huggingface.co/spaces/keerthii05/Analysis/resolve/main/app.py
808 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| # Load the sentiment-analysis pipeline with a more reliable model | |
| model = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english") | |
| # Function for sentiment analysis | |
| def analyze_sentiment(feedback_text): | |
| result = model(feedback_text) | |
| sentiment = result[0]['label'] # The model outputs something like 'POSITIVE' or 'NEGATIVE' | |
| confidence = result[0]['score'] # The confidence score for the sentiment | |
| return sentiment, confidence | |
| # Gradio interface | |
| iface = gr.Interface(fn=analyze_sentiment, | |
| inputs="text", | |
| outputs=["text", "number"], | |
| live=True) # Set live=True to provide instant results as you type | |
| # Launch the interface | |
| iface.launch() | |