Spaces:
Sleeping
Sleeping
Download app.py from Sunder34/txt-summarization: direct link, hf CLI and curl.
- Browser
- Download file 718 Bytes
-
https://huggingface.co/spaces/Sunder34/txt-summarization/resolve/main/app.py
- Command line
-
hf download hf://spaces/Sunder34/txt-summarization/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Sunder34/txt-summarization/resolve/main/app.py
718 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| # Load the summarization pipeline | |
| pipe = pipeline("summarization", model="facebook/bart-large-cnn") | |
| # Define a function that summarizes text based on the input | |
| def summarize_text(text): | |
| summary = pipe(text, max_length=150, min_length=40, do_sample=False) | |
| return summary[0]['summary_text'] | |
| # Set up the Gradio interface | |
| interface = gr.Interface( | |
| fn=summarize_text, | |
| inputs=gr.Textbox(lines=10, label="Enter text to summarize"), | |
| outputs=gr.Textbox(label="Summary"), | |
| title="Text Summarization with BART", | |
| description="Enter a text block and get a summarized version using the BART model." | |
| ) | |
| # Launch the Gradio app | |
| interface.launch() | |