svtrv2_smtr_gtc_rctc.yml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. Global:
  2. device: gpu
  3. epoch_num: 20
  4. log_smooth_window: 20
  5. print_batch_step: 10
  6. output_dir: ./output/rec/u14m_filter/svtrv2_smtr_gtc_rctc
  7. save_epoch_step: [15, 1]
  8. # evaluation is run every 2000 iterations
  9. eval_batch_step: [0, 500]
  10. eval_epoch_step: [0, 1]
  11. cal_metric_during_train: True
  12. pretrained_model:
  13. # ./output/rec/u14m_filter/svtrv2_rctc/best.pth
  14. checkpoints:
  15. use_tensorboard: false
  16. infer_img:
  17. # for data or label process
  18. character_dict_path: &character_dict_path ./tools/utils/EN_symbol_dict.txt # 96en
  19. # ./tools/utils/ppocr_keys_v1.txt # ch
  20. max_text_length: &max_text_length 25
  21. use_space_char: &use_space_char False
  22. save_res_path: ./output/rec/u14m_filter/predicts_svtrv2_smtr_gtc_rctc.txt
  23. use_amp: True
  24. Optimizer:
  25. name: AdamW
  26. lr: 0.000325 # for 4gpus bs128/gpu
  27. weight_decay: 0.05
  28. filter_bias_and_bn: True
  29. LRScheduler:
  30. name: OneCycleLR
  31. warmup_epoch: 1.5 # pct_start 0.075*20 = 1.5ep
  32. cycle_momentum: False
  33. Architecture:
  34. model_type: rec
  35. algorithm: SVTRv2
  36. in_channels: 3
  37. Transform:
  38. Encoder:
  39. name: SVTRv2LNConvTwo33
  40. use_pos_embed: False
  41. dims: [128, 256, 384]
  42. depths: [6, 6, 6]
  43. num_heads: [4, 8, 12]
  44. mixer: [['Conv','Conv','Conv','Conv','Conv','Conv'],['Conv','Conv','FGlobal','Global','Global','Global'],['Global','Global','Global','Global','Global','Global']]
  45. local_k: [[5, 5], [5, 5], [-1, -1]]
  46. sub_k: [[1, 1], [2, 1], [-1, -1]]
  47. last_stage: false
  48. feat2d: True
  49. Decoder:
  50. name: GTCDecoder
  51. infer_gtc: True
  52. detach: False
  53. gtc_decoder:
  54. name: SMTRDecoder
  55. num_layer: 1
  56. ds: True
  57. max_len: *max_text_length
  58. next_mode: &next True
  59. sub_str_len: &subsl 5
  60. ctc_decoder:
  61. name: RCTCDecoder
  62. Loss:
  63. name: GTCLoss
  64. ctc_weight: 0.1
  65. gtc_loss:
  66. name: SMTRLoss
  67. PostProcess:
  68. name: GTCLabelDecode
  69. gtc_label_decode:
  70. name: SMTRLabelDecode
  71. next_mode: *next
  72. character_dict_path: *character_dict_path
  73. use_space_char: *use_space_char
  74. Metric:
  75. name: RecGTCMetric
  76. main_indicator: acc
  77. is_filter: True
  78. Train:
  79. dataset:
  80. name: RatioDataSetTVResize
  81. ds_width: True
  82. padding: false
  83. data_dir_list: ['../Union14M-L-LMDB-Filtered/filter_train_challenging',
  84. '../Union14M-L-LMDB-Filtered/filter_train_hard',
  85. '../Union14M-L-LMDB-Filtered/filter_train_medium',
  86. '../Union14M-L-LMDB-Filtered/filter_train_normal',
  87. '../Union14M-L-LMDB-Filtered/filter_train_easy',
  88. ]
  89. transforms:
  90. - DecodeImagePIL: # load image
  91. img_mode: RGB
  92. - PARSeqAugPIL:
  93. - GTCLabelEncode: # Class handling label
  94. gtc_label_encode:
  95. name: SMTRLabelEncode
  96. sub_str_len: *subsl
  97. character_dict_path: *character_dict_path
  98. use_space_char: *use_space_char
  99. max_text_length: *max_text_length
  100. - KeepKeys:
  101. keep_keys: ['image', 'label', 'label_subs', 'label_next', 'length_subs',
  102. 'label_subs_pre', 'label_next_pre', 'length_subs_pre', 'length', 'ctc_label', 'ctc_length'] # dataloader will return list in this order
  103. sampler:
  104. name: RatioSampler
  105. scales: [[128, 32]] # w, h
  106. # divide_factor: to ensure the width and height dimensions can be devided by downsampling multiple
  107. first_bs: &bs 128
  108. fix_bs: false
  109. divided_factor: [4, 16] # w, h
  110. is_training: True
  111. loader:
  112. shuffle: True
  113. batch_size_per_card: *bs
  114. drop_last: True
  115. max_ratio: &max_ratio 12
  116. num_workers: 4
  117. Eval:
  118. dataset:
  119. name: RatioDataSetTVResize
  120. ds_width: True
  121. padding: False
  122. data_dir_list: [
  123. '../evaluation/CUTE80',
  124. '../evaluation/IC13_857',
  125. '../evaluation/IC15_1811',
  126. '../evaluation/IIIT5k',
  127. '../evaluation/SVT',
  128. '../evaluation/SVTP',
  129. ]
  130. transforms:
  131. - DecodeImagePIL: # load image
  132. img_mode: RGB
  133. - GTCLabelEncode: # Class handling label
  134. gtc_label_encode:
  135. name: ARLabelEncode
  136. character_dict_path: *character_dict_path
  137. use_space_char: *use_space_char
  138. max_text_length: *max_text_length
  139. - KeepKeys:
  140. keep_keys: ['image', 'label', 'length', 'ctc_label', 'ctc_length'] # dataloader will return list in this order
  141. sampler:
  142. name: RatioSampler
  143. scales: [[128, 32]] # w, h
  144. # divide_factor: to ensure the width and height dimensions can be devided by downsampling multiple
  145. first_bs: *bs
  146. fix_bs: false
  147. divided_factor: [4, 16] # w, h
  148. is_training: False
  149. loader:
  150. shuffle: False
  151. drop_last: False
  152. batch_size_per_card: *bs
  153. max_ratio: *max_ratio
  154. num_workers: 4