import gradio as gr from transformers import pipeline pipe_summarization = pipeline("summarization", model="facebook/bart-large-cnn") def summarization_fun(txt): txt_summ = pipe_summarization(txt, min_length=10, max_length=100) txt_summ2 = txt_summ[0]["summary_text"] return txt_summ2 ex = ["The Saudi Founding Day is a national occasion in the Kingdom of Saudi Arabia, commemorating the founding of the First Saudi State in 1727 by Imam Mohammed Bin Saud. It was approved by a Royal Decree issued by the Custodian of the Two Holy Mosques, King Salman Bin Abdulaziz Al Saud, on January 27, 2022. February 22 of each year is designated as the anniversary of the founding of the Kingdom and an official holiday."] custom_css = """ body { background-color: #F5F5DC; } """ interface = gr.Interface( fn=summarization_fun, inputs=gr.Textbox(label="Enter your Text That you want to summarize it", lines=10), outputs=gr.Textbox(label="The summurized text"), examples=ex, css=custom_css) interface.launch()