import torch import gradio as gr # Use a pipeline as a high-level helper from transformers import pipeline #text = '''Elon Reeve Musk (/ˈiːlɒn mʌsk/; born June 28, 1971) is a businessman and political figure known for his key roles in the automotive company Tesla, Inc. and the space company SpaceX. Since January 2025, he is serving as Administrator of the Department of Government Efficiency, under the second Donald Trump presidential administration of the United States. He is also known for his ownership of X Corp. (the company that operates the social media platform X, formerly Twitter), 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$427 billion.''' pipe = pipeline("summarization", model="sshleifer/distilbart-xsum-12-1", torch_dtype=torch.bfloat16) def summary(input): output = pipe(input) return output[0]['summary_text'] gr.close_all() demo = gr.Interface(fn=summary, inputs=[gr.Textbox(label='Input text to summarize', lines=6)], outputs=[gr.Textbox(label='Summarized text', lines=4)], description='This is the text summarizer project', title='GenAI Summarizer', ) demo.launch(share='True')