import torch as t import gradio as gr from transformers import pipeline # model_path = ("../Model/models--zaib32--autotrain-finetuned_distillbart-3664997842/snapshots/a44da4a43958852b7010ccc60a65dc3bb69b403e") pipe = pipeline("summarization", model="zaib32/autotrain-finetuned_distillbart-3664997842", torch_dtype=t.bfloat16) # text='''Elon Reeve Musk (born June 28, 1971) is a businessman and investor. He is the founder, chairman, CEO, and CTO of SpaceX; angel investor, CEO, product architect, and former chairman of Tesla, Inc.; owner, executive chairman, and CTO of X Corp.; founder of the Boring Company and xAI; co-founder of Neuralink and OpenAI; and president of the Musk Foundation.''' # print(pipe(text)) def summary(text): output = pipe(text) 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="@GenAILearning Project 1: Text Summarizer", description="This application will summarize text") demo.launch()