Spaces:
Sleeping
Sleeping
Download app.py from Alpha108/sentiment_analyzer: direct link, hf CLI and curl.
- Browser
- Download file 763 Bytes
-
https://huggingface.co/spaces/Alpha108/sentiment_analyzer/resolve/main/app.py
- Command line
-
hf download hf://spaces/Alpha108/sentiment_analyzer/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Alpha108/sentiment_analyzer/resolve/main/app.py
763 Bytes
| import streamlit as st | |
| from transformers import pipeline | |
| # Page setup | |
| st.set_page_config(page_title="π Sentiment Analyzer", layout="centered") | |
| st.title("π Sentiment Analyzer") | |
| st.markdown("Enter text below and see if it's Positive, Negative, or Neutral.") | |
| # Load model | |
| def load_model(): | |
| return pipeline("sentiment-analysis") | |
| analyzer = load_model() | |
| # User input | |
| text = st.text_area("Enter your text here:") | |
| if st.button("Analyze"): | |
| if text.strip(): | |
| with st.spinner("Analyzing..."): | |
| result = analyzer(text)[0] | |
| st.subheader("π Result:") | |
| st.write(f"**Label:** {result['label']} | **Confidence:** {result['score']:.2f}") | |
| else: | |
| st.warning("β οΈ Please enter some text first!") | |