Spaces:
Runtime error
Runtime error
Eunchan Lee
commited on
Commit
•
256cbd2
1
Parent(s):
55ec43f
ddad
Browse files- app.py +14 -3
- requirements.txt +1 -0
app.py
CHANGED
@@ -9,9 +9,13 @@ import torch
|
|
9 |
#import transformers
|
10 |
from transformers import pipeline
|
11 |
from PIL import Image
|
|
|
12 |
|
13 |
|
14 |
|
|
|
|
|
|
|
15 |
image = Image.open('hb.jpg')
|
16 |
|
17 |
#from transformers import
|
@@ -37,7 +41,9 @@ def load_zeroshot_classifier():
|
|
37 |
|
38 |
def get_summarizer(summarizer, sequence:str, maximum_tokens:int, minimum_tokens:int):
|
39 |
output = summarizer(sequence, num_beams=4, max_length=maximum_tokens, min_length=minimum_tokens, do_sample=False)
|
40 |
-
|
|
|
|
|
41 |
|
42 |
|
43 |
|
@@ -82,8 +88,12 @@ output_text = []
|
|
82 |
|
83 |
if submit_button:
|
84 |
with st.spinner('On summarizing !...wait a second please..'):
|
85 |
-
|
86 |
-
|
|
|
|
|
|
|
|
|
87 |
#output_text.append(get_summarizer(summarizer_3, text_input, 150, 5))
|
88 |
|
89 |
|
@@ -92,6 +102,7 @@ if submit_button:
|
|
92 |
for i in range(2):
|
93 |
st.markdown("**"+ plms[i] +"s Output: ** ")
|
94 |
st.text(output_text[i])
|
|
|
95 |
st.success(f"{i+1} of 3 are done!")
|
96 |
|
97 |
st.success("Congrats!!! ALL DONE!")
|
|
|
9 |
#import transformers
|
10 |
from transformers import pipeline
|
11 |
from PIL import Image
|
12 |
+
import datasets
|
13 |
|
14 |
|
15 |
|
16 |
+
metric = datasets.load_metric("rouge")
|
17 |
+
|
18 |
+
|
19 |
image = Image.open('hb.jpg')
|
20 |
|
21 |
#from transformers import
|
|
|
41 |
|
42 |
def get_summarizer(summarizer, sequence:str, maximum_tokens:int, minimum_tokens:int):
|
43 |
output = summarizer(sequence, num_beams=4, max_length=maximum_tokens, min_length=minimum_tokens, do_sample=False)
|
44 |
+
|
45 |
+
metric.add_batch(predictions=output[0].get('summary_text'), references=sequence)
|
46 |
+
return output[0].get('summary_text')
|
47 |
|
48 |
|
49 |
|
|
|
88 |
|
89 |
if submit_button:
|
90 |
with st.spinner('On summarizing !...wait a second please..'):
|
91 |
+
|
92 |
+
get_1 = get_summarizer(summarizer_1, text_input, 150, 5)
|
93 |
+
get_2 = get_summarizer(summarizer_2, text_input, 150, 5)
|
94 |
+
|
95 |
+
output_text.append(get_1)
|
96 |
+
output_text.append(get_2)
|
97 |
#output_text.append(get_summarizer(summarizer_3, text_input, 150, 5))
|
98 |
|
99 |
|
|
|
102 |
for i in range(2):
|
103 |
st.markdown("**"+ plms[i] +"s Output: ** ")
|
104 |
st.text(output_text[i])
|
105 |
+
st.text("final ROUGE score: "+ metric.compute())
|
106 |
st.success(f"{i+1} of 3 are done!")
|
107 |
|
108 |
st.success("Congrats!!! ALL DONE!")
|
requirements.txt
CHANGED
@@ -1,2 +1,3 @@
|
|
1 |
transformers
|
2 |
torch
|
|
|
|
1 |
transformers
|
2 |
torch
|
3 |
+
datasets
|