From 8a6f1062374ccf74273d0396ee5fb9e06f3f1848 Mon Sep 17 00:00:00 2001 From: LDOUBLEV Date: Mon, 25 May 2020 18:14:13 +0800 Subject: [PATCH] fix predict_det not found unclip_ratio --- README.md | 4 ++-- doc/detection.md | 7 +++++++ tools/infer/predict_det.py | 5 +++-- tools/infer/utility.py | 1 + 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6a7785c1ef..a749b8faad 100644 --- a/README.md +++ b/README.md @@ -64,13 +64,13 @@ PaddleOCR开源的文本检测算法列表: 在ICDAR2015文本检测公开数据集上,算法效果如下: |模型|骨干网络|precision|recall|Hmean|下载链接| -|-|-|-|-| +|-|-|-|-|-|-| |EAST|ResNet50_vd|88.18%|85.51|86.82%|[下载链接](https://paddleocr.bj.bcebos.com/det_r50_vd_east.tar)| |EAST|MobileNetV3|81.67%|79.83%|80.74%|[下载链接](https://paddleocr.bj.bcebos.com/det_mv3_east.tar)| |DB|ResNet50_vd|83.79%|80.65%|82.19%|[下载链接](https://paddleocr.bj.bcebos.com/det_r50_vd_db.tar)| |DB|MobileNetV3|75.92%|73.18%|74.53%|[下载链接](https://paddleocr.bj.bcebos.com/det_mv3_db.tar)| -* 注: 上述模型的训练和评估,设置后处理参数box_thresh=0.6,unclip_ratio=1.5,使用不同数据集、不同模型训练,可调整这两个参数进行优化 +* 注: 上述DB模型的训练和评估,需设置后处理参数box_thresh=0.6,unclip_ratio=1.5,使用不同数据集、不同模型训练,可调整这两个参数进行优化 PaddleOCR文本检测算法的训练和使用请参考文档教程中[文本检测模型训练/评估/预测](./doc/detection.md)。 diff --git a/doc/detection.md b/doc/detection.md index dc4f9cc181..0fa32116e1 100644 --- a/doc/detection.md +++ b/doc/detection.md @@ -75,6 +75,7 @@ python3 tools/eval.py -c configs/det/det_mv3_db.yml -o Global.checkpoints="{pat python3 tools/eval.py -c configs/det/det_mv3_db.yml -o Global.checkpoints="./output/det_db/best_accuracy" PostProcess.box_thresh=0.6 PostProcess.unclip_ratio=1.5 ``` +* 注:box_thresh、unclip_ratio是DB后处理所需要的参数,在评估EAST模型时不需要设置 ## 测试检测效果 @@ -83,6 +84,12 @@ 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.infer_img="./doc/imgs_en/img_10.jpg" Global.checkpoints="./output/det_db/best_accuracy" ``` +测试DB模型时,调整后处理阈值, +``` +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" PostProcess.box_thresh=0.6 PostProcess.unclip_ratio=1.5 +``` + + 测试文件夹下所有图像的检测效果 ``` 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/tools/infer/predict_det.py b/tools/infer/predict_det.py index 82fed48fee..35d8a09daf 100755 --- a/tools/infer/predict_det.py +++ b/tools/infer/predict_det.py @@ -39,6 +39,7 @@ def __init__(self, args): postprocess_params["thresh"] = args.det_db_thresh postprocess_params["box_thresh"] = args.det_db_box_thresh postprocess_params["max_candidates"] = 1000 + postprocess_params["unclip_ratio"] = args.det_db_unclip_ratio self.postprocess_op = DBPostProcess(postprocess_params) elif self.det_algorithm == "EAST": self.preprocess_op = EASTProcessTest(preprocess_params) @@ -142,5 +143,5 @@ def __call__(self, img): src_im = utility.draw_text_det_res(dt_boxes, image_file) img_name_pure = image_file.split("/")[-1] cv2.imwrite("./inference_results/det_res_%s" % img_name_pure, src_im) - if count > 1: - print("Avg Time:", total_time / (count - 1)) + if count > 1: + print("Avg Time:", total_time / (count - 1)) diff --git a/tools/infer/utility.py b/tools/infer/utility.py index 947a549577..ce7ae68627 100755 --- a/tools/infer/utility.py +++ b/tools/infer/utility.py @@ -45,6 +45,7 @@ def str2bool(v): #DB parmas parser.add_argument("--det_db_thresh", type=float, default=0.3) parser.add_argument("--det_db_box_thresh", type=float, default=0.5) + parser.add_argument("--det_db_unclip_ratio", type=float, default=2.0) #EAST parmas parser.add_argument("--det_east_score_thresh", type=float, default=0.8)