From fdad3d4d880d5067eb6928144f10e137fca4497f Mon Sep 17 00:00:00 2001 From: LDOUBLEV Date: Wed, 20 May 2020 20:12:53 +0800 Subject: [PATCH] single_img_path to infer_img as rec model, fix eval Hmean=0 --- configs/det/det_db_icdar15_reader.yml | 2 +- configs/det/det_east_icdar15_reader.yml | 2 +- configs/rec/rec_benchmark_reader.yml | 3 ++- doc/detection.md | 4 ++-- ppocr/data/det/dataset_traversal.py | 2 +- tools/eval.py | 1 + tools/eval_utils/eval_det_utils.py | 2 +- tools/infer_det.py | 3 +-- 8 files changed, 10 insertions(+), 9 deletions(-) diff --git a/configs/det/det_db_icdar15_reader.yml b/configs/det/det_db_icdar15_reader.yml index 388cd318..0f99257b 100755 --- a/configs/det/det_db_icdar15_reader.yml +++ b/configs/det/det_db_icdar15_reader.yml @@ -15,7 +15,7 @@ EvalReader: TestReader: reader_function: ppocr.data.det.dataset_traversal,EvalTestReader process_function: ppocr.data.det.db_process,DBProcessTest - single_img_path: + infer_img: img_set_dir: ./train_data/icdar2015/text_localization/ label_file_path: ./train_data/icdar2015/text_localization/test_icdar2015_label.txt test_image_shape: [736, 1280] diff --git a/configs/det/det_east_icdar15_reader.yml b/configs/det/det_east_icdar15_reader.yml index 478bfcd8..060ed4dd 100755 --- a/configs/det/det_east_icdar15_reader.yml +++ b/configs/det/det_east_icdar15_reader.yml @@ -17,7 +17,7 @@ EvalReader: TestReader: reader_function: ppocr.data.det.dataset_traversal,EvalTestReader process_function: ppocr.data.det.east_process,EASTProcessTest - single_img_path: + 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/rec/rec_benchmark_reader.yml b/configs/rec/rec_benchmark_reader.yml index d119c7aa..44cc0567 100755 --- a/configs/rec/rec_benchmark_reader.yml +++ b/configs/rec/rec_benchmark_reader.yml @@ -9,4 +9,5 @@ EvalReader: TestReader: reader_function: ppocr.data.rec.dataset_traversal,LMDBReader - lmdb_sets_dir: ./train_data/data_lmdb_release/evaluation/ \ No newline at end of file + lmdb_sets_dir: ./train_data/data_lmdb_release/evaluation/ + infer_img: ./infer_img \ No newline at end of file diff --git a/doc/detection.md b/doc/detection.md index fce534d1..2fbe3c42 100644 --- a/doc/detection.md +++ b/doc/detection.md @@ -79,10 +79,10 @@ python3 tools/eval.py -c configs/det/det_mv3_db.yml -o Global.checkpoints="./ou 测试单张图像的检测效果 ``` -python3 tools/infer_det.py -c configs/det/det_mv3_db.yml -o TestReader.single_img_path="./doc/imgs_en/img_10.jpg" Global.checkpoints="./output/det_db/best_accuracy" +python3 tools/infer_det.py -c configs/det/det_mv3_db.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.yml -o TestReader.single_img_path="./doc/imgs_en/" Global.checkpoints="./output/det_db/best_accuracy" +python3 tools/infer_det.py -c configs/det/det_mv3_db.yml -o TestReader.infer_img="./doc/imgs_en/" Global.checkpoints="./output/det_db/best_accuracy" ``` diff --git a/ppocr/data/det/dataset_traversal.py b/ppocr/data/det/dataset_traversal.py index 3bd93185..3051c60d 100755 --- a/ppocr/data/det/dataset_traversal.py +++ b/ppocr/data/det/dataset_traversal.py @@ -84,7 +84,7 @@ class EvalTestReader(object): img_path = os.path.join(img_set_dir, img_name) img_list.append(img_path) else: - img_path = self.params['single_img_path'] + img_path = self.params['infer_img'] img_list = get_image_file_list(img_path) def batch_iter_reader(): diff --git a/tools/eval.py b/tools/eval.py index fcb572c6..d1762e92 100755 --- a/tools/eval.py +++ b/tools/eval.py @@ -78,6 +78,7 @@ def main(): 'fetch_name_list':eval_fetch_name_list,\ 'fetch_varname_list':eval_fetch_varname_list} metrics = eval_det_run(exe, config, eval_info_dict, "eval") + print("Eval result", metrics) else: reader_type = config['Global']['reader_yml'] if "benchmark" not in reader_type: diff --git a/tools/eval_utils/eval_det_utils.py b/tools/eval_utils/eval_det_utils.py index 25cda208..252c9364 100644 --- a/tools/eval_utils/eval_det_utils.py +++ b/tools/eval_utils/eval_det_utils.py @@ -96,7 +96,7 @@ def load_label_infor(label_file_path, do_ignore=False): if text == "###" and do_ignore: ignore = True bbox_infor[bno]['ignore'] = ignore - img_name_label_dict[substr[0]] = bbox_infor + img_name_label_dict[os.path.basename(substr[0])] = bbox_infor return img_name_label_dict diff --git a/tools/infer_det.py b/tools/infer_det.py index 9da617d1..80006765 100755 --- a/tools/infer_det.py +++ b/tools/infer_det.py @@ -106,7 +106,6 @@ def main(): with open(save_res_path, "wb") as fout: test_reader = reader_main(config=config, mode='test') - # image_file_list = get_image_file_list(args.image_dir) tackling_num = 0 for data in test_reader(): img_num = len(data) @@ -135,7 +134,7 @@ def main(): elif config['Global']['algorithm'] == 'DB': dic = {'maps': outs[0]} else: - raise Exception("only support algorithm: ['EAST', 'BD']") + raise Exception("only support algorithm: ['EAST', 'DB']") dt_boxes_list = postprocess(dic, ratio_list) for ino in range(img_num): dt_boxes = dt_boxes_list[ino] -- GitLab