focalsvtr_smtr.yml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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/focalsvtr_smtr_maxratio12
  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: ./output/rec/focalsvtr_smtr/best.pth
  13. # ./output/focalnet_subs_nocmff_20ep_u14m_k8_max_ratio12_h8_norand1_h2_padrand_doub_96/best.pth
  14. # ./output/rec/focalsvtr_smtr/best.pth
  15. checkpoints:
  16. use_tensorboard: false
  17. infer_img: ../ltb/img
  18. # for data or label process
  19. character_dict_path: &character_dict_path ./tools/utils/EN_symbol_dict.txt # 96en
  20. # ./tools/utils/ppocr_keys_v1.txt # ch
  21. max_text_length: &max_text_length 25
  22. use_space_char: &use_space_char False
  23. save_res_path: ./output/rec/u14m_filter/predicts_focalsvtr_smtr_maxratio12.txt
  24. use_amp: True
  25. Optimizer:
  26. name: AdamW
  27. lr: 0.00065 # for 4gpus bs256/gpu
  28. weight_decay: 0.05
  29. filter_bias_and_bn: True
  30. LRScheduler:
  31. name: OneCycleLR
  32. warmup_epoch: 1.5 # pct_start 0.075*20 = 1.5ep
  33. cycle_momentum: False
  34. Architecture:
  35. model_type: rec
  36. algorithm: SMTR
  37. in_channels: 3
  38. Transform:
  39. Encoder:
  40. name: FocalSVTR
  41. img_size: [32, 128]
  42. depths: [6, 6, 6]
  43. embed_dim: 96
  44. sub_k: [[1, 1], [2, 1], [1, 1]]
  45. focal_levels: [3, 3, 3]
  46. last_stage: False
  47. Decoder:
  48. name: SMTRDecoder
  49. num_layer: 1
  50. ds: True
  51. max_len: *max_text_length
  52. next_mode: &next True
  53. sub_str_len: &subsl 5
  54. Loss:
  55. name: SMTRLoss
  56. PostProcess:
  57. name: SMTRLabelDecode
  58. next_mode: *next
  59. character_dict_path: *character_dict_path
  60. use_space_char: *use_space_char
  61. Metric:
  62. name: RecMetric
  63. main_indicator: acc
  64. is_filter: True
  65. Train:
  66. dataset:
  67. name: RatioDataSet
  68. ds_width: True
  69. padding: &padding True
  70. padding_rand: True
  71. padding_doub: True
  72. data_dir_list: ['../Union14M-L-LMDB-Filtered/filter_train_challenging',
  73. '../Union14M-L-LMDB-Filtered/filter_train_hard',
  74. '../Union14M-L-LMDB-Filtered/filter_train_medium',
  75. '../Union14M-L-LMDB-Filtered/filter_train_normal',
  76. '../Union14M-L-LMDB-Filtered/filter_train_easy',
  77. ]
  78. transforms:
  79. - DecodeImage: # load image
  80. img_mode: BGR
  81. channel_first: False
  82. - PARSeqAug:
  83. - SMTRLabelEncode: # Class handling label
  84. sub_str_len: *subsl
  85. character_dict_path: *character_dict_path
  86. use_space_char: *use_space_char
  87. max_text_length: *max_text_length
  88. - KeepKeys:
  89. keep_keys: ['image', 'label', 'label_subs', 'label_next', 'length_subs',
  90. 'label_subs_pre', 'label_next_pre', 'length_subs_pre', 'length'] # dataloader will return list in this order
  91. sampler:
  92. name: RatioSampler
  93. scales: [[128, 32]] # w, h
  94. # divide_factor: to ensure the width and height dimensions can be devided by downsampling multiple
  95. first_bs: &bs 256
  96. fix_bs: false
  97. divided_factor: [4, 16] # w, h
  98. is_training: True
  99. loader:
  100. shuffle: True
  101. batch_size_per_card: *bs
  102. drop_last: True
  103. max_ratio: &max_ratio 12
  104. num_workers: 4
  105. Eval:
  106. dataset:
  107. name: RatioDataSet
  108. ds_width: True
  109. padding: False
  110. padding_rand: False
  111. data_dir_list: [
  112. '../evaluation/CUTE80',
  113. '../evaluation/IC13_857',
  114. '../evaluation/IC15_1811',
  115. '../evaluation/IIIT5k',
  116. '../evaluation/SVT',
  117. '../evaluation/SVTP',
  118. ]
  119. transforms:
  120. - DecodeImage: # load image
  121. img_mode: BGR
  122. channel_first: False
  123. - ARLabelEncode: # Class handling label
  124. character_dict_path: *character_dict_path
  125. use_space_char: *use_space_char
  126. max_text_length: *max_text_length
  127. - KeepKeys:
  128. keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
  129. sampler:
  130. name: RatioSampler
  131. scales: [[128, 32]] # w, h
  132. # divide_factor: to ensure the width and height dimensions can be devided by downsampling multiple
  133. first_bs: 128
  134. fix_bs: false
  135. divided_factor: [4, 16] # w, h
  136. is_training: False
  137. loader:
  138. shuffle: False
  139. drop_last: False
  140. max_ratio: *max_ratio
  141. batch_size_per_card: 128
  142. num_workers: 4