Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,13 @@
|
|
1 |
-
from transformers import
|
2 |
import gradio as grad
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
def
|
7 |
-
text= "
|
8 |
-
|
9 |
-
response =
|
10 |
return response
|
11 |
-
grad.
|
|
|
|
|
|
1 |
+
from transformers import PegasusForConditionalGeneration, PegasusTokenizer
|
2 |
import gradio as grad
|
3 |
+
mdl_name = "google/pegasus-xsum"
|
4 |
+
pegasus_tkn = PegasusTokenizer.from_pretrained(mdl_name)
|
5 |
+
mdl = PegasusForConditionalGeneration.from_pretrained(mdl_name)
|
6 |
+
def summarize(text):
|
7 |
+
tokens = pegasus_tkn(text, truncation=True, padding="longest", return_tensors="pt")
|
8 |
+
txt_summary = mdl.generate(**tokens)
|
9 |
+
response = pegasus_tkn.batch_decode(txt_summary, skip_special_tokens=True)
|
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()
|