deeplearningwithpython5240 commited on
Commit
595443b
·
verified ·
1 Parent(s): db41ca1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -36,10 +36,10 @@ def chi2eng(filtered_data):
36
  language_Classification = langid.classify(filtered_data[0])[0]
37
  if language_Classification == "zh":
38
  st.write("Your input is Chinese, translating to English")
39
- st.write('▶️ Translation model start downing, loading model may takes time, please wait...')
40
  trans_pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-zh-en")
41
- st.write('⏺️ Translation model successfully loaded')
42
- st.write('▶️ Start translating...')
43
  translation_progress_count = 0
44
  translation_bar = st.progress(0)
45
  for i in filtered_data:
@@ -55,13 +55,13 @@ def chi2eng(filtered_data):
55
 
56
  # Text Classification:Negative/Neutral/Positive
57
  def emotion_classification(translated_data):
58
- st.write('▶️ Classification model start downing, loading model may takes time, please wait...')
59
  emo_pipe = pipeline("text-classification", model="deeplearningwithpython5240/twitter_roberta_base_sentiment_fintune_with_app_reviews")
60
- st.write('⏺️ Classification model successfully loaded')
61
  negative_count, neutral_count, positive_count = 0,0,0
62
  negative_dict = {}
63
  emotion_progress_count = 0
64
- st.write('▶️ Data processing ...')
65
  emotion_bar = st.progress(0)
66
  for i in translated_data:
67
  labelled_result = emo_pipe(i)[0]['label']
@@ -78,7 +78,7 @@ def emotion_classification(translated_data):
78
  emotion_progress_count += 1/len(translated_data)
79
  emotion_bar.progress(emotion_progress_count)
80
  sizes = [negative_count, neutral_count, positive_count]
81
- labels = ['negative_review', 'neutral_review', 'positive_review']
82
  # 创建饼状图
83
  st.write('Number of Positive Reviews: ', positive_count)
84
  st.write('Number of Neutral Reviews: ', neutral_count)
@@ -107,9 +107,9 @@ def emotion_classification(translated_data):
107
 
108
  # Summarization
109
  def summarization(top10_negative_str):
110
- st.write('▶️ Summarizatio model start downing, loading model may takes time, please wait...')
111
  summarize_pipe = pipeline("text2text-generation", model="deeplearningwithpython5240/summarisation-t5-finetuned-model", max_new_tokens =512)
112
- st.write('⏺️ Summarization model successfully loaded')
113
  st.write('▶️ Summarizing...')
114
  summarized_text = summarize_pipe(top10_negative_str)
115
  return summarized_text
@@ -149,7 +149,8 @@ def main():
149
  #stage 4:Summarization
150
  st.text('🔶 Processing Summarization 🔶')
151
  summarized_text = summarization(top10_negative_str)
152
- st.write(summarized_text)
 
153
  st.text('️️🟢 Summarization Finished 🟢')
154
  except:
155
  st.write("")
 
36
  language_Classification = langid.classify(filtered_data[0])[0]
37
  if language_Classification == "zh":
38
  st.write("Your input is Chinese, translating to English")
39
+ st.write('▶️ Loading Translation Model...')
40
  trans_pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-zh-en")
41
+ st.write('⏺️ Translation Model Successfully Loaded')
42
+ st.write('▶️ Start Translating...')
43
  translation_progress_count = 0
44
  translation_bar = st.progress(0)
45
  for i in filtered_data:
 
55
 
56
  # Text Classification:Negative/Neutral/Positive
57
  def emotion_classification(translated_data):
58
+ st.write('▶️ Loading Classification Model...')
59
  emo_pipe = pipeline("text-classification", model="deeplearningwithpython5240/twitter_roberta_base_sentiment_fintune_with_app_reviews")
60
+ st.write('⏺️ Classification Model Successfully Loaded')
61
  negative_count, neutral_count, positive_count = 0,0,0
62
  negative_dict = {}
63
  emotion_progress_count = 0
64
+ st.write('▶️ Data Processing ...')
65
  emotion_bar = st.progress(0)
66
  for i in translated_data:
67
  labelled_result = emo_pipe(i)[0]['label']
 
78
  emotion_progress_count += 1/len(translated_data)
79
  emotion_bar.progress(emotion_progress_count)
80
  sizes = [negative_count, neutral_count, positive_count]
81
+ labels = ['Negative_Reviews', 'Neutral_Reviews', 'Positive_Reviews']
82
  # 创建饼状图
83
  st.write('Number of Positive Reviews: ', positive_count)
84
  st.write('Number of Neutral Reviews: ', neutral_count)
 
107
 
108
  # Summarization
109
  def summarization(top10_negative_str):
110
+ st.write('▶️ Loading Summarizatio Model...')
111
  summarize_pipe = pipeline("text2text-generation", model="deeplearningwithpython5240/summarisation-t5-finetuned-model", max_new_tokens =512)
112
+ st.write('⏺️ Summarization Model Successfully Loaded')
113
  st.write('▶️ Summarizing...')
114
  summarized_text = summarize_pipe(top10_negative_str)
115
  return summarized_text
 
149
  #stage 4:Summarization
150
  st.text('🔶 Processing Summarization 🔶')
151
  summarized_text = summarization(top10_negative_str)
152
+ st.write('Summarized Negative Comments:')
153
+ st.write(summarized_text[0]["generated_text"])
154
  st.text('️️🟢 Summarization Finished 🟢')
155
  except:
156
  st.write("")