From 502a8abc438a7a69d1f2379a2a5cec8354f941cb Mon Sep 17 00:00:00 2001 From: barrierye Date: Thu, 16 Apr 2020 16:19:23 +0800 Subject: [PATCH] fix bug in gpu web_service && test=serving --- .../general-server/op/general_response_op.cpp | 1 - .../op/general_text_response_op.cpp | 1 - .../paddle_serving_server_gpu/web_service.py | 22 ++++++++++++++----- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/core/general-server/op/general_response_op.cpp b/core/general-server/op/general_response_op.cpp index 39869a7a..6992227c 100644 --- a/core/general-server/op/general_response_op.cpp +++ b/core/general-server/op/general_response_op.cpp @@ -183,7 +183,6 @@ int GeneralResponseOp::inference() { for (uint32_t pi = 0; pi < pre_node_names.size(); ++pi) { input_blob = get_depend_argument(pre_node_names[pi]); VLOG(2) << "p size for input blob: " << input_blob->p_size; - ModelOutput *output = res->mutable_outputs(pi); int profile_time_idx = -1; if (pi == 0) { profile_time_idx = 0; diff --git a/core/general-server/op/general_text_response_op.cpp b/core/general-server/op/general_text_response_op.cpp index 64c59ae4..ae194119 100644 --- a/core/general-server/op/general_text_response_op.cpp +++ b/core/general-server/op/general_text_response_op.cpp @@ -138,7 +138,6 @@ int GeneralTextResponseOp::inference() { for (uint32_t pi = 0; pi < pre_node_names.size(); ++pi) { input_blob = get_depend_argument(pre_node_names[pi]); VLOG(2) << "p size for input blob: " << input_blob->p_size; - ModelOutput *output = res->mutable_outputs(pi); int profile_time_idx = -1; if (pi == 0) { profile_time_idx = 0; diff --git a/python/paddle_serving_server_gpu/web_service.py b/python/paddle_serving_server_gpu/web_service.py index 1bb8e93b..3081f15f 100755 --- a/python/paddle_serving_server_gpu/web_service.py +++ b/python/paddle_serving_server_gpu/web_service.py @@ -11,6 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +# pylint: disable=doc-string-missing from flask import Flask, request, abort from paddle_serving_server_gpu import OpMaker, OpSeqMaker, Server @@ -103,11 +104,22 @@ class WebService(object): abort(400) if "fetch" not in request.json: abort(400) - feed, fetch = self.preprocess(request.json, request.json["fetch"]) - fetch_map_batch = self.client.predict(feed=feed, fetch=fetch) - fetch_map_batch = self.postprocess( - feed=request.json, fetch=fetch, fetch_map=fetch_map_batch) - result = {"result": fetch_map_batch} + try: + feed, fetch = self.preprocess(request.json, request.json["fetch"]) + if isinstance(feed, list): + fetch_map_batch = self.client.predict( + feed_batch=feed, fetch=fetch) + fetch_map_batch = self.postprocess( + feed=request.json, fetch=fetch, fetch_map=fetch_map_batch) + result = {"result": fetch_map_batch} + elif isinstance(feed, dict): + if "fetch" in feed: + del feed["fetch"] + fetch_map = self.client_service.predict(feed=feed, fetch=fetch) + result = self.postprocess( + feed=request.json, fetch=fetch, fetch_map=fetch_map) + except ValueError: + result = {"result": "Request Value Error"} return result def run_server(self): -- GitLab