IFA-summarizer / app.py
edemgold's picture
Added block by block summarizing
e8e2eea
raw
history blame
634 Bytes
from transformers import pipeline
import gradio as gr
#model
model = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6") #model="sshleifer/distilbart-cnn-12-6")
def func(Text):
words = Text.split()
grouped_words = [' '.join(words[i: i + 300]) for i in range(0, len(words), 300)]
summary_list = []
for i in grouped_words:
y = model(i, max_length=80, do_sample=False)
summary_list.append(y)
final_summary = ','.join(str(v) for v in summary_list)
return final_summary
import gradio as gr
app = gr.Interface(fn=func, inputs="textbox", outputs="textbox", title="InfluencerAI-Summarizer")
app.launch()