djohari commited on
Commit
4a1a5d4
1 Parent(s): 923a64b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # Load the text classification model pipeline
5
+ classifier = pipeline("text-classification", model='djohari/EmployeeEmotionAnalysis', return_all_scores=True)
6
+
7
+ # Streamlit application title
8
+ st.title("Text Classification")
9
+ st.write("Classification for 6 emotions: sadness, joy, love, anger, fear, surprise")
10
+
11
+ # Text input for user to enter the text to classify
12
+ text = st.text_area("Enter the text to classify", "")
13
+
14
+ # Perform text classification when the user clicks the "Classify" button
15
+ if st.button("Classify"):
16
+ # Perform text classification on the input text
17
+ results = classifier(text)[0]
18
+
19
+ # Display the classification result
20
+ max_score = float('-inf')
21
+ max_label = ''
22
+ for result in results:
23
+ if result['score'] > max_score:
24
+ max_score = result['score']
25
+ max_label = result['label']
26
+
27
+ st.write("Text:", text)
28
+ st.write("Label:", max_label)
29
+ st.write("Score:", max_score)