Download app.py from fclong/summary: direct link, hf CLI and curl.
- Browser
- Download file 689 Bytes
-
https://huggingface.co/spaces/fclong/summary/resolve/22274e070f8598bfcad4d7e7cafdbc6df5e94332/app.py
- Command line
-
hf download hf://spaces/fclong/summary@22274e070f8598bfcad4d7e7cafdbc6df5e94332/app.py
-
curl -L -o app.py https://huggingface.co/spaces/fclong/summary/resolve/22274e070f8598bfcad4d7e7cafdbc6df5e94332/app.py
689 Bytes
| import gradio as gr | |
| from transformers import PegasusForConditionalGeneration | |
| from tokenizers_pegasus import PegasusTokenizer | |
| def summary(name): | |
| model = PegasusForConditionalGeneration.from_pretrained("IDEA-CCNL/Randeng-Pegasus-238M-Summary-Chinese") | |
| tokenizer = PegasusTokenizer.from_pretrained("IDEA-CCNL/Randeng-Pegasus-238M-Summary-Chinese") | |
| inputs = tokenizer(text, max_length=1024, return_tensors="pt") | |
| # Generate Summary | |
| summary_ids = model.generate(inputs["input_ids"]) | |
| return tokenizer.batch_decode(summary_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0] | |
| iface = gr.Interface(fn=summary, inputs="text", outputs="text") | |
| iface.launch() |