mim981 commited on
Commit
f339f2c
·
verified ·
1 Parent(s): 3ca5e89

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # Load a pretrained sentiment-analysis model from Hugging Face
5
+ @st.cache_resource
6
+ def load_model():
7
+ return pipeline("sentiment-analysis")
8
+
9
+ model = load_model()
10
+
11
+ # Streamlit UI
12
+ st.title("🧠 Sentiment Analysis App")
13
+ st.write("Type a sentence and find out if it’s Positive or Negative!")
14
+
15
+ user_input = st.text_area("Enter your text here 👇")
16
+
17
+ if st.button("Analyze Sentiment"):
18
+ if user_input.strip():
19
+ result = model(user_input)[0]
20
+ st.success(f"**Label:** {result['label']} | **Score:** {result['score']:.2f}")
21
+ else:
22
+ st.warning("Please enter some text!")