import streamlit as st from transformers import pipeline # Set page config st.set_page_config(page_title="Sentiment Analyzer", layout="centered") # Header st.markdown("

🧠 Sentiment Analyzer App

", unsafe_allow_html=True) st.markdown("

Using Hugging Face Transformers with Streamlit

", unsafe_allow_html=True) # Input area st.write("### Enter your text below:") text = st.text_area("") # Button to run analysis if st.button("🔍 Analyze Sentiment"): if text.strip() == "": st.warning("Please enter some text!") else: # Load model classifier = pipeline("sentiment-analysis") result = classifier(text)[0] label = result["label"] score = result["score"] # Output result st.success(f"**Sentiment:** {label}") st.info(f"**Confidence Score:** {score:.2f}") # Display bar chart st.write("### Sentiment Analysis Results") st.bar_chart({"Sentiment": [label], "Score": [score]})