Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # Load the summarization pipeline | |
| summarizer = pipeline("summarization", model="facebook/bart-large-cnn") | |
| def summarize_text(text): | |
| if not text.strip(): | |
| return "Please enter some text to summarize." | |
| summary = summarizer(text, min_length=10, max_length=100, do_sample=False) | |
| return summary[0]['summary_text'] | |
| # Define the Gradio interface | |
| with gr.Blocks() as demo: | |
| gr.Markdown("# Text Summarization using BART Model") | |
| gr.Markdown("Enter a long piece of text below and click 'Summarize' to generate a concise summary.") | |
| text_input = gr.Textbox(label="Input Text", placeholder="Enter your text here...", lines=10) | |
| summarize_button = gr.Button("Summarize") | |
| output_text = gr.Textbox(label="Summarized Text", lines=5, interactive=False) | |
| summarize_button.click(summarize_text, inputs=text_input, outputs=output_text) | |
| # Launch the Gradio app | |
| demo.launch() |