Spaces:
Sleeping
Sleeping
deploy summarizer
Browse files
app.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
# Use a pipeline as a high-level helper
|
5 |
+
from transformers import pipeline
|
6 |
+
|
7 |
+
text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-6-6")
|
8 |
+
|
9 |
+
# model_path = ("../Models/models--sshleifer--distilbart-cnn-6-6/snapshots/d2fde4ca965ba893255479612e4b801aa6500029")
|
10 |
+
|
11 |
+
# text_summary = pipeline("summarization", model=model_path,
|
12 |
+
# torch_dtype=torch.bfloat16)
|
13 |
+
|
14 |
+
|
15 |
+
# 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]
|
16 |
+
|
17 |
+
# 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.'''
|
18 |
+
|
19 |
+
# print(text_summary(text))
|
20 |
+
|
21 |
+
def summary(input):
|
22 |
+
output = text_summary(input)
|
23 |
+
return output[0]['summary_text']
|
24 |
+
|
25 |
+
gr.close_all()
|
26 |
+
# demo = gr.Interface(fn=summary,inputs="text", outputs="text")
|
27 |
+
demo = gr.Interface(fn=summary,
|
28 |
+
inputs=[gr.Textbox(label="Input text to summarize", lines=6)],
|
29 |
+
outputs=[gr.Textbox(label="Summarized text", lines=4)],
|
30 |
+
title="Text Summarizer",
|
31 |
+
description="This application will be used to summarise the text")
|
32 |
+
demo.launch()
|