Download app.py from Arhashmi/Sentiment: direct link, hf CLI and curl.
- Browser
- Download file 738 Bytes
-
https://huggingface.co/spaces/Arhashmi/Sentiment/resolve/main/app.py
- Command line
-
hf download hf://spaces/Arhashmi/Sentiment/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Arhashmi/Sentiment/resolve/main/app.py
738 Bytes
| import streamlit as st | |
| from transformers import pipeline | |
| model_path = "citizenlab/twitter-xlm-roberta-base-sentiment-finetunned" | |
| st.set_page_config(page_title="Sentiment Analysis App") | |
| sentiment_classifier = pipeline("text-classification", model=model_path, tokenizer=model_path) | |
| st.title("Sentiment Analysis App") | |
| user_input = st.text_area("Enter a message:") | |
| if st.button("Analyze Sentiment"): | |
| if user_input: | |
| # Perform sentiment analysis | |
| results = sentiment_classifier(user_input) | |
| sentiment_label = results[0]["label"] | |
| sentiment_score = results[0]["score"] | |
| st.write(f"Sentiment: {sentiment_label}") | |
| st.write(f"Confidence Score: {sentiment_score:.2f}") | |
| # Run the Streamlit app |