Spaces:
Build error
Build error
Download app.py from bertiekeller/ml: direct link, hf CLI and curl.
- Browser
- Download file 662 Bytes
-
https://huggingface.co/spaces/bertiekeller/ml/resolve/main/app.py
- Command line
-
hf download hf://spaces/bertiekeller/ml/app.py
-
curl -L -o app.py https://huggingface.co/spaces/bertiekeller/ml/resolve/main/app.py
662 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| # Initialize the sentiment analysis pipeline | |
| classifier = pipeline("sentiment-analysis") | |
| def analyze_sentiment(text): | |
| result = classifier(text) | |
| return result[0]['label'], result[0]['score'] | |
| # Create Gradio interface | |
| demo = gr.Interface( | |
| fn=analyze_sentiment, | |
| inputs=gr.Textbox(label="Enter text to analyze"), | |
| outputs=[ | |
| gr.Label(label="Sentiment"), | |
| gr.Number(label="Confidence Score") | |
| ], | |
| title="Sentiment Analysis Demo", | |
| description="Enter some text to analyze its sentiment using Hugging Face's transformers." | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() |