lqqqqqqqqq commited on
Commit
51caef2
1 Parent(s): a59bc98

Create app.py

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