Spaces:
Sleeping
Sleeping
Download app.py from Vivekfriendly/simpleapp: direct link, hf CLI and curl.
- Browser
- Download file 807 Bytes
-
https://huggingface.co/spaces/Vivekfriendly/simpleapp/resolve/main/app.py
- Command line
-
hf download hf://spaces/Vivekfriendly/simpleapp/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Vivekfriendly/simpleapp/resolve/main/app.py
807 Bytes
| from transformers import pipeline | |
| import gradio as gr | |
| # Load the sentiment analysis pipeline | |
| sentiment_model = pipeline("sentiment-analysis") | |
| # Function to use the model | |
| def analyze_sentiment(text): | |
| result = sentiment_model(text)[0] | |
| label = result['label'] | |
| score = result['score'] | |
| return f"Sentiment: {label}, Confidence: {score:.2f}" | |
| # Gradio interface | |
| interface = gr.Interface(fn=analyze_sentiment, | |
| inputs=gr.Textbox(lines=2, placeholder="Enter text here..."), | |
| outputs="text", | |
| title="Sentiment Analyzer", | |
| description="Enter a sentence to analyze its sentiment.") | |
| # Launch the app (comment this out if you're uploading to Hugging Face) | |
| if __name__ == "__main__": | |
| interface.launch() | |