PaddlePaddle / PaddleOCR

Awesome multilingual OCR toolkits based on PaddlePaddle (practical ultra lightweight OCR system, support 80+ languages recognition, provide data annotation and synthesis tools, support training and deployment among server, mobile, embedded and IoT devices)
https://paddlepaddle.github.io/PaddleOCR/
Apache License 2.0
42.57k stars 7.67k forks source link

db_det推理后效果损失严重 #214

Closed bleakie closed 4 years ago

bleakie commented 4 years ago

自己训练的mv3_db_det模型,利用原始模型的检测效果可以接受,然而推理后得到的模型测试效果差距很大 这是什么原因呢?怎么解决? 原始模型:0160 推理模型: det_res_0160

LDOUBLEV commented 4 years ago

提供下你转换inference模型的命令和 用inference模型预测的代码吧。

另外,你在训练中有没有加一些特殊的数据处理或者改了超参数?

bleakie commented 4 years ago

inference指令:python3 tools/export_model.py -c configs/det/det_mv3_db.yml -o Global.checkpoints=./output/det_db/iter_epoch_90 Global.save_inference_dir=./inference/det_db/ 训练时只修改了base_lr: 0.0001,train_batch_size_per_card:12,别的没有改变

LDOUBLEV commented 4 years ago

方便提供一下你训练好的模型和一张测试图样本吗?我们测试下,排查下问题

bleakie commented 4 years ago

det_db_mv3.zip 期待您的回复

bleakie commented 4 years ago

测试rec推理后的模型结果精度损失也很大 `

推理指令

python3 tools/infer/predict_rec.py --image_dir=output/det_east/det_results/ --rec_model_dir="./inference/rec_crnn/" --rec_image_shape "3, 24, 94" --rec_char_type ch --rec_char_dict_path ./ppocr/utils/ccpd_dict.txt

result

infer_img:output/det_east/detresults/0001.jpg word : 皖A82A48 score : 0.9999848 infer_img:output/det_east/detresults/0002.jpg word : 皖AQ8611 score : 0.9999853 infer_img:output/det_east/detresults/0003.jpg word : 苏B252KB score : 0.9999436 infer_img:output/det_east/detresults/0004.jpg none

原始model

python3 tools/infer_rec.py -c configs/rec/rec_ccpd_train.yml -o Global.checkpoints=output/rec_CRNN/best_accuracy Global.infer_img=output/det_east/det_results/

result

Predicts of output/det_east/detresults/0001.jpg:['皖A82A48', 0.92690617] Predicts of output/det_east/detresults/0002.jpg:['皖BAQ86111', 0.9733797] Predicts of output/det_east/detresults/0003.jpg:['苏B252KB9', 0.94363064] Predicts of output/det_east/detresults/0004.jpg:['皖A1L10921', 0.8255394] `

tink2123 commented 4 years ago

识别模型使用 predict_rec.py 时,默认在 rec_char_type= "ch" 模式下根据图片长宽比resize,你指定的shape可能没有生效,可以试着注释掉这两行,看下结果会不会一致: https://github.com/PaddlePaddle/PaddleOCR/blob/ed4313d611b7708a7763d4612f00cb7f318a0e1f/tools/infer/predict_rec.py#L54-L55 如果还有diff的话,麻烦发一下识别模型的配置文件、字典、训练参数,我这边复现一下问题

bleakie commented 4 years ago

@tink2123 识别模型按照您的指导,注释掉以后效果和原始model已经很接近了,那det模型的损失是什么原因呢?

bleakie commented 4 years ago

初步定位出问题可能是resize造成的,我的理解:

  1. 采用源码中resize_image_type是不合理的,有很多图片长宽比可能是>1or<1
  2. 我觉得测试图片采用padding的方式才是最合理的
yby9212 commented 4 years ago

det inference 模型后处理的参数,若不在运行推理的命令中指定,会由 tools/infer/utility.py 中 parse_args 函数设定为默认值,可能与训练所用的 config 文件中的参数不同,特别是 db 模型的 PostProcess 的相关参数。是否是因此导致 inference 模型的结果变化呢

zcswdt commented 3 years ago

自己训练的mv3_db_det模型,利用原始模型的检测效果可以接受,然而推理后得到的模型测试效果差距很大 这是什么原因呢?怎么解决? 原始模型:0160 推理模型: det_res_0160

请教一下你训练的文字检测模型为啥不检测左上角的日期和汽车上的‘上海大众’等文字。

ddz-mark commented 3 years ago

请问:自己训练的 文本识别 rec 模型,同一批测试集,inference模型与eval模型最后的准确率差距很大,为什么?