diff --git a/python/examples/fit_a_line/README.md b/python/examples/fit_a_line/README.md index 8ea146e9b7a8e781cbebd004bd54c6e0adfba7c2..acc51938e39fc7b758071292e06b195ecfa558cb 100644 --- a/python/examples/fit_a_line/README.md +++ b/python/examples/fit_a_line/README.md @@ -46,5 +46,5 @@ python -m paddle_serving_server.serve --model uci_housing_model --thread 10 --po ### Client prediction ``` shell -curl -H "Content-Type:application/json" -X POST -d '{"x": [0.0137, -0.1136, 0.2553, -0.0692, 0.0582, -0.0727, -0.1583, -0.0584, 0.6283, 0.4919, 0.1856, 0.0795, -0.0332], "fetch":["price"]}' http://127.0.0.1:9393/uci/prediction +curl -H "Content-Type:application/json" -X POST -d '{"feed":[{"x": [0.0137, -0.1136, 0.2553, -0.0692, 0.0582, -0.0727, -0.1583, -0.0584, 0.6283, 0.4919, 0.1856, 0.0795, -0.0332]}], "fetch":["price"]}' http://127.0.0.1:9393/uci/prediction ``` diff --git a/python/paddle_serving_server/web_service.py b/python/paddle_serving_server/web_service.py index 4a033cbcf1d32a55eaacbe9c0f6704e304e127b3..56cbd976e49bdd0743b4354a9c6a31872657f168 100755 --- a/python/paddle_serving_server/web_service.py +++ b/python/paddle_serving_server/web_service.py @@ -61,14 +61,15 @@ class WebService(object): if "fetch" not in request.json: abort(400) try: - feed, fetch = self.preprocess(request.json, request.json["fetch"]) + feed, fetch = self.preprocess(request.json["feed"], + request.json["fetch"]) if isinstance(feed, dict) and "fetch" in feed: del feed["fetch"] fetch_map = self.client_service.predict(feed=feed, fetch=fetch) for key in fetch_map: - fetch_map[key] = fetch_map[key][0].tolist() + fetch_map[key] = fetch_map[key].tolist() result = self.postprocess( - feed=request.json, fetch=fetch, fetch_map=fetch_map) + feed=feed, fetch=fetch, fetch_map=fetch_map) result = {"result": result} except ValueError: result = {"result": "Request Value Error"} @@ -83,8 +84,8 @@ class WebService(object): p_rpc = Process(target=self._launch_rpc_service) p_rpc.start() - def preprocess(self, feed={}, fetch=[]): + def preprocess(self, feed=[], fetch=[]): return feed, fetch - def postprocess(self, feed={}, fetch=[], fetch_map=None): + def postprocess(self, feed=[], fetch=[], fetch_map=None): return fetch_map diff --git a/python/paddle_serving_server_gpu/web_service.py b/python/paddle_serving_server_gpu/web_service.py index cb833ba32b20edeb22efd5b772506d32e05e4497..6482f9b252ca5520bdde31d6aa8e1069364e82a0 100644 --- a/python/paddle_serving_server_gpu/web_service.py +++ b/python/paddle_serving_server_gpu/web_service.py @@ -105,14 +105,15 @@ class WebService(object): if "fetch" not in request.json: abort(400) try: - feed, fetch = self.preprocess(request.json, request.json["fetch"]) + feed, fetch = self.preprocess(request.json["feed"], + request.json["fetch"]) if isinstance(feed, dict) and "fetch" in feed: del feed["fetch"] fetch_map = self.client.predict(feed=feed, fetch=fetch) for key in fetch_map: - fetch_map[key] = fetch_map[key][0].tolist() + fetch_map[key] = fetch_map[key].tolist() result = self.postprocess( - feed=request.json, fetch=fetch, fetch_map=fetch_map) + feed=feed, fetch=fetch, fetch_map=fetch_map) result = {"result": result} except ValueError: result = {"result": "Request Value Error"} @@ -131,8 +132,8 @@ class WebService(object): for p in server_pros: p.start() - def preprocess(self, feed={}, fetch=[]): + def preprocess(self, feed=[], fetch=[]): return feed, fetch - def postprocess(self, feed={}, fetch=[], fetch_map=None): + def postprocess(self, feed=[], fetch=[], fetch_map=None): return fetch_map