File size: 1,214 Bytes
282e5ac
 
 
c2fd48b
282e5ac
2a1640e
a2f7601
 
2a1640e
 
a2f7601
8a1c525
 
2a1640e
 
 
a2f7601
 
3f0b748
a2f7601
cb04c3b
2a1640e
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import gradio as gr
from transformers import pipeline

summarizer = pipeline("summarization", model="facebook/bart-large-cnn")


def summarize(text, slen):
    return summarizer(text, max_length=slen, min_length=50)[0]["summary_text"]


title = "Bart large CNN 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(label="Input Text", lines=12, placeholder="Enter text to summarize here"),
                gr.inputs.Slider(60, 1000, default=400, label="Max summary length")    
           ],
    outputs=gr.outputs.Textbox(type="text", label="Summary"),
    title=title,
    description=description,
    article=article,
).launch()