Spaces:
Sleeping
Sleeping
Download app.py from piyush2205/summarization: direct link, hf CLI and curl.
- Browser
- Download file 677 Bytes
-
https://huggingface.co/spaces/piyush2205/summarization/resolve/main/app.py
- Command line
-
hf download hf://spaces/piyush2205/summarization/app.py
-
curl -L -o app.py https://huggingface.co/spaces/piyush2205/summarization/resolve/main/app.py
677 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| # Load summarization pipeline | |
| summarizer = pipeline("summarization", model="facebook/bart-large-cnn") | |
| def summarize_text(text): | |
| summary = summarizer(text, max_length=130, min_length=30, do_sample=False)[0]['summary_text'] | |
| return summary | |
| # Gradio interface | |
| iface = gr.Interface( | |
| fn=summarize_text, | |
| inputs=gr.Textbox(lines=10, placeholder="Paste article or paragraph here...", label="Input Text"), | |
| outputs=gr.Textbox(label="Summary"), | |
| title="🧾 Text Summarizer", | |
| description="Get a quick summary of any paragraph, article, or blog using the BART model." | |
| ) | |
| iface.launch() | |