memsum_app / app.py
bauerem's picture
Update app.py
8442d6f
raw
history blame
570 Bytes
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()