svtrv2_smtr_gtc_rctc_ch.yml 4.3 KB

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