Download app.py from amoeed004/MLOPs: direct link, hf CLI and curl.
- Browser
- Download file 875 Bytes
-
https://huggingface.co/spaces/amoeed004/MLOPs/resolve/main/app.py
- Command line
-
hf download hf://spaces/amoeed004/MLOPs/app.py
-
curl -L -o app.py https://huggingface.co/spaces/amoeed004/MLOPs/resolve/main/app.py
875 Bytes
| from transformers import pipeline | |
| import gradio as gr | |
| # Load the sentiment analysis pipeline | |
| model = pipeline("sentiment-analysis") | |
| def predict_sentiment(user_input): | |
| if not user_input.strip(): | |
| return "Please enter some text to analyze." | |
| result = model(user_input)[0] | |
| return f"Sentiment: {result['label']} (Confidence: {result['score']:.2f})" | |
| interface = gr.Interface( | |
| fn=predict_sentiment, | |
| inputs=gr.Textbox(lines=5, placeholder="Enter text to analyze...", label="User Input"), | |
| outputs="text", | |
| title="Sentiment Analysis Tool", | |
| description="This tool predicts whether the sentiment of the given text is Positive, Negative, or Neutral.", | |
| examples=[ | |
| "I love spending time with my family!", | |
| "This weather is terrible.", | |
| "The movie was okay, not great but not bad." | |
| ] | |
| ) | |
| interface.launch(share=True) | |