help='Batch size') parser.add_argument('-n_best', type=int, default=1, help="""If verbose is set, will output the n_best decoded sentences""") parser.add_argument('-no_cuda', action='store_true') opt = parser.parse_args() opt.cuda = not opt.no_cuda # Prepare DataLoader data = torch.load(opt.src) data['settings'].cuda = opt.cuda # Create Translator Model translator = Summarizer(opt) # Create Tokenizer tokenizer = FullTokenizer(opt.vocab) @app.route('/', methods=['POST']) def summarization(): json_data = request.get_json() data_loader = preprocess(json_data) summaries = summarize(data_loader) summaries = remove_symbol(summaries) return jsonify({ 'summaries': summaries, })