Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from summarizer import TransformerSummarizer
|
3 |
+
|
4 |
+
title = "Summarizer"
|
5 |
+
description = """
|
6 |
+
This demo is GPT-2 based Summarizer,
|
7 |
+
works with English, Ukrainian, and Russian (and a few other languages too, it`s GPT-2 after all).
|
8 |
+
"""
|
9 |
+
|
10 |
+
|
11 |
+
def start_fn(article_input: str) -> str:
|
12 |
+
"""
|
13 |
+
GPT-2 based solution, input full text, output summarized text
|
14 |
+
:param article_input:
|
15 |
+
:return summarized article_output:
|
16 |
+
"""
|
17 |
+
GPT2_model = TransformerSummarizer(transformer_type="GPT2", transformer_model_key="gpt2-medium")
|
18 |
+
full = ''.join(GPT2_model(article_input, min_length=60))
|
19 |
+
return full
|
20 |
+
|
21 |
+
|
22 |
+
face = gr.Interface(fn=start_fn,
|
23 |
+
inputs=gr.inputs.Textbox(lines=2, placeholder="Paste article here.", label='Input Article'),
|
24 |
+
outputs=gr.inputs.Textbox(lines=2, placeholder="Summarized article here.", label='Summarized '
|
25 |
+
'Article'),
|
26 |
+
title=title,
|
27 |
+
description=description,)
|
28 |
+
face.launch(server_name="0.0.0.0", share=True)
|