From fa8a0e3805cd9838851bf481b8c65f01530b6ec0 Mon Sep 17 00:00:00 2001 From: WenmuZhou Date: Wed, 24 Feb 2021 15:38:54 +0800 Subject: [PATCH 1/6] Add hint --- paddleocr.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/paddleocr.py b/paddleocr.py index 7c126261ef..b7053a71c2 100644 --- a/paddleocr.py +++ b/paddleocr.py @@ -282,8 +282,13 @@ class PaddleOCR(predict_system.TextSystem): if isinstance(img, list) and det == True: logger.error('When input a list of images, det must be false') exit(0) + if cls == False: + self.use_angle_cls = False + elif cls == True and self.use_angle_cls == False: + logger.warning( + 'Since the angle classifier is not initialized, the angle classifier will not be uesd during the forward process' + ) - self.use_angle_cls = cls if isinstance(img, str): # download net image if img.startswith('http'): @@ -301,6 +306,7 @@ class PaddleOCR(predict_system.TextSystem): if isinstance(img, np.ndarray) and len(img.shape) == 2: img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR) if det and rec: + dt_boxes, rec_res = self.__call__(img) return [[box.tolist(), res] for box, res in zip(dt_boxes, rec_res)] elif det and not rec: @@ -342,3 +348,9 @@ def main(): if result is not None: for line in result: logger.info(line) + + +if __name__ == '__main__': + ocr = PaddleOCR(use_angle_cls=False) + r = ocr.ocr('doc/imgs/1.jpg') + print(r) From 8e6c03f537168c5a17a6a33b14cb9aa13a0f19a1 Mon Sep 17 00:00:00 2001 From: WenmuZhou Date: Wed, 24 Feb 2021 15:40:58 +0800 Subject: [PATCH 2/6] remove blank line --- paddleocr.py | 1 - 1 file changed, 1 deletion(-) diff --git a/paddleocr.py b/paddleocr.py index b7053a71c2..c176be3ba4 100644 --- a/paddleocr.py +++ b/paddleocr.py @@ -306,7 +306,6 @@ class PaddleOCR(predict_system.TextSystem): if isinstance(img, np.ndarray) and len(img.shape) == 2: img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR) if det and rec: - dt_boxes, rec_res = self.__call__(img) return [[box.tolist(), res] for box, res in zip(dt_boxes, rec_res)] elif det and not rec: From 20a9d3086562b0b355724f1a9704ac55aee084b4 Mon Sep 17 00:00:00 2001 From: WenmuZhou Date: Wed, 24 Feb 2021 15:41:11 +0800 Subject: [PATCH 3/6] remove blank line --- paddleocr.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/paddleocr.py b/paddleocr.py index c176be3ba4..99cb369fd9 100644 --- a/paddleocr.py +++ b/paddleocr.py @@ -347,9 +347,3 @@ def main(): if result is not None: for line in result: logger.info(line) - - -if __name__ == '__main__': - ocr = PaddleOCR(use_angle_cls=False) - r = ocr.ocr('doc/imgs/1.jpg') - print(r) From 6b12c81a727d2a98f84f9887b9bad3fb68e5b140 Mon Sep 17 00:00:00 2001 From: WenmuZhou Date: Tue, 2 Mar 2021 19:15:55 +0800 Subject: [PATCH 4/6] fix bug of custom rec dict path --- paddleocr.py | 8 +++++--- setup.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/paddleocr.py b/paddleocr.py index 99cb369fd9..c3741b2645 100644 --- a/paddleocr.py +++ b/paddleocr.py @@ -236,7 +236,9 @@ class PaddleOCR(predict_system.TextSystem): assert lang in model_urls[ 'rec'], 'param lang must in {}, but got {}'.format( model_urls['rec'].keys(), lang) + use_inner_dict = False if postprocess_params.rec_char_dict_path is None: + use_inner_dict = True postprocess_params.rec_char_dict_path = model_urls['rec'][lang][ 'dict_path'] @@ -263,9 +265,9 @@ class PaddleOCR(predict_system.TextSystem): if postprocess_params.rec_algorithm not in SUPPORT_REC_MODEL: logger.error('rec_algorithm must in {}'.format(SUPPORT_REC_MODEL)) sys.exit(0) - - postprocess_params.rec_char_dict_path = str( - Path(__file__).parent / postprocess_params.rec_char_dict_path) + if use_inner_dict: + postprocess_params.rec_char_dict_path = str( + Path(__file__).parent / postprocess_params.rec_char_dict_path) # init det_model and rec_model super().__init__(postprocess_params) diff --git a/setup.py b/setup.py index 58f6de4854..70400df484 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ setup( package_dir={'paddleocr': ''}, include_package_data=True, entry_points={"console_scripts": ["paddleocr= paddleocr.paddleocr:main"]}, - version='2.0.2', + version='2.0.3', install_requires=requirements, license='Apache License 2.0', description='Awesome OCR toolkits based on PaddlePaddle (8.6M ultra-lightweight pre-trained model, support training and deployment among server, mobile, embeded and IoT devices', From acffd750f7ad93cf545e761e95b090384345aac2 Mon Sep 17 00:00:00 2001 From: WenmuZhou Date: Thu, 11 Mar 2021 15:30:33 +0800 Subject: [PATCH 5/6] fix attn export --- ppocr/modeling/heads/rec_att_head.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ppocr/modeling/heads/rec_att_head.py b/ppocr/modeling/heads/rec_att_head.py index 0d222714ff..4286d7691d 100644 --- a/ppocr/modeling/heads/rec_att_head.py +++ b/ppocr/modeling/heads/rec_att_head.py @@ -38,7 +38,7 @@ class AttentionHead(nn.Layer): return input_ont_hot def forward(self, inputs, targets=None, batch_max_length=25): - batch_size = inputs.shape[0] + batch_size = paddle.shape(inputs)[0] num_steps = batch_max_length hidden = paddle.zeros((batch_size, self.hidden_size)) From 9749cad317dc0bbc92aa57889c3562a6d2037677 Mon Sep 17 00:00:00 2001 From: littletomatodonkey <2120160898@bit.edu.cn> Date: Thu, 18 Mar 2021 10:29:11 +0800 Subject: [PATCH 6/6] add google drive link (#2277) --- doc/doc_ch/algorithm_overview.md | 4 +++- doc/doc_en/algorithm_overview_en.md | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/doc_ch/algorithm_overview.md b/doc/doc_ch/algorithm_overview.md index c8fc280d80..19d7a69c7f 100755 --- a/doc/doc_ch/algorithm_overview.md +++ b/doc/doc_ch/algorithm_overview.md @@ -28,7 +28,9 @@ PaddleOCR开源的文本检测算法列表: | --- | --- | --- | --- | --- | --- | |SAST|ResNet50_vd|89.63%|78.44%|83.66%|[下载链接](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_r50_vd_sast_totaltext_v2.0_train.tar)| -**说明:** SAST模型训练额外加入了icdar2013、icdar2017、COCO-Text、ArT等公开数据集进行调优。PaddleOCR用到的经过整理格式的英文公开数据集下载:[百度云地址](https://pan.baidu.com/s/12cPnZcVuV1zn5DOd4mqjVw) (提取码: 2bpi) +**说明:** SAST模型训练额外加入了icdar2013、icdar2017、COCO-Text、ArT等公开数据集进行调优。PaddleOCR用到的经过整理格式的英文公开数据集下载: +* [百度云地址](https://pan.baidu.com/s/12cPnZcVuV1zn5DOd4mqjVw) (提取码: 2bpi) +* [Google Drive下载地址](https://drive.google.com/drive/folders/1ll2-XEVyCQLpJjawLDiRlvo_i4BqHCJe?usp=sharing) PaddleOCR文本检测算法的训练和使用请参考文档教程中[模型训练/评估中的文本检测部分](./detection.md)。 diff --git a/doc/doc_en/algorithm_overview_en.md b/doc/doc_en/algorithm_overview_en.md index 77b9642e3b..d70f99bb5c 100755 --- a/doc/doc_en/algorithm_overview_en.md +++ b/doc/doc_en/algorithm_overview_en.md @@ -31,7 +31,9 @@ On Total-Text dataset, the text detection result is as follows: | --- | --- | --- | --- | --- | --- | |SAST|ResNet50_vd|89.63%|78.44%|83.66%|[Download link](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_r50_vd_sast_totaltext_v2.0_train.tar)| -**Note:** Additional data, like icdar2013, icdar2017, COCO-Text, ArT, was added to the model training of SAST. Download English public dataset in organized format used by PaddleOCR from [Baidu Drive](https://pan.baidu.com/s/12cPnZcVuV1zn5DOd4mqjVw) (download code: 2bpi). +**Note:** Additional data, like icdar2013, icdar2017, COCO-Text, ArT, was added to the model training of SAST. Download English public dataset in organized format used by PaddleOCR from: +* [Baidu Drive](https://pan.baidu.com/s/12cPnZcVuV1zn5DOd4mqjVw) (download code: 2bpi). +* [Google Drive](https://drive.google.com/drive/folders/1ll2-XEVyCQLpJjawLDiRlvo_i4BqHCJe?usp=sharing) For the training guide and use of PaddleOCR text detection algorithms, please refer to the document [Text detection model training/evaluation/prediction](./detection_en.md)