Paula Leonova commited on
Commit
9947e0d
·
1 Parent(s): 79d9303

Add progress spinners

Browse files
Files changed (1) hide show
  1. app.py +6 -0
app.py CHANGED
@@ -31,6 +31,7 @@ with st.form(key='my_form'):
31
  labels = list(set([x.strip() for x in labels.strip().split(',') if len(x.strip()) > 0]))
32
  submit_button = st.form_submit_button(label='Submit')
33
 
 
34
  summarizer = load_summary_model()
35
  classifier = load_model()
36
 
@@ -38,6 +39,7 @@ if submit_button:
38
  if len(labels) == 0:
39
  st.write('Enter some text and at least one possible topic to see predictions.')
40
 
 
41
  # For each body of text, create text chunks of a certain token size required for the transformer
42
  nested_sentences = create_nest_sentences(document = text_input, token_max_length = 1024)
43
 
@@ -63,6 +65,7 @@ if submit_button:
63
  st.markdown("### Combined Summary")
64
  st.markdown(final_summary)
65
 
 
66
  topics, scores = classifier_zero(classifier, sequence=final_summary, labels=labels, multi_class=True)
67
  # st.markdown("### Top Label Predictions: Combined Summary")
68
  # plot_result(topics[::-1][:], scores[::-1][:])
@@ -79,6 +82,7 @@ if submit_button:
79
  topics_ex_text, scores_ex_text = classifier_zero(classifier, sequence=example_text, labels=labels, multi_class=True)
80
  plot_dual_bar_chart(topics, scores, topics_ex_text, scores_ex_text)
81
 
 
82
  data_ex_text = pd.DataFrame({'label': topics_ex_text, 'scores_from_full_text': scores_ex_text})
83
  data2 = pd.merge(data, data_ex_text, on = ['label'])
84
  st.markdown("### Data Table")
@@ -89,3 +93,5 @@ if submit_button:
89
  unsafe_allow_html = True
90
  )
91
  st.dataframe(data2)
 
 
 
31
  labels = list(set([x.strip() for x in labels.strip().split(',') if len(x.strip()) > 0]))
32
  submit_button = st.form_submit_button(label='Submit')
33
 
34
+
35
  summarizer = load_summary_model()
36
  classifier = load_model()
37
 
 
39
  if len(labels) == 0:
40
  st.write('Enter some text and at least one possible topic to see predictions.')
41
 
42
+ with st.spinner('Generating partial summaries...')
43
  # For each body of text, create text chunks of a certain token size required for the transformer
44
  nested_sentences = create_nest_sentences(document = text_input, token_max_length = 1024)
45
 
 
65
  st.markdown("### Combined Summary")
66
  st.markdown(final_summary)
67
 
68
+ with st.spinner('Matching labels to text...')
69
  topics, scores = classifier_zero(classifier, sequence=final_summary, labels=labels, multi_class=True)
70
  # st.markdown("### Top Label Predictions: Combined Summary")
71
  # plot_result(topics[::-1][:], scores[::-1][:])
 
82
  topics_ex_text, scores_ex_text = classifier_zero(classifier, sequence=example_text, labels=labels, multi_class=True)
83
  plot_dual_bar_chart(topics, scores, topics_ex_text, scores_ex_text)
84
 
85
+ with st.spinner('Creating a download link...')
86
  data_ex_text = pd.DataFrame({'label': topics_ex_text, 'scores_from_full_text': scores_ex_text})
87
  data2 = pd.merge(data, data_ex_text, on = ['label'])
88
  st.markdown("### Data Table")
 
93
  unsafe_allow_html = True
94
  )
95
  st.dataframe(data2)
96
+
97
+ st.success('All Done!')