Update app.py
Browse files
app.py
CHANGED
@@ -39,9 +39,13 @@ def chi2eng(filtered_data):
|
|
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 |
for i in filtered_data:
|
43 |
-
st.write(trans_pipe(i)[0]['translation_text'])
|
44 |
translated_data.append(trans_pipe(i)[0]['translation_text'])
|
|
|
|
|
45 |
elif language_Classification == 'en':
|
46 |
st.write("Your input is English, moving to next stage...")
|
47 |
translated_data = [i for i in filtered_data]
|
@@ -56,11 +60,14 @@ def emotion_classification(translated_data):
|
|
56 |
st.write('⏺️ Classification model successfully loaded')
|
57 |
negative_count, neutral_count, positive_count = 0,0,0
|
58 |
negative_dict = {}
|
|
|
|
|
|
|
59 |
for i in translated_data:
|
60 |
labelled_result = emo_pipe(i)[0]['label']
|
61 |
-
st.write('Text: ',i)
|
62 |
-
st.write('Label: ',labelled_result)
|
63 |
-
st.write(' ')
|
64 |
if labelled_result == 'negative':
|
65 |
negative_dict[i] = emo_pipe(i)[0]['score']
|
66 |
negative_count += 1
|
@@ -68,6 +75,8 @@ def emotion_classification(translated_data):
|
|
68 |
neutral_count += 1
|
69 |
if labelled_result == 'positive':
|
70 |
positive_count += 1
|
|
|
|
|
71 |
sizes = [negative_count, neutral_count, positive_count]
|
72 |
labels = ['negative_review', 'neutral_review', 'positive_review']
|
73 |
# 创建饼状图
|
@@ -101,6 +110,7 @@ def summarization(top10_negative_str):
|
|
101 |
st.write('▶️ Summarizatio model start downing, loading model may takes time, please wait...')
|
102 |
summarize_pipe = pipeline("text2text-generation", model="deeplearningwithpython5240/summarisation-t5-finetuned-model", max_new_tokens =512)
|
103 |
st.write('⏺️ Summarization model successfully loaded')
|
|
|
104 |
summarized_text = summarize_pipe(top10_negative_str)
|
105 |
return summarized_text
|
106 |
|
|
|
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:
|
|
|
46 |
translated_data.append(trans_pipe(i)[0]['translation_text'])
|
47 |
+
translation_progress_count += 1/len(filtered_data)
|
48 |
+
translation_bar.progress(translation_progress_count)
|
49 |
elif language_Classification == 'en':
|
50 |
st.write("Your input is English, moving to next stage...")
|
51 |
translated_data = [i for i in filtered_data]
|
|
|
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']
|
68 |
+
# st.write('Text: ',i)
|
69 |
+
# st.write('Label: ',labelled_result)
|
70 |
+
# st.write(' ')
|
71 |
if labelled_result == 'negative':
|
72 |
negative_dict[i] = emo_pipe(i)[0]['score']
|
73 |
negative_count += 1
|
|
|
75 |
neutral_count += 1
|
76 |
if labelled_result == 'positive':
|
77 |
positive_count += 1
|
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 |
# 创建饼状图
|
|
|
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
|
116 |
|