import gradio as gr from memsum import MemSum sent_tokenize = lambda txt: txt.split('. ') model_path = "model/MemSum_Final/model.pt" summarizer = MemSum(model_path, "model/glove/vocabulary_200dim.pkl") def preprocess(text): text = text.replace("\n","") text = text.replace("ΒΆ","") text = " ".join(text.split()) return text def summarize(text): text = sent_tokenize( preprocess(text) ) summary = "\n".join( summarizer.summarize(text) ) return summary demo = gr.Interface(fn=summarize, inputs="text", outputs="text") demo.launch()