diff --git a/configs/det/det_db_icdar15_reader.yml b/configs/det/det_db_icdar15_reader.yml index 6258a304cc0394656d4e3b73e7d8cbf566527126..6c6833612ae3d56fbe1a23d80da24b00ab13ef3a 100755 --- a/configs/det/det_db_icdar15_reader.yml +++ b/configs/det/det_db_icdar15_reader.yml @@ -15,7 +15,6 @@ EvalReader: TestReader: reader_function: ppocr.data.det.dataset_traversal,EvalTestReader process_function: ppocr.data.det.db_process,DBProcessTest - infer_img: img_set_dir: ./train_data/icdar2015/text_localization/ label_file_path: ./train_data/icdar2015/text_localization/test_icdar2015_label.txt do_eval: True diff --git a/configs/det/det_east_icdar15_reader.yml b/configs/det/det_east_icdar15_reader.yml index 060ed4dd380d0457574c1d20be3225c7fd188108..f2df30ca29115035bc6acb7c3d8d6b33498fa6c2 100755 --- a/configs/det/det_east_icdar15_reader.yml +++ b/configs/det/det_east_icdar15_reader.yml @@ -17,7 +17,6 @@ EvalReader: TestReader: reader_function: ppocr.data.det.dataset_traversal,EvalTestReader process_function: ppocr.data.det.east_process,EASTProcessTest - infer_img: img_set_dir: ./train_data/icdar2015/text_localization/ label_file_path: ./train_data/icdar2015/text_localization/test_icdar2015_label.txt do_eval: True diff --git a/configs/det/det_mv3_db.yml b/configs/det/det_mv3_db.yml index 91a8e86f8bba440df83c1d9f7da0e6523d5907bb..24443a8f2adfff29a17fa9ae527852ba7abc8143 100755 --- a/configs/det/det_mv3_db.yml +++ b/configs/det/det_mv3_db.yml @@ -16,6 +16,7 @@ Global: checkpoints: save_res_path: ./output/det_db/predicts_db.txt save_inference_dir: + infer_img: Architecture: function: ppocr.modeling.architectures.det_model,DetModel diff --git a/configs/det/det_mv3_db_v1.1.yml b/configs/det/det_mv3_db_v1.1.yml index afc11aa01dc329d095abac6d61a48cf604ee2aa2..3cd7e34e5aade2e91910164ba71a6a792c1b0e70 100755 --- a/configs/det/det_mv3_db_v1.1.yml +++ b/configs/det/det_mv3_db_v1.1.yml @@ -16,6 +16,7 @@ Global: checkpoints: save_res_path: ./output/det_db/predicts_db.txt save_inference_dir: + infer_img: Architecture: function: ppocr.modeling.architectures.det_model,DetModel diff --git a/configs/det/det_mv3_east.yml b/configs/det/det_mv3_east.yml index 67b82fffff8c47e5ee5866ad22f238ece3822776..14f453c705e43076b6f27cb7127bb44d3f628587 100755 --- a/configs/det/det_mv3_east.yml +++ b/configs/det/det_mv3_east.yml @@ -15,6 +15,7 @@ Global: checkpoints: save_res_path: ./output/det_east/predicts_east.txt save_inference_dir: + infer_img: Architecture: function: ppocr.modeling.architectures.det_model,DetModel diff --git a/configs/det/det_r18_vd_db_v1.1.yml b/configs/det/det_r18_vd_db_v1.1.yml index f7cfe57f3883de58c26efb67d4837e37094c665a..c850599b0cd324fb078ab6e433cd0fb819733aba 100755 --- a/configs/det/det_r18_vd_db_v1.1.yml +++ b/configs/det/det_r18_vd_db_v1.1.yml @@ -15,6 +15,7 @@ Global: save_res_path: ./output/det_r18_vd_db/predicts_db.txt checkpoints: save_inference_dir: + infer_img: Architecture: function: ppocr.modeling.architectures.det_model,DetModel diff --git a/configs/det/det_r50_vd_db.yml b/configs/det/det_r50_vd_db.yml index 9a3b77e7cebce99f669d0b1be89ee56c84f41034..726ecd8ea012a42f4e82690aeb06250a35520b89 100755 --- a/configs/det/det_r50_vd_db.yml +++ b/configs/det/det_r50_vd_db.yml @@ -15,6 +15,7 @@ Global: save_res_path: ./output/det_db/predicts_db.txt checkpoints: save_inference_dir: + infer_img: Architecture: function: ppocr.modeling.architectures.det_model,DetModel diff --git a/configs/det/det_r50_vd_east.yml b/configs/det/det_r50_vd_east.yml index 8d86819937c902e47dded38ae0238fb8254d8ff0..2fb8e5cf024fac1f5e5e056965d96f3173b35c0c 100755 --- a/configs/det/det_r50_vd_east.yml +++ b/configs/det/det_r50_vd_east.yml @@ -15,6 +15,7 @@ Global: save_res_path: ./output/det_east/predicts_east.txt checkpoints: save_inference_dir: + infer_img: Architecture: function: ppocr.modeling.architectures.det_model,DetModel diff --git a/configs/det/det_r50_vd_sast_icdar15.yml b/configs/det/det_r50_vd_sast_icdar15.yml index f1ecd61dc8ccb14fde98c2fc55cb2c9e630b5c44..02593293bd0bb83cdb73a99370af6c1820f131f3 100644 --- a/configs/det/det_r50_vd_sast_icdar15.yml +++ b/configs/det/det_r50_vd_sast_icdar15.yml @@ -15,6 +15,7 @@ Global: save_res_path: ./output/det_sast/predicts_sast.txt checkpoints: save_inference_dir: + infer_img: Architecture: function: ppocr.modeling.architectures.det_model,DetModel diff --git a/configs/det/det_r50_vd_sast_totaltext.yml b/configs/det/det_r50_vd_sast_totaltext.yml index ec42ce6d4bafd0c5d4360a255f35d07e83f90787..96522852836b70a8995ae54f1e56765b58240e2d 100644 --- a/configs/det/det_r50_vd_sast_totaltext.yml +++ b/configs/det/det_r50_vd_sast_totaltext.yml @@ -15,6 +15,7 @@ Global: save_res_path: ./output/det_sast/predicts_sast.txt checkpoints: save_inference_dir: + infer_img: Architecture: function: ppocr.modeling.architectures.det_model,DetModel diff --git a/configs/det/det_sast_icdar15_reader.yml b/configs/det/det_sast_icdar15_reader.yml index ee45a85da7452e2069b0d7467b1ccfc44dd656b7..db5c6ac64e84eed4ade19a6bdaa92103aad030fb 100644 --- a/configs/det/det_sast_icdar15_reader.yml +++ b/configs/det/det_sast_icdar15_reader.yml @@ -20,5 +20,4 @@ EvalReader: TestReader: reader_function: ppocr.data.det.dataset_traversal,EvalTestReader process_function: ppocr.data.det.sast_process,SASTProcessTest - infer_img: ./train_data/icdar2015/text_localization/ch4_test_images/img_11.jpg max_side_len: 1536 diff --git a/configs/det/det_sast_totaltext_reader.yml b/configs/det/det_sast_totaltext_reader.yml index 92503d9f0e2b57f0d22b15591c5400185daf2afa..d303d176d5cee89827255ddddea4d5d771f19ddb 100644 --- a/configs/det/det_sast_totaltext_reader.yml +++ b/configs/det/det_sast_totaltext_reader.yml @@ -20,5 +20,4 @@ EvalReader: TestReader: reader_function: ppocr.data.det.dataset_traversal,EvalTestReader process_function: ppocr.data.det.sast_process,SASTProcessTest - infer_img: ./train_data/afs/total_text/Images/Test/img623.jpg max_side_len: 768 diff --git a/doc/doc_ch/detection.md b/doc/doc_ch/detection.md index 3945b7f0b996a18cfdb943c3ec68ce43fa53e6f3..5796114d69195d8fbac313f1b021fda46a870d4c 100644 --- a/doc/doc_ch/detection.md +++ b/doc/doc_ch/detection.md @@ -17,7 +17,7 @@ wget -P ./train_data/ https://paddleocr.bj.bcebos.com/dataset/test_icdar2015_la PaddleOCR 也提供了数据格式转换脚本,可以将官网 label 转换支持的数据格式。 数据转换工具在 `train_data/gen_label.py`, 这里以训练集为例: ``` -# 将官网下载的标签文件转换为 train_icdar2015_label.txt +# 将官网下载的标签文件转换为 train_icdar2015_label.txt python gen_label.py --mode="det" --root_path="icdar_c4_train_imgs/" \ --input_path="ch4_training_localization_transcription_gt" \ --output_label="train_icdar2015_label.txt" @@ -74,7 +74,7 @@ tar -xf ./pretrain_models/MobileNetV3_large_x0_5_pretrained.tar ./pretrain_model ```shell # 训练 mv3_db 模型,并将训练日志保存为 tain_det.log -python3 tools/train.py -c configs/det/det_mv3_db_v1.1.yml \ +python3 tools/train.py -c configs/det/det_mv3_db_v1.1.yml \ -o Global.pretrain_weights=./pretrain_models/MobileNetV3_large_x0_5_pretrained/ \ 2>&1 | tee train_det.log ``` @@ -119,16 +119,16 @@ python3 tools/eval.py -c configs/det/det_mv3_db_v1.1.yml -o Global.checkpoints= 测试单张图像的检测效果 ```shell -python3 tools/infer_det.py -c configs/det/det_mv3_db_v1.1.yml -o TestReader.infer_img="./doc/imgs_en/img_10.jpg" Global.checkpoints="./output/det_db/best_accuracy" +python3 tools/infer_det.py -c configs/det/det_mv3_db_v1.1.yml -o Global.infer_img="./doc/imgs_en/img_10.jpg" Global.checkpoints="./output/det_db/best_accuracy" ``` 测试DB模型时,调整后处理阈值, ```shell -python3 tools/infer_det.py -c configs/det/det_mv3_db_v1.1.yml -o TestReader.infer_img="./doc/imgs_en/img_10.jpg" Global.checkpoints="./output/det_db/best_accuracy" PostProcess.box_thresh=0.6 PostProcess.unclip_ratio=1.5 +python3 tools/infer_det.py -c configs/det/det_mv3_db_v1.1.yml -o Global.infer_img="./doc/imgs_en/img_10.jpg" Global.checkpoints="./output/det_db/best_accuracy" PostProcess.box_thresh=0.6 PostProcess.unclip_ratio=1.5 ``` 测试文件夹下所有图像的检测效果 ```shell -python3 tools/infer_det.py -c configs/det/det_mv3_db_v1.1.yml -o TestReader.infer_img="./doc/imgs_en/" Global.checkpoints="./output/det_db/best_accuracy" +python3 tools/infer_det.py -c configs/det/det_mv3_db_v1.1.yml -o Global.infer_img="./doc/imgs_en/" Global.checkpoints="./output/det_db/best_accuracy" ``` diff --git a/doc/doc_en/detection_en.md b/doc/doc_en/detection_en.md index 96928364486c3aa122806ad5144681dfde785556..2d9983be7892b1e93a762b337c0c8bd26d79cc5b 100644 --- a/doc/doc_en/detection_en.md +++ b/doc/doc_en/detection_en.md @@ -27,7 +27,7 @@ The provided annotation file format is as follow, seperated by "\t": " Image file name Image annotation information encoded by json.dumps" ch4_test_images/img_61.jpg [{"transcription": "MASA", "points": [[310, 104], [416, 141], [418, 216], [312, 179]]}, {...}] ``` -The image annotation after **json.dumps()** encoding is a list containing multiple dictionaries. +The image annotation after **json.dumps()** encoding is a list containing multiple dictionaries. The `points` in the dictionary represent the coordinates (x, y) of the four points of the text box, arranged clockwise from the point at the upper left corner. @@ -110,16 +110,16 @@ python3 tools/eval.py -c configs/det/det_mv3_db_v1.1.yml -o Global.checkpoints= Test the detection result on a single image: ```shell -python3 tools/infer_det.py -c configs/det/det_mv3_db_v1.1.yml -o TestReader.infer_img="./doc/imgs_en/img_10.jpg" Global.checkpoints="./output/det_db/best_accuracy" +python3 tools/infer_det.py -c configs/det/det_mv3_db_v1.1.yml -o Global.infer_img="./doc/imgs_en/img_10.jpg" Global.checkpoints="./output/det_db/best_accuracy" ``` When testing the DB model, adjust the post-processing threshold: ```shell -python3 tools/infer_det.py -c configs/det/det_mv3_db_v1.1.yml -o TestReader.infer_img="./doc/imgs_en/img_10.jpg" Global.checkpoints="./output/det_db/best_accuracy" PostProcess.box_thresh=0.6 PostProcess.unclip_ratio=1.5 +python3 tools/infer_det.py -c configs/det/det_mv3_db_v1.1.yml -o Global.infer_img="./doc/imgs_en/img_10.jpg" Global.checkpoints="./output/det_db/best_accuracy" PostProcess.box_thresh=0.6 PostProcess.unclip_ratio=1.5 ``` Test the detection result on all images in the folder: ```shell -python3 tools/infer_det.py -c configs/det/det_mv3_db_v1.1.yml -o TestReader.infer_img="./doc/imgs_en/" Global.checkpoints="./output/det_db/best_accuracy" +python3 tools/infer_det.py -c configs/det/det_mv3_db_v1.1.yml -o Global.infer_img="./doc/imgs_en/" Global.checkpoints="./output/det_db/best_accuracy" ``` diff --git a/doc/doc_en/recognition_en.md b/doc/doc_en/recognition_en.md index 41b00c52a7780d02c144c251553f427e5b875e5e..1f1195c24b7ebd49f1f767a6561e30ab7f98fe95 100644 --- a/doc/doc_en/recognition_en.md +++ b/doc/doc_en/recognition_en.md @@ -294,7 +294,7 @@ The default prediction picture is stored in `infer_img`, and the weight is speci ``` # Predict English results -python3 tools/infer_rec.py -c configs/rec/ch_ppocr_v1.1/rec_chinese_lite_train_v1.1.yml -o Global.checkpoints={path/to/weights}/best_accuracy TestReader.infer_img=doc/imgs_words/en/word_1.jpg +python3 tools/infer_rec.py -c configs/rec/ch_ppocr_v1.1/rec_chinese_lite_train_v1.1.yml -o Global.checkpoints={path/to/weights}/best_accuracy Global.infer_img=doc/imgs_words/en/word_1.jpg ``` Input image: @@ -313,7 +313,7 @@ The configuration file used for prediction must be consistent with the training. ``` # Predict Chinese results -python3 tools/infer_rec.py -c configs/rec/ch_ppocr_v1.1/rec_chinese_lite_train_v1.1.yml -o Global.checkpoints={path/to/weights}/best_accuracy TestReader.infer_img=doc/imgs_words/ch/word_1.jpg +python3 tools/infer_rec.py -c configs/rec/ch_ppocr_v1.1/rec_chinese_lite_train_v1.1.yml -o Global.checkpoints={path/to/weights}/best_accuracy Global.infer_img=doc/imgs_words/ch/word_1.jpg ``` Input image: diff --git a/tools/infer_det.py b/tools/infer_det.py index 1e7fdcc46a1d2f47a7928d6dc171ae393b15f901..4ac441a4edc60db87097d45a47e77ece4b55a8f7 100755 --- a/tools/infer_det.py +++ b/tools/infer_det.py @@ -104,8 +104,8 @@ def main(): save_res_path = config['Global']['save_res_path'] if not os.path.exists(os.path.dirname(save_res_path)): os.makedirs(os.path.dirname(save_res_path)) - with open(save_res_path, "wb") as fout: + with open(save_res_path, "wb") as fout: test_reader = reader_main(config=config, mode='test') tackling_num = 0 for data in test_reader(): @@ -135,9 +135,15 @@ def main(): elif config['Global']['algorithm'] == 'DB': dic = {'maps': outs[0]} elif config['Global']['algorithm'] == 'SAST': - dic = {'f_score': outs[0], 'f_border': outs[1], 'f_tvo': outs[2], 'f_tco': outs[3]} + dic = { + 'f_score': outs[0], + 'f_border': outs[1], + 'f_tvo': outs[2], + 'f_tco': outs[3] + } else: - raise Exception("only support algorithm: ['EAST', 'DB', 'SAST']") + raise Exception( + "only support algorithm: ['EAST', 'DB', 'SAST']") dt_boxes_list = postprocess(dic, ratio_list) for ino in range(img_num): dt_boxes = dt_boxes_list[ino] @@ -151,7 +157,7 @@ def main(): fout.write(otstr.encode()) src_img = cv2.imread(img_name) draw_det_res(dt_boxes, config, src_img, img_name) - + logger.info("success!") diff --git a/tools/program.py b/tools/program.py index beccba55154fcc9151a6039489ab1d568a967293..f1f4b8913bea7f36b6bc11f7dade9d8b2a3bc7a0 100755 --- a/tools/program.py +++ b/tools/program.py @@ -121,7 +121,10 @@ def merge_config(config): global_config.keys(), sub_keys[0]) cur = global_config[sub_keys[0]] for idx, sub_key in enumerate(sub_keys[1:]): - assert (sub_key in cur) + assert ( + sub_key in cur + ), "key {} not in sub_keys: {}, please check your running command.".format( + sub_key, cur) if idx == len(sub_keys) - 2: cur[sub_key] = value else: