Ryleeeee commited on
Commit
7bacf44
·
verified ·
1 Parent(s): 87fefb3

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # Load the sentiment analysis model pipeline
5
+ classifier = pipeline("text-classification",model='Ryleeeee/CustomSentimentModel', return_all_scores=True)
6
+
7
+ # Streamlit application title and background image
8
+ st.image("./header.png")
9
+ st.title("Sentiment Analysis")
10
+ st.write("Setiment classification: positive, netural, negative")
11
+
12
+ # User can enter the customer review
13
+ text = st.text_area("Enter the customer review", "")
14
+
15
+ # Perform sentiment analysis when the user clicks the "Classify sentiment" button
16
+ if st.button("Classify sentiment"):
17
+ # Perform sentiment analysis on the input text
18
+ results = classifier(text)[0]
19
+
20
+ # Display the classification result
21
+ max_score = float('-inf')
22
+ max_label = ''
23
+
24
+ for result in results:
25
+ if result['score'] > max_score:
26
+ max_score = result['score']
27
+ max_label = result['label']
28
+
29
+ st.write("Label:", max_label)
30
+ st.write("Score:", max_score)
31
+