Spaces:
Build error
Build error
import os | |
import model as st_model | |
import gradio as gr | |
model = st_model.summarizer() | |
title = "SummerTime: Text Summarization for Non-Experts" | |
description = "This is a demo of SummerTime: An open-source text summarization toolkit for non-experts. You can read more about the project at the links below. Input your text below (or click one of the examples to load them), and the model will generate a summary for it. Results should take 10-15s" | |
article = "<p style='text-align: center'><a target='_blank' href='https://arxiv.org/abs/2108.12738'>SummerTime: Text Summarization Toolkit for Non-experts</a> | <a target='_blank' href='https://github.com/Yale-LILY/SummerTime'>Github Repo</a> | <a target='_blank' href='https://colab.research.google.com/drive/19tPdBgaJ4_QjSiFyoxtpnFGW4OG1gTec?usp=sharing'>Colab Notebook</a></p>" | |
examples=[["""PG&E stated it scheduled the blackouts in response to forecasts for high winds amid dry conditions. | |
The aim is to reduce the risk of wildfires. Nearly 800 thousand customers were scheduled to be affected | |
by the shutoffs which were expected to last through at least midday tomorrow."""], | |
["""Representative Kevin McCarthy, the House Republican leader, has threatened to retaliate against any company that complies with the congressional committee investigating the Jan. 6 riot, after the panel asked dozens of firms to preserve the phone and social media records of 11 far-right members of Congress who pushed to overturn the results of the 2020 election. Mr. McCarthy’s warning was an escalation of his efforts to thwart a full accounting of the deadly attack at the Capitol carried out by a pro-Trump mob, and his latest attempt to insulate the former president and Republican lawmakers from scrutiny of any ties to the violence. It came after he led the G.O.P. opposition to the creation of an independent bipartisan commission to investigate the riot, and then pulled five Republican congressmen from the select committee that Democrats created on their own, boycotting the proceedings."""], | |
["""Asked about the report, Google responded in an email that its "advertising technologies help websites and apps fund their content, enable small businesses to grow, and protect users from exploitative privacy practices and bad ad experiences." A lawsuit by 38 U.S. states and territories accuses Google of abusing its market power in an effort to make its search engine as dominant inside cars, TVs and speakers as it is in phones. This was consolidated with the federal lawsuit for purposes of discovery. Texas, backed by other states, filed a separate lawsuit against Google, accusing it of breaking antitrust law in how it runs its online advertising business."""]] | |
cache = {} | |
for example in examples: | |
cache[example[0]] = model.summarize(example)[0] | |
def inference(text): | |
if text in cache: | |
return cache[text] | |
documents = [text] | |
return model.summarize(documents)[0] | |
gr.Interface( | |
inference, | |
[gr.inputs.Textbox(label="Input", lines=20)], | |
gr.outputs.Textbox(label="Output"), | |
title=title, | |
description=description, | |
article=article, | |
examples=examples).launch(debug=True) |