focalsvtr_smtr_long.yml 3.5 KB

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