Ryleeeee commited on
Commit
928c6f0
·
verified ·
1 Parent(s): a490586

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -26
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", 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("Sentiment classification: positive, neutral, negative")
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
- if max_label == "negative":
34
- # Streamlit application title
35
- st.title("Product categories of negative review")
36
- st.write("Product classification of this negative review: smartTv, books, mobile, mobile accessories and refrigerators")
37
-
38
- # Load the product classification model pipeline
39
- product_classifier = pipeline("text-classification", model='model_name', return_all_scores=True)
40
-
41
- # Perform product classification analysis when the user clicks the "Classify product" button
42
- if st.button("Classify product"):
43
- # Perform product classification analysis on the input text
44
- results_1 = product_classifier(text)[0]
45
-
46
- # Display the classification result
47
- max_score_1 = float('-inf')
48
- max_label_1 = ''
49
-
50
- for result_1 in results_1:
51
- if result_1['score'] > max_score_1:
52
- max_score_1 = result_1['score']
53
- max_label_1 = result_1['label']
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)