Spaces:
Runtime error
Runtime error
Commit
·
061a8cf
1
Parent(s):
b08fa21
Update app.py
Browse files
app.py
CHANGED
@@ -29,7 +29,7 @@ def summ_t5(text):
|
|
29 |
return summary_text
|
30 |
|
31 |
def summ_bert(text):
|
32 |
-
input_ids = tokenizer_bert(text, return_tensors="pt")
|
33 |
summary_ids= model_bert.generate(input_ids,
|
34 |
max_length=100,
|
35 |
num_beams=10,
|
@@ -43,7 +43,7 @@ def summ_bert(text):
|
|
43 |
return summary_text
|
44 |
|
45 |
def para_t5(text):
|
46 |
-
encoding = t5_para_tokenizer
|
47 |
outputs = t5_para_model.generate(
|
48 |
input_ids=encoding["input_ids"],
|
49 |
attention_mask=encoding["attention_mask"],
|
@@ -61,10 +61,10 @@ def para_t5(text):
|
|
61 |
]
|
62 |
|
63 |
def summarize(text):
|
64 |
-
|
65 |
bert_ = summ_bert(text)
|
66 |
-
|
67 |
-
return bert_
|
68 |
|
69 |
if __name__ == "__main__":
|
70 |
with gr.Blocks() as demo:
|
@@ -73,8 +73,8 @@ if __name__ == "__main__":
|
|
73 |
input_text = gr.Textbox(label="Input Text")
|
74 |
analyze_button = gr.Button(label="Analyze")
|
75 |
with gr.Column():
|
76 |
-
|
77 |
-
bert_output = gr.Textbox(label="
|
78 |
-
|
79 |
-
analyze_button.click(summarize, inputs=input_text, outputs=[bert_output])
|
80 |
demo.launch()
|
|
|
29 |
return summary_text
|
30 |
|
31 |
def summ_bert(text):
|
32 |
+
input_ids = tokenizer_bert.encode(text, return_tensors="pt")
|
33 |
summary_ids= model_bert.generate(input_ids,
|
34 |
max_length=100,
|
35 |
num_beams=10,
|
|
|
43 |
return summary_text
|
44 |
|
45 |
def para_t5(text):
|
46 |
+
encoding = t5_para_tokenizer(text, padding='longest', return_tensors='pt')
|
47 |
outputs = t5_para_model.generate(
|
48 |
input_ids=encoding["input_ids"],
|
49 |
attention_mask=encoding["attention_mask"],
|
|
|
61 |
]
|
62 |
|
63 |
def summarize(text):
|
64 |
+
t5_ = summ_t5(text)
|
65 |
bert_ = summ_bert(text)
|
66 |
+
para_ = para_t5(t5_)
|
67 |
+
return t5_, bert_, para_
|
68 |
|
69 |
if __name__ == "__main__":
|
70 |
with gr.Blocks() as demo:
|
|
|
73 |
input_text = gr.Textbox(label="Input Text")
|
74 |
analyze_button = gr.Button(label="Analyze")
|
75 |
with gr.Column():
|
76 |
+
t5_output = gr.Textbox(label="T5 Base Output")
|
77 |
+
bert_output = gr.Textbox(label="Bert2Bert Base Output")
|
78 |
+
para_output = gr.Textbox(label="T5 Paraphrase Output")
|
79 |
+
analyze_button.click(summarize, inputs=input_text, outputs=[t5_ouput, bert_output, para_output])
|
80 |
demo.launch()
|