Closed ainndejj11 closed 2 years ago
猜测是提取出来的Student模型没有被正确加载到配置文件里,可以看下日志中是否参数被加载到模型的日志
训练用的是哪个配置文件?
提取出来Teacher和Student模型分别使用哪个配置文件评估的呢?
训练用的配置文件: ch_PP-OCRv2_rec_distillation.yml 这个 Global: debug: false use_gpu: true epoch_num: 800 #a. 训练轮数epoch log_smooth_window: 20 print_batch_step: 10 #每XX个iter在终端输出一次 save_model_dir: ./output/my_shouxie_num_rec_OCRV2_distill save_epoch_step: 5 eval_batch_step: 40 #多少个iter验证一次 cal_metric_during_train: true pretrained_model: my_pretrain/ch_PP-OCRv2_rec_train/best_accuracy.pdparams #预训练模型路径 checkpoints: save_inference_dir: use_visualdl: false infer_img: doc/imgs_words/ch/word_1.jpg character_dict_path: ppocr/utils/my_shouxie_num.txt #d. 设置字典路径 max_text_length: 25 infer_mode: false use_space_char: true distributed: true save_res_path: output/my_shouxie_num_rec_OCRV2_distill/predicts_pp-OCRv2_distillation.txt
Optimizer: name: Adam beta1: 0.9 beta2: 0.999 lr: name: Piecewise decay_epochs : [700, 800] values : [0.001, 0.0001] warmup_epoch: 5 regularizer: name: L2 factor: 2.0e-05
Architecture: model_type: &model_type "rec" name: DistillationModel algorithm: Distillation Models: Teacher: pretrained: freeze_params: false return_all_feats: true model_type: model_type algorithm: CRNN Transform: Backbone: name: MobileNetV1Enhance scale: 0.5 Neck: name: SequenceEncoder encoder_type: rnn hidden_size: 64 Head: name: CTCHead mid_channels: 96 fc_decay: 0.00002 Student: pretrained: freeze_params: false return_all_feats: true model_type: model_type algorithm: CRNN Transform: Backbone: name: MobileNetV1Enhance scale: 0.5 Neck: name: SequenceEncoder encoder_type: rnn hidden_size: 64 Head: name: CTCHead mid_channels: 96 fc_decay: 0.00002
Loss: name: CombinedLoss loss_config_list:
PostProcess: name: DistillationCTCLabelDecode model_name: ["Student", "Teacher"] key: head_out
Metric: name: DistillationMetric base_metric_name: RecMetric main_indicator: acc key: "Student"
Train: dataset: name: SimpleDataSet data_dir: ./ #e. 训练数据路径 label_file_list: [ "dataset_shouxie_num/train.txt" ] #e. 训练集txt路径 transforms:
Teacher和Student模型使用这个训练的配置文件和ch_PP-OCRv2_rec.yml 都是acc为0
验证输出很多,以下信息没截完,打印了很多 ih_l1_reverse', '.neck.encoder.lstm.bias_hh_l1_reverse', '.neck.encoder.lstm.0.cell_fw.weight_ih', '.neck.encoder.lstm.0.cell_fw.weight_hh', '.neck.encoder.lstm.0.cell_fw.bias_ih', '.neck.encoder.lstm.0.cell_fw.bias_hh', '.neck.encoder.lstm.0.cell_bw.weight_ih', '.neck.encoder.lstm.0.cell_bw.weight_hh', '.neck.encoder.lstm.0.cell_bw.bias_ih', '.neck.encoder.lstm.0.cell_bw.bias_hh', '.neck.encoder.lstm.1.cell_fw.weight_ih', '.neck.encoder.lstm.1.cell_fw.weight_hh', '.neck.encoder.lstm.1.cell_fw.bias_ih', '.neck.encoder.lstm.1.cell_fw.bias_hh', '.neck.encoder.lstm.1.cell_bw.weight_ih', '.neck.encoder.lstm.1.cell_bw.weight_hh', '.neck.encoder.lstm.1.cell_bw.bias_ih', '.neck.encoder.lstm.1.cell_bw.bias_hh', '.head.fc1.weight', '.head.fc1.bias', '.head.fc2.weight', '.head.fc2.bias']) ! [2022/06/16 13:43:59] ppocr WARNING: Student.head.fc2.bias not in loaded params dict_keys(['.backbone.conv1._conv.weight', '.backbone.conv1._batch_norm.weight', '.backbone.conv1._batch_norm.bias', '.backbone.conv1._batch_norm._mean', '.backbone.conv1._batch_norm._variance', '.backbone.block_list.0._depthwise_conv._conv.weight', '.backbone.block_list.0._depthwise_conv._batch_norm.weight', '.backbone.block_list.0._depthwise_conv._batch_norm.bias', '.backbone.block_list.0._depthwise_conv._batch_norm._mean', '.backbone.block_list.0._depthwise_conv._batch_norm._variance', '.backbone.block_list.0._pointwise_conv._conv.weight', '.backbone.block_list.0._pointwise_conv._batch_norm.weight', '.backbone.block_list.0._pointwise_conv._batch_norm.bias', '.backbone.block_list.0._pointwise_conv._batch_norm._mean', '.backbone.block_list.0._pointwise_conv._batch_norm._variance', '.backbone.block_list.1._depthwise_conv._conv.weight', '.backbone.block_list.1._depthwise_conv._batch_norm.weight', '.backbone.block_list.1._depthwise_conv._batch_norm.bias', '.backbone.block_list.1._depthwise_conv._batch_norm._mean', '.backbone.block_list.1._depthwise_conv._batch_norm._variance', '.backbone.block_list.1._pointwise_conv._conv.weight', '.backbone.block_list.1._pointwise_conv._batch_norm.weight', '.backbone.block_list.1._pointwise_conv._batch_norm.bias', '.backbone.block_list.1._pointwise_conv._batch_norm._mean', '.backbone.block_list.1._pointwise_conv._batch_norm._variance', '.backbone.block_list.2._depthwise_conv._conv.weight', '.backbone.block_list.2._depthwise_conv._batch_norm.weight', '.backbone.block_list.2._depthwise_conv._batch_norm.bias', '.backbone.block_list.2._depthwise_conv._batch_norm._mean', '.backbone.block_list.2._depthwise_conv._batch_norm._variance', '.backbone.block_list.2._pointwise_conv._conv.weight', '.backbone.block_list.2._pointwise_conv._batch_norm.weight', '.backbone.block_list.2._pointwise_conv._batch_norm.bias', '.backbone.block_list.2._pointwise_conv._batch_norm._mean', '.backbone.block_list.2._pointwise_conv._batch_norm._variance', '.backbone.block_list.3._depthwise_conv._conv.weight', '.backbone.block_list.3._depthwise_conv._batch_norm.weight', '.backbone.block_list.3._depthwise_conv._batch_norm.bias', '.backbone.block_list.3._depthwise_conv._batch_norm._mean', '.backbone.block_list.3._depthwise_conv._batch_norm._variance', '.backbone.block_list.3._pointwise_conv._conv.weight', '.backbone.block_list.3._pointwise_conv._batch_norm.weight', '.backbone.block_list.3._pointwise_conv._batch_norm.bias', '.backbone.block_list.3._pointwise_conv._batch_norm._mean', '.backbone.block_list.3._pointwise_conv._batch_norm._variance', '.backbone.block_list.4._depthwise_conv._conv.weight', '.backbone.block_list.4._depthwise_conv._batch_norm.weight', '.backbone.block_list.4._depthwise_conv._batch_norm.bias', '.backbone.block_list.4._depthwise_conv._batch_norm._mean', '.backbone.block_list.4._depthwise_conv._batch_norm._variance', '.backbone.block_list.4._pointwise_conv._conv.weight', '.backbone.block_list.4._pointwise_conv._batch_norm.weight', '.backbone.block_list.4._pointwise_conv._batch_norm.bias', '.backbone.block_list.4._pointwise_conv._batch_norm._mean', '.backbone.block_list.4._pointwise_conv._batch_norm._variance', '.backbone.block_list.5._depthwise_conv._conv.weight', '.backbone.block_list.5._depthwise_conv._batch_norm.weight', '.backbone.block_list.5._depthwise_conv._batch_norm.bias', '.backbone.block_list.5._depthwise_conv._batch_norm._mean', '.backbone.block_list.5._depthwise_conv._batch_norm._variance', '.backbone.block_list.5._pointwise_conv._conv.weight', '.backbone.block_list.5._pointwise_conv._batch_norm.weight', '.backbone.block_list.5._pointwise_conv._batch_norm.bias', '.backbone.block_list.5._pointwise_conv._batch_norm._mean', '.backbone.block_list.5._pointwise_conv._batch_norm._variance', '.backbone.block_list.6._depthwise_conv._conv.weight', '.backbone.block_list.6._depthwise_conv._batch_norm.weight', '.backbone.block_list.6._depthwise_conv._batch_norm.bias', '.backbone.block_list.6._depthwise_conv._batch_norm._mean', '.backbone.block_list.6._depthwise_conv._batch_norm._variance', '.backbone.block_list.6._pointwise_conv._conv.weight', '.backbone.block_list.6._pointwise_conv._batch_norm.weight', '.backbone.block_list.6._pointwise_conv._batch_norm.bias', '.backbone.block_list.6._pointwise_conv._batch_norm._mean', '.backbone.block_list.6._pointwise_conv._batch_norm._variance', '.backbone.block_list.7._depthwise_conv._conv.weight', '.backbone.block_list.7._depthwise_conv._batch_norm.weight', '.backbone.block_list.7._depthwise_conv._batch_norm.bias', '.backbone.block_list.7._depthwise_conv._batch_norm._mean', '.backbone.block_list.7._depthwise_conv._batch_norm._variance', '.backbone.block_list.7._pointwise_conv._conv.weight', '.backbone.block_list.7._pointwise_conv._batch_norm.weight', '.backbone.block_list.7._pointwise_conv._batch_norm.bias', '.backbone.block_list.7._pointwise_conv._batch_norm._mean', '.backbone.block_list.7._pointwise_conv._batch_norm._variance', '.backbone.block_list.8._depthwise_conv._conv.weight', '.backbone.block_list.8._depthwise_conv._batch_norm.weight', '.backbone.block_list.8._depthwise_conv._batch_norm.bias', '.backbone.block_list.8._depthwise_conv._batch_norm._mean', '.backbone.block_list.8._depthwise_conv._batch_norm._variance', '.backbone.block_list.8._pointwise_conv._conv.weight', '.backbone.block_list.8._pointwise_conv._batch_norm.weight', '.backbone.block_list.8._pointwise_conv._batch_norm.bias', '.backbone.block_list.8._pointwise_conv._batch_norm._mean', '.backbone.block_list.8._pointwise_conv._batch_norm._variance', '.backbone.block_list.9._depthwise_conv._conv.weight', '.backbone.block_list.9._depthwise_conv._batch_norm.weight', '.backbone.block_list.9._depthwise_conv._batch_norm.bias', '.backbone.block_list.9._depthwise_conv._batch_norm._mean', '.backbone.block_list.9._depthwise_conv._batch_norm._variance', '.backbone.block_list.9._pointwise_conv._conv.weight', '.backbone.block_list.9._pointwise_conv._batch_norm.weight', '.backbone.block_list.9._pointwise_conv._batch_norm.bias', '.backbone.block_list.9._pointwise_conv._batch_norm._mean', '.backbone.block_list.9._pointwise_conv._batch_norm._variance', '.backbone.block_list.10._depthwise_conv._conv.weight', '.backbone.block_list.10._depthwise_conv._batch_norm.weight', '.backbone.block_list.10._depthwise_conv._batch_norm.bias', '.backbone.block_list.10._depthwise_conv._batch_norm._mean', '.backbone.block_list.10._depthwise_conv._batch_norm._variance', '.backbone.block_list.10._pointwise_conv._conv.weight', '.backbone.block_list.10._pointwise_conv._batch_norm.weight', '.backbone.block_list.10._pointwise_conv._batch_norm.bias', '.backbone.block_list.10._pointwise_conv._batch_norm._mean', '.backbone.block_list.10._pointwise_conv._batch_norm._variance', '.backbone.block_list.11._depthwise_conv._conv.weight', '.backbone.block_list.11._depthwise_conv._batch_norm.weight', '.backbone.block_list.11._depthwise_conv._batch_norm.bias', '.backbone.block_list.11._depthwise_conv._batch_norm._mean', '.backbone.block_list.11._depthwise_conv._batch_norm._variance', '.backbone.block_list.11._se.conv1.weight', '.backbone.block_list.11._se.conv1.bias', '.backbone.block_list.11._se.conv2.weight', '.backbone.block_list.11._se.conv2.bias', '.backbone.block_list.11._pointwise_conv._conv.weight', '.backbone.block_list.11._pointwise_conv._batch_norm.weight', '.backbone.block_list.11._pointwise_conv._batch_norm.bias', '.backbone.block_list.11._pointwise_conv._batch_norm._mean', '.backbone.block_list.11._pointwise_conv._batch_norm._variance', '.backbone.block_list.12._depthwise_conv._conv.weight', '.backbone.block_list.12._depthwise_conv._batch_norm.weight', '.backbone.block_list.12._depthwise_conv._batch_norm.bias', '.backbone.block_list.12._depthwise_conv._batch_norm._mean', '.backbone.block_list.12._depthwise_conv._batch_norm._variance', '.backbone.block_list.12._se.conv1.weight', '.backbone.block_list.12._se.conv1.bias', '.backbone.block_list.12._se.conv2.weight', '.backbone.block_list.12._se.conv2.bias', '.backbone.block_list.12._pointwise_conv._conv.weight', '.backbone.block_list.12._pointwise_conv._batch_norm.weight', '.backbone.block_list.12._pointwise_conv._batch_norm.bias', '.backbone.block_list.12._pointwise_conv._batch_norm._mean', '.backbone.block_list.12._pointwise_conv._batch_norm._variance', '.neck.encoder.lstm.weight_ih_l0', '.neck.encoder.lstm.weight_hh_l0', '.neck.encoder.lstm.bias_ih_l0', '.neck.encoder.lstm.bias_hh_l0', '.neck.encoder.lstm.weight_ih_l0_reverse', '.neck.encoder.lstm.weight_hh_l0_reverse', '.neck.encoder.lstm.bias_ih_l0_reverse', '.neck.encoder.lstm.bias_hh_l0_reverse', '.neck.encoder.lstm.weight_ih_l1', '.neck.encoder.lstm.weight_hh_l1', '.neck.encoder.lstm.bias_ih_l1', '.neck.encoder.lstm.bias_hh_l1', '.neck.encoder.lstm.weight_ih_l1_reverse', '.neck.encoder.lstm.weight_hh_l1_reverse', '.neck.encoder.lstm.bias_ih_l1_reverse', '.neck.encoder.lstm.bias_hh_l1_reverse', '.neck.encoder.lstm.0.cell_fw.weight_ih', '.neck.encoder.lstm.0.cell_fw.weight_hh', '.neck.encoder.lstm.0.cell_fw.bias_ih', '.neck.encoder.lstm.0.cell_fw.bias_hh', '.neck.encoder.lstm.0.cell_bw.weight_ih', '.neck.encoder.lstm.0.cell_bw.weight_hh', '.neck.encoder.lstm.0.cell_bw.bias_ih', '.neck.encoder.lstm.0.cell_bw.bias_hh', '.neck.encoder.lstm.1.cell_fw.weight_ih', '.neck.encoder.lstm.1.cell_fw.weight_hh', '.neck.encoder.lstm.1.cell_fw.bias_ih', '.neck.encoder.lstm.1.cell_fw.bias_hh', '.neck.encoder.lstm.1.cell_bw.weight_ih', '.neck.encoder.lstm.1.cell_bw.weight_hh', '.neck.encoder.lstm.1.cell_bw.bias_ih', '.neck.encoder.lstm.1.cell_bw.bias_hh', '.head.fc1.weight', '.head.fc1.bias', '.head.fc2.weight', '.head.fc2.bias']) ! [2022/06/16 13:43:59] ppocr INFO: resume from output/my_shouxie_num_rec_OCRV2_distill/student eval model:: 100%|██████████████████████████████| 10/10 [00:00<00:00, 28.73it/s] [2022/06/16 13:43:59] ppocr INFO: metric eval *** [2022/06/16 13:43:59] ppocr INFO: acc:0.0 [2022/06/16 13:43:59] ppocr INFO: norm_edit_dis:0.05336097368903259 [2022/06/16 13:43:59] ppocr INFO: Teacher_acc:0.0 [2022/06/16 13:43:59] ppocr INFO: Teacher_norm_edit_dis:0.0788766755124074 [2022/06/16 13:43:59] ppocr INFO: fps:643.3570992525152
训练保存的模型是包括Student和Teacher模型参数,如果是只加载student和teacher, 可以单独创建一个student的配置文件,或者可以用这个配置文件去评估 https://github.com/PaddlePaddle/PaddleOCR/blob/release%2F2.5/configs/rec/ch_PP-OCRv2/ch_PP-OCRv2_rec.yml 上述配置文件里只有Student模型的配置;
ppocrv2识别的模型蒸馏训练完,用best_accuracy验证准确率没问题,但是提取出来Teacher和Student模型,单独验证这俩模型准确率 就都为0,请问什么原因?
best_accuracy验证: eval model:: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:00<00:00, 32.99it/s] [2022/06/16 09:54:28] ppocr INFO: metric eval *** [2022/06/16 09:54:28] ppocr INFO: acc:0.9999999328859105 [2022/06/16 09:54:28] ppocr INFO: norm_edit_dis:1.0 [2022/06/16 09:54:28] ppocr INFO: Teacher_acc:0.9999999328859105 [2022/06/16 09:54:28] ppocr INFO: Teacher_norm_edit_dis:1.0 [2022/06/16 09:54:28] ppocr INFO: fps:734.5592958964908
student验证: eval model:: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:00<00:00, 33.85it/s] [2022/06/16 09:53:52] ppocr INFO: metric eval *** [2022/06/16 09:53:52] ppocr INFO: acc:0.0 [2022/06/16 09:53:52] ppocr INFO: norm_edit_dis:0.0919608965272185 [2022/06/16 09:53:52] ppocr INFO: Teacher_acc:0.0 [2022/06/16 09:53:52] ppocr INFO: Teacher_norm_edit_dis:0.07771065294813129 [2022/06/16 09:53:52] ppocr INFO: fps:741.0905623952016
teacher验证: eval model:: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:00<00:00, 33.73it/s] [2022/06/16 09:55:47] ppocr INFO: metric eval *** [2022/06/16 09:55:47] ppocr INFO: acc:0.0 [2022/06/16 09:55:47] ppocr INFO: norm_edit_dis:0.04471942938584661 [2022/06/16 09:55:47] ppocr INFO: Teacher_acc:0.0 [2022/06/16 09:55:47] ppocr INFO: Teacher_norm_edit_dis:6.711408950810238e-08 [2022/06/16 09:55:47] ppocr INFO: fps:734.0019684530731