File size: 1,115 Bytes
94f99af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from summarizer import TransformerSummarizer

title = "Summarizer"
description = """
This demo is GPT-2 based Summarizer, 
works with English, Ukrainian, and Russian (and a few other languages too, it`s GPT-2 after all).
"""


def start_fn(article_input: str) -> str:
    """
    GPT-2 based solution, input full text, output summarized text
    :param article_input:
    :return summarized article_output:
    """
    GPT2_model = TransformerSummarizer(transformer_type="GPT2", transformer_model_key="gpt2-medium")
    full = ''.join(GPT2_model(article_input, min_length=60))
    return full


face = gr.Interface(fn=start_fn,
                    inputs=gr.inputs.Textbox(lines=2, placeholder="Paste article here.", label='Input Article'),
                    outputs=gr.inputs.Textbox(lines=2, placeholder="Summarized article here.", label='Summarized '
                                                                                                     'Article'),
                    title=title,
                    description=description,)
face.launch(server_name="0.0.0.0", share=True)