ch_PP-OCRv2_det_distill.yml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. Global:
  2. use_gpu: true
  3. epoch_num: 1200
  4. log_smooth_window: 20
  5. print_batch_step: 2
  6. save_model_dir: ./output/ch_db_mv3/
  7. save_epoch_step: 1200
  8. # evaluation is run every 5000 iterations after the 4000th iteration
  9. eval_batch_step: [3000, 2000]
  10. cal_metric_during_train: False
  11. pretrained_model: ./pretrain_models/MobileNetV3_large_x0_5_pretrained
  12. checkpoints:
  13. save_inference_dir:
  14. use_visualdl: False
  15. infer_img: doc/imgs_en/img_10.jpg
  16. save_res_path: ./output/det_db/predicts_db.txt
  17. Architecture:
  18. name: DistillationModel
  19. algorithm: Distillation
  20. model_type: det
  21. Models:
  22. Student:
  23. pretrained: ./pretrain_models/MobileNetV3_large_x0_5_pretrained
  24. freeze_params: false
  25. return_all_feats: false
  26. model_type: det
  27. algorithm: DB
  28. Backbone:
  29. name: MobileNetV3
  30. scale: 0.5
  31. model_name: large
  32. disable_se: True
  33. Neck:
  34. name: DBFPN
  35. out_channels: 96
  36. Head:
  37. name: DBHead
  38. k: 50
  39. Teacher:
  40. pretrained: ./pretrain_models/ch_ppocr_server_v2.0_det_train/best_accuracy
  41. freeze_params: true
  42. return_all_feats: false
  43. model_type: det
  44. algorithm: DB
  45. Transform:
  46. Backbone:
  47. name: ResNet_vd
  48. layers: 18
  49. Neck:
  50. name: DBFPN
  51. out_channels: 256
  52. Head:
  53. name: DBHead
  54. k: 50
  55. Loss:
  56. name: CombinedLoss
  57. loss_config_list:
  58. - DistillationDilaDBLoss:
  59. weight: 1.0
  60. model_name_pairs:
  61. - ["Student", "Teacher"]
  62. key: maps
  63. balance_loss: true
  64. main_loss_type: DiceLoss
  65. alpha: 5
  66. beta: 10
  67. ohem_ratio: 3
  68. - DistillationDBLoss:
  69. weight: 1.0
  70. model_name_list: ["Student"]
  71. name: DBLoss
  72. balance_loss: true
  73. main_loss_type: DiceLoss
  74. alpha: 5
  75. beta: 10
  76. ohem_ratio: 3
  77. Optimizer:
  78. name: Adam
  79. beta1: 0.9
  80. beta2: 0.999
  81. lr:
  82. name: Cosine
  83. learning_rate: 0.001
  84. warmup_epoch: 2
  85. regularizer:
  86. name: 'L2'
  87. factor: 0
  88. PostProcess:
  89. name: DistillationDBPostProcess
  90. model_name: ["Student"]
  91. key: head_out
  92. thresh: 0.3
  93. box_thresh: 0.6
  94. max_candidates: 1000
  95. unclip_ratio: 1.5
  96. Metric:
  97. name: DistillationMetric
  98. base_metric_name: DetMetric
  99. main_indicator: hmean
  100. key: "Student"
  101. Train:
  102. dataset:
  103. name: SimpleDataSet
  104. data_dir: ./train_data/icdar2015/text_localization/
  105. label_file_list:
  106. - ./train_data/icdar2015/text_localization/train_icdar2015_label.txt
  107. ratio_list: [1.0]
  108. transforms:
  109. - DecodeImage: # load image
  110. img_mode: BGR
  111. channel_first: False
  112. - DetLabelEncode: # Class handling label
  113. - CopyPaste:
  114. - IaaAugment:
  115. augmenter_args:
  116. - { 'type': Fliplr, 'args': { 'p': 0.5 } }
  117. - { 'type': Affine, 'args': { 'rotate': [-10, 10] } }
  118. - { 'type': Resize, 'args': { 'size': [0.5, 3] } }
  119. - EastRandomCropData:
  120. size: [960, 960]
  121. max_tries: 50
  122. keep_ratio: true
  123. - MakeBorderMap:
  124. shrink_ratio: 0.4
  125. thresh_min: 0.3
  126. thresh_max: 0.7
  127. - MakeShrinkMap:
  128. shrink_ratio: 0.4
  129. min_text_size: 8
  130. - NormalizeImage:
  131. scale: 1./255.
  132. mean: [0.485, 0.456, 0.406]
  133. std: [0.229, 0.224, 0.225]
  134. order: 'hwc'
  135. - ToCHWImage:
  136. - KeepKeys:
  137. keep_keys: ['image', 'threshold_map', 'threshold_mask', 'shrink_map', 'shrink_mask'] # the order of the dataloader list
  138. loader:
  139. shuffle: True
  140. drop_last: False
  141. batch_size_per_card: 8
  142. num_workers: 4
  143. Eval:
  144. dataset:
  145. name: SimpleDataSet
  146. data_dir: ./train_data/icdar2015/text_localization/
  147. label_file_list:
  148. - ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
  149. transforms:
  150. - DecodeImage: # load image
  151. img_mode: BGR
  152. channel_first: False
  153. - DetLabelEncode: # Class handling label
  154. - DetResizeForTest:
  155. # image_shape: [736, 1280]
  156. - NormalizeImage:
  157. scale: 1./255.
  158. mean: [0.485, 0.456, 0.406]
  159. std: [0.229, 0.224, 0.225]
  160. order: 'hwc'
  161. - ToCHWImage:
  162. - KeepKeys:
  163. keep_keys: ['image', 'shape', 'polys', 'ignore_tags']
  164. loader:
  165. shuffle: False
  166. drop_last: False
  167. batch_size_per_card: 1 # must be 1
  168. num_workers: 2