Eunchan Lee commited on
Commit
ecfe56e
1 Parent(s): 1fff449
Files changed (1) hide show
  1. app.py +30 -13
app.py CHANGED
@@ -15,23 +15,22 @@ st.write("__Inputs__: Text your input article!!")
15
  st.write("__Outputs__: Summarizing output text by Google-Pegasus! ")
16
 
17
 
18
- model_name= "google/pegasus-xsum"
19
 
20
- def load_summary_model():
 
21
  #model_name = "google/pegasus-xsum"
22
  summarizer = pipeline(task="summarization", model=model_name)
23
 
24
  return summarizer
25
 
26
 
27
- def summarizer_gen(summarizer, sequence:str, maximum_tokens:int, minimum_tokens:int):
28
  output = summarizer(sequence, num_beams=4, max_length=maximum_tokens, min_length=minimum_tokens, do_sample=False)
29
  return output[0].get('summary_text')
30
 
31
 
32
 
33
-
34
-
35
  ARTICLE ="""New York (CNN)
36
  When Liana Barrientos was 23 years old, she got married in Westchester County, New York.A year later, she got married again in Westchester County, but to a different man and without divorcing her first husband.Only 18 days after that marriage, she got hitched yet again. Then, Barrientos declared "I do" five more times, sometimes only within two weeks of each other.In 2010, she married once more, this time in the Bronx. In an application for a marriage license, she stated it was her "first and only" marriage.Barrientos, now 39, is facing two criminal counts of "offering a false instrument for filing in the first degree," referring to her false statements on the 2010 marriage license application, according to court documents.
37
  Prosecutors said the marriages were part of an immigration scam. On Friday, she pleaded not guilty at State Supreme Court in the Bronx, according to her attorney, Christopher Wright, who declined to comment further. After leaving court, Barrientos was arrested and charged with theft of service and criminal trespass for allegedly sneaking into the New York subway through an emergency exit, said Detective Annette Markowski, a police spokeswoman. In total, Barrientos has been married 10 times, with nine of her marriages occurring between 1999 and 2002. All occurred either in Westchester County, Long Island, New Jersey or the Bronx. She is believed to still be married to four men, and at one time, she was married to eight men at once, prosecutors say. Prosecutors said the immigration scam involved some of her husbands, who filed for permanent residence status shortly after the marriages. Any divorces happened only after such filings were approved. It was unclear whether any of the men will be prosecuted.
@@ -39,25 +38,43 @@ Prosecutors said the marriages were part of an immigration scam. On Friday, she
39
 
40
 
41
 
42
-
43
  with st.spinner('Loading Pretrained '+ model_name +' Models (_please allow for 10 seconds_)...'):
44
- summarizer = load_summary_model()
 
 
45
 
46
 
47
- with st.form(key="my_form"):
48
  display_text = ARTICLE + "\n\n"
49
  text_input = st.text_area("Input any text you want to summaryize & classify here (keep in mind very long text will take a while to process):", display_text)
50
- submit_button = st.form_submit_button(label='Submit')
 
51
 
52
 
 
53
 
54
  if submit_button:
55
  with st.spinner('On summarizing !...wait a second please..'):
56
- output_text = summarizer_gen(summarizer, text_input, 150, 5)
 
 
57
 
58
 
59
  st.markdown("### Outputs are here !: ")
60
- st.text(output_text)
61
 
62
- st.success("ALL DONE!")
63
- st.balloons()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  st.write("__Outputs__: Summarizing output text by Google-Pegasus! ")
16
 
17
 
18
+ plms =["facebook/bart-large-cnn", "google/pegasus-xsum", "t5-base" ]
19
 
20
+
21
+ def load_plms(model_name):
22
  #model_name = "google/pegasus-xsum"
23
  summarizer = pipeline(task="summarization", model=model_name)
24
 
25
  return summarizer
26
 
27
 
28
+ def get_summarizer(summarizer, sequence:str, maximum_tokens:int, minimum_tokens:int):
29
  output = summarizer(sequence, num_beams=4, max_length=maximum_tokens, min_length=minimum_tokens, do_sample=False)
30
  return output[0].get('summary_text')
31
 
32
 
33
 
 
 
34
  ARTICLE ="""New York (CNN)
35
  When Liana Barrientos was 23 years old, she got married in Westchester County, New York.A year later, she got married again in Westchester County, but to a different man and without divorcing her first husband.Only 18 days after that marriage, she got hitched yet again. Then, Barrientos declared "I do" five more times, sometimes only within two weeks of each other.In 2010, she married once more, this time in the Bronx. In an application for a marriage license, she stated it was her "first and only" marriage.Barrientos, now 39, is facing two criminal counts of "offering a false instrument for filing in the first degree," referring to her false statements on the 2010 marriage license application, according to court documents.
36
  Prosecutors said the marriages were part of an immigration scam. On Friday, she pleaded not guilty at State Supreme Court in the Bronx, according to her attorney, Christopher Wright, who declined to comment further. After leaving court, Barrientos was arrested and charged with theft of service and criminal trespass for allegedly sneaking into the New York subway through an emergency exit, said Detective Annette Markowski, a police spokeswoman. In total, Barrientos has been married 10 times, with nine of her marriages occurring between 1999 and 2002. All occurred either in Westchester County, Long Island, New Jersey or the Bronx. She is believed to still be married to four men, and at one time, she was married to eight men at once, prosecutors say. Prosecutors said the immigration scam involved some of her husbands, who filed for permanent residence status shortly after the marriages. Any divorces happened only after such filings were approved. It was unclear whether any of the men will be prosecuted.
 
38
 
39
 
40
 
 
41
  with st.spinner('Loading Pretrained '+ model_name +' Models (_please allow for 10 seconds_)...'):
42
+ summarizer_1 = load_plms(plms[0])
43
+ summarizer_2 = load_plms(plms[1])
44
+ summarizer_3 = load_plms(plms[2])
45
 
46
 
47
+ with st.form(key="input_area"):
48
  display_text = ARTICLE + "\n\n"
49
  text_input = st.text_area("Input any text you want to summaryize & classify here (keep in mind very long text will take a while to process):", display_text)
50
+ submit_button = st.form_submit_button(label='SUBMIT')
51
+
52
 
53
 
54
+ output_text = []
55
 
56
  if submit_button:
57
  with st.spinner('On summarizing !...wait a second please..'):
58
+ output_text.append(get_summarizer(summarizer_1, text_input, 150, 5))
59
+ output_text.append(get_summarizer(summarizer_2, text_input, 150, 5))
60
+ output_text.append(get_summarizer(summarizer_3, text_input, 150, 5))
61
 
62
 
63
  st.markdown("### Outputs are here !: ")
 
64
 
65
+ for i in range(3):
66
+ st.markdown("**"+ plms[i] +"s Output: ** ")
67
+ st.text(output_text[i])
68
+ st.success(f"{i+1} of 3 are done!")
69
+
70
+ st.success("Congrats!!! ALL DONE!")
71
+ st.balloons()
72
+
73
+ balloon_button = st.form_submit_button(label='More Balloon?')
74
+
75
+ if balloon_button:
76
+ st.balloons()
77
+
78
+
79
+
80
+