Ryleeeee commited on
Commit
fd16468
·
verified ·
1 Parent(s): a1dc42b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -5
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 text summarization model pipeline
8
- product_categorizer = pipeline("zero-shot-classification", model="MoritzLaurer/deberta-v3-xsmall-zeroshot-v1.1-all-33")
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("Setiment classification: positive, netural, negative")
 
 
 
 
 
 
 
 
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("Product category: ", category)
 
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}")