Alpha108 commited on
Commit
e702a97
·
verified ·
1 Parent(s): cf56530

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # Page setup
5
+ st.set_page_config(page_title="😊 Sentiment Analyzer", layout="centered")
6
+ st.title("😊 Sentiment Analyzer")
7
+ st.markdown("Enter text below and see if it's Positive, Negative, or Neutral.")
8
+
9
+ # Load model
10
+ @st.cache_resource
11
+ def load_model():
12
+ return pipeline("sentiment-analysis")
13
+
14
+ analyzer = load_model()
15
+
16
+ # User input
17
+ text = st.text_area("Enter your text here:")
18
+
19
+ if st.button("Analyze"):
20
+ if text.strip():
21
+ with st.spinner("Analyzing..."):
22
+ result = analyzer(text)[0]
23
+ st.subheader("📌 Result:")
24
+ st.write(f"**Label:** {result['label']} | **Confidence:** {result['score']:.2f}")
25
+ else:
26
+ st.warning("⚠️ Please enter some text first!")