CoolFace
Apppublic

sydneysimmons/Transformers-Project

sourceHugging Faceupdated 4y agoView on Hugging Face
0likes
app.py32 linesDownload Raw Back to root
1import gradio as gr2from transformers import pipeline3from newspaper import Article4 5summarizer_fb_bart = pipeline("summarization", model = "facebook/bart-large-cnn")6 7def summarizer(url):8  def article_to_text(url):9    url = url10 11    # download and parse article12    article = Article(url)13    article.download()14    article.parse()15    16    # print article text17    text = article.text18 19    # account for article length and cut it off20    words = text.split()21    if len(words) > 512:22      words = words[:512]23    text = ' '.join(words)24 25    return text26 27  return summarizer_fb_bart(article_to_text(url))28 29iface = gr.Interface(fn=summarizer, inputs=gr.Textbox(lines=2, label="Input URL to Sports Article Here:"), outputs="text", title = "Sports Article Summarization")30iface.launch()31 32