|
@@ -0,0 +1,209 @@
|
|
|
+Global:
|
|
|
+ debug: false
|
|
|
+ use_gpu: true
|
|
|
+ epoch_num: 50
|
|
|
+ log_smooth_window: 20
|
|
|
+ print_batch_step: 10
|
|
|
+ save_model_dir: ./output/rec_ppocr_v3_distillation_front_no_name_0202
|
|
|
+ save_epoch_step: 5
|
|
|
+ eval_batch_step: [0, 100]
|
|
|
+ cal_metric_during_train: true
|
|
|
+ pretrained_model: /home/aistudio/work/PaddleOCR/pretrain_models/ch_PP-OCRv3_rec_train/best_accuracy.pdparams
|
|
|
+ checkpoints:
|
|
|
+ save_inference_dir:
|
|
|
+ use_visualdl: true
|
|
|
+ infer_img: doc/imgs_words/ch/word_1.jpg
|
|
|
+ character_dict_path: ppocr/utils/ppocr_keys_v1.txt
|
|
|
+ max_text_length: &max_text_length 25
|
|
|
+ infer_mode: false
|
|
|
+ use_space_char: false
|
|
|
+ distributed: true
|
|
|
+ save_res_path: ./output/rec/predicts_ppocrv3_distillation.txt
|
|
|
+
|
|
|
+
|
|
|
+Optimizer:
|
|
|
+ name: Adam
|
|
|
+ beta1: 0.9
|
|
|
+ beta2: 0.999
|
|
|
+ lr:
|
|
|
+ name: Piecewise
|
|
|
+ decay_epochs : [40, 50]
|
|
|
+ values : [0.0003, 0.00003]
|
|
|
+ warmup_epoch: 2
|
|
|
+ regularizer:
|
|
|
+ name: L2
|
|
|
+ factor: 3.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: SVTR
|
|
|
+ Transform:
|
|
|
+ Backbone:
|
|
|
+ name: MobileNetV1Enhance
|
|
|
+ scale: 0.5
|
|
|
+ last_conv_stride: [1, 2]
|
|
|
+ last_pool_type: avg
|
|
|
+ Head:
|
|
|
+ name: MultiHead
|
|
|
+ head_list:
|
|
|
+ - CTCHead:
|
|
|
+ Neck:
|
|
|
+ name: svtr
|
|
|
+ dims: 64
|
|
|
+ depth: 2
|
|
|
+ hidden_dims: 120
|
|
|
+ use_guide: True
|
|
|
+ Head:
|
|
|
+ fc_decay: 0.00001
|
|
|
+ - SARHead:
|
|
|
+ enc_dim: 512
|
|
|
+ max_text_length: *max_text_length
|
|
|
+ Student:
|
|
|
+ pretrained:
|
|
|
+ freeze_params: false
|
|
|
+ return_all_feats: true
|
|
|
+ model_type: *model_type
|
|
|
+ algorithm: SVTR
|
|
|
+ Transform:
|
|
|
+ Backbone:
|
|
|
+ name: MobileNetV1Enhance
|
|
|
+ scale: 0.5
|
|
|
+ last_conv_stride: [1, 2]
|
|
|
+ last_pool_type: avg
|
|
|
+ Head:
|
|
|
+ name: MultiHead
|
|
|
+ head_list:
|
|
|
+ - CTCHead:
|
|
|
+ Neck:
|
|
|
+ name: svtr
|
|
|
+ dims: 64
|
|
|
+ depth: 2
|
|
|
+ hidden_dims: 120
|
|
|
+ use_guide: True
|
|
|
+ Head:
|
|
|
+ fc_decay: 0.00001
|
|
|
+ - SARHead:
|
|
|
+ enc_dim: 512
|
|
|
+ max_text_length: *max_text_length
|
|
|
+Loss:
|
|
|
+ name: CombinedLoss
|
|
|
+ loss_config_list:
|
|
|
+ - DistillationDMLLoss:
|
|
|
+ weight: 1.0
|
|
|
+ act: "softmax"
|
|
|
+ use_log: true
|
|
|
+ model_name_pairs:
|
|
|
+ - ["Student", "Teacher"]
|
|
|
+ key: head_out
|
|
|
+ multi_head: True
|
|
|
+ dis_head: ctc
|
|
|
+ name: dml_ctc
|
|
|
+ - DistillationDMLLoss:
|
|
|
+ weight: 0.5
|
|
|
+ act: "softmax"
|
|
|
+ use_log: true
|
|
|
+ model_name_pairs:
|
|
|
+ - ["Student", "Teacher"]
|
|
|
+ key: head_out
|
|
|
+ multi_head: True
|
|
|
+ dis_head: sar
|
|
|
+ name: dml_sar
|
|
|
+ - DistillationDistanceLoss:
|
|
|
+ weight: 1.0
|
|
|
+ mode: "l2"
|
|
|
+ model_name_pairs:
|
|
|
+ - ["Student", "Teacher"]
|
|
|
+ key: backbone_out
|
|
|
+ - DistillationCTCLoss:
|
|
|
+ weight: 1.0
|
|
|
+ model_name_list: ["Student", "Teacher"]
|
|
|
+ key: head_out
|
|
|
+ multi_head: True
|
|
|
+ - DistillationSARLoss:
|
|
|
+ weight: 1.0
|
|
|
+ model_name_list: ["Student", "Teacher"]
|
|
|
+ key: head_out
|
|
|
+ multi_head: True
|
|
|
+
|
|
|
+PostProcess:
|
|
|
+ name: DistillationCTCLabelDecode
|
|
|
+ model_name: ["Student", "Teacher"]
|
|
|
+ key: head_out
|
|
|
+ multi_head: True
|
|
|
+
|
|
|
+Metric:
|
|
|
+ name: DistillationMetric
|
|
|
+ base_metric_name: RecMetric
|
|
|
+ main_indicator: acc
|
|
|
+ key: "Student"
|
|
|
+ ignore_space: False
|
|
|
+
|
|
|
+Train:
|
|
|
+ dataset:
|
|
|
+ name: SimpleDataSet
|
|
|
+ data_dir: /home/aistudio/data/data189092/tw_idcard_front_rec_no_name_0202/test
|
|
|
+ ext_op_transform_idx: 1
|
|
|
+ label_file_list:
|
|
|
+ - /home/aistudio/data/data189092/tw_idcard_front_rec_no_name_0202/test/labels1.txt
|
|
|
+ - /home/aistudio/data/data189092/tw_idcard_front_rec_no_name_0202/test/rec_gt.txt
|
|
|
+ transforms:
|
|
|
+ - DecodeImage:
|
|
|
+ img_mode: BGR
|
|
|
+ channel_first: false
|
|
|
+ - RecConAug:
|
|
|
+ prob: 0.5
|
|
|
+ ext_data_num: 2
|
|
|
+ image_shape: [48, 320, 3]
|
|
|
+ max_text_length: *max_text_length
|
|
|
+ - RecAug:
|
|
|
+ - MultiLabelEncode:
|
|
|
+ - RecResizeImg:
|
|
|
+ image_shape: [3, 48, 320]
|
|
|
+ - KeepKeys:
|
|
|
+ keep_keys:
|
|
|
+ - image
|
|
|
+ - label_ctc
|
|
|
+ - label_sar
|
|
|
+ - length
|
|
|
+ - valid_ratio
|
|
|
+ loader:
|
|
|
+ shuffle: true
|
|
|
+ batch_size_per_card: 128
|
|
|
+ drop_last: true
|
|
|
+ num_workers: 4
|
|
|
+Eval:
|
|
|
+ dataset:
|
|
|
+ name: SimpleDataSet
|
|
|
+ data_dir: /home/aistudio/data/data189092/tw_idcard_front_rec_no_name_0202/val_real
|
|
|
+ label_file_list:
|
|
|
+ - /home/aistudio/data/data189092/tw_idcard_front_rec_no_name_0202/val_real/rec_gt.txt
|
|
|
+ transforms:
|
|
|
+ - DecodeImage:
|
|
|
+ img_mode: BGR
|
|
|
+ channel_first: false
|
|
|
+ - MultiLabelEncode:
|
|
|
+ - RecResizeImg:
|
|
|
+ image_shape: [3, 48, 320]
|
|
|
+ - KeepKeys:
|
|
|
+ keep_keys:
|
|
|
+ - image
|
|
|
+ - label_ctc
|
|
|
+ - label_sar
|
|
|
+ - length
|
|
|
+ - valid_ratio
|
|
|
+ loader:
|
|
|
+ shuffle: false
|
|
|
+ drop_last: false
|
|
|
+ batch_size_per_card: 8
|
|
|
+ num_workers: 4
|
|
|
+
|
|
|
+# python tools/train.py -c configs/rec/PP-OCRv3/ch_PP-OCRv3_rec_distillation_front_no_name_0202.yml
|