Spaces:
Sleeping
Sleeping
| 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() | |