Ryleeeee commited on
Commit
e93d87a
·
verified ·
1 Parent(s): 8699379

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -4,8 +4,12 @@ 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
  # Streamlit application title and background image
8
- st.image("./header.png", width=600, use_column_width=False)
 
9
  st.markdown("<h1 style='text-align: center;'>Customer Review Analysis</h1>", unsafe_allow_html=True)
10
 
11
  st.write("Setiment classification: positive, netural, negative")
@@ -22,7 +26,12 @@ def sentiment_class(text):
22
  max_score = result['score']
23
  max_label = result['label']
24
  return max_score, max_label
25
-
 
 
 
 
 
26
  # Perform sentiment analysis when the user clicks the "Classify Sentiment" button
27
  if st.button("Classify Sentiment"):
28
  # Check if the user has entered review
@@ -34,3 +43,5 @@ if st.button("Classify Sentiment"):
34
  st.write("This review sentiment is ", sentiment_result[1])
35
  st.write("Prediction score is ", sentiment_result[0])
36
 
 
 
 
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
+ summarizer = pipeline("summarization", model="MurkatG/review-summarizer-en")
9
+
10
  # Streamlit application title and background image
11
+ # st.image("./header.png", width=300, use_column_width=False)
12
+ st.markdown("<div style='text-align:center'><img src='./header.png' width='300'></div>", unsafe_allow_html=True)
13
  st.markdown("<h1 style='text-align: center;'>Customer Review Analysis</h1>", unsafe_allow_html=True)
14
 
15
  st.write("Setiment classification: positive, netural, negative")
 
26
  max_score = result['score']
27
  max_label = result['label']
28
  return max_score, max_label
29
+
30
+ def summarize_text(text):
31
+ results = summarizer(text)[0]['summary_text']
32
+ return results
33
+
34
+
35
  # Perform sentiment analysis when the user clicks the "Classify Sentiment" button
36
  if st.button("Classify Sentiment"):
37
  # Check if the user has entered review
 
43
  st.write("This review sentiment is ", sentiment_result[1])
44
  st.write("Prediction score is ", sentiment_result[0])
45
 
46
+ if sentiment_result[1] == 'negative':
47
+ st.button("Summarize Review")