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
44.68k stars 7.86k forks source link

使用ch_PP-OCRv3_det_cml.yml训练fintune #8371

Closed lifanhanhan closed 2 years ago

lifanhanhan commented 2 years ago

请提供下述完整信息以便快速定位问题/Please provide the following information to quickly locate the problem (先谢谢大佬们回答) 在训练前验证下载的预训练权重的hmean 和训练后测试训练权重的hmean

-2、自己经过ch_PP-OCRv3_det_cml.yml训练fintune,评估时hmean为0,这是什么原因呢? ch_PP-OCRv3_det_cml.yml如下所示:

Global: debug: false use_gpu: true epoch_num: 100 #500 log_smooth_window: 20 print_batch_step: 1 save_model_dir: ./output/ch_PP-OCR_v3_det/ save_epoch_step: 10 eval_batch_step: [0, 50] cal_metric_during_train: false pretrained_model: D:/model/PaddleOCR-release-2.6/pretrain_models/ch_PP-OCRv3_det_distill_train/best_accuracy checkpoints: # D:/model/PaddleOCR-release-2.6/output/ch_PP-OCR_v3_det/latest save_inference_dir: null use_visualdl: true infer_img: OCR/HWA/12000/Image_70.bmp save_res_path: ./checkpoints/det_db/predicts_db.txt distributed: true

Architecture: name: DistillationModel algorithm: Distillation model_type: det Models: Student: pretrained: model_type: det algorithm: DB Transform: null Backbone: name: MobileNetV3 scale: 0.5 model_name: large disable_se: true Neck: name: RSEFPN out_channels: 96 shortcut: True Head: name: DBHead k: 50 Student2: pretrained: model_type: det algorithm: DB Transform: null Backbone: name: MobileNetV3 scale: 0.5 model_name: large disable_se: true Neck: name: RSEFPN out_channels: 96 shortcut: True Head: name: DBHead k: 50 Teacher: freeze_params: true return_all_feats: false model_type: det algorithm: DB Backbone: name: ResNet_vd in_channels: 3 layers: 50 Neck: name: LKPAN out_channels: 256 Head: name: DBHead kernel_list: [7,2,2] k: 50

Loss: name: CombinedLoss loss_config_list:

Optimizer: name: Adam beta1: 0.9 beta2: 0.999 lr: name: Cosine learning_rate: 0.00025 #0.001 warmup_epoch: 2 regularizer: name: L2 factor: 5.0e-05

PostProcess: name: DistillationDBPostProcess model_name: ["Student"] key: head_out thresh: 0.3 box_thresh: 0.6 max_candidates: 1000 unclip_ratio: 1.5

Metric: name: DistillationMetric base_metric_name: DetMetric main_indicator: hmean key: "Student"

Train: dataset: name: SimpleDataSet data_dir: ./OCR/ label_file_list:

Eval: dataset: name: SimpleDataSet data_dir: ./OCR/ label_file_list:

LDOUBLEV commented 2 years ago

评估时Global.pretrained_model换成Global.checkpoints试试:python tools/eval.py -c configs/det/ch_PP-OCRv3/ch_PP-OCRv3_det_cml_myself.yml -o Global.checkpoints="./pretrained_models/ch_PP-OCRv3_det_distill_train/best_accuracy"

而我直接将预训练权重export_model成推理权重,一个框都没出来,疑问一:官方给出的预训练权重和推理权重不是同一个吗?

结合评估hmean为0的问题,猜测是预训练模型没有加载上

v3检测的训练参考这个文档:https://github.com/PaddlePaddle/PaddleOCR/blob/release%2F2.6/doc/doc_ch/PP-OCRv3_det_train.md

lifanhanhan commented 2 years ago

评估时Global.pretrained_model换成Global.checkpoints试试:python tools/eval.py -c configs/det/ch_PP-OCRv3/ch_PP-OCRv3_det_cml_myself.yml -o Global.checkpoints="./pretrained_models/ch_PP-OCRv3_det_distill_train/best_accuracy"

而我直接将预训练权重export_model成推理权重,一个框都没出来,疑问一:官方给出的预训练权重和推理权重不是同一个吗?

结合评估hmean为0的问题,猜测是预训练模型没有加载上

v3检测的训练参考这个文档:https://github.com/PaddlePaddle/PaddleOCR/blob/release%2F2.6/doc/doc_ch/PP-OCRv3_det_train.md

谢谢大佬回复,试了checkpoint加载,也不行,然后换成paddle官方给出test_icdar2015_label.txt及test文件,官方预训练和我训练出来的权重都能正常有hmean,但换回自己数据集却不行,我的自制数据集是.bmp格式,分辨率是5472*3648,验证时候是否跟格式或者分辨率有关?关于标签问题,train和test的标签都是用paddlelabel标注,刚用自己数据集训练的权重也能验证test_icdar2015,应该不是标签问题了

lifanhanhan commented 2 years ago

评估时Global.pretrained_model换成Global.checkpoints试试:python tools/eval.py -c configs/det/ch_PP-OCRv3/ch_PP-OCRv3_det_cml_myself.yml -o Global.checkpoints="./pretrained_models/ch_PP-OCRv3_det_distill_train/best_accuracy"

而我直接将预训练权重export_model成推理权重,一个框都没出来,疑问一:官方给出的预训练权重和推理权重不是同一个吗?

结合评估hmean为0的问题,猜测是预训练模型没有加载上 v3检测的训练参考这个文档:https://github.com/PaddlePaddle/PaddleOCR/blob/release%2F2.6/doc/doc_ch/PP-OCRv3_det_train.md

谢谢大佬回复,试了checkpoint加载,也不行,然后换成paddle官方给出test_icdar2015_label.txt及test文件,官方预训练和我训练出来的权重都能正常有hmean,但换回自己数据集却不行,我的自制数据集是.bmp格式,分辨率是5472*3648,验证时候是否跟格式或者分辨率有关?关于标签问题,train和test的标签都是用paddlelabel标注,刚用自己数据集训练的权重也能验证test_icdar2015,应该不是标签问题了

找到大致原因了,因为ch_PP-OCRv3_det_cml.yml里面的Eval.DetResizeForTest没有定义risize值,所以我的图片过大,造成hmean几乎为0的现象。 image