File size: 604 Bytes
4436b5b
fca2fe7
4436b5b
fca2fe7
a14091f
fca2fe7
a14091f
 
afc6983
 
9b8f129
fefb2c2
 
 
afc6983
 
a14091f
b098e20
4436b5b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import gradio as gr
from transformers import pipeline

summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
ner = pipeline("ner", aggregation_strategy="simple")

def get_entities(article):
    return ner(article)
    
def make_summary(article, max_length=130, min_length=30, do_sample=False):
    summ = summarizer(article, max_length, min_length, do_sample)[0]
    ents = get_entities(article)
    entslen = len(ents[0].keys())
    return summ.get('summary_text'), entslen, ents



iface = gr.Interface(fn=make_summary, inputs="text", outputs=['text', 'text', 'text'])
iface.launch()