Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| from transformers import pipeline | |
| st.set_page_config(page_title="Sentiment Analyzer", page_icon="π¬") | |
| # Load sentiment analysis pipeline | |
| def load_model(): | |
| return pipeline("sentiment-analysis") | |
| sentiment_analyzer = load_model() | |
| st.title("π¬ Sentiment Analysis App") | |
| st.write("Enter some text and the model will predict its sentiment.") | |
| # User input | |
| user_input = st.text_area("Enter your text here:", height=150) | |
| # Button to analyze sentiment | |
| if st.button("Analyze Sentiment"): | |
| if user_input.strip() == "": | |
| st.warning("β οΈ Please enter some text.") | |
| else: | |
| with st.spinner("Analyzing..."): | |
| result = sentiment_analyzer(user_input)[0] | |
| label = result['label'] | |
| score = result['score'] | |
| st.success(f"**Sentiment:** {label}") | |
| st.info(f"**Confidence:** {score:.2f}") |