frankai98 commited on
Commit
b271a7a
·
verified ·
1 Parent(s): ea9d7f1

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # My model code
2
+ import streamlit as st
3
+ from transformers import pipeline
4
+
5
+ # Load the text classification model pipeline
6
+ classifier = pipeline("text-classification",model='isom5240ust/bert-base-uncased-emotion', return_all_scores=True)
7
+
8
+ # Streamlit application title
9
+ st.title("Text Classification for you")
10
+ st.write("Classification for 6 emotions: sadness, joy, love, anger, fear, surprise")
11
+
12
+ # Text input for user to enter the text to classify
13
+ text = st.text_area("Enter the text to classify", "")
14
+
15
+ # Perform text classification when the user clicks the "Classify" button
16
+ if st.button("Classify"):
17
+ # Perform text classification 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("Text:", text)
30
+ st.write("Label:", max_label)
31
+ st.write("Score:", max_score)