ch_PP-OCRv2_rec.yml 3.3 KB
Newer Older
littletomatodonkey's avatar
littletomatodonkey 已提交
1 2 3 4 5 6
Global:
  debug: false
  use_gpu: true
  epoch_num: 800
  log_smooth_window: 20
  print_batch_step: 10
7
  save_model_dir: ./output/rec_chinese_lite_distillation_v2.1
littletomatodonkey's avatar
littletomatodonkey 已提交
8
  save_epoch_step: 3
9
  eval_batch_step: [0, 2000]
littletomatodonkey's avatar
littletomatodonkey 已提交
10
  cal_metric_during_train: true
littletomatodonkey's avatar
littletomatodonkey 已提交
11 12 13
  pretrained_model:
  checkpoints:
  save_inference_dir:
littletomatodonkey's avatar
littletomatodonkey 已提交
14 15 16 17 18 19
  use_visualdl: false
  infer_img: doc/imgs_words/ch/word_1.jpg
  character_dict_path: ppocr/utils/ppocr_keys_v1.txt
  character_type: ch
  max_text_length: 25
  infer_mode: false
20
  use_space_char: true
littletomatodonkey's avatar
littletomatodonkey 已提交
21
  distributed: true
littletomatodonkey's avatar
littletomatodonkey 已提交
22
  save_res_path: ./output/rec/predicts_chinese_lite_distillation_v2.1.txt
littletomatodonkey's avatar
littletomatodonkey 已提交
23 24 25 26 27 28 29


Optimizer:
  name: Adam
  beta1: 0.9
  beta2: 0.999
  lr:
30 31 32
    name: Piecewise
    decay_epochs : [700, 800]
    values : [0.001, 0.0001]
littletomatodonkey's avatar
littletomatodonkey 已提交
33 34 35
    warmup_epoch: 5
  regularizer:
    name: L2
36 37
    factor: 2.0e-05

littletomatodonkey's avatar
littletomatodonkey 已提交
38
Architecture:
39
  model_type: &model_type "rec"
littletomatodonkey's avatar
littletomatodonkey 已提交
40 41 42
  name: DistillationModel
  algorithm: Distillation
  Models:
43
    Teacher:
littletomatodonkey's avatar
littletomatodonkey 已提交
44
      pretrained:
45
      freeze_params: false
46
      return_all_feats: true
47
      model_type: *model_type
littletomatodonkey's avatar
littletomatodonkey 已提交
48 49 50
      algorithm: CRNN
      Transform:
      Backbone:
51
        name: MobileNetV1Enhance
littletomatodonkey's avatar
littletomatodonkey 已提交
52 53 54 55
        scale: 0.5
      Neck:
        name: SequenceEncoder
        encoder_type: rnn
56
        hidden_size: 64
littletomatodonkey's avatar
littletomatodonkey 已提交
57 58
      Head:
        name: CTCHead
59
        mid_channels: 96
60 61
        fc_decay: 0.00002
    Student:
littletomatodonkey's avatar
littletomatodonkey 已提交
62
      pretrained:
63
      freeze_params: false
64
      return_all_feats: true
65
      model_type: *model_type
littletomatodonkey's avatar
littletomatodonkey 已提交
66 67 68
      algorithm: CRNN
      Transform:
      Backbone:
69
        name: MobileNetV1Enhance
littletomatodonkey's avatar
littletomatodonkey 已提交
70 71 72 73
        scale: 0.5
      Neck:
        name: SequenceEncoder
        encoder_type: rnn
74
        hidden_size: 64
littletomatodonkey's avatar
littletomatodonkey 已提交
75 76
      Head:
        name: CTCHead
77
        mid_channels: 96
78
        fc_decay: 0.00002
littletomatodonkey's avatar
littletomatodonkey 已提交
79 80 81 82 83 84 85 86
  

Loss:
  name: CombinedLoss
  loss_config_list:
  - DistillationCTCLoss:
      weight: 1.0
      model_name_list: ["Student", "Teacher"]
87
      key: head_out
littletomatodonkey's avatar
littletomatodonkey 已提交
88 89
  - DistillationDMLLoss:
      weight: 1.0
90 91 92
      act: "softmax"
      model_name_pairs:
      - ["Student", "Teacher"]
93 94 95 96 97 98 99
      key: head_out
  - DistillationDistanceLoss:
      weight: 1.0
      mode: "l2"
      model_name_pairs:
      - ["Student", "Teacher"]
      key: backbone_out
littletomatodonkey's avatar
littletomatodonkey 已提交
100 101 102

PostProcess:
  name: DistillationCTCLabelDecode
littletomatodonkey's avatar
littletomatodonkey 已提交
103
  model_name: ["Student", "Teacher"]
104
  key: head_out
105

littletomatodonkey's avatar
littletomatodonkey 已提交
106
Metric:
littletomatodonkey's avatar
littletomatodonkey 已提交
107 108
  name: DistillationMetric
  base_metric_name: RecMetric
littletomatodonkey's avatar
littletomatodonkey 已提交
109
  main_indicator: acc
littletomatodonkey's avatar
littletomatodonkey 已提交
110
  key: "Student"
111

littletomatodonkey's avatar
littletomatodonkey 已提交
112 113 114 115 116 117 118 119 120 121
Train:
  dataset:
    name: SimpleDataSet
    data_dir: ./train_data/
    label_file_list:
    - ./train_data/train_list.txt
    transforms:
    - DecodeImage:
        img_mode: BGR
        channel_first: false
littletomatodonkey's avatar
littletomatodonkey 已提交
122 123
    - RecAug:
    - CTCLabelEncode:
littletomatodonkey's avatar
littletomatodonkey 已提交
124
    - RecResizeImg:
125
        image_shape: [3, 32, 320]
littletomatodonkey's avatar
littletomatodonkey 已提交
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
    - KeepKeys:
        keep_keys:
        - image
        - label
        - length
  loader:
    shuffle: true
    batch_size_per_card: 128
    drop_last: true
    num_sections: 1
    num_workers: 8
Eval:
  dataset:
    name: SimpleDataSet
    data_dir: ./train_data
    label_file_list:
    - ./train_data/val_list.txt
    transforms:
    - DecodeImage:
        img_mode: BGR
        channel_first: false
littletomatodonkey's avatar
littletomatodonkey 已提交
147
    - CTCLabelEncode:
littletomatodonkey's avatar
littletomatodonkey 已提交
148
    - RecResizeImg:
149
        image_shape: [3, 32, 320]
littletomatodonkey's avatar
littletomatodonkey 已提交
150 151 152 153 154 155 156 157 158 159
    - KeepKeys:
        keep_keys:
        - image
        - label
        - length
  loader:
    shuffle: false
    drop_last: false
    batch_size_per_card: 128
    num_workers: 8