File size: 1,103 Bytes
8a4de57
 
b4d0042
 
8a4de57
07a225e
7d83082
 
 
5d4f177
 
b4d0042
 
 
 
 
 
5d4f177
b4d0042
5d4f177
 
731f753
b4d0042
5d4f177
 
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
import gradio as gr

#def greet(name):
#   return "Hello " + name + "!!"

from transformers import pipeline

get_completion = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6")


def summarize(input, max_length='5'):
    output = get_completion(input)
    return output[0]['summary_text']
    
gr.close_all()
demo = gr.Interface(fn=summarize, 
                    inputs=[gr.Textbox(label="Text to summarize", lines=6)],
                    outputs=[gr.Textbox(label="Summary result", lines=3)],
                    title="Text summarization with distilbart-cnn",
                    #title="Text summarization of large data",
                    #description="Summarize any text using the `shleifer/distilbart-cnn-12-6` model under the hood!"
                    description="GV user interface to summarize large text. Summarization produces a shorter version of the document (for example a research paper) while preserving the relevant and important information of the document."
                   )
#demo.launch(share=True, server_port=int(os.environ['PORT2']))
demo.launch(share=True)