Update app.py
Browse filesupdate summary
app.py
CHANGED
@@ -1,7 +1,14 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
-
def
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
iface = gr.Interface(fn=
|
7 |
-
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import PegasusForConditionalGeneration
|
3 |
+
from tokenizers_pegasus import PegasusTokenizer
|
4 |
|
5 |
+
def summary(name):
|
6 |
+
model = PegasusForConditionalGeneration.from_pretrained("IDEA-CCNL/Randeng-Pegasus-238M-Summary-Chinese")
|
7 |
+
tokenizer = PegasusTokenizer.from_pretrained("IDEA-CCNL/Randeng-Pegasus-238M-Summary-Chinese")
|
8 |
+
inputs = tokenizer(text, max_length=1024, return_tensors="pt")
|
9 |
+
# Generate Summary
|
10 |
+
summary_ids = model.generate(inputs["input_ids"])
|
11 |
+
return tokenizer.batch_decode(summary_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
|
12 |
|
13 |
+
iface = gr.Interface(fn=summary, inputs="text", outputs="text")
|
14 |
+
iface.launch()
|