Skip to content

Commit

Permalink
Merge pull request #95 from LDOUBLEV/fixocr
Browse files Browse the repository at this point in the history
fix predict_det not found unclip_ratio
  • Loading branch information
LDOUBLEV committed May 25, 2020
2 parents f47165b + 8a6f106 commit 6081c67
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 7 additions & 0 deletions doc/detection.md
Original file line number Diff line number Diff line change
Expand Up @@ -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模型时不需要设置

## 测试检测效果

Expand All @@ -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"
Expand Down
5 changes: 3 additions & 2 deletions tools/infer/predict_det.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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))
1 change: 1 addition & 0 deletions tools/infer/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6081c67

Please sign in to comment.