Spaces:
Sleeping
Sleeping
Download app.py from AbdulQadoos/SentimentAnalysis: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/spaces/AbdulQadoos/SentimentAnalysis/resolve/main/app.py
- Command line
-
hf download hf://spaces/AbdulQadoos/SentimentAnalysis/app.py
-
curl -L -o app.py https://huggingface.co/spaces/AbdulQadoos/SentimentAnalysis/resolve/main/app.py
1.03 kB
| import streamlit as st | |
| from transformers import pipeline | |
| import tensorflow | |
| import torch | |
| # Create a sentiment analysis pipeline | |
| pipe = pipeline("sentiment-analysis") | |
| # Streamlit UI | |
| st.title("Sentiment Analysis with Transformers") | |
| sentence = st.text_area("Enter a sentence:") | |
| if st.button("Analyze"): | |
| if sentence: | |
| result = pipe(sentence) | |
| st.write("Sentiment:", result[0]['label'], "with confidence:", result[0]['score']) | |
| else: | |
| st.warning("Please enter a sentence.") | |
| # Deployment-specific code | |
| if __name__ == "__main__": | |
| import hugginface_hub | |
| commit_message = "Deploying Sentiment Analysis app" | |
| repo_id = "your-huggingface-username/your-repo-name" # Replace with your repo details | |
| branch = "main" # Replace with your desired branch | |
| with st.spinner("Deploying to Hugging Face Spaces..."): | |
| huggingface_hub.deploy( | |
| repo_id=repo_id, | |
| branch=branch, | |
| commit_message=commit_message, | |
| ) | |
| st.success("Deployment successful!") | |