import gradio as gr from transformers import pipeline # Load lightweight summarization model summarizer = pipeline( "summarization", model="sshleifer/distilbart-cnn-12-6", device=-1 ) def summarize(text): if not text or not text.strip(): return "Please enter some text." text = text[:4000] result = summarizer( text, max_length=150, min_length=40, do_sample=False ) return result[0]["summary_text"] app = gr.Interface( fn=summarize, inputs=gr.Textbox(lines=10, label="Paste text here"), outputs=gr.Textbox(label="Summary"), title="AI Text Summarizer", description="Simple AI-powered text summarization tool" ) app.launch()