# Use a pipeline as a high-level helper from transformers import pipeline import gradio as gr import os pipe = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6") def summarize(input): output = pipe(input) return output[0]['summary_text'] gr.close_all() demo = gr.Interface(fn=summarize, inputs=[gr.Textbox(label="Text to summarize", lines=10)], outputs=[gr.Textbox(label="Text to summarize", lines=5)], title="Text Summarization", description="Summarize any text using distilbart") demo.launch()