Spaces:
Sleeping
Sleeping
Download app.py from Sunder34m2010/Summarization: direct link, hf CLI and curl.
- Browser
- Download file 685 Bytes
-
https://huggingface.co/spaces/Sunder34m2010/Summarization/resolve/main/app.py
- Command line
-
hf download hf://spaces/Sunder34m2010/Summarization/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Sunder34m2010/Summarization/resolve/main/app.py
685 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| # Load summarization pipeline | |
| summarizer = pipeline("summarization", model="facebook/bart-large-cnn") | |
| # Function to summarize text | |
| def summarize_text(text): | |
| summary = summarizer(text, max_length=130, min_length=30, do_sample=False) | |
| return summary[0]['summary_text'] | |
| # Gradio interface | |
| interface = gr.Interface( | |
| fn=summarize_text, | |
| inputs=gr.Textbox(lines=10, placeholder="Paste your long text here...", label="Input Text"), | |
| outputs=gr.Textbox(label="Summary"), | |
| title="📝 Text Summarizer", | |
| description="Summarize long articles using a pre-trained BART model from Hugging Face." | |
| ) | |
| interface.launch() | |