BartSummarizer / app.py
derina's picture
Update app.py
2a1640e
raw
history blame
1.02 kB
import gradio as gr
from transformers import pipeline
summarizer = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6")
def summarize(text):
return summarizer(text, max_length=400, min_length=50)[0]["summary_text"]
title = "OpenAI Summarizer"
description = "Abstractive Text Summarization using Hugging Face transformers."
article = "<div style='text-align: center; max-width:800px; margin:10px auto;'><p></p><p>Sources: <a href='https://github.com/huggingface/transformers/' target='_blank'>Transformers</a>: Machine Learning with pretrained models</p><p style='text-align: center'> With help of <a href='https://fxstrengthmeter.com/' target='_blank'>Currency Strength meter</a>: live indicator with real-time market data that compares a currency with other major currencies</p></div>"
gr.Interface(
fn=summarize,
inputs=gr.inputs.Textbox(lines=12, placeholder="Enter text to summarize here"),
outputs="text",
title=title,
description=description,
article=article,
).launch()