import torch import gradio as gr # Use a pipeline as a high-level helper from transformers import pipeline text_summary = pipeline("summarization", model="facebook/bart-large-cnn", torch_dtype=torch.bfloat16) # model_path = ("../Model/models--facebook--bart-large-cnn/snapshots/37f520fa929c961707657b28798b30c003dd100b") # text_summary = pipeline("summarization", model=model_path, # torch_dtype=torch.bfloat16) # text=""" # The tower is 324 metres (1,063 ft) tall, about the same height as # an 81-storey building, and the tallest structure in Paris. Its base # is square, measuring 125 metres (410 ft) on each side. During its # construction, the Eiffel Tower surpassed the Washington Monument to # become the tallest man-made structure in the world, a title it held # for 41 years until the Chrysler Building in New York City was finished in 1930. # It was the first structure to reach a height of 300 metres. Due to the addition # of a broadcasting aerial at the top of the tower in 1957, it is now taller than # the Chrysler Building by 5.2 metres (17 ft). Excluding transmitters, the Eiffel # Tower is the second tallest free-standing structure in France after the Millau Viaduct. # """ # 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="EQNZ Text Summarizer", description="THIS APPLICATION WILL BE USED TO SUMMARIZE THE TEXT") demo.launch()