JustHuggingFaces commited on
Commit
570a6f9
1 Parent(s): 44ee5e5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -17
app.py CHANGED
@@ -1,23 +1,25 @@
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
13
- results = classifier(text)[0]
14
- # Display the classification result
15
- max_score = float('-inf')
16
- max_label = ''
17
- for result in results:
18
- if result['score'] > max_score:
19
- max_score = result['score']
20
- max_label = result['label']
21
- st.write("Text:", text)
22
- st.write("Label:", max_label)
23
- st.write("Score:", max_score
 
1
  import streamlit as st
2
  from transformers import pipeline
3
+ import soundfile as sf
4
+ $ pip install txtai[pipeline]
5
+ from txtai.pipeline import TextToSpeech
6
+
7
+ # Load the text classification model pipeline, filter out the spam and leave the ham
8
+ classifier = pipeline("text-classification", model='JustHuggingFaces/OptimalSpamDetect', return_all_scores=True)
9
+ to_speech = TextToSpeech("NeuML/ljspeech-jets-onnx")
10
  # Streamlit application title
11
+ st.title("Reading Ham")
12
+ st.write("Classification for Spam Email: spam or ham?")
13
  # Text input for user to enter the text to classify
14
+ text = st.text_area("Paste the email to classify", "")
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
+ # Display the classification result
20
+ spam = "LABEL_1"
21
+ ham = "LABEL_0"
22
+ for result in results:
23
+ if result['label'] == spam:
24
+ #st.write("Text:", text)
25
+ st.write("Label: Spam")