File size: 629 Bytes
de45d18
 
 
b8a57f3
de45d18
b8a57f3
 
 
de45d18
b8a57f3
 
 
 
 
 
 
 
 
de45d18
 
 
b8a57f3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
from transformers import pipeline

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

def summarize_text(text):
    summary = pipe(text, max_length=150, min_length=40, do_sample=False)
    return summary[0]['summary_text']

title = "Text Summarization with BART"
description = "Provide a block of text, and the BART model will summarize it."

interface = gr.Interface(
    fn=summarize_text,
    inputs=gr.Textbox(lines=10, label="Input Text"),
    outputs=gr.Textbox(label="Summarized Text"),
    title=title,
    description=description,
)

if __name__ == "__main__":
    interface.launch()