From 164aa758cbe1c7bc5a8d892de073080e7d92bf5b Mon Sep 17 00:00:00 2001 From: guru4elephant Date: Sun, 8 Mar 2020 21:11:19 +0800 Subject: [PATCH] update web service --- python/examples/bert/prepare_model.py | 5 +++-- python/paddle_serving_server/web_service.py | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/python/examples/bert/prepare_model.py b/python/examples/bert/prepare_model.py index b5f80a78..5a7c5893 100644 --- a/python/examples/bert/prepare_model.py +++ b/python/examples/bert/prepare_model.py @@ -14,11 +14,12 @@ import paddlehub as hub import paddle.fluid as fluid +import sys import paddle_serving_client.io as serving_io model_name = "bert_chinese_L-12_H-768_A-12" module = hub.Module(model_name) -inputs, outputs, program = module.context(trainable=True, max_seq_len=20) +inputs, outputs, program = module.context(trainable=True, max_seq_len=int(sys.argv[1])) place = fluid.core_avx.CPUPlace() exe = fluid.Executor(place) input_ids = inputs["input_ids"] @@ -34,7 +35,7 @@ feed_var_names = [ target_vars = [pooled_output, sequence_output] -serving_io.save_model("serving_server_model", "serving_client_conf", { +serving_io.save_model("bert_seq{}_model".format(sys.argv[1]), "bert_seq{}_client".format(sys.argv[1]), { "input_ids": input_ids, "position_ids": position_ids, "segment_ids": segment_ids, diff --git a/python/paddle_serving_server/web_service.py b/python/paddle_serving_server/web_service.py index 00c060f1..d54dc776 100755 --- a/python/paddle_serving_server/web_service.py +++ b/python/paddle_serving_server/web_service.py @@ -60,6 +60,8 @@ class WebService(object): if "fetch" not in request.json: abort(400) feed, fetch = self.preprocess(request.json, request.json["fetch"]) + if "fetch" in feed: + del feed["fetch"] fetch_map = client_service.predict(feed=feed, fetch=fetch) fetch_map = self.postprocess(feed=request.json, fetch=fetch, fetch_map=fetch_map) return fetch_map -- GitLab