news_summary / app.py
skhage's picture
added ner as output
afc6983
raw
history blame
498 Bytes
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):
return summarizer(article, max_length, min_length, do_sample), get_entities(article)
iface = gr.Interface(fn=make_summary, inputs="text", outputs=['text', 'text'])
iface.launch()