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/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 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() 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() diff --git a/python/paddle_serving_app/reader/image_reader.py b/python/paddle_serving_app/reader/image_reader.py index 50c0753c2..38a176643 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 @@ -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, 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, 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 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' ]