Paula Leonova
commited on
Commit
•
87ccdf0
1
Parent(s):
4787e82
Update headings
Browse files
app.py
CHANGED
@@ -32,7 +32,7 @@ with st.form(key='my_form'):
|
|
32 |
submit_button = st.form_submit_button(label='Submit')
|
33 |
|
34 |
|
35 |
-
with st.spinner('Loading pretrained models (_please allow for
|
36 |
summarizer = load_summary_model()
|
37 |
classifier = load_model()
|
38 |
|
@@ -53,12 +53,12 @@ if submit_button:
|
|
53 |
# For each chunk of sentences (within the token max), generate a summary
|
54 |
for n in range(0, len(nested_sentences)):
|
55 |
text_chunk = " ".join(map(str, nested_sentences[n]))
|
56 |
-
st.markdown(f"###### Chunk {n+1}/{len(nested_sentences)}" )
|
57 |
st.markdown(text_chunk)
|
58 |
|
59 |
chunk_summary = summarizer_gen(summarizer, sequence=text_chunk, maximum_tokens = 300, minimum_tokens = 20)
|
60 |
summary.append(chunk_summary)
|
61 |
-
st.markdown("###### Partial Summary")
|
62 |
st.markdown(chunk_summary)
|
63 |
# Combine all the summaries into a list and compress into one document, again
|
64 |
final_summary = " \n".join(list(summary))
|
@@ -67,6 +67,8 @@ if submit_button:
|
|
67 |
st.markdown("### Combined Summary")
|
68 |
st.markdown(final_summary)
|
69 |
|
|
|
|
|
70 |
with st.spinner('Matching labels...'):
|
71 |
topics, scores = classifier_zero(classifier, sequence=final_summary, labels=labels, multi_class=True)
|
72 |
# st.markdown("### Top Label Predictions: Combined Summary")
|
@@ -80,7 +82,6 @@ if submit_button:
|
|
80 |
# unsafe_allow_html = True
|
81 |
# )
|
82 |
|
83 |
-
st.markdown("### Top Label Predictions: Summary & Full Text")
|
84 |
topics_ex_text, scores_ex_text = classifier_zero(classifier, sequence=example_text, labels=labels, multi_class=True)
|
85 |
plot_dual_bar_chart(topics, scores, topics_ex_text, scores_ex_text)
|
86 |
|
|
|
32 |
submit_button = st.form_submit_button(label='Submit')
|
33 |
|
34 |
|
35 |
+
with st.spinner('Loading pretrained models (_please allow for 10 seconds_)...'):
|
36 |
summarizer = load_summary_model()
|
37 |
classifier = load_model()
|
38 |
|
|
|
53 |
# For each chunk of sentences (within the token max), generate a summary
|
54 |
for n in range(0, len(nested_sentences)):
|
55 |
text_chunk = " ".join(map(str, nested_sentences[n]))
|
56 |
+
st.markdown(f"###### Original Text Chunk {n+1}/{len(nested_sentences)}" )
|
57 |
st.markdown(text_chunk)
|
58 |
|
59 |
chunk_summary = summarizer_gen(summarizer, sequence=text_chunk, maximum_tokens = 300, minimum_tokens = 20)
|
60 |
summary.append(chunk_summary)
|
61 |
+
st.markdown(f"###### Partial Summary {n+1}/{len(nested_sentences)}")
|
62 |
st.markdown(chunk_summary)
|
63 |
# Combine all the summaries into a list and compress into one document, again
|
64 |
final_summary = " \n".join(list(summary))
|
|
|
67 |
st.markdown("### Combined Summary")
|
68 |
st.markdown(final_summary)
|
69 |
|
70 |
+
|
71 |
+
st.markdown("### Top Label Predictions on Summary & Full Text")
|
72 |
with st.spinner('Matching labels...'):
|
73 |
topics, scores = classifier_zero(classifier, sequence=final_summary, labels=labels, multi_class=True)
|
74 |
# st.markdown("### Top Label Predictions: Combined Summary")
|
|
|
82 |
# unsafe_allow_html = True
|
83 |
# )
|
84 |
|
|
|
85 |
topics_ex_text, scores_ex_text = classifier_zero(classifier, sequence=example_text, labels=labels, multi_class=True)
|
86 |
plot_dual_bar_chart(topics, scores, topics_ex_text, scores_ex_text)
|
87 |
|