ch_PP-OCRv2_rec_distillation.yml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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, 2000]
  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. amp_custom_black_list: ['matmul','matmul_v2','elementwise_add']
  23. Optimizer:
  24. name: Adam
  25. beta1: 0.9
  26. beta2: 0.999
  27. lr:
  28. name: Piecewise
  29. decay_epochs : [700, 800]
  30. values : [0.001, 0.0001]
  31. warmup_epoch: 5
  32. regularizer:
  33. name: L2
  34. factor: 2.0e-05
  35. Architecture:
  36. model_type: &model_type "rec"
  37. name: DistillationModel
  38. algorithm: Distillation
  39. Models:
  40. Teacher:
  41. pretrained:
  42. freeze_params: false
  43. return_all_feats: true
  44. model_type: *model_type
  45. algorithm: CRNN
  46. Transform:
  47. Backbone:
  48. name: MobileNetV1Enhance
  49. scale: 0.5
  50. Neck:
  51. name: SequenceEncoder
  52. encoder_type: rnn
  53. hidden_size: 64
  54. Head:
  55. name: CTCHead
  56. mid_channels: 96
  57. fc_decay: 0.00002
  58. Student:
  59. pretrained:
  60. freeze_params: false
  61. return_all_feats: true
  62. model_type: *model_type
  63. algorithm: CRNN
  64. Transform:
  65. Backbone:
  66. name: MobileNetV1Enhance
  67. scale: 0.5
  68. Neck:
  69. name: SequenceEncoder
  70. encoder_type: rnn
  71. hidden_size: 64
  72. Head:
  73. name: CTCHead
  74. mid_channels: 96
  75. fc_decay: 0.00002
  76. Loss:
  77. name: CombinedLoss
  78. loss_config_list:
  79. - DistillationCTCLoss:
  80. weight: 1.0
  81. model_name_list: ["Student", "Teacher"]
  82. key: head_out
  83. - DistillationDMLLoss:
  84. weight: 1.0
  85. act: "softmax"
  86. use_log: true
  87. model_name_pairs:
  88. - ["Student", "Teacher"]
  89. key: head_out
  90. - DistillationDistanceLoss:
  91. weight: 1.0
  92. mode: "l2"
  93. model_name_pairs:
  94. - ["Student", "Teacher"]
  95. key: backbone_out
  96. PostProcess:
  97. name: DistillationCTCLabelDecode
  98. model_name: ["Student", "Teacher"]
  99. key: head_out
  100. Metric:
  101. name: DistillationMetric
  102. base_metric_name: RecMetric
  103. main_indicator: acc
  104. key: "Student"
  105. Train:
  106. dataset:
  107. name: SimpleDataSet
  108. data_dir: ./train_data/
  109. label_file_list:
  110. - ./train_data/train_list.txt
  111. transforms:
  112. - DecodeImage:
  113. img_mode: BGR
  114. channel_first: false
  115. - RecAug:
  116. - CTCLabelEncode:
  117. - RecResizeImg:
  118. image_shape: [3, 32, 320]
  119. - KeepKeys:
  120. keep_keys:
  121. - image
  122. - label
  123. - length
  124. loader:
  125. shuffle: true
  126. batch_size_per_card: 128
  127. drop_last: true
  128. num_sections: 1
  129. num_workers: 8
  130. Eval:
  131. dataset:
  132. name: SimpleDataSet
  133. data_dir: ./train_data
  134. label_file_list:
  135. - ./train_data/val_list.txt
  136. transforms:
  137. - DecodeImage:
  138. img_mode: BGR
  139. channel_first: false
  140. - CTCLabelEncode:
  141. - RecResizeImg:
  142. image_shape: [3, 32, 320]
  143. - KeepKeys:
  144. keep_keys:
  145. - image
  146. - label
  147. - length
  148. loader:
  149. shuffle: false
  150. drop_last: false
  151. batch_size_per_card: 128
  152. num_workers: 8