Spaces:
Sleeping
Sleeping
File size: 1,678 Bytes
7e9821b 9a82ad6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
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()
|