diff --git a/deploy/cpp_infer/readme.md b/deploy/cpp_infer/readme.md index 0b2441097fbdd0c0ea3acb7ce5a696837645443f..571ed2eb2b071574aec3cabdff01b6c9d7f17440 100644 --- a/deploy/cpp_infer/readme.md +++ b/deploy/cpp_infer/readme.md @@ -193,6 +193,9 @@ make -j sh tools/run.sh ``` +* 若需要使用方向分类器,则需要将`tools/config.txt`中的`use_angle_cls`参数修改为1,表示开启方向分类器的预测。 + + 最终屏幕上会输出检测结果如下。
diff --git a/deploy/cpp_infer/readme_en.md b/deploy/cpp_infer/readme_en.md index ecb29f9b9673446c86b2b561440b57d29ea457f4..a545b8606cda0b476b439543382d997065721892 100644 --- a/deploy/cpp_infer/readme_en.md +++ b/deploy/cpp_infer/readme_en.md @@ -162,7 +162,7 @@ inference/ sh tools/build.sh ``` -具体地,`tools/build.sh`中内容如下。 +Specifically, the content in `tools/build.sh` is as follows. ```shell OPENCV_DIR=your_opencv_dir @@ -201,6 +201,8 @@ make -j sh tools/run.sh ``` +* If you want to orientation classifier to correct the detected boxes, you can set `use_angle_cls` in the file `tools/config.txt` as 1 to enable the function. + The detection results will be shown on the screen, which is as follows.
diff --git a/deploy/cpp_infer/tools/config.txt b/deploy/cpp_infer/tools/config.txt index 28bacba60d4a599ad951c9820938b38e55b07283..9fa770bb04dd4991e6844ad67aa1bbcfa7788318 100644 --- a/deploy/cpp_infer/tools/config.txt +++ b/deploy/cpp_infer/tools/config.txt @@ -15,7 +15,7 @@ det_model_dir ./inference/det_db # cls config use_angle_cls 0 -cls_model_dir ../inference/cls +cls_model_dir ./inference/cls cls_thresh 0.9 # rec config diff --git a/doc/doc_ch/whl.md b/doc/doc_ch/whl.md index 657f9837a768f6753b68b5e937134e10440e382d..46796ce64a60f12db9bbfbdd7b16ff77238c1831 100644 --- a/doc/doc_ch/whl.md +++ b/doc/doc_ch/whl.md @@ -19,7 +19,9 @@ pip install dist/paddleocr-x.x.x-py3-none-any.whl # x.x.x是paddleocr的版本 * 检测+分类+识别全流程 ```python from paddleocr import PaddleOCR, draw_ocr -ocr = PaddleOCR(use_angle_cls=True) # need to run only once to download and load model into memory +# Paddleocr目前支持中英文、英文、法语、德语、韩语、日语,可以通过修改lang参数进行切换 +# 参数依次为`zh`, `en`, `french`, `german`, `korean`, `japan`。 +ocr = PaddleOCR(use_angle_cls=True, lang="ch") # need to run only once to download and load model into memory img_path = 'PaddleOCR/doc/imgs/11.jpg' result = ocr.ocr(img_path, cls=True) for line in result: diff --git a/doc/doc_en/whl_en.md b/doc/doc_en/whl_en.md index b62e5454e82a9bf4f8242b94b0d37544d3796c13..4049d9dcb2d52eb5f610d5f02017a9d2d4f14f47 100644 --- a/doc/doc_en/whl_en.md +++ b/doc/doc_en/whl_en.md @@ -17,12 +17,16 @@ pip install dist/paddleocr-x.x.x-py3-none-any.whl # x.x.x is the version of padd * detection classification and recognition ```python from paddleocr import PaddleOCR,draw_ocr +# Paddleocr supports Chinese, English, French, German, Korean and Japanese. +# You can set the parameter `lang` as `zh`, `en`, `french`, `german`, `korean`, `japan` +# to switch the language model in order. ocr = PaddleOCR(use_angle_cls=True, lang='en') # need to run only once to download and load model into memory img_path = 'PaddleOCR/doc/imgs_en/img_12.jpg' result = ocr.ocr(img_path, cls=True) for line in result: print(line) + # draw result from PIL import Image image = Image.open(img_path).convert('RGB') diff --git a/paddleocr.py b/paddleocr.py index 55ca87ac93996311d2760b9e2b63530acc7e5092..7e9b2402ad792b4d690b1147f042203df46872a5 100644 --- a/paddleocr.py +++ b/paddleocr.py @@ -46,6 +46,26 @@ model_urls = { 'url': 'https://paddleocr.bj.bcebos.com/20-09-22/mobile/en/en_ppocr_mobile_v1.1_rec_infer.tar', 'dict_path': './ppocr/utils/ic15_dict.txt' + }, + 'french': { + 'url': + 'https://paddleocr.bj.bcebos.com/20-09-22/mobile/fr/french_ppocr_mobile_v1.1_rec_infer.tar', + 'dict_path': './ppocr/utils/french_dict.txt' + }, + 'german': { + 'url': + 'https://paddleocr.bj.bcebos.com/20-09-22/mobile/ge/german_ppocr_mobile_v1.1_rec_infer.tar', + 'dict_path': './ppocr/utils/german_dict.txt' + }, + 'korean': { + 'url': + 'https://paddleocr.bj.bcebos.com/20-09-22/mobile/kr/korean_ppocr_mobile_v1.1_rec_infer.tar', + 'dict_path': './ppocr/utils/korean_dict.txt' + }, + 'japan': { + 'url': + 'https://paddleocr.bj.bcebos.com/20-09-22/mobile/jp/japan_ppocr_mobile_v1.1_rec_infer.tar', + 'dict_path': './ppocr/utils/japan_dict.txt' } }, 'cls': @@ -165,8 +185,9 @@ class PaddleOCR(predict_system.TextSystem): postprocess_params.__dict__.update(**kwargs) self.use_angle_cls = postprocess_params.use_angle_cls lang = postprocess_params.lang - assert lang in model_urls['rec'], 'param lang must in {}'.format( - model_urls['rec'].keys()) + assert lang in model_urls[ + 'rec'], 'param lang must in {}, but got {}'.format( + model_urls['rec'].keys(), lang) if postprocess_params.rec_char_dict_path is None: postprocess_params.rec_char_dict_path = model_urls['rec'][lang][ 'dict_path']