Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load Hugging Face model
|
5 |
+
model_name = "distilbert-base-uncased-finetuned-sst-2-english"
|
6 |
+
classifier = pipeline("sentiment-analysis", model=model_name)
|
7 |
+
|
8 |
+
# Streamlit UI
|
9 |
+
st.title("🤖 Sentiment Analysis App")
|
10 |
+
st.write("Enter some English text below to analyze sentiment.")
|
11 |
+
|
12 |
+
user_input = st.text_area("Text input", height=150)
|
13 |
+
|
14 |
+
if st.button("Predict"):
|
15 |
+
if user_input.strip() == "":
|
16 |
+
st.warning("Please enter some text.")
|
17 |
+
else:
|
18 |
+
with st.spinner("Analyzing..."):
|
19 |
+
result = classifier(user_input)[0]
|
20 |
+
st.success(f"**Label**: {result['label']} \n**Confidence**: {result['score']:.4f}")
|