Spaces:
Sleeping
Sleeping
| import torch | |
| import gradio as gr | |
| # Use a pipeline as a high-level helper | |
| from transformers import pipeline | |
| text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-6-6") | |
| # model_path = ("../Models/models--sshleifer--distilbart-cnn-6-6/snapshots/d2fde4ca965ba893255479612e4b801aa6500029") | |
| # text_summary = pipeline("summarization", model=model_path, | |
| # torch_dtype=torch.bfloat16) | |
| # text = '''Satoshi Nakamoto is the name used by the presumed pseudonymous[1][2][3][4] person or persons who developed bitcoin, authored the bitcoin white paper, and created and deployed bitcoin's original reference implementation.[5] As part of the implementation, Nakamoto also devised the first blockchain database.[6] Nakamoto was active in the development of bitcoin until December 2010.[7] | |
| # There has been widespread speculation about Nakamoto's true identity, with various people posited as the person or persons behind the name. Though Nakamoto's name is Japanese, and inscribed as a man living in Japan,[8] most of the speculation has involved software and cryptography experts in the United States or Europe.''' | |
| # 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 summarise the text") | |
| demo.launch() | |