Spaces:
Runtime error
Runtime error
Download app.py from mhd2255/textsummarizer: direct link, hf CLI and curl.
- Browser
- Download file 537 Bytes
-
https://huggingface.co/spaces/mhd2255/textsummarizer/resolve/main/app.py
- Command line
-
hf download hf://spaces/mhd2255/textsummarizer/app.py
-
curl -L -o app.py https://huggingface.co/spaces/mhd2255/textsummarizer/resolve/main/app.py
537 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| # Load model | |
| summarizer = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6") | |
| def summarize(text): | |
| result = summarizer(text, max_length=130, min_length=30, do_sample=False) | |
| return result[0]['summary_text'] | |
| # Create interface | |
| iface = gr.Interface( | |
| fn=summarize, | |
| inputs=gr.Textbox(lines=10, label="Input Text"), | |
| outputs=gr.Textbox(label="Summary"), | |
| title="Text Summarizer", | |
| description="Summarize text using DistilBART-CNN" | |
| ) | |
| iface.launch() |