import torch import gradio as gr # Use a pipeline as a high-level helper from transformers import pipeline text_summary = pipeline(task="summarization", model= "sshleifer/distilbart-cnn-12-6", torch_dtype=torch.bfloat16) # 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/ EE-lon; born June 28, 1971) is a businessman known for his key roles in Tesla, Inc., SpaceX, and Twitter (which he rebranded as X). Since 2025, he has been a senior advisor to United States president Donald Trump and de facto head of the Department of Government Efficiency (DOGE). Musk is the wealthiest person in the world; as of February 2025, Forbes estimates his net worth to be US$353 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="TEXT SUMMARIZER", description="THIS APPLICATION WILL BE USED TO SUMMARIZE TEXT") demo.launch()