ch_PP-OCRv3_rec_distillation.yml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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_ppocr_v3_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: &max_text_length 25
  18. infer_mode: false
  19. use_space_char: true
  20. distributed: true
  21. save_res_path: ./output/rec/predicts_ppocrv3_distillation.txt
  22. Optimizer:
  23. name: Adam
  24. beta1: 0.9
  25. beta2: 0.999
  26. lr:
  27. name: Piecewise
  28. decay_epochs : [700]
  29. values : [0.0005, 0.00005]
  30. warmup_epoch: 5
  31. regularizer:
  32. name: L2
  33. factor: 3.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: SVTR
  45. Transform:
  46. Backbone:
  47. name: MobileNetV1Enhance
  48. scale: 0.5
  49. last_conv_stride: [1, 2]
  50. last_pool_type: avg
  51. Head:
  52. name: MultiHead
  53. head_list:
  54. - CTCHead:
  55. Neck:
  56. name: svtr
  57. dims: 64
  58. depth: 2
  59. hidden_dims: 120
  60. use_guide: True
  61. Head:
  62. fc_decay: 0.00001
  63. - SARHead:
  64. enc_dim: 512
  65. max_text_length: *max_text_length
  66. Student:
  67. pretrained:
  68. freeze_params: false
  69. return_all_feats: true
  70. model_type: *model_type
  71. algorithm: SVTR
  72. Transform:
  73. Backbone:
  74. name: MobileNetV1Enhance
  75. scale: 0.5
  76. last_conv_stride: [1, 2]
  77. last_pool_type: avg
  78. Head:
  79. name: MultiHead
  80. head_list:
  81. - CTCHead:
  82. Neck:
  83. name: svtr
  84. dims: 64
  85. depth: 2
  86. hidden_dims: 120
  87. use_guide: True
  88. Head:
  89. fc_decay: 0.00001
  90. - SARHead:
  91. enc_dim: 512
  92. max_text_length: *max_text_length
  93. Loss:
  94. name: CombinedLoss
  95. loss_config_list:
  96. - DistillationDMLLoss:
  97. weight: 1.0
  98. act: "softmax"
  99. use_log: true
  100. model_name_pairs:
  101. - ["Student", "Teacher"]
  102. key: head_out
  103. multi_head: True
  104. dis_head: ctc
  105. name: dml_ctc
  106. - DistillationDMLLoss:
  107. weight: 0.5
  108. act: "softmax"
  109. use_log: true
  110. model_name_pairs:
  111. - ["Student", "Teacher"]
  112. key: head_out
  113. multi_head: True
  114. dis_head: sar
  115. name: dml_sar
  116. - DistillationDistanceLoss:
  117. weight: 1.0
  118. mode: "l2"
  119. model_name_pairs:
  120. - ["Student", "Teacher"]
  121. key: backbone_out
  122. - DistillationCTCLoss:
  123. weight: 1.0
  124. model_name_list: ["Student", "Teacher"]
  125. key: head_out
  126. multi_head: True
  127. - DistillationSARLoss:
  128. weight: 1.0
  129. model_name_list: ["Student", "Teacher"]
  130. key: head_out
  131. multi_head: True
  132. PostProcess:
  133. name: DistillationCTCLabelDecode
  134. model_name: ["Student", "Teacher"]
  135. key: head_out
  136. multi_head: True
  137. Metric:
  138. name: DistillationMetric
  139. base_metric_name: RecMetric
  140. main_indicator: acc
  141. key: "Student"
  142. ignore_space: False
  143. Train:
  144. dataset:
  145. name: SimpleDataSet
  146. data_dir: ./train_data/
  147. ext_op_transform_idx: 1
  148. label_file_list:
  149. - ./train_data/train_list.txt
  150. transforms:
  151. - DecodeImage:
  152. img_mode: BGR
  153. channel_first: false
  154. - RecConAug:
  155. prob: 0.5
  156. ext_data_num: 2
  157. image_shape: [48, 320, 3]
  158. max_text_length: *max_text_length
  159. - RecAug:
  160. - MultiLabelEncode:
  161. - RecResizeImg:
  162. image_shape: [3, 48, 320]
  163. - KeepKeys:
  164. keep_keys:
  165. - image
  166. - label_ctc
  167. - label_sar
  168. - length
  169. - valid_ratio
  170. loader:
  171. shuffle: true
  172. batch_size_per_card: 128
  173. drop_last: true
  174. num_workers: 4
  175. Eval:
  176. dataset:
  177. name: SimpleDataSet
  178. data_dir: ./train_data
  179. label_file_list:
  180. - ./train_data/val_list.txt
  181. transforms:
  182. - DecodeImage:
  183. img_mode: BGR
  184. channel_first: false
  185. - MultiLabelEncode:
  186. - RecResizeImg:
  187. image_shape: [3, 48, 320]
  188. - KeepKeys:
  189. keep_keys:
  190. - image
  191. - label_ctc
  192. - label_sar
  193. - length
  194. - valid_ratio
  195. loader:
  196. shuffle: false
  197. drop_last: false
  198. batch_size_per_card: 128
  199. num_workers: 4