textSummary2 / app.py
MoJaff's picture
Create app.py
3fc1af5 verified
import gradio as gr
from transformers import pipeline
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
def summarization(article, min_length, max_length):
summary = summarizer(article, min_length=min_length, max_length=max_length)
return summary[0]['summary_text']
example = [['''
The january signing came off the bench in the 60th minute to put Ahly ahead twelve minutes later. However, Mahmoud Bentayg, another Moroccan, equalized for Zamalek six minutes from time to grab an important point for his team
The result takes Ahly to the top top of the Egyptian Premier League with 33 points, level with Pyramids FC who has played one game less.
Zamalek are third with 28 points after 15 games to remain in the title race.
Ahly dominated the early stages, with Emam Ashour hitting the crossbar and then firing over in quick succession.
The Red Devils dominated play, in term of possession, but could not find spaces in a packed Zamalek's defence.
Zamalek grew into the game, relying on set-pieces, but struggled to create clear chances.
Zamalek started the second half strongly, with Nabil 'Dunga' Emad forcing a save from Ahly goalkeeper Mohamed El Shenawy.
Bencharki then broke the deadlock in the 72nd minute, heading home a a brilliant cross from Nejc Gradisar.
Five minutes later, Ahmed "Zizo" El Sayed went close with a header.
In the 84th minute, Bentayg scores from the goal line converting Omar Gaber's cross
Ahly's Marcel Koller responded with changes of his own, but Ashour's late effort was deflected wide as the match finished level.
''',
30,
100,
]]
iface = gr.Interface(
fn=summarization,
examples=example,
inputs=[
gr.Textbox(label='Enter an article to summarize'),
gr.Slider(minimum=10, maximum=50, value=30, label='Set min length'),
gr.Slider(minimum=50, maximum=150, value=100, label='Set max length')
],
outputs=gr.Textbox(label='Summary'),
)
iface.launch()