import streamlit as st from transformers import pipeline st.set_page_config(page_title="Sentiment Analyzer", page_icon="💬") # Load sentiment analysis pipeline @st.cache_resource 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}")