Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,13 +2,13 @@ import streamlit as st
|
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
# Load the sentiment analysis model pipeline
|
| 5 |
-
classifier = pipeline("text-classification",
|
| 6 |
|
| 7 |
# Streamlit application title and background image
|
| 8 |
st.image("./header.png", use_column_width=True)
|
| 9 |
st.title("Step 1: Sentiment Analysis", use_column_width=True)
|
| 10 |
|
| 11 |
-
st.write("
|
| 12 |
|
| 13 |
# User can enter the customer review
|
| 14 |
text = st.text_area("Enter the customer review", "")
|
|
@@ -30,27 +30,25 @@ if st.button("Classify sentiment"):
|
|
| 30 |
st.write("This review sentiment is:", max_label)
|
| 31 |
st.write("Accuracy rate is:", max_score)
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
# Perform product classification analysis
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
st.write("This negative review belongs to:", max_label_1)
|
| 56 |
-
st.write("Accuracy rate is:", max_score_1)
|
|
|
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
# Load the sentiment analysis model pipeline
|
| 5 |
+
classifier = pipeline("text-classification",model='Ryleeeee/CustomSentimentModel', return_all_scores=True)
|
| 6 |
|
| 7 |
# Streamlit application title and background image
|
| 8 |
st.image("./header.png", use_column_width=True)
|
| 9 |
st.title("Step 1: Sentiment Analysis", use_column_width=True)
|
| 10 |
|
| 11 |
+
st.write("Setiment classification: positive, netural, negative")
|
| 12 |
|
| 13 |
# User can enter the customer review
|
| 14 |
text = st.text_area("Enter the customer review", "")
|
|
|
|
| 30 |
st.write("This review sentiment is:", max_label)
|
| 31 |
st.write("Accuracy rate is:", max_score)
|
| 32 |
|
| 33 |
+
|
| 34 |
+
if max_lable == "negative":
|
| 35 |
+
# Streamlit application title
|
| 36 |
+
st.title("Product categories of negative review")
|
| 37 |
+
st.write("Product classification of this negative review: smartTv, books, mobile, mobile accessories and refrigerators")
|
| 38 |
+
|
| 39 |
+
# Perform product classification analysis when the user clicks the "Classify product" button
|
| 40 |
+
if st.button("Classify product"):
|
| 41 |
+
# Perform product classification analysis on the input text
|
| 42 |
+
results_1 = classifier(text)[0]
|
| 43 |
+
|
| 44 |
+
# Display the classification result
|
| 45 |
+
max_score_1 = float('-inf')
|
| 46 |
+
max_label_1 = ''
|
| 47 |
+
|
| 48 |
+
for result_1 in results_1:
|
| 49 |
+
if result_1['score_1'] > max_score_1:
|
| 50 |
+
max_score_1 = result_1['score_1']
|
| 51 |
+
max_label_1 = result_1['label_1']
|
| 52 |
+
|
| 53 |
+
st.write("This negative review belongs to:", max_label_1)
|
| 54 |
+
st.write("Accuracy rate is:", max_score_1)
|
|
|
|
|
|