From a4190e1b6f67c1a7f4e596488c9ba6913eea5d14 Mon Sep 17 00:00:00 2001 From: MRXLT Date: Mon, 14 Sep 2020 11:45:23 +0000 Subject: [PATCH 1/9] fix blazepostprocess --- python/paddle_serving_app/reader/image_reader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/paddle_serving_app/reader/image_reader.py b/python/paddle_serving_app/reader/image_reader.py index 50c0753c2..bccf6480f 100644 --- a/python/paddle_serving_app/reader/image_reader.py +++ b/python/paddle_serving_app/reader/image_reader.py @@ -317,7 +317,7 @@ def _bbox2out(self, results, clsid2catid, is_bbox_normalized=False): self.clip_bbox([xmin, ymin, xmax, ymax]) w = xmax - xmin h = ymax - ymin - im_shape = t['im_shape'][0][i].tolist() + im_shape = t['im_shape'].tolist() im_height, im_width = int(im_shape[0]), int(im_shape[1]) xmin *= im_width ymin *= im_height From 3810bcee8e50cd982a32bcff784ed1eb050cf5a5 Mon Sep 17 00:00:00 2001 From: MRXLT Date: Mon, 14 Sep 2020 13:27:56 +0000 Subject: [PATCH 2/9] fix ocr demo --- python/examples/ocr/det_debugger_server.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/examples/ocr/det_debugger_server.py b/python/examples/ocr/det_debugger_server.py index 78970af4d..913a0bb4c 100644 --- a/python/examples/ocr/det_debugger_server.py +++ b/python/examples/ocr/det_debugger_server.py @@ -23,7 +23,7 @@ from paddle_serving_app.reader import DBPostProcess, FilterBoxes if sys.argv[1] == 'gpu': from paddle_serving_server_gpu.web_service import WebService -elif sys.argv[1] == 'cpu' +elif sys.argv[1] == 'cpu': from paddle_serving_server.web_service import WebService import time import re @@ -69,7 +69,8 @@ def postprocess(self, feed={}, fetch=[], fetch_map=None): ocr_service.load_model_config("ocr_det_model") if sys.argv[1] == 'gpu': ocr_service.set_gpus("0") - ocr_service.prepare_server(workdir="workdir", port=9292, device="gpu", gpuid=0) + ocr_service.prepare_server( + workdir="workdir", port=9292, device="gpu", gpuid=0) elif sys.argv[1] == 'cpu': ocr_service.prepare_server(workdir="workdir", port=9292) ocr_service.init_det() From 06519a9ab2fcf903cea3d0c3348fd86783988adb Mon Sep 17 00:00:00 2001 From: wangjiawei04 Date: Mon, 10 Aug 2020 22:45:16 +0800 Subject: [PATCH 3/9] add debugger to webservice --- python/paddle_serving_server/web_service.py | 28 +++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/python/paddle_serving_server/web_service.py b/python/paddle_serving_server/web_service.py index f576b49d1..86a77fac8 100755 --- a/python/paddle_serving_server/web_service.py +++ b/python/paddle_serving_server/web_service.py @@ -91,6 +91,8 @@ def get_prediction(self, request): request.json["fetch"]) if isinstance(feed, dict) and "fetch" in feed: del feed["fetch"] + if len(feed) == 0: + raise ValueError("empty input") fetch_map = self.client.predict(feed=feed, fetch=fetch) result = self.postprocess( feed=request.json["feed"], fetch=fetch, fetch_map=fetch_map) @@ -122,6 +124,32 @@ def run(): self.app_instance = app_instance + def run_debugger_service(self): + import socket + localIP = socket.gethostbyname(socket.gethostname()) + print("web service address:") + print("http://{}:{}/{}/prediction".format(localIP, self.port, + self.name)) + app_instance = Flask(__name__) + + @app_instance.before_first_request + def init(): + self._launch_local_predictor() + + service_name = "/" + self.name + "/prediction" + + @app_instance.route(service_name, methods=["POST"]) + def run(): + return self.get_prediction(request) + + self.app_instance = app_instance + + def _launch_local_predictor(self): + from paddle_serving_app.local_predict import Debugger + self.client = Debugger() + self.client.load_model_config( + "{}".format(self.model_config), gpu=False, profile=False) + def run_web_service(self): self.app_instance.run(host="0.0.0.0", port=self.port, From 6568642c5278c4eea55d758bf5d789dc3d0e9417 Mon Sep 17 00:00:00 2001 From: wangjiawei04 Date: Tue, 11 Aug 2020 15:22:03 +0800 Subject: [PATCH 4/9] fix conflict From 322ac2eff32c812be504e34ec8d9ce3ea3fdce30 Mon Sep 17 00:00:00 2001 From: wangjiawei04 Date: Tue, 11 Aug 2020 22:20:10 +0800 Subject: [PATCH 5/9] app package depend opencv <=4.2.0.32 --- python/setup.py.app.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/setup.py.app.in b/python/setup.py.app.in index 1ee1cabb5..2b7ae9303 100644 --- a/python/setup.py.app.in +++ b/python/setup.py.app.in @@ -42,7 +42,7 @@ if '${PACK}' == 'ON': REQUIRED_PACKAGES = [ - 'six >= 1.10.0', 'sentencepiece', 'opencv-python', 'pillow', + 'six >= 1.10.0', 'sentencepiece', 'opencv-python<=4.2.0.32', 'pillow', 'shapely', 'pyclipper' ] From dfc1aa3784125439e8b1f5a714b63647259768cd Mon Sep 17 00:00:00 2001 From: Jiawei Wang Date: Tue, 11 Aug 2020 23:40:11 +0800 Subject: [PATCH 6/9] Update requirements.txt --- python/requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/python/requirements.txt b/python/requirements.txt index 697b24fd4..d3c7b1893 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -1,5 +1,6 @@ numpy>=1.12, <=1.16.4 ; python_version<"3.5" google>=2.0.3 +opencv-python==4.2.0.32 protobuf>=3.12.2 grpcio-tools>=1.28.1 grpcio>=1.28.1 From f93d7c8a96a6e3f9412673c2c59baa13b1158ec0 Mon Sep 17 00:00:00 2001 From: wangjiawei04 Date: Tue, 11 Aug 2020 23:58:32 +0800 Subject: [PATCH 7/9] fix codesytle --- python/examples/ocr/det_web_server.py | 3 ++- python/examples/ocr/ocr_web_server.py | 3 ++- python/examples/ocr/rec_web_server.py | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/python/examples/ocr/det_web_server.py b/python/examples/ocr/det_web_server.py index 14be74130..38c6541c7 100644 --- a/python/examples/ocr/det_web_server.py +++ b/python/examples/ocr/det_web_server.py @@ -70,7 +70,8 @@ def postprocess(self, feed={}, fetch=[], fetch_map=None): ocr_service.load_model_config("ocr_det_model") if sys.argv[1] == 'gpu': ocr_service.set_gpus("0") - ocr_service.prepare_server(workdir="workdir", port=9292, device="gpu", gpuid=0) + ocr_service.prepare_server( + workdir="workdir", port=9292, device="gpu", gpuid=0) elif sys.argv[1] == 'cpu': ocr_service.prepare_server(workdir="workdir", port=9292, device="cpu") ocr_service.init_det() diff --git a/python/examples/ocr/ocr_web_server.py b/python/examples/ocr/ocr_web_server.py index 6c0de4466..de83ca94a 100644 --- a/python/examples/ocr/ocr_web_server.py +++ b/python/examples/ocr/ocr_web_server.py @@ -95,7 +95,8 @@ def postprocess(self, feed={}, fetch=[], fetch_map=None): ocr_service.load_model_config("ocr_rec_model") if sys.argv[1] == 'gpu': ocr_service.set_gpus("0") - ocr_service.prepare_server(workdir="workdir", port=9292, device="gpu", gpuid=0) + ocr_service.prepare_server( + workdir="workdir", port=9292, device="gpu", gpuid=0) elif sys.argv[1] == 'cpu': ocr_service.prepare_server(workdir="workdir", port=9292) ocr_service.init_det_client( diff --git a/python/examples/ocr/rec_web_server.py b/python/examples/ocr/rec_web_server.py index 0f4e9f6d2..aae97fd9e 100644 --- a/python/examples/ocr/rec_web_server.py +++ b/python/examples/ocr/rec_web_server.py @@ -70,7 +70,8 @@ def postprocess(self, feed={}, fetch=[], fetch_map=None): ocr_service.init_rec() if sys.argv[1] == 'gpu': ocr_service.set_gpus("0") - ocr_service.prepare_server(workdir="workdir", port=9292, device="gpu", gpuid=0) + ocr_service.prepare_server( + workdir="workdir", port=9292, device="gpu", gpuid=0) elif sys.argv[1] == 'cpu': ocr_service.prepare_server(workdir="workdir", port=9292, device="cpu") ocr_service.run_rpc_service() From a91ca420868101f74e2cc71b1b0f538581c2051e Mon Sep 17 00:00:00 2001 From: Jiawei Wang Date: Thu, 13 Aug 2020 19:47:54 +0800 Subject: [PATCH 8/9] Update README.md --- python/examples/ocr/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/examples/ocr/README.md b/python/examples/ocr/README.md index 43dcb30e1..a0fc9f601 100644 --- a/python/examples/ocr/README.md +++ b/python/examples/ocr/README.md @@ -63,7 +63,7 @@ Dataset: RCTW 500 sample images | Serving web service | 8.69 | 13.41 | 109.97 | 2.82 | 87.76 | 4.29 | 3.98 | 78.51 | 3.66 | 4.12 | 181.02 | 136.49 | 317.51 | | Serving Debugger web service | 8.73 | 16.42 | 115.27 | 2.93 | 20.63 | 3.97 | 4.48 | 13.84 | 3.60 | 6.91 | 49.45 | 147.33 | 196.78 | -## Appendix: Det or Rec only +## Appendix: For Users who want to launch Det or Rec only if you are going to detect images not recognize it or directly recognize the words from images. We also provide Det and Rec server for you. ### Det Server From 724d99a7d4382d6780194f86c9aedc35bd339d17 Mon Sep 17 00:00:00 2001 From: MRXLT Date: Mon, 14 Sep 2020 14:28:17 +0000 Subject: [PATCH 9/9] update infer lib && fix blaze postprocess --- cmake/paddlepaddle.cmake | 2 +- python/paddle_serving_app/reader/image_reader.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/paddlepaddle.cmake b/cmake/paddlepaddle.cmake index 7670444ed..5a164e934 100644 --- a/cmake/paddlepaddle.cmake +++ b/cmake/paddlepaddle.cmake @@ -31,7 +31,7 @@ message( "WITH_GPU = ${WITH_GPU}") # Paddle Version should be one of: # latest: latest develop build # version number like 1.5.2 -SET(PADDLE_VERSION "1.7.2") +SET(PADDLE_VERSION "1.8.4") if (WITH_GPU) SET(PADDLE_LIB_VERSION "${PADDLE_VERSION}-gpu-cuda${CUDA_VERSION_MAJOR}-cudnn7-avx-mkl") diff --git a/python/paddle_serving_app/reader/image_reader.py b/python/paddle_serving_app/reader/image_reader.py index bccf6480f..38a176643 100644 --- a/python/paddle_serving_app/reader/image_reader.py +++ b/python/paddle_serving_app/reader/image_reader.py @@ -420,7 +420,7 @@ def __call__(self, image_with_bbox): for key in image_with_bbox: if key == "image": continue - if ".lod" in key: + if ".lod" in key or "im_shape" in key: continue fetch_name = key bbox_result = self._get_bbox_result(image_with_bbox, fetch_name,