File size: 682 Bytes
eb8b23b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import streamlit as st
from transformers import pipeline

# Load Hugging Face model
model_name = "distilbert-base-uncased-finetuned-sst-2-english"
classifier = pipeline("sentiment-analysis", model=model_name)

# Streamlit UI
st.title("🤖 Sentiment Analysis App")
st.write("Enter some English text below to analyze sentiment.")

user_input = st.text_area("Text input", height=150)

if st.button("Predict"):
    if user_input.strip() == "":
        st.warning("Please enter some text.")
    else:
        with st.spinner("Analyzing..."):
            result = classifier(user_input)[0]
            st.success(f"**Label**: {result['label']}  \n**Confidence**: {result['score']:.4f}")