Raj Sethi
fix summarization
5a17398
raw
history blame contribute delete
871 Bytes
from transformers import pipeline
import gradio as gr
summarization=pipeline(task="summarization", model="sshleifer/distilbart-cnn-12-6")
def summarize(text:str, max_length:int):
if max_length<10:
raise gr.Error()
if text=="":
raise gr.Error("Text field is empty. Please enter some text")
summary=summarization(text,min_length=10,max_length=max_length)
return summary[0]['summary_text']
demo = gr.Interface(fn=summarize, inputs=[gr.TextArea(label="Text",placeholder="Enter any long text to be summarized"),
gr.Number(label="Words",info="Enter the max word of the summary. Min 10",minimum=10)],
outputs=gr.TextArea(label="Summary"), title="Summarization App using AI", description="This app uses AI to summarize long text into your given number of words.")
demo.launch(share=True)