Bhagyajoshi commited on
Commit
c77b825
·
verified ·
1 Parent(s): a7ea231

Upload 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
+ def load_model():
5
+ return pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english")
6
+
7
+ classifier = load_model()
8
+
9
+ st.title("Text Classification App")
10
+ st.write("Enter a sentence: ")
11
+
12
+ user_input = st.text_area("Enter text here:")
13
+
14
+ if st.button("Classify Sentiment"):
15
+ if user_input:
16
+ result = classifier(user_input)
17
+ label = result[0]['label']
18
+ score = result[0]['score']
19
+
20
+ if label == "POSITIVE":
21
+ st.write("Sentiment: Positive 😊")
22
+ else:
23
+ st.write("Sentiment: Negative 😟")
24
+ st.write(f"Confidence Score: {score:.2f}")
25
+ else:
26
+ st.write("Please enter text to classify.")