RanjithkumarPanjabikesan's picture
Create app.py
73a6969 verified
raw
history blame contribute delete
803 Bytes
#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()