Spaces:
Runtime error
Runtime error
Download app.py from jproques/summarizer: direct link, hf CLI and curl.
- Browser
- Download file 934 Bytes
-
https://huggingface.co/spaces/jproques/summarizer/resolve/main/app.py
- Command line
-
hf download hf://spaces/jproques/summarizer/app.py
-
curl -L -o app.py https://huggingface.co/spaces/jproques/summarizer/resolve/main/app.py
934 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| # def summarize(model, input): | |
| # summarizer = pipeline("summarization", model=model) | |
| # result = summarizer(input, max_length=130, min_length=30, do_sample=False) | |
| # return result[0]['summary_text'] | |
| def run_pipeline(task, model, input): | |
| print(task, model, input) | |
| pipeline_to_run = pipeline(task, model=model, max_length=len(input)) | |
| return pipeline_to_run(input) | |
| iface = gr.Interface( | |
| fn=run_pipeline, | |
| inputs=[ | |
| gr.Dropdown( | |
| ["summarization"], label="task", value="summarization" | |
| ), | |
| gr.Dropdown( | |
| ["facebook/bart-large-cnn", "philschmid/bart-large-cnn-samsum", "csebuetnlp/mT5_multilingual_XLSum", "philschmid/flan-t5-base-samsum"], label="model", value="facebook/bart-large-cnn" | |
| ), | |
| gr.Textbox(lines=10, placeholder = "Text to summarize...") | |
| ], | |
| outputs="text") | |
| iface.launch() |