Spaces:
No application file
No application file
File size: 1,106 Bytes
9bc1121 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import streamlit as st
from transformers import pipeline
# Set page config
st.set_page_config(page_title="Sentiment Analyzer", layout="centered")
# Header
st.markdown("<h1 style='text-align: center; color: #4CAF50;'>🧠 Sentiment Analyzer App</h1>", unsafe_allow_html=True)
st.markdown("<p style='text-align: center;'>Using Hugging Face Transformers with Streamlit</p>", 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]})
|