Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
bleakie opened this issue Jun 16, 2020 · 11 comments
Closed

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

bleakie opened this issue Jun 16, 2020 · 11 comments

Comments

@bleakie
Copy link

bleakie commented Jun 16, 2020

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

@LDOUBLEV
Copy link
Collaborator

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

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

@bleakie
Copy link
Author

bleakie commented Jun 17, 2020

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
Copy link
Collaborator

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

@bleakie
Copy link
Author

bleakie commented Jun 17, 2020

det_db_mv3.zip
期待您的回复

@bleakie
Copy link
Author

bleakie commented Jun 17, 2020

测试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/det_results/0001_.jpg word : 皖A82A48 score : 0.9999848
infer_img:output/det_east/det_results/0002_.jpg word : 皖AQ8611 score : 0.9999853
infer_img:output/det_east/det_results/0003_.jpg word : 苏B252KB score : 0.9999436
infer_img:output/det_east/det_results/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/det_results/0001_.jpg:['皖A82A48', 0.92690617]
Predicts of output/det_east/det_results/0002_.jpg:['皖BAQ86111', 0.9733797]
Predicts of output/det_east/det_results/0003_.jpg:['苏B252KB9', 0.94363064]
Predicts of output/det_east/det_results/0004_.jpg:['皖A1L10921', 0.8255394]
`

@tink2123
Copy link
Collaborator

识别模型使用 predict_rec.py 时,默认在 rec_char_type= "ch" 模式下根据图片长宽比resize,你指定的shape可能没有生效,可以试着注释掉这两行,看下结果会不会一致:

if self.character_type == "ch":
imgW = int(32 * max_wh_ratio)

如果还有diff的话,麻烦发一下识别模型的配置文件、字典、训练参数,我这边复现一下问题

@bleakie
Copy link
Author

bleakie commented Jun 18, 2020

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

@bleakie
Copy link
Author

bleakie commented Jun 18, 2020

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

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

@yby9212
Copy link

yby9212 commented Jun 29, 2020

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

@zcswdt
Copy link

zcswdt commented Sep 23, 2020

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

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

@ddz-mark
Copy link

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

an1018 pushed a commit to an1018/PaddleOCR that referenced this issue Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants