Ashleyinust commited on
Commit
6957001
1 Parent(s): 1bdc8ce

Update app.py

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