Spaces:
Sleeping
Sleeping
Commit
·
ed27f2f
1
Parent(s):
eda6ba9
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,4 +10,19 @@ def summarize(text):
|
|
| 10 |
return response
|
| 11 |
txt=grad.Textbox(lines=10, label="English", placeholder="English Text here")
|
| 12 |
out=grad.Textbox(lines=10, label="Summary")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
grad.Interface(summarize, inputs=txt, outputs=out).launch()
|
|
|
|
| 10 |
return response
|
| 11 |
txt=grad.Textbox(lines=10, label="English", placeholder="English Text here")
|
| 12 |
out=grad.Textbox(lines=10, label="Summary")
|
| 13 |
+
grad.Interface(summarize, inputs=txt, outputs=out).launch()
|
| 14 |
+
|
| 15 |
+
from transformers import PegasusForConditionalGeneration, PegasusTokenizer
|
| 16 |
+
import gradio as grad
|
| 17 |
+
mdl_name = "google/pegasus-xsum"
|
| 18 |
+
pegasus_tkn = PegasusTokenizer.from_pretrained(mdl_name)
|
| 19 |
+
mdl = PegasusForConditionalGeneration.from_pretrained(mdl_name)
|
| 20 |
+
|
| 21 |
+
def summarize(text):
|
| 22 |
+
tokens = pegasus_tkn(text, truncation=True, padding="longest", return_tensors="pt")
|
| 23 |
+
translated_txt = mdl.generate(**tokens,num_return_sequences=5,max_length=200,temperature=1.5,num_beams=10)
|
| 24 |
+
response = pegasus_tkn.batch_decode(translated_txt, skip_special_tokens=True)
|
| 25 |
+
return response
|
| 26 |
+
txt=grad.Textbox(lines=10, label="English", placeholder="English Text here")
|
| 27 |
+
out=grad.Textbox(lines=10, label="Summary")
|
| 28 |
grad.Interface(summarize, inputs=txt, outputs=out).launch()
|