diff --git a/doc/doc_ch/whl.md b/doc/doc_ch/whl.md index 17278926bbf072bd9708d2422d0a792065ff1fdb..511e0421f1e249e340f2002a900b59633e31880e 100644 --- a/doc/doc_ch/whl.md +++ b/doc/doc_ch/whl.md @@ -199,12 +199,10 @@ for line in result: paddleocr -h ``` -**注意** whl包默认使用`PP-OCRv3`模型,识别模型使用的输入shape为`3,48,320`, 因此如果使用识别功能,需要添加参数`--rec_image_shape 3,48,320`,如果不使用默认的`PP-OCRv3`模型,则无需设置该参数。 - * 检测+方向分类器+识别全流程 ```bash -paddleocr --image_dir PaddleOCR/doc/imgs/11.jpg --use_angle_cls true --rec_image_shape 3,48,320 +paddleocr --image_dir PaddleOCR/doc/imgs/11.jpg --use_angle_cls true ``` 结果是一个list,每个item包含了文本框,文字和识别置信度 @@ -217,7 +215,7 @@ paddleocr --image_dir PaddleOCR/doc/imgs/11.jpg --use_angle_cls true --rec_image * 检测+识别 ```bash -paddleocr --image_dir PaddleOCR/doc/imgs/11.jpg --rec_image_shape 3,48,320 +paddleocr --image_dir PaddleOCR/doc/imgs/11.jpg ``` 结果是一个list,每个item包含了文本框,文字和识别置信度 @@ -230,7 +228,7 @@ paddleocr --image_dir PaddleOCR/doc/imgs/11.jpg --rec_image_shape 3,48,320 * 方向分类器+识别 ```bash -paddleocr --image_dir PaddleOCR/doc/imgs_words/ch/word_1.jpg --use_angle_cls true --det false --rec_image_shape 3,48,320 +paddleocr --image_dir PaddleOCR/doc/imgs_words/ch/word_1.jpg --use_angle_cls true --det false ``` 结果是一个list,每个item只包含识别结果和识别置信度 @@ -256,7 +254,7 @@ paddleocr --image_dir PaddleOCR/doc/imgs/11.jpg --rec false * 单独执行识别 ```bash -paddleocr --image_dir PaddleOCR/doc/imgs_words/ch/word_1.jpg --det false --rec_image_shape 3,48,320 +paddleocr --image_dir PaddleOCR/doc/imgs_words/ch/word_1.jpg --det false ``` 结果是一个list,每个item只包含识别结果和识别置信度 diff --git a/doc/doc_en/whl_en.md b/doc/doc_en/whl_en.md index 9f7e10d4ece14ec191b08950eef0304dfd0ae966..d81e5532cf1db0193abf61b972420bdc3bacfd0b 100644 --- a/doc/doc_en/whl_en.md +++ b/doc/doc_en/whl_en.md @@ -172,11 +172,9 @@ show help information paddleocr -h ``` -**Note**: The whl package uses the `PP-OCRv3` model by default, and the input shape used by the recognition model is `3,48,320`, so if you use the recognition function, you need to add the parameter `--rec_image_shape 3,48,320`, if you do not use the default `PP- OCRv3` model, you do not need to set this parameter. - * detection classification and recognition ```bash -paddleocr --image_dir PaddleOCR/doc/imgs_en/img_12.jpg --use_angle_cls true --lang en --rec_image_shape 3,48,320 +paddleocr --image_dir PaddleOCR/doc/imgs_en/img_12.jpg --use_angle_cls true --lang en ``` Output will be a list, each item contains bounding box, text and recognition confidence @@ -189,7 +187,7 @@ Output will be a list, each item contains bounding box, text and recognition con * detection and recognition ```bash -paddleocr --image_dir PaddleOCR/doc/imgs_en/img_12.jpg --lang en --rec_image_shape 3,48,320 +paddleocr --image_dir PaddleOCR/doc/imgs_en/img_12.jpg --lang en ``` Output will be a list, each item contains bounding box, text and recognition confidence @@ -202,7 +200,7 @@ Output will be a list, each item contains bounding box, text and recognition con * classification and recognition ```bash -paddleocr --image_dir PaddleOCR/doc/imgs_words_en/word_10.png --use_angle_cls true --det false --lang en --rec_image_shape 3,48,320 +paddleocr --image_dir PaddleOCR/doc/imgs_words_en/word_10.png --use_angle_cls true --det false --lang en ``` Output will be a list, each item contains text and recognition confidence @@ -225,7 +223,7 @@ Output will be a list, each item only contains bounding box * only recognition ```bash -paddleocr --image_dir PaddleOCR/doc/imgs_words_en/word_10.png --det false --lang en --rec_image_shape 3,48,320 +paddleocr --image_dir PaddleOCR/doc/imgs_words_en/word_10.png --det false --lang en ``` Output will be a list, each item contains text and recognition confidence diff --git a/paddleocr.py b/paddleocr.py index 3ed4b47bf129889f388d07ca9c2ae0bc8ecda018..f7871db6470c75db82e8251dff5361c099c4adda 100644 --- a/paddleocr.py +++ b/paddleocr.py @@ -412,6 +412,10 @@ class PaddleOCR(predict_system.TextSystem): params.cls_model_dir, cls_url = confirm_model_dir_url( params.cls_model_dir, os.path.join(BASE_DIR, 'whl', 'cls'), cls_model_config['url']) + if params.ocr_version == 'PP-OCRv3': + params.rec_image_shape = "3, 48, 320" + else: + params.rec_image_shape = "3, 32, 320" # download model maybe_download(params.det_model_dir, det_url) maybe_download(params.rec_model_dir, rec_url)