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 = [ [""" Over the past half-century, the relationship between technology and society has undergone a profound transformation. The earliest digital systems were narrow in scope, expensive to maintain, and accessible only to governments and large research institutions. Their primary function was to accelerate numerical calculations, simulate complex physical systems, and automate a limited range of administrative tasks. By contrast, contemporary digital technologies influence almost every aspect of social, economic, and cultural life. The proliferation of personal devices, the rise of global communication networks, and the emergence of intelligent systems have collectively reshaped the way individuals interact with information, institutions, and one another. A particularly significant development has been the shift from passive computation to adaptive, data-driven systems capable of learning from examples. Machine learning, and deep learning in particular, now underpin applications ranging from medical diagnostics and financial forecasting to translation services and autonomous vehicles. These systems exhibit performance that, in some domains, rivals or exceeds that of trained human experts. Their growing prominence has prompted renewed interest in the ethics of automation, including concerns regarding fairness, accountability, transparency, and the potential reinforcement of existing social inequalities. """ ], [""" In recent years, debates about the future of work have intensified as automation and artificial intelligence continue to advance at an impressive pace. Industries that once relied upon large numbers of routine, manual workers have begun adopting sophisticated systems capable of performing complex tasks with remarkable consistency. Manufacturers now use intelligent robotics to monitor supply chains, maintain production lines, and identify defects in real time, while service providers increasingly rely upon algorithmic tools to streamline logistics, customer support, and administrative processes. Although these developments promise efficiency and cost savings, they also raise important questions about job security, professional identity, and the capacity of existing institutions to support individuals whose roles may change or disappear. The transformation is not confined to industrial labour; professions such as law, journalism, and medicine are also beginning to feel the effects of algorithmic decision-making, prompting renewed discussions about the value of human judgement in an environment shaped by relentless technological acceleration. Alongside these economic and professional considerations, attention has turned towards the broader societal implications of widespread automation. Public discourse frequently highlights the tension between technological progress and social wellbeing, particularly in light of concerns about privacy, data ownership, and democratic accountability. As more personal information is collected, processed, and acted upon by automated systems, citizens increasingly seek assurances that these technologies are deployed responsibly and transparently. Policymakers, however, often struggle to keep pace with innovation, resulting in regulatory frameworks that are uneven, reactive, or insufficiently aligned with public expectations. The challenge is further complicated by global inequalities: nations with limited technical infrastructure may find themselves dependent upon systems developed elsewhere, with little influence over how those systems evolve. These realities underscore the need for thoughtful governance, interdisciplinary dialogue, and inclusive decision-making to ensure that the benefits of automation are shared widely rather than reserved for a narrow segment of society. """] ] 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, label="Summary" ) run_btn = gr.Button("Summarise") run_btn.click(summarise, inputs=input_box, outputs=output_box) gr.Examples( examples=example_texts, inputs=input_box, label="Example Texts" ) demo.launch()