Spaces:
Sleeping
Sleeping
| from transformers import pipeline | |
| import gradio as gr | |
| # Load the BART summarisation pipeline | |
| summariser = pipeline("summarization", model="facebook/bart-large-cnn") | |
| def summarise(text): | |
| summary = summariser(text, max_length=150, min_length=40, do_sample=False)[0]["summary_text"] | |
| return summary | |
| # Two example passages for quick testing | |
| example_texts = [ | |
| ["Artificial intelligence has progressed rapidly over the past decade. " | |
| "New methods in deep learning have made it possible to process vast amounts of data, " | |
| "leading to significant advances in language modelling, computer vision, and reinforcement learning. " | |
| "As organisations adopt these technologies, questions emerge regarding transparency, fairness, " | |
| "and the wider societal impact of automated decision-making."], | |
| ["The Industrial Revolution transformed Europe’s economic landscape. " | |
| "Mechanised production replaced traditional craft methods, enabling factories to produce goods at a scale " | |
| "previously unimaginable. These developments shifted labour patterns, encouraged urban migration, " | |
| "and laid the foundations for modern industrial capitalism."] | |
| ] | |
| with gr.Blocks(title="BART Text Summariser") as demo: | |
| gr.Markdown( | |
| """### BART Text Summariser | |
| Paste a passage of text and receive a concise summary. | |
| Two sample texts are provided below for immediate experimentation.""" | |
| ) | |
| input_box = gr.Textbox( | |
| lines=12, | |
| label="Input Text", | |
| placeholder="Paste the text you wish to summarise…" | |
| ) | |
| output_box = gr.Textbox( | |
| lines=10, # Increased height for the summary output | |
| label="Summary" | |