import torch import gradio as gr # Use a pipeline as a high-level helper # from transformers import pipeline from transformers import pipeline text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6") # model_path="../my_project_env/Models/models--sshleifer--distilbart-cnn-12-6/snapshots/a4f8f3ea906ed274767e9906dbaede7531d660ff" # # text_summary = pipeline("summarization", model=model_path) # text= "Born to a wealthy family in Pretoria, South Africa, Musk emigrated in 1989 to Canada. He received bachelor's degrees from the University of Pennsylvania in 1997 before moving to California, United States, 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. That year, Musk also became an American citizen. In 2002, Musk founded the space technology company SpaceX, becoming its CEO and chief engineer; the company has since led innovations in reusable rockets and commercial spaceflight. Musk joined the automaker Tesla as an early investor in 2004 and became its CEO and product architect in 2008; it has since become a leader in electric vehicles. In 2015, he co-founded OpenAI to advance artificial intelligence (AI) research but later left; growing discontent with the organization's direction and their leadership in the AI boom in the 2020s led him to establish xAI. In 2022, he acquired the social network Twitter, implementing significant changes and rebranding it as X in 2023. His other businesses include the neurotechnology company Neuralink, which he co-founded in 2016, and the tunneling company the Boring Company, which he founded in 2017." # print(text_summary(text)) def summary(input): output_text = text_summary(input) return output_text[0]['summary_text'] gr.close_all() demo = gr.Interface(fn=summary,inputs=[gr.Textbox(label="Input summarized url/text",lines=6)], outputs=[gr.Textbox(label="Summarized text",lines=4)], title="@GENAI Project1 : Summary Extractor", description="This app will extract summary from provided input") demo.launch()