Spaces:
Runtime error
Runtime error
lqqqqqqqqq
commited on
Commit
•
84b6cc7
1
Parent(s):
9d9948c
Update app.py
Browse files
app.py
CHANGED
@@ -6,25 +6,28 @@ classifier = pipeline("text-classification", model="lqqqqqqqqq/FinetunedModelGr9
|
|
6 |
|
7 |
# Streamlit application title
|
8 |
st.title("Text Classification")
|
9 |
-
st.write("Classification for 3 labels: negative,
|
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 |
-
#
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
6 |
|
7 |
# Streamlit application title
|
8 |
st.title("Text Classification")
|
9 |
+
st.write("Classification for 3 labels: negative, neutral, positive")
|
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 |
+
if text.strip(): # Check if text is not empty
|
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)
|
32 |
+
else:
|
33 |
+
st.write("Please enter some text to classify.")
|