import torch import gradio as gr from transformers import pipeline text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-3") # model_path=r".\models\models--sshleifer--distilbart-cnn-12-6\snapshots\a4f8f3ea906ed274767e9906dbaede7531d660ff" # model_path="./models/models--sshleifer--distilbart-cnn-12-6/snapshots/a4f8f3ea906ed274767e9906dbaede7531d660ff" # text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-3") # text="Born into a wealthy family in Pretoria, South Africa, Musk emigrated in 1989 to Canada; he has Canadian citizenship since his mother was born there. He received bachelor's degrees in 1997 from the University of Pennsylvania before moving to California to pursue business ventures. In 1995, Musk co-founded the software company Zip2. Following its sale in 1999, he co-founded X.com, an online payment company that later merged to form PayPal, which was acquired by eBay in 2002. Musk also became an American citizen in 2002." # print(text_summary(text)) def summary(input): output = text_summary(input) return output[0]["summary_text"] gr.close_all() # demo = gr.Interface(fn=summary,inputs='text', outputs='text') # demo.launch() demo = gr.Interface( fn=summary, inputs=[gr.Textbox(label="Input text to summarize", lines=6)], outputs=[gr.Textbox(label="Summary", lines=4)], title="Rajendra", description='This app used to Summarize text' ) demo.launch()