File size: 803 Bytes
73a6969
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#Summarize any text using the `shleifer/distilbart-cnn-12-6` model
#Create a text summarization Pipeline
from transformers import pipeline
tsp = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6")
#Build the Text Summarization App and Launch
import gradio as gr
#Define summarization function
def summarize(input):
    output = tsp(input)
    return output[0]['summary_text']

textsummarizationapp = gr.Interface(fn=summarize,
                    inputs=[gr.Textbox(label="Text to summarize", lines=6)],
                    outputs=[gr.Textbox(label="Result", lines=3)],
                    title="Text summarization with distilbart-cnn",
                    description="Summarize any text using the `sshleifer/distilbart-cnn-12-6` model"
                   )
textsummarizationapp.launch()