Spaces:
Sleeping
Sleeping
| 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-12-6\snapshots\a4f8f3ea906ed274767e9906dbaede7531d660ff") | |
| #torch_dtype - compress the model | |
| text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6",torch_dtype=torch.bfloat16) | |
| # text="Once upon a time, while flying through the air, a stork noticed the sparkle of a ring. It belonged to a rabbit who was getting married that day. The rabbit went inside its burrow leaving the ring outside, and the stork decided to try it on quickly without asking." | |
| # 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() | |