diff --git a/deploy/hubserving/ocr_det/params.py b/deploy/hubserving/ocr_det/params.py index ba41dd07f135402b5878add415c482edf12e2695..3a310e0b523af7ebc124382761c443ef6c4cbf0c 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 09bdeeb3c62abe3a1d197719b79d4f523ff5e5e1..b8854c8c0718ddade7415e1d52b3deb0b2659868 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 9972a3ded83589e7552b308c59b9dc09a9a4399b..4df1979a103345c3d2089cd0b1872bad49dcb944 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 ab6dbeff749beb5ddb14d116f2d3580ad074d337..183a25912c2c62371e6db6af2fde5c792fbcbecb 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 8b99796a257f45d48cf3e0386c741ec798ee23e0..27eccbb5e9c465f20b3725f04aa1652e6829fa3c 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