Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,14 +4,22 @@ from transformers import pipeline
|
|
| 4 |
# Load the sentiment analysis model pipeline
|
| 5 |
sentiment_classifier = pipeline("text-classification",model='Ryleeeee/CustomSentimentModel', return_all_scores=True)
|
| 6 |
|
| 7 |
-
# Load the
|
| 8 |
-
product_categorizer = pipeline("
|
| 9 |
|
| 10 |
# Streamlit application title and background image
|
| 11 |
st.image("./header.png", use_column_width=True)
|
| 12 |
st.markdown("<h1 style='text-align: center;'>Customer Review Analysis</h1>", unsafe_allow_html=True)
|
| 13 |
|
| 14 |
-
st.write("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
# User can enter the customer review
|
| 17 |
review = st.text_area("Enter the customer review", "")
|
|
@@ -44,5 +52,5 @@ if st.button("Classify Sentiment"):
|
|
| 44 |
|
| 45 |
# Perform text summarization when the review sentiment is classified as negative
|
| 46 |
if sentiment_result[1] == 'negative':
|
| 47 |
-
category = product_category(review)
|
| 48 |
-
st.write("
|
|
|
|
| 4 |
# Load the sentiment analysis model pipeline
|
| 5 |
sentiment_classifier = pipeline("text-classification",model='Ryleeeee/CustomSentimentModel', return_all_scores=True)
|
| 6 |
|
| 7 |
+
# Load the product category classification model pipeline
|
| 8 |
+
product_categorizer = pipeline("text-classification", model="Ryleeeee/CustomProductCategoryModel")
|
| 9 |
|
| 10 |
# Streamlit application title and background image
|
| 11 |
st.image("./header.png", use_column_width=True)
|
| 12 |
st.markdown("<h1 style='text-align: center;'>Customer Review Analysis</h1>", unsafe_allow_html=True)
|
| 13 |
|
| 14 |
+
st.write("Sentiment classification: positive, netural, negative")
|
| 15 |
+
st.write("Product category classification: books, mobile, mobile accessories, refrigerator, smartTv")
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
product_dic = {0: "books", 1: "mobile", 2: "mobile accessories", 3: "refrigerator", 4: "smartTv"}
|
| 19 |
+
predictions3 = [output_dic[int(o['label'].split("_")[1])] for o in output3]
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
|
| 23 |
|
| 24 |
# User can enter the customer review
|
| 25 |
review = st.text_area("Enter the customer review", "")
|
|
|
|
| 52 |
|
| 53 |
# Perform text summarization when the review sentiment is classified as negative
|
| 54 |
if sentiment_result[1] == 'negative':
|
| 55 |
+
category = output_dic[int(product_category(review)["label"].split("_")[1])]
|
| 56 |
+
st.write(f"Category of the faulty product is {category}")
|