From f10c4580a87dbec84c70e8ea78b4c61e0a1246b1 Mon Sep 17 00:00:00 2001 From: xiaoting <31891223+tink2123@users.noreply.github.com> Date: Wed, 8 Jun 2022 14:01:21 +0800 Subject: [PATCH] update for serving (#6518) --- deploy/pdserving/README.md | 2 +- deploy/pdserving/README_CN.md | 2 +- deploy/pdserving/web_service.py | 7 ++++--- test_tipc/test_serving_infer_cpp.sh | 2 -- test_tipc/test_serving_infer_python.sh | 6 ++---- 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/deploy/pdserving/README.md b/deploy/pdserving/README.md index 29c85c082..83329a11c 100644 --- a/deploy/pdserving/README.md +++ b/deploy/pdserving/README.md @@ -136,7 +136,7 @@ The recognition model is the same. 2. Run the following command to start the service. ``` # Start the service and save the running log in log.txt - python3 web_service.py &>log.txt & + python3 web_service.py --config=config.yml &>log.txt & ``` After the service is successfully started, a log similar to the following will be printed in log.txt ![](./imgs/start_server.png) diff --git a/deploy/pdserving/README_CN.md b/deploy/pdserving/README_CN.md index 92b1ad0c6..ab05b766e 100644 --- a/deploy/pdserving/README_CN.md +++ b/deploy/pdserving/README_CN.md @@ -135,7 +135,7 @@ python3 -m paddle_serving_client.convert --dirname ./ch_PP-OCRv3_rec_infer/ \ 2. 启动服务可运行如下命令: ``` # 启动服务,运行日志保存在log.txt - python3 web_service.py &>log.txt & + python3 web_service.py --config=config.yml &>log.txt & ``` 成功启动服务后,log.txt中会打印类似如下日志 ![](./imgs/start_server.png) diff --git a/deploy/pdserving/web_service.py b/deploy/pdserving/web_service.py index d8491dc57..b6fadb91d 100644 --- a/deploy/pdserving/web_service.py +++ b/deploy/pdserving/web_service.py @@ -19,7 +19,7 @@ import copy import cv2 import base64 # from paddle_serving_app.reader import OCRReader -from ocr_reader import OCRReader, DetResizeForTest +from ocr_reader import OCRReader, DetResizeForTest, ArgsParser from paddle_serving_app.reader import Sequential, ResizeByFactor from paddle_serving_app.reader import Div, Normalize, Transpose from paddle_serving_app.reader import DBPostProcess, FilterBoxes, GetRotateCropImage, SortedBoxes @@ -85,7 +85,7 @@ class RecOp(Op): dt_boxes = copy.deepcopy(self.dt_list) feed_list = [] img_list = [] - max_wh_ratio = 320/48. + max_wh_ratio = 320 / 48. ## Many mini-batchs, the type of feed_data is list. max_batch_size = 6 # len(dt_boxes) @@ -163,5 +163,6 @@ class OcrService(WebService): uci_service = OcrService(name="ocr") -uci_service.prepare_pipeline_config("config.yml") +FLAGS = ArgsParser().parse_args() +uci_service.prepare_pipeline_config(yml_dict=FLAGS.conf_dict) uci_service.run_service() diff --git a/test_tipc/test_serving_infer_cpp.sh b/test_tipc/test_serving_infer_cpp.sh index cad17506e..6b90fe943 100644 --- a/test_tipc/test_serving_infer_cpp.sh +++ b/test_tipc/test_serving_infer_cpp.sh @@ -106,8 +106,6 @@ function func_serving(){ cd ${serving_dir_value} # cpp serving - unset https_proxy - unset http_proxy for gpu_id in ${gpu_value[*]}; do if [ ${gpu_id} = "null" ]; then if [ ${model_name} = "ch_PP-OCRv2" ] || [ ${model_name} = "ch_PP-OCRv3" ] || [ ${model_name} = "ch_ppocr_mobile_v2.0" ] || [ ${model_name} = "ch_ppocr_server_v2.0" ]; then diff --git a/test_tipc/test_serving_infer_python.sh b/test_tipc/test_serving_infer_python.sh index 8bdb27bce..1523f6655 100644 --- a/test_tipc/test_serving_infer_python.sh +++ b/test_tipc/test_serving_infer_python.sh @@ -107,8 +107,6 @@ function func_serving(){ python_list=(${python_list}) cd ${serving_dir_value} - unset https_proxy - unset http_proxy python=${python_list[0]} # python serving @@ -147,7 +145,7 @@ function func_serving(){ status_check $last_status "${pipeline_cmd}" "${status_log}" "${model_name}" sleep 2s done - ps ux | grep -E 'web_service|pipeline' | awk '{print $2}' | xargs kill -s 9 + ps ux | grep -E 'web_service' | awk '{print $2}' | xargs kill -s 9 done done elif [ ${use_gpu} = "gpu" ]; then @@ -197,7 +195,7 @@ function func_serving(){ status_check $last_status "${pipeline_cmd}" "${status_log}" "${model_name}" sleep 2s done - ps ux | grep -E 'web_service|pipeline' | awk '{print $2}' | xargs kill -s 9 + ps ux | grep -E 'web_service' | awk '{print $2}' | xargs kill -s 9 done done else