Spaces:
Sleeping
Sleeping
Download app.py from steevshaji123/MyFirstApp: direct link, hf CLI and curl.
- Browser
- Download file 513 Bytes
-
https://huggingface.co/spaces/steevshaji123/MyFirstApp/resolve/main/app.py
- Command line
-
hf download hf://spaces/steevshaji123/MyFirstApp/app.py
-
curl -L -o app.py https://huggingface.co/spaces/steevshaji123/MyFirstApp/resolve/main/app.py
513 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| # Initialize the sentiment analysis pipeline | |
| sentiment_pipeline = pipeline("sentiment-analysis") | |
| def get_sentiment(input_text): | |
| result = sentiment_pipeline(input_text) # fixed typo | |
| return result[0]['label'] | |
| # Launch the web UI | |
| iface = gr.Interface( | |
| fn=get_sentiment, | |
| inputs='text', | |
| outputs='text', | |
| title="My First AI App", | |
| description="Enter some text and I will tell you whether it is positive or negative" | |
| ) | |
| iface.launch() | |