From 879be30f3a540ed827c3eb51e57db31815613f88 Mon Sep 17 00:00:00 2001 From: andyjpaddle Date: Thu, 5 May 2022 08:19:06 +0000 Subject: [PATCH] update hubserving for v3 --- deploy/hubserving/ocr_det/params.py | 2 +- deploy/hubserving/ocr_rec/params.py | 4 ++-- deploy/hubserving/ocr_system/params.py | 6 +++--- deploy/hubserving/readme.md | 8 +++++--- deploy/hubserving/readme_en.md | 8 +++++--- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/deploy/hubserving/ocr_det/params.py b/deploy/hubserving/ocr_det/params.py index ba41dd07..3a310e0b 100755 --- a/deploy/hubserving/ocr_det/params.py +++ b/deploy/hubserving/ocr_det/params.py @@ -26,7 +26,7 @@ def read_params(): #params for text detector cfg.det_algorithm = "DB" - cfg.det_model_dir = "./inference/ch_PP-OCRv2_det_infer/" + cfg.det_model_dir = "./inference/ch_PP-OCRv3_det_infer/" cfg.det_limit_side_len = 960 cfg.det_limit_type = 'max' diff --git a/deploy/hubserving/ocr_rec/params.py b/deploy/hubserving/ocr_rec/params.py index 09bdeeb3..b8854c8c 100644 --- a/deploy/hubserving/ocr_rec/params.py +++ b/deploy/hubserving/ocr_rec/params.py @@ -26,9 +26,9 @@ def read_params(): #params for text recognizer cfg.rec_algorithm = "CRNN" - cfg.rec_model_dir = "./inference/ch_PP-OCRv2_rec_infer/" + cfg.rec_model_dir = "./inference/ch_PP-OCRv3_rec_infer/" - cfg.rec_image_shape = "3, 32, 320" + cfg.rec_image_shape = "3, 48, 320" cfg.rec_batch_num = 6 cfg.max_text_length = 25 diff --git a/deploy/hubserving/ocr_system/params.py b/deploy/hubserving/ocr_system/params.py index 9972a3de..4df1979a 100755 --- a/deploy/hubserving/ocr_system/params.py +++ b/deploy/hubserving/ocr_system/params.py @@ -26,7 +26,7 @@ def read_params(): #params for text detector cfg.det_algorithm = "DB" - cfg.det_model_dir = "./inference/ch_PP-OCRv2_det_infer/" + cfg.det_model_dir = "./inference/ch_PP-OCRv3_det_infer/" cfg.det_limit_side_len = 960 cfg.det_limit_type = 'max' @@ -44,9 +44,9 @@ def read_params(): #params for text recognizer cfg.rec_algorithm = "CRNN" - cfg.rec_model_dir = "./inference/ch_PP-OCRv2_rec_infer/" + cfg.rec_model_dir = "./inference/ch_PP-OCRv3_rec_infer/" - cfg.rec_image_shape = "3, 32, 320" + cfg.rec_image_shape = "3, 48, 320" cfg.rec_batch_num = 6 cfg.max_text_length = 25 diff --git a/deploy/hubserving/readme.md b/deploy/hubserving/readme.md index ab6dbeff..183a2591 100755 --- a/deploy/hubserving/readme.md +++ b/deploy/hubserving/readme.md @@ -41,6 +41,7 @@ deploy/hubserving/ocr_system/ ``` ## 1. 近期更新 +* 2022.05.05 新增PP-OCRv3检测和识别模型。 * 2022.03.30 新增PP-Structure和表格识别两种服务。 ## 2. 快速启动服务 @@ -53,10 +54,10 @@ pip3 install paddlehub==2.1.0 --upgrade -i https://mirror.baidu.com/pypi/simple ``` ### 2.2 下载推理模型 -安装服务模块前,需要准备推理模型并放到正确路径。默认使用的是PP-OCRv2模型,默认模型路径为: +安装服务模块前,需要准备推理模型并放到正确路径。默认使用的是PP-OCRv3模型,默认模型路径为: ``` -检测模型:./inference/ch_PP-OCRv2_det_infer/ -识别模型:./inference/ch_PP-OCRv2_rec_infer/ +检测模型:./inference/ch_PP-OCRv3_det_infer/ +识别模型:./inference/ch_PP-OCRv3_rec_infer/ 方向分类器:./inference/ch_ppocr_mobile_v2.0_cls_infer/ 表格结构识别模型:./inference/en_ppocr_mobile_v2.0_table_structure_infer/ ``` @@ -223,6 +224,7 @@ hub serving start -c deploy/hubserving/ocr_system/config.json - 2、 到相应的`module.py`和`params.py`等文件中根据实际需求修改代码。 例如,如果需要替换部署服务所用模型,则需要到`params.py`中修改模型路径参数`det_model_dir`和`rec_model_dir`,如果需要关闭文本方向分类器,则将参数`use_angle_cls`置为`False`,当然,同时可能还需要修改其他相关参数,请根据实际情况修改调试。 **强烈建议修改后先直接运行`module.py`调试,能正确运行预测后再启动服务测试。** +**注意** PPOCR-v3识别模型使用的图片输入shape为`3,48,320`,因此需要修改`params.py`中的`cfg.rec_image_shape = "3, 48, 320"`,如果不使用PPOCR-v3识别模型,则无需修改该参数。 - 3、 卸载旧服务包 ```hub uninstall ocr_system``` diff --git a/deploy/hubserving/readme_en.md b/deploy/hubserving/readme_en.md index 8b99796a..27eccbb5 100755 --- a/deploy/hubserving/readme_en.md +++ b/deploy/hubserving/readme_en.md @@ -41,6 +41,7 @@ deploy/hubserving/ocr_system/ ``` ## 1. Update +* 2022.05.05 add PP-OCRv3 text detection and recognition models. * 2022.03.30 add PP-Structure and table recognition services。 @@ -55,10 +56,10 @@ pip3 install paddlehub==2.1.0 --upgrade -i https://pypi.tuna.tsinghua.edu.cn/sim ``` ### 2.2 Download inference model -Before installing the service module, you need to prepare the inference model and put it in the correct path. By default, the PP-OCRv2 models are used, and the default model path is: +Before installing the service module, you need to prepare the inference model and put it in the correct path. By default, the PP-OCRv3 models are used, and the default model path is: ``` -text detection model: ./inference/ch_PP-OCRv2_det_infer/ -text recognition model: ./inference/ch_PP-OCRv2_rec_infer/ +text detection model: ./inference/ch_PP-OCRv3_det_infer/ +text recognition model: ./inference/ch_PP-OCRv3_rec_infer/ text angle classifier: ./inference/ch_ppocr_mobile_v2.0_cls_infer/ tanle recognition: ./inference/en_ppocr_mobile_v2.0_table_structure_infer/ ``` @@ -233,6 +234,7 @@ hub serving stop --port/-p XXXX ``` - 2. Modify the code in the corresponding files, like `module.py` and `params.py`, according to the actual needs. For example, if you need to replace the model used by the deployed service, you need to modify model path parameters `det_model_dir` and `rec_model_dir` in `params.py`. If you want to turn off the text direction classifier, set the parameter `use_angle_cls` to `False`. Of course, other related parameters may need to be modified at the same time. Please modify and debug according to the actual situation. It is suggested to run `module.py` directly for debugging after modification before starting the service test. +**Note** The image input shape used by the PPOCR-v3 recognition model is `3, 48, 320`, so you need to modify `cfg.rec_image_shape = "3, 48, 320"` in `params.py`, if you do not use the PPOCR-v3 recognition model, then there is no need to modify this parameter. - 3. Uninstall old service module ```shell hub uninstall ocr_system -- GitLab