import torch import gradio as gr # Use a pipeline as a high-level helper from transformers import pipeline text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6") # model_path ="../Models/models--sshleifer--distilbart-cnn-12-6/snapshots/a4f8f3ea906ed274767e9906dbaede7531d660ff" # text_summary = pipeline("summarization", model=model_path, # torch_dtype=torch.bfloat16) # text=''Elon Reeve Musk (/ˈiːlɒn mʌsk/; born June 28, 1971) is a businessman and United States # special government employee known for his key roles in the automotive company Tesla, Inc. # and the space company SpaceX. He is also known for his ownership of the technology company # X Corp. and his role in the founding of the Boring Company, xAI, Neuralink, and OpenAI. # Musk is the wealthiest individual in the world; as of January 2025, Forbes estimates his net # worth to be US$426 billion. Musk has engaged in political activities in several countries, including # as a vocal and financial supporter of U.S. president Donald Trump. He became the largest # donor in the 2024 United States presidential election, and a supporter of international # far-right political parties, activists, and causes. # # A member of the wealthy South African Musk family, Musk was born in Pretoria before immigrating to # Canada, acquiring its citizenship through his Canadian-born mother, Maye. Two years later, he matriculated # at Queen's University in Canada. Musk later transferred to the University of Pennsylvania and received bachelor's # degrees in economics and physics. He moved to California in 1995 to attend Stanford University, and with his brother # Kimbal co-founded the software company Zip2, that was later acquired by Compaq in 1999. That same year, Musk co-founded # X.com, a direct bank, that later formed PayPal. In 2002, Musk acquired United States citizenship, and eBay acquired PayPal. # Using the money he made from the sale, Musk founded SpaceX, a spaceflight services company, in 2002. '' # print(text_summary(text)) def summary(inputtext): output= text_summary(inputtext) return output[0]['summary_text'] gr.close_all() demo = gr.Interface(fn=summary, inputs="text", outputs="text") # demo = gr.Interface(fn=summary, # inputs=[gr.Textbox(label="Input text to summarize",lines=6)], # outputs=[gr.Textbox(label="Summarized text",lines=4)], # title="GenAI Project 1: Text Summarizer", # description="THIS APPLICATION IS USED TO SUMMARIZE TEXT") demo.launch()