import gradio as gr from transformers import pipeline # Load the summarization pipeline pipe = pipeline("summarization", model="facebook/bart-large-cnn") # Define a function that summarizes text based on the input def summarize_text(text): summary = pipe(text, max_length=150, min_length=40, do_sample=False) return summary[0]['summary_text'] # Set up the Gradio interface interface = gr.Interface( fn=summarize_text, inputs=gr.Textbox(lines=10, label="Enter text to summarize"), outputs=gr.Textbox(label="Summary"), title="Text Summarization with BART", description="Enter a text block and get a summarized version using the BART model." ) # Launch the Gradio app interface.launch()