import torch import gradio as gr # Use a pipeline as a high-level helper from transformers import pipeline #model_path = ("../Models/models--sshleifer--distilbart-cnn-6-6/snapshots" # "/d2fde4ca965ba893255479612e4b801aa6500029") #text_summary = pipeline("summarization", model=model_path, torch_dtype=torch.bfloat16) text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-6-6", torch_dtype=torch.bfloat16) #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. 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.''' #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 = gr.Interface(fn=summary, inputs=[gr.Textbox(label="Input text to summarize",lines=6)], outputs=[gr.Textbox(label="Summarized text",lines=4)], title="@GenAILearniverse Project 1: Text Summarizer", description="THIS APPLICATION WILL BE USED TO SUMMARIZE THE TEXT") demo.launch()