ch_PP-OCRv2_rec_distillation.yml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. Global:
  2. debug: false
  3. use_gpu: true
  4. epoch_num: 800
  5. log_smooth_window: 20
  6. print_batch_step: 10
  7. save_model_dir: ./output/rec_pp-OCRv2_distillation
  8. save_epoch_step: 3
  9. eval_batch_step: [0, 200000]
  10. cal_metric_during_train: true
  11. pretrained_model:
  12. checkpoints:
  13. save_inference_dir:
  14. use_visualdl: false
  15. infer_img: doc/imgs_words/ch/word_1.jpg
  16. character_dict_path: ppocr/utils/ppocr_keys_v1.txt
  17. max_text_length: 25
  18. infer_mode: false
  19. use_space_char: true
  20. distributed: true
  21. save_res_path: ./output/rec/predicts_pp-OCRv2_distillation.txt
  22. Optimizer:
  23. name: Adam
  24. beta1: 0.9
  25. beta2: 0.999
  26. lr:
  27. name: Piecewise
  28. decay_epochs : [700, 800]
  29. values : [0.001, 0.0001]
  30. warmup_epoch: 5
  31. regularizer:
  32. name: L2
  33. factor: 2.0e-05
  34. Architecture:
  35. model_type: &model_type "rec"
  36. name: DistillationModel
  37. algorithm: Distillation
  38. Models:
  39. Teacher:
  40. pretrained:
  41. freeze_params: false
  42. return_all_feats: true
  43. model_type: *model_type
  44. algorithm: CRNN
  45. Transform:
  46. Backbone:
  47. name: MobileNetV1Enhance
  48. scale: 0.5
  49. Neck:
  50. name: SequenceEncoder
  51. encoder_type: rnn
  52. hidden_size: 64
  53. Head:
  54. name: CTCHead
  55. mid_channels: 96
  56. fc_decay: 0.00002
  57. Student:
  58. pretrained:
  59. freeze_params: false
  60. return_all_feats: true
  61. model_type: *model_type
  62. algorithm: CRNN
  63. Transform:
  64. Backbone:
  65. name: MobileNetV1Enhance
  66. scale: 0.5
  67. Neck:
  68. name: SequenceEncoder
  69. encoder_type: rnn
  70. hidden_size: 64
  71. Head:
  72. name: CTCHead
  73. mid_channels: 96
  74. fc_decay: 0.00002
  75. Loss:
  76. name: CombinedLoss
  77. loss_config_list:
  78. - DistillationCTCLoss:
  79. weight: 1.0
  80. model_name_list: ["Student", "Teacher"]
  81. key: head_out
  82. - DistillationDMLLoss:
  83. weight: 1.0
  84. act: "softmax"
  85. use_log: true
  86. model_name_pairs:
  87. - ["Student", "Teacher"]
  88. key: head_out
  89. - DistillationDistanceLoss:
  90. weight: 1.0
  91. mode: "l2"
  92. model_name_pairs:
  93. - ["Student", "Teacher"]
  94. key: backbone_out
  95. PostProcess:
  96. name: DistillationCTCLabelDecode
  97. model_name: ["Student", "Teacher"]
  98. key: head_out
  99. Metric:
  100. name: DistillationMetric
  101. base_metric_name: RecMetric
  102. main_indicator: acc
  103. key: "Student"
  104. Train:
  105. dataset:
  106. name: SimpleDataSet
  107. data_dir: ./train_data/ic15_data/
  108. label_file_list:
  109. - ./train_data/ic15_data/rec_gt_train.txt
  110. transforms:
  111. - DecodeImage:
  112. img_mode: BGR
  113. channel_first: false
  114. - RecAug:
  115. - CTCLabelEncode:
  116. - RecResizeImg:
  117. image_shape: [3, 32, 320]
  118. - KeepKeys:
  119. keep_keys:
  120. - image
  121. - label
  122. - length
  123. loader:
  124. shuffle: true
  125. batch_size_per_card: 128
  126. drop_last: true
  127. num_sections: 1
  128. num_workers: 8
  129. Eval:
  130. dataset:
  131. name: SimpleDataSet
  132. data_dir: ./train_data/ic15_data
  133. label_file_list:
  134. - ./train_data/ic15_data/rec_gt_test.txt
  135. transforms:
  136. - DecodeImage:
  137. img_mode: BGR
  138. channel_first: false
  139. - CTCLabelEncode:
  140. - RecResizeImg:
  141. image_shape: [3, 32, 320]
  142. - KeepKeys:
  143. keep_keys:
  144. - image
  145. - label
  146. - length
  147. loader:
  148. shuffle: false
  149. drop_last: false
  150. batch_size_per_card: 128
  151. num_workers: 8