pk5ls20 commited on
Commit
5d46e17
·
1 Parent(s): 452d3d0

add configs

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. configs/cls/ch_PP-OCRv3/ch_PP-OCRv3_rotnet.yml +98 -0
  2. configs/cls/cls_mv3.yml +95 -0
  3. configs/det/ch_PP-OCRv2/ch_PP-OCRv2_det_cml.yml +206 -0
  4. configs/det/ch_PP-OCRv2/ch_PP-OCRv2_det_distill.yml +175 -0
  5. configs/det/ch_PP-OCRv2/ch_PP-OCRv2_det_dml.yml +178 -0
  6. configs/det/ch_PP-OCRv2/ch_PP-OCRv2_det_student.yml +132 -0
  7. configs/det/ch_PP-OCRv3/ch_PP-OCRv3_det_cml.yml +217 -0
  8. configs/det/ch_PP-OCRv3/ch_PP-OCRv3_det_dml.yml +166 -0
  9. configs/det/ch_PP-OCRv3/ch_PP-OCRv3_det_student.yml +161 -0
  10. configs/det/ch_PP-OCRv4/ch_PP-OCRv4_det_cml.yml +234 -0
  11. configs/det/ch_PP-OCRv4/ch_PP-OCRv4_det_student.yml +167 -0
  12. configs/det/ch_PP-OCRv4/ch_PP-OCRv4_det_teacher.yml +167 -0
  13. configs/det/ch_ppocr_v2.0/ch_det_mv3_db_v2.0.yml +132 -0
  14. configs/det/ch_ppocr_v2.0/ch_det_res18_db_v2.0.yml +131 -0
  15. configs/det/det_mv3_db.yml +131 -0
  16. configs/det/det_mv3_east.yml +109 -0
  17. configs/det/det_mv3_pse.yml +135 -0
  18. configs/det/det_r18_vd_ct.yml +107 -0
  19. configs/det/det_r50_db++_icdar15.yml +164 -0
  20. configs/det/det_r50_db++_td_tr.yml +167 -0
  21. configs/det/det_r50_drrg_ctw.yml +133 -0
  22. configs/det/det_r50_vd_db.yml +128 -0
  23. configs/det/det_r50_vd_dcn_fce_ctw.yml +139 -0
  24. configs/det/det_r50_vd_east.yml +108 -0
  25. configs/det/det_r50_vd_pse.yml +134 -0
  26. configs/det/det_r50_vd_sast_icdar15.yml +109 -0
  27. configs/det/det_r50_vd_sast_totaltext.yml +108 -0
  28. configs/det/det_res18_db_v2.0.yml +131 -0
  29. configs/e2e/e2e_r50_vd_pg.yml +121 -0
  30. configs/kie/layoutlm_series/re_layoutlmv2_xfund_zh.yml +123 -0
  31. configs/kie/layoutlm_series/re_layoutxlm_xfund_zh.yml +123 -0
  32. configs/kie/layoutlm_series/ser_layoutlm_xfund_zh.yml +121 -0
  33. configs/kie/layoutlm_series/ser_layoutlmv2_xfund_zh.yml +122 -0
  34. configs/kie/layoutlm_series/ser_layoutxlm_xfund_zh.yml +122 -0
  35. configs/kie/sdmgr/kie_unet_sdmgr.yml +111 -0
  36. configs/kie/vi_layoutxlm/re_vi_layoutxlm_xfund_zh.yml +130 -0
  37. configs/kie/vi_layoutxlm/re_vi_layoutxlm_xfund_zh_udml.yml +177 -0
  38. configs/kie/vi_layoutxlm/ser_vi_layoutxlm_xfund_zh.yml +138 -0
  39. configs/kie/vi_layoutxlm/ser_vi_layoutxlm_xfund_zh_udml.yml +182 -0
  40. configs/rec/PP-OCRv3/ch_PP-OCRv3_rec.yml +119 -0
  41. configs/rec/PP-OCRv3/ch_PP-OCRv3_rec_distillation.yml +205 -0
  42. configs/rec/PP-OCRv4/ch_PP-OCRv4_rec.yml +133 -0
  43. configs/rec/PP-OCRv4/ch_PP-OCRv4_rec_distill.yml +200 -0
  44. configs/rec/PP-OCRv4/ch_PP-OCRv4_rec_hgnet.yml +134 -0
  45. configs/rec/ch_PP-OCRv2/ch_PP-OCRv2_rec.yml +110 -0
  46. configs/rec/ch_PP-OCRv2/ch_PP-OCRv2_rec_distillation.yml +160 -0
  47. configs/rec/ch_PP-OCRv2/ch_PP-OCRv2_rec_enhanced_ctc_loss.yml +124 -0
  48. configs/rec/ch_ppocr_v2.0/rec_chinese_common_train_v2.0.yml +100 -0
  49. configs/rec/ch_ppocr_v2.0/rec_chinese_lite_train_v2.0.yml +102 -0
  50. configs/rec/multi_language/generate_multi_language_configs.py +226 -0
configs/cls/ch_PP-OCRv3/ch_PP-OCRv3_rotnet.yml ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ debug: false
3
+ use_gpu: true
4
+ epoch_num: 100
5
+ log_smooth_window: 20
6
+ print_batch_step: 10
7
+ output_dir: ./output/rec_ppocr_v3_rotnet
8
+ save_epoch_step: 3
9
+ eval_batch_step: [0, 2000]
10
+ cal_metric_during_train: true
11
+ pretrained_model: null
12
+ checkpoints: null
13
+ save_inference_dir: null
14
+ use_visualdl: false
15
+ infer_img: doc/imgs_words/ch/word_1.jpg
16
+ character_dict_path: ppocr/utils/ppocr_keys_v1.txt
17
+ max_text_length: 25
18
+ infer_mode: false
19
+ use_space_char: true
20
+ save_res_path: ./output/rec/predicts_chinese_lite_v2.0.txt
21
+ Optimizer:
22
+ name: Adam
23
+ beta1: 0.9
24
+ beta2: 0.999
25
+ lr:
26
+ name: Cosine
27
+ learning_rate: 0.001
28
+ regularizer:
29
+ name: L2
30
+ factor: 1.0e-05
31
+ Architecture:
32
+ model_type: cls
33
+ algorithm: CLS
34
+ Transform: null
35
+ Backbone:
36
+ name: MobileNetV1Enhance
37
+ scale: 0.5
38
+ last_conv_stride: [1, 2]
39
+ last_pool_type: avg
40
+ Neck:
41
+ Head:
42
+ name: ClsHead
43
+ class_dim: 4
44
+
45
+ Loss:
46
+ name: ClsLoss
47
+ main_indicator: acc
48
+
49
+ PostProcess:
50
+ name: ClsPostProcess
51
+
52
+ Metric:
53
+ name: ClsMetric
54
+ main_indicator: acc
55
+
56
+ Train:
57
+ dataset:
58
+ name: SimpleDataSet
59
+ data_dir: ./train_data
60
+ label_file_list:
61
+ - ./train_data/train_list.txt
62
+ transforms:
63
+ - DecodeImage:
64
+ img_mode: BGR
65
+ channel_first: false
66
+ - BaseDataAugmentation:
67
+ - RandAugment:
68
+ - SSLRotateResize:
69
+ image_shape: [3, 48, 320]
70
+ - KeepKeys:
71
+ keep_keys: ["image", "label"]
72
+ loader:
73
+ collate_fn: "SSLRotateCollate"
74
+ shuffle: true
75
+ batch_size_per_card: 32
76
+ drop_last: true
77
+ num_workers: 8
78
+ Eval:
79
+ dataset:
80
+ name: SimpleDataSet
81
+ data_dir: ./train_data
82
+ label_file_list:
83
+ - ./train_data/val_list.txt
84
+ transforms:
85
+ - DecodeImage:
86
+ img_mode: BGR
87
+ channel_first: false
88
+ - SSLRotateResize:
89
+ image_shape: [3, 48, 320]
90
+ - KeepKeys:
91
+ keep_keys: ["image", "label"]
92
+ loader:
93
+ collate_fn: "SSLRotateCollate"
94
+ shuffle: false
95
+ drop_last: false
96
+ batch_size_per_card: 64
97
+ num_workers: 8
98
+ profiler_options: null
configs/cls/cls_mv3.yml ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 100
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/cls/mv3/
7
+ eval_epoch_step: [0, 1]
8
+ cal_metric_during_train: True
9
+ pretrained_model:
10
+ checkpoints:
11
+ use_tensorboard: False
12
+ infer_img: img2
13
+ label_list: &label_list ['0','180']
14
+
15
+ Export:
16
+ export_dir:
17
+ export_shape: [ 1, 3, 48, 192 ]
18
+ dynamic_axes: [0]
19
+
20
+ Architecture:
21
+ model_type: cls
22
+ algorithm: CLS
23
+ Transform:
24
+ Backbone:
25
+ name: MobileNetV3
26
+ scale: 0.35
27
+ model_name: small
28
+ Neck:
29
+ Head:
30
+ name: ClsHead
31
+ class_dim: 2
32
+
33
+ Loss:
34
+ name: ClsLoss
35
+
36
+ Optimizer:
37
+ name: Adam
38
+ lr: 0.001
39
+ weight_decay: 0
40
+
41
+ LRScheduler:
42
+ name: CosineAnnealingLR
43
+ warmup_epoch: 2
44
+
45
+ PostProcess:
46
+ name: ClsPostProcess
47
+ label_list: *label_list
48
+
49
+ Metric:
50
+ name: ClsMetric
51
+ main_indicator: acc
52
+
53
+ Train:
54
+ dataset:
55
+ name: SimpleDataSet
56
+ data_dir: ./train_data/cls
57
+ label_file_list:
58
+ - ./train_data/cls/train.txt
59
+ transforms:
60
+ - DecodeImage: # load image
61
+ img_mode: BGR
62
+ channel_first: False
63
+ - ClsLabelEncode: # Class handling label
64
+ - BaseDataAugmentation:
65
+ - RandAugment:
66
+ - ClsResizeImg:
67
+ image_shape: [3, 48, 192]
68
+ - KeepKeys:
69
+ keep_keys: ['image', 'label'] # dataloader will return list in this order
70
+ loader:
71
+ shuffle: True
72
+ batch_size_per_card: 512
73
+ drop_last: True
74
+ num_workers: 8
75
+
76
+ Eval:
77
+ dataset:
78
+ name: SimpleDataSet
79
+ data_dir: ./train_data/cls
80
+ label_file_list:
81
+ - ./train_data/cls/test.txt
82
+ transforms:
83
+ - DecodeImage: # load image
84
+ img_mode: BGR
85
+ channel_first: False
86
+ - ClsLabelEncode: # Class handling label
87
+ - ClsResizeImg:
88
+ image_shape: [3, 48, 192]
89
+ - KeepKeys:
90
+ keep_keys: ['image', 'label'] # dataloader will return list in this order
91
+ loader:
92
+ shuffle: False
93
+ drop_last: False
94
+ batch_size_per_card: 512
95
+ num_workers: 4
configs/det/ch_PP-OCRv2/ch_PP-OCRv2_det_cml.yml ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: true
3
+ epoch_num: 1200
4
+ log_smooth_window: 20
5
+ print_batch_step: 2
6
+ output_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:
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
+ use_amp: False
18
+ amp_level: O2
19
+ amp_dtype: bfloat16
20
+
21
+ Architecture:
22
+ name: DistillationModel
23
+ algorithm: Distillation
24
+ model_type: det
25
+ Models:
26
+ Teacher:
27
+ pretrained: ./pretrain_models/ch_ppocr_server_v2.0_det_train/best_accuracy
28
+ freeze_params: true
29
+ return_all_feats: false
30
+ model_type: det
31
+ algorithm: DB
32
+ Transform:
33
+ Backbone:
34
+ name: ResNet_vd
35
+ layers: 18
36
+ Neck:
37
+ name: DBFPN
38
+ out_channels: 256
39
+ Head:
40
+ name: DBHead
41
+ k: 50
42
+ Student:
43
+ pretrained:
44
+ freeze_params: false
45
+ return_all_feats: false
46
+ model_type: det
47
+ algorithm: DB
48
+ Backbone:
49
+ name: MobileNetV3
50
+ scale: 0.5
51
+ model_name: large
52
+ disable_se: True
53
+ Neck:
54
+ name: DBFPN
55
+ out_channels: 96
56
+ Head:
57
+ name: DBHead
58
+ k: 50
59
+ Student2:
60
+ pretrained:
61
+ freeze_params: false
62
+ return_all_feats: false
63
+ model_type: det
64
+ algorithm: DB
65
+ Transform:
66
+ Backbone:
67
+ name: MobileNetV3
68
+ scale: 0.5
69
+ model_name: large
70
+ disable_se: True
71
+ Neck:
72
+ name: DBFPN
73
+ out_channels: 96
74
+ Head:
75
+ name: DBHead
76
+ k: 50
77
+
78
+ Loss:
79
+ name: CombinedLoss
80
+ loss_config_list:
81
+ - DistillationDilaDBLoss:
82
+ weight: 1.0
83
+ model_name_pairs:
84
+ - ["Student", "Teacher"]
85
+ - ["Student2", "Teacher"]
86
+ key: maps
87
+ balance_loss: true
88
+ main_loss_type: DiceLoss
89
+ alpha: 5
90
+ beta: 10
91
+ ohem_ratio: 3
92
+ - DistillationDMLLoss:
93
+ model_name_pairs:
94
+ - ["Student", "Student2"]
95
+ maps_name: "thrink_maps"
96
+ weight: 1.0
97
+ # act: None
98
+ model_name_pairs: ["Student", "Student2"]
99
+ key: maps
100
+ - DistillationDBLoss:
101
+ weight: 1.0
102
+ model_name_list: ["Student", "Student2"]
103
+ # key: maps
104
+ # name: DBLoss
105
+ balance_loss: true
106
+ main_loss_type: DiceLoss
107
+ alpha: 5
108
+ beta: 10
109
+ ohem_ratio: 3
110
+
111
+
112
+ Optimizer:
113
+ name: Adam
114
+ beta1: 0.9
115
+ beta2: 0.999
116
+ lr:
117
+ name: Cosine
118
+ learning_rate: 0.001
119
+ warmup_epoch: 2
120
+ regularizer:
121
+ name: 'L2'
122
+ factor: 0
123
+
124
+ PostProcess:
125
+ name: DistillationDBPostProcess
126
+ model_name: ["Student", "Student2", "Teacher"]
127
+ # key: maps
128
+ thresh: 0.3
129
+ box_thresh: 0.6
130
+ max_candidates: 1000
131
+ unclip_ratio: 1.5
132
+
133
+ Metric:
134
+ name: DistillationMetric
135
+ base_metric_name: DetMetric
136
+ main_indicator: hmean
137
+ key: "Student"
138
+
139
+ Train:
140
+ dataset:
141
+ name: SimpleDataSet
142
+ data_dir: ./train_data/icdar2015/text_localization/
143
+ label_file_list:
144
+ - ./train_data/icdar2015/text_localization/train_icdar2015_label.txt
145
+ ratio_list: [1.0]
146
+ transforms:
147
+ - DecodeImage: # load image
148
+ img_mode: BGR
149
+ channel_first: False
150
+ - DetLabelEncode: # Class handling label
151
+ - CopyPaste:
152
+ - IaaAugment:
153
+ augmenter_args:
154
+ - { 'type': Fliplr, 'args': { 'p': 0.5 } }
155
+ - { 'type': Affine, 'args': { 'rotate': [-10, 10] } }
156
+ - { 'type': Resize, 'args': { 'size': [0.5, 3] } }
157
+ - EastRandomCropData:
158
+ size: [960, 960]
159
+ max_tries: 50
160
+ keep_ratio: true
161
+ - MakeBorderMap:
162
+ shrink_ratio: 0.4
163
+ thresh_min: 0.3
164
+ thresh_max: 0.7
165
+ - MakeShrinkMap:
166
+ shrink_ratio: 0.4
167
+ min_text_size: 8
168
+ - NormalizeImage:
169
+ scale: 1./255.
170
+ mean: [0.485, 0.456, 0.406]
171
+ std: [0.229, 0.224, 0.225]
172
+ order: 'hwc'
173
+ - ToCHWImage:
174
+ - KeepKeys:
175
+ keep_keys: ['image', 'threshold_map', 'threshold_mask', 'shrink_map', 'shrink_mask'] # the order of the dataloader list
176
+ loader:
177
+ shuffle: True
178
+ drop_last: False
179
+ batch_size_per_card: 8
180
+ num_workers: 4
181
+
182
+ Eval:
183
+ dataset:
184
+ name: SimpleDataSet
185
+ data_dir: ./train_data/icdar2015/text_localization/
186
+ label_file_list:
187
+ - ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
188
+ transforms:
189
+ - DecodeImage: # load image
190
+ img_mode: BGR
191
+ channel_first: False
192
+ - DetLabelEncode: # Class handling label
193
+ - DetResizeForTest:
194
+ - NormalizeImage:
195
+ scale: 1./255.
196
+ mean: [0.485, 0.456, 0.406]
197
+ std: [0.229, 0.224, 0.225]
198
+ order: 'hwc'
199
+ - ToCHWImage:
200
+ - KeepKeys:
201
+ keep_keys: ['image', 'shape', 'polys', 'ignore_tags']
202
+ loader:
203
+ shuffle: False
204
+ drop_last: False
205
+ batch_size_per_card: 1 # must be 1
206
+ num_workers: 2
configs/det/ch_PP-OCRv2/ch_PP-OCRv2_det_distill.yml ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: true
3
+ epoch_num: 1200
4
+ log_smooth_window: 20
5
+ print_batch_step: 2
6
+ output_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
+
18
+ Architecture:
19
+ name: DistillationModel
20
+ algorithm: Distillation
21
+ model_type: det
22
+ Models:
23
+ Student:
24
+ pretrained: ./pretrain_models/MobileNetV3_large_x0_5_pretrained
25
+ freeze_params: false
26
+ return_all_feats: false
27
+ model_type: det
28
+ algorithm: DB
29
+ Backbone:
30
+ name: MobileNetV3
31
+ scale: 0.5
32
+ model_name: large
33
+ disable_se: True
34
+ Neck:
35
+ name: DBFPN
36
+ out_channels: 96
37
+ Head:
38
+ name: DBHead
39
+ k: 50
40
+ Teacher:
41
+ pretrained: ./pretrain_models/ch_ppocr_server_v2.0_det_train/best_accuracy
42
+ freeze_params: true
43
+ return_all_feats: false
44
+ model_type: det
45
+ algorithm: DB
46
+ Transform:
47
+ Backbone:
48
+ name: ResNet_vd
49
+ layers: 18
50
+ Neck:
51
+ name: DBFPN
52
+ out_channels: 256
53
+ Head:
54
+ name: DBHead
55
+ k: 50
56
+
57
+ Loss:
58
+ name: CombinedLoss
59
+ loss_config_list:
60
+ - DistillationDilaDBLoss:
61
+ weight: 1.0
62
+ model_name_pairs:
63
+ - ["Student", "Teacher"]
64
+ key: maps
65
+ balance_loss: true
66
+ main_loss_type: DiceLoss
67
+ alpha: 5
68
+ beta: 10
69
+ ohem_ratio: 3
70
+ - DistillationDBLoss:
71
+ weight: 1.0
72
+ model_name_list: ["Student"]
73
+ name: DBLoss
74
+ balance_loss: true
75
+ main_loss_type: DiceLoss
76
+ alpha: 5
77
+ beta: 10
78
+ ohem_ratio: 3
79
+
80
+ Optimizer:
81
+ name: Adam
82
+ beta1: 0.9
83
+ beta2: 0.999
84
+ lr:
85
+ name: Cosine
86
+ learning_rate: 0.001
87
+ warmup_epoch: 2
88
+ regularizer:
89
+ name: 'L2'
90
+ factor: 0
91
+
92
+ PostProcess:
93
+ name: DistillationDBPostProcess
94
+ model_name: ["Student"]
95
+ key: head_out
96
+ thresh: 0.3
97
+ box_thresh: 0.6
98
+ max_candidates: 1000
99
+ unclip_ratio: 1.5
100
+
101
+ Metric:
102
+ name: DistillationMetric
103
+ base_metric_name: DetMetric
104
+ main_indicator: hmean
105
+ key: "Student"
106
+
107
+ Train:
108
+ dataset:
109
+ name: SimpleDataSet
110
+ data_dir: ./train_data/icdar2015/text_localization/
111
+ label_file_list:
112
+ - ./train_data/icdar2015/text_localization/train_icdar2015_label.txt
113
+ ratio_list: [1.0]
114
+ transforms:
115
+ - DecodeImage: # load image
116
+ img_mode: BGR
117
+ channel_first: False
118
+ - DetLabelEncode: # Class handling label
119
+ - CopyPaste:
120
+ - IaaAugment:
121
+ augmenter_args:
122
+ - { 'type': Fliplr, 'args': { 'p': 0.5 } }
123
+ - { 'type': Affine, 'args': { 'rotate': [-10, 10] } }
124
+ - { 'type': Resize, 'args': { 'size': [0.5, 3] } }
125
+ - EastRandomCropData:
126
+ size: [960, 960]
127
+ max_tries: 50
128
+ keep_ratio: true
129
+ - MakeBorderMap:
130
+ shrink_ratio: 0.4
131
+ thresh_min: 0.3
132
+ thresh_max: 0.7
133
+ - MakeShrinkMap:
134
+ shrink_ratio: 0.4
135
+ min_text_size: 8
136
+ - NormalizeImage:
137
+ scale: 1./255.
138
+ mean: [0.485, 0.456, 0.406]
139
+ std: [0.229, 0.224, 0.225]
140
+ order: 'hwc'
141
+ - ToCHWImage:
142
+ - KeepKeys:
143
+ keep_keys: ['image', 'threshold_map', 'threshold_mask', 'shrink_map', 'shrink_mask'] # the order of the dataloader list
144
+ loader:
145
+ shuffle: True
146
+ drop_last: False
147
+ batch_size_per_card: 8
148
+ num_workers: 4
149
+
150
+ Eval:
151
+ dataset:
152
+ name: SimpleDataSet
153
+ data_dir: ./train_data/icdar2015/text_localization/
154
+ label_file_list:
155
+ - ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
156
+ transforms:
157
+ - DecodeImage: # load image
158
+ img_mode: BGR
159
+ channel_first: False
160
+ - DetLabelEncode: # Class handling label
161
+ - DetResizeForTest:
162
+ # image_shape: [736, 1280]
163
+ - NormalizeImage:
164
+ scale: 1./255.
165
+ mean: [0.485, 0.456, 0.406]
166
+ std: [0.229, 0.224, 0.225]
167
+ order: 'hwc'
168
+ - ToCHWImage:
169
+ - KeepKeys:
170
+ keep_keys: ['image', 'shape', 'polys', 'ignore_tags']
171
+ loader:
172
+ shuffle: False
173
+ drop_last: False
174
+ batch_size_per_card: 1 # must be 1
175
+ num_workers: 2
configs/det/ch_PP-OCRv2/ch_PP-OCRv2_det_dml.yml ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: true
3
+ epoch_num: 1200
4
+ log_smooth_window: 20
5
+ print_batch_step: 2
6
+ output_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
+
18
+ Architecture:
19
+ name: DistillationModel
20
+ algorithm: Distillation
21
+ model_type: det
22
+ Models:
23
+ Student:
24
+ pretrained: ./pretrain_models/MobileNetV3_large_x0_5_pretrained
25
+ freeze_params: false
26
+ return_all_feats: false
27
+ model_type: det
28
+ algorithm: DB
29
+ Backbone:
30
+ name: MobileNetV3
31
+ scale: 0.5
32
+ model_name: large
33
+ disable_se: True
34
+ Neck:
35
+ name: DBFPN
36
+ out_channels: 96
37
+ Head:
38
+ name: DBHead
39
+ k: 50
40
+ Teacher:
41
+ pretrained: ./pretrain_models/MobileNetV3_large_x0_5_pretrained
42
+ freeze_params: false
43
+ return_all_feats: false
44
+ model_type: det
45
+ algorithm: DB
46
+ Transform:
47
+ Backbone:
48
+ name: MobileNetV3
49
+ scale: 0.5
50
+ model_name: large
51
+ disable_se: True
52
+ Neck:
53
+ name: DBFPN
54
+ out_channels: 96
55
+ Head:
56
+ name: DBHead
57
+ k: 50
58
+
59
+
60
+ Loss:
61
+ name: CombinedLoss
62
+ loss_config_list:
63
+ - DistillationDMLLoss:
64
+ model_name_pairs:
65
+ - ["Student", "Teacher"]
66
+ maps_name: "thrink_maps"
67
+ weight: 1.0
68
+ # act: None
69
+ model_name_pairs: ["Student", "Teacher"]
70
+ key: maps
71
+ - DistillationDBLoss:
72
+ weight: 1.0
73
+ model_name_list: ["Student", "Teacher"]
74
+ # key: maps
75
+ name: DBLoss
76
+ balance_loss: true
77
+ main_loss_type: DiceLoss
78
+ alpha: 5
79
+ beta: 10
80
+ ohem_ratio: 3
81
+
82
+
83
+ Optimizer:
84
+ name: Adam
85
+ beta1: 0.9
86
+ beta2: 0.999
87
+ lr:
88
+ name: Cosine
89
+ learning_rate: 0.001
90
+ warmup_epoch: 2
91
+ regularizer:
92
+ name: 'L2'
93
+ factor: 0
94
+
95
+ PostProcess:
96
+ name: DistillationDBPostProcess
97
+ model_name: ["Student", "Teacher"]
98
+ key: head_out
99
+ thresh: 0.3
100
+ box_thresh: 0.6
101
+ max_candidates: 1000
102
+ unclip_ratio: 1.5
103
+
104
+ Metric:
105
+ name: DistillationMetric
106
+ base_metric_name: DetMetric
107
+ main_indicator: hmean
108
+ key: "Student"
109
+
110
+ Train:
111
+ dataset:
112
+ name: SimpleDataSet
113
+ data_dir: ./train_data/icdar2015/text_localization/
114
+ label_file_list:
115
+ - ./train_data/icdar2015/text_localization/train_icdar2015_label.txt
116
+ ratio_list: [1.0]
117
+ transforms:
118
+ - DecodeImage: # load image
119
+ img_mode: BGR
120
+ channel_first: False
121
+ - DetLabelEncode: # Class handling label
122
+ - CopyPaste:
123
+ - IaaAugment:
124
+ augmenter_args:
125
+ - { 'type': Fliplr, 'args': { 'p': 0.5 } }
126
+ - { 'type': Affine, 'args': { 'rotate': [-10, 10] } }
127
+ - { 'type': Resize, 'args': { 'size': [0.5, 3] } }
128
+ - EastRandomCropData:
129
+ size: [960, 960]
130
+ max_tries: 50
131
+ keep_ratio: true
132
+ - MakeBorderMap:
133
+ shrink_ratio: 0.4
134
+ thresh_min: 0.3
135
+ thresh_max: 0.7
136
+ - MakeShrinkMap:
137
+ shrink_ratio: 0.4
138
+ min_text_size: 8
139
+ - NormalizeImage:
140
+ scale: 1./255.
141
+ mean: [0.485, 0.456, 0.406]
142
+ std: [0.229, 0.224, 0.225]
143
+ order: 'hwc'
144
+ - ToCHWImage:
145
+ - KeepKeys:
146
+ keep_keys: ['image', 'threshold_map', 'threshold_mask', 'shrink_map', 'shrink_mask'] # the order of the dataloader list
147
+ loader:
148
+ shuffle: True
149
+ drop_last: False
150
+ batch_size_per_card: 8
151
+ num_workers: 4
152
+
153
+ Eval:
154
+ dataset:
155
+ name: SimpleDataSet
156
+ data_dir: ./train_data/icdar2015/text_localization/
157
+ label_file_list:
158
+ - ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
159
+ transforms:
160
+ - DecodeImage: # load image
161
+ img_mode: BGR
162
+ channel_first: False
163
+ - DetLabelEncode: # Class handling label
164
+ - DetResizeForTest:
165
+ # image_shape: [736, 1280]
166
+ - NormalizeImage:
167
+ scale: 1./255.
168
+ mean: [0.485, 0.456, 0.406]
169
+ std: [0.229, 0.224, 0.225]
170
+ order: 'hwc'
171
+ - ToCHWImage:
172
+ - KeepKeys:
173
+ keep_keys: ['image', 'shape', 'polys', 'ignore_tags']
174
+ loader:
175
+ shuffle: False
176
+ drop_last: False
177
+ batch_size_per_card: 1 # must be 1
178
+ num_workers: 2
configs/det/ch_PP-OCRv2/ch_PP-OCRv2_det_student.yml ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: true
3
+ epoch_num: 1200
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_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: [0, 400]
10
+ cal_metric_during_train: False
11
+ pretrained_model: ./pretrain_models/student.pdparams
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
+
18
+ Architecture:
19
+ model_type: det
20
+ algorithm: DB
21
+ Transform:
22
+ Backbone:
23
+ name: MobileNetV3
24
+ scale: 0.5
25
+ model_name: large
26
+ disable_se: True
27
+ Neck:
28
+ name: DBFPN
29
+ out_channels: 96
30
+ Head:
31
+ name: DBHead
32
+ k: 50
33
+
34
+ Loss:
35
+ name: DBLoss
36
+ balance_loss: true
37
+ main_loss_type: DiceLoss
38
+ alpha: 5
39
+ beta: 10
40
+ ohem_ratio: 3
41
+
42
+ Optimizer:
43
+ name: Adam
44
+ beta1: 0.9
45
+ beta2: 0.999
46
+ lr:
47
+ name: Cosine
48
+ learning_rate: 0.001
49
+ warmup_epoch: 2
50
+ regularizer:
51
+ name: 'L2'
52
+ factor: 0
53
+
54
+ PostProcess:
55
+ name: DBPostProcess
56
+ thresh: 0.3
57
+ box_thresh: 0.6
58
+ max_candidates: 1000
59
+ unclip_ratio: 1.5
60
+
61
+ Metric:
62
+ name: DetMetric
63
+ main_indicator: hmean
64
+
65
+ Train:
66
+ dataset:
67
+ name: SimpleDataSet
68
+ data_dir: ./train_data/icdar2015/text_localization/
69
+ label_file_list:
70
+ - ./train_data/icdar2015/text_localization/train_icdar2015_label.txt
71
+ ratio_list: [1.0]
72
+ transforms:
73
+ - DecodeImage: # load image
74
+ img_mode: BGR
75
+ channel_first: False
76
+ - DetLabelEncode: # Class handling label
77
+ - IaaAugment:
78
+ augmenter_args:
79
+ - { 'type': Fliplr, 'args': { 'p': 0.5 } }
80
+ - { 'type': Affine, 'args': { 'rotate': [-10, 10] } }
81
+ - { 'type': Resize, 'args': { 'size': [0.5, 3] } }
82
+ - EastRandomCropData:
83
+ size: [960, 960]
84
+ max_tries: 50
85
+ keep_ratio: true
86
+ - MakeBorderMap:
87
+ shrink_ratio: 0.4
88
+ thresh_min: 0.3
89
+ thresh_max: 0.7
90
+ - MakeShrinkMap:
91
+ shrink_ratio: 0.4
92
+ min_text_size: 8
93
+ - NormalizeImage:
94
+ scale: 1./255.
95
+ mean: [0.485, 0.456, 0.406]
96
+ std: [0.229, 0.224, 0.225]
97
+ order: 'hwc'
98
+ - ToCHWImage:
99
+ - KeepKeys:
100
+ keep_keys: ['image', 'threshold_map', 'threshold_mask', 'shrink_map', 'shrink_mask'] # the order of the dataloader list
101
+ loader:
102
+ shuffle: True
103
+ drop_last: False
104
+ batch_size_per_card: 8
105
+ num_workers: 4
106
+
107
+ Eval:
108
+ dataset:
109
+ name: SimpleDataSet
110
+ data_dir: ./train_data/icdar2015/text_localization/
111
+ label_file_list:
112
+ - ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
113
+ transforms:
114
+ - DecodeImage: # load image
115
+ img_mode: BGR
116
+ channel_first: False
117
+ - DetLabelEncode: # Class handling label
118
+ - DetResizeForTest:
119
+ # image_shape: [736, 1280]
120
+ - NormalizeImage:
121
+ scale: 1./255.
122
+ mean: [0.485, 0.456, 0.406]
123
+ std: [0.229, 0.224, 0.225]
124
+ order: 'hwc'
125
+ - ToCHWImage:
126
+ - KeepKeys:
127
+ keep_keys: ['image', 'shape', 'polys', 'ignore_tags']
128
+ loader:
129
+ shuffle: False
130
+ drop_last: False
131
+ batch_size_per_card: 1 # must be 1
132
+ num_workers: 2
configs/det/ch_PP-OCRv3/ch_PP-OCRv3_det_cml.yml ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 500
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/det/ch_PP-OCR_V3_det_cml/
7
+ eval_epoch_step: [0, 1]
8
+ cal_metric_during_train: false
9
+ pretrained_model:
10
+ checkpoints:
11
+ use_tensorboard: false
12
+ infer_img: doc/imgs/1.jpg
13
+
14
+ Export:
15
+ export_dir:
16
+ export_shape: [ 1, 3, 640, 640 ]
17
+ dynamic_axes: [ 0, 2, 3 ]
18
+
19
+ Architecture:
20
+ name: DistillationModel
21
+ algorithm: Distillation
22
+ model_type: det
23
+ Models:
24
+ Student:
25
+ pretrained:
26
+ model_type: det
27
+ algorithm: DB
28
+ Transform: null
29
+ Backbone:
30
+ name: MobileNetV3
31
+ scale: 0.5
32
+ model_name: large
33
+ disable_se: true
34
+ Neck:
35
+ name: RSEFPN
36
+ out_channels: 96
37
+ shortcut: True
38
+ Head:
39
+ name: DBHead
40
+ k: 50
41
+ Student2:
42
+ pretrained:
43
+ model_type: det
44
+ algorithm: DB
45
+ Transform: null
46
+ Backbone:
47
+ name: MobileNetV3
48
+ scale: 0.5
49
+ model_name: large
50
+ disable_se: true
51
+ Neck:
52
+ name: RSEFPN
53
+ out_channels: 96
54
+ shortcut: True
55
+ Head:
56
+ name: DBHead
57
+ k: 50
58
+ Teacher:
59
+ freeze_params: true
60
+ return_all_feats: false
61
+ model_type: det
62
+ algorithm: DB
63
+ Backbone:
64
+ name: ResNet_vd
65
+ in_channels: 3
66
+ layers: 50
67
+ Neck:
68
+ name: LKPAN
69
+ out_channels: 256
70
+ Head:
71
+ name: DBHead
72
+ kernel_list: [7,2,2]
73
+ k: 50
74
+
75
+ Loss:
76
+ name: CombinedLoss
77
+ loss_config_list:
78
+ - DistillationDilaDBLoss:
79
+ weight: 1.0
80
+ model_name_pairs:
81
+ - ["Student", "Teacher"]
82
+ - ["Student2", "Teacher"]
83
+ key: res
84
+ balance_loss: true
85
+ main_loss_type: DiceLoss
86
+ alpha: 5
87
+ beta: 10
88
+ ohem_ratio: 3
89
+ - DistillationDMLLoss:
90
+ maps_name: "thrink_maps"
91
+ weight: 1.0
92
+ model_name_pairs: ["Student", "Student2"]
93
+ key: res
94
+ - DistillationDBLoss:
95
+ weight: 1.0
96
+ model_name_list: ["Student", "Student2"]
97
+ balance_loss: true
98
+ main_loss_type: DiceLoss
99
+ alpha: 5
100
+ beta: 10
101
+ ohem_ratio: 3
102
+
103
+ Optimizer:
104
+ name: Adam
105
+ lr: 0.001
106
+ weight_decay: 5.0e-05
107
+
108
+ LRScheduler:
109
+ name: CosineAnnealingLR
110
+ warmup_epoch: 2
111
+
112
+ PostProcess:
113
+ name: DistillationDBPostProcess
114
+ model_name: ["Student"]
115
+ key: head_out
116
+ thresh: 0.3
117
+ box_thresh: 0.6
118
+ max_candidates: 1000
119
+ unclip_ratio: 1.5
120
+
121
+ Metric:
122
+ name: DistillationMetric
123
+ base_metric_name: DetMetric
124
+ main_indicator: hmean
125
+ key: "Student"
126
+
127
+ Train:
128
+ dataset:
129
+ name: SimpleDataSet
130
+ data_dir: ./train_data/icdar2015/text_localization/
131
+ label_file_list:
132
+ - ./train_data/icdar2015/text_localization/train_icdar2015_label.txt
133
+ ratio_list: [1.0]
134
+ transforms:
135
+ - DecodeImage:
136
+ img_mode: BGR
137
+ channel_first: false
138
+ - DetLabelEncode: null
139
+ - CopyPaste:
140
+ - IaaAugment:
141
+ augmenter_args:
142
+ - type: Fliplr
143
+ args:
144
+ p: 0.5
145
+ - type: Affine
146
+ args:
147
+ rotate:
148
+ - -10
149
+ - 10
150
+ - type: Resize
151
+ args:
152
+ size:
153
+ - 0.5
154
+ - 3
155
+ - EastRandomCropData:
156
+ size:
157
+ - 960
158
+ - 960
159
+ max_tries: 50
160
+ keep_ratio: true
161
+ - MakeBorderMap:
162
+ shrink_ratio: 0.4
163
+ thresh_min: 0.3
164
+ thresh_max: 0.7
165
+ - MakeShrinkMap:
166
+ shrink_ratio: 0.4
167
+ min_text_size: 8
168
+ - NormalizeImage:
169
+ scale: 1./255.
170
+ mean:
171
+ - 0.485
172
+ - 0.456
173
+ - 0.406
174
+ std:
175
+ - 0.229
176
+ - 0.224
177
+ - 0.225
178
+ order: hwc
179
+ - ToCHWImage: null
180
+ - KeepKeys:
181
+ keep_keys:
182
+ - image
183
+ - threshold_map
184
+ - threshold_mask
185
+ - shrink_map
186
+ - shrink_mask
187
+ loader:
188
+ shuffle: true
189
+ drop_last: false
190
+ batch_size_per_card: 8
191
+ num_workers: 4
192
+
193
+ Eval:
194
+ dataset:
195
+ name: SimpleDataSet
196
+ data_dir: ./train_data/icdar2015/text_localization/
197
+ label_file_list:
198
+ - ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
199
+ transforms:
200
+ - DecodeImage: # load image
201
+ img_mode: BGR
202
+ channel_first: False
203
+ - DetLabelEncode: # Class handling label
204
+ - DetResizeForTest:
205
+ - NormalizeImage:
206
+ scale: 1./255.
207
+ mean: [0.485, 0.456, 0.406]
208
+ std: [0.229, 0.224, 0.225]
209
+ order: 'hwc'
210
+ - ToCHWImage:
211
+ - KeepKeys:
212
+ keep_keys: ['image', 'shape', 'polys', 'ignore_tags']
213
+ loader:
214
+ shuffle: False
215
+ drop_last: False
216
+ batch_size_per_card: 1 # must be 1
217
+ num_workers: 2
configs/det/ch_PP-OCRv3/ch_PP-OCRv3_det_dml.yml ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 1200
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/det/ch_PP-OCR_V3_det_dml/
7
+ eval_epoch_step: [0, 1]
8
+ cal_metric_during_train: false
9
+ pretrained_model:
10
+ checkpoints:
11
+ use_tensorboard: false
12
+ infer_img: doc/imgs/1.jpg
13
+
14
+ Export:
15
+ export_dir:
16
+ export_shape: [ 1, 3, 640, 640 ]
17
+ dynamic_axes: [ 0, 2, 3 ]
18
+
19
+ Architecture:
20
+ name: DistillationModel
21
+ algorithm: Distillation
22
+ model_type: det
23
+ Models:
24
+ Student:
25
+ return_all_feats: false
26
+ model_type: det
27
+ algorithm: DB
28
+ Backbone:
29
+ name: ResNet_vd
30
+ in_channels: 3
31
+ layers: 50
32
+ Neck:
33
+ name: LKPAN
34
+ out_channels: 256
35
+ Head:
36
+ name: DBHead
37
+ kernel_list: [7,2,2]
38
+ k: 50
39
+ Student2:
40
+ return_all_feats: false
41
+ model_type: det
42
+ algorithm: DB
43
+ Backbone:
44
+ name: ResNet_vd
45
+ in_channels: 3
46
+ layers: 50
47
+ Neck:
48
+ name: LKPAN
49
+ out_channels: 256
50
+ Head:
51
+ name: DBHead
52
+ kernel_list: [7,2,2]
53
+ k: 50
54
+
55
+
56
+ Loss:
57
+ name: CombinedLoss
58
+ loss_config_list:
59
+ - DistillationDMLLoss:
60
+ maps_name: "thrink_maps"
61
+ weight: 1.0
62
+ model_name_pairs: ["Student", "Student2"]
63
+ key: res
64
+ - DistillationDBLoss:
65
+ weight: 1.0
66
+ model_name_list: ["Student", "Student2"]
67
+ name: DBLoss
68
+ balance_loss: true
69
+ main_loss_type: DiceLoss
70
+ alpha: 5
71
+ beta: 10
72
+ ohem_ratio: 3
73
+
74
+ Optimizer:
75
+ name: Adam
76
+ lr: 0.001
77
+ weight_decay: 0
78
+
79
+ LRScheduler:
80
+ name: CosineAnnealingLR
81
+ warmup_epoch: 2
82
+
83
+ PostProcess:
84
+ name: DistillationDBPostProcess
85
+ model_name: ["Student", "Student2"]
86
+ key: head_out
87
+ thresh: 0.3
88
+ box_thresh: 0.6
89
+ max_candidates: 1000
90
+ unclip_ratio: 1.5
91
+
92
+ Metric:
93
+ name: DistillationMetric
94
+ base_metric_name: DetMetric
95
+ main_indicator: hmean
96
+ key: "Student"
97
+
98
+ Train:
99
+ dataset:
100
+ name: SimpleDataSet
101
+ data_dir: ./train_data/icdar2015/text_localization/
102
+ label_file_list:
103
+ - ./train_data/icdar2015/text_localization/train_icdar2015_label.txt
104
+ ratio_list: [1.0]
105
+ transforms:
106
+ - DecodeImage: # load image
107
+ img_mode: BGR
108
+ channel_first: False
109
+ - DetLabelEncode: # Class handling label
110
+ - CopyPaste:
111
+ - IaaAugment:
112
+ augmenter_args:
113
+ - { 'type': Fliplr, 'args': { 'p': 0.5 } }
114
+ - { 'type': Affine, 'args': { 'rotate': [-10, 10] } }
115
+ - { 'type': Resize, 'args': { 'size': [0.5, 3] } }
116
+ - EastRandomCropData:
117
+ size: [960, 960]
118
+ max_tries: 50
119
+ keep_ratio: true
120
+ - MakeBorderMap:
121
+ shrink_ratio: 0.4
122
+ thresh_min: 0.3
123
+ thresh_max: 0.7
124
+ - MakeShrinkMap:
125
+ shrink_ratio: 0.4
126
+ min_text_size: 8
127
+ - NormalizeImage:
128
+ scale: 1./255.
129
+ mean: [0.485, 0.456, 0.406]
130
+ std: [0.229, 0.224, 0.225]
131
+ order: 'hwc'
132
+ - ToCHWImage:
133
+ - KeepKeys:
134
+ keep_keys: ['image', 'threshold_map', 'threshold_mask', 'shrink_map', 'shrink_mask'] # the order of the dataloader list
135
+ loader:
136
+ shuffle: True
137
+ drop_last: False
138
+ batch_size_per_card: 8
139
+ num_workers: 4
140
+
141
+ Eval:
142
+ dataset:
143
+ name: SimpleDataSet
144
+ data_dir: ./train_data/icdar2015/text_localization/
145
+ label_file_list:
146
+ - ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
147
+ transforms:
148
+ - DecodeImage: # load image
149
+ img_mode: BGR
150
+ channel_first: False
151
+ - DetLabelEncode: # Class handling label
152
+ - DetResizeForTest:
153
+ # image_shape: [736, 1280]
154
+ - NormalizeImage:
155
+ scale: 1./255.
156
+ mean: [0.485, 0.456, 0.406]
157
+ std: [0.229, 0.224, 0.225]
158
+ order: 'hwc'
159
+ - ToCHWImage:
160
+ - KeepKeys:
161
+ keep_keys: ['image', 'shape', 'polys', 'ignore_tags']
162
+ loader:
163
+ shuffle: False
164
+ drop_last: False
165
+ batch_size_per_card: 1 # must be 1
166
+ num_workers: 2
configs/det/ch_PP-OCRv3/ch_PP-OCRv3_det_student.yml ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 500
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/det/ch_PP-OCR_V3_det/
7
+ eval_epoch_step: [0, 1]
8
+ cal_metric_during_train: false
9
+ pretrained_model:
10
+ checkpoints:
11
+ use_tensorboard: false
12
+ infer_img: doc/imgs/1.jpg
13
+
14
+ Export:
15
+ export_dir:
16
+ export_shape: [ 1, 3, 640, 640 ]
17
+ dynamic_axes: [ 0, 2, 3 ]
18
+
19
+ Architecture:
20
+ model_type: det
21
+ algorithm: DB
22
+ Transform:
23
+ Backbone:
24
+ name: MobileNetV3
25
+ scale: 0.5
26
+ model_name: large
27
+ disable_se: True
28
+ Neck:
29
+ name: RSEFPN
30
+ out_channels: 96
31
+ shortcut: True
32
+ Head:
33
+ name: DBHead
34
+ k: 50
35
+
36
+ Loss:
37
+ name: DBLoss
38
+ balance_loss: true
39
+ main_loss_type: DiceLoss
40
+ alpha: 5
41
+ beta: 10
42
+ ohem_ratio: 3
43
+
44
+ Optimizer:
45
+ name: Adam
46
+ lr: 0.001
47
+ weight_decay: 5.0e-05
48
+
49
+ LRScheduler:
50
+ name: CosineAnnealingLR
51
+ warmup_epoch: 2
52
+
53
+ PostProcess:
54
+ name: DBPostProcess
55
+ thresh: 0.3
56
+ box_thresh: 0.6
57
+ max_candidates: 1000
58
+ unclip_ratio: 1.5
59
+
60
+ Metric:
61
+ name: DetMetric
62
+ main_indicator: hmean
63
+ Train:
64
+ dataset:
65
+ name: SimpleDataSet
66
+ data_dir: ./train_data/icdar2015/text_localization/
67
+ label_file_list:
68
+ - ./train_data/icdar2015/text_localization/train_icdar2015_label.txt
69
+ ratio_list: [1.0]
70
+ transforms:
71
+ - DecodeImage:
72
+ img_mode: BGR
73
+ channel_first: false
74
+ - DetLabelEncode: null
75
+ - IaaAugment:
76
+ augmenter_args:
77
+ - type: Fliplr
78
+ args:
79
+ p: 0.5
80
+ - type: Affine
81
+ args:
82
+ rotate:
83
+ - -10
84
+ - 10
85
+ - type: Resize
86
+ args:
87
+ size:
88
+ - 0.5
89
+ - 3
90
+ - EastRandomCropData:
91
+ size:
92
+ - 960
93
+ - 960
94
+ max_tries: 50
95
+ keep_ratio: true
96
+ - MakeBorderMap:
97
+ shrink_ratio: 0.4
98
+ thresh_min: 0.3
99
+ thresh_max: 0.7
100
+ - MakeShrinkMap:
101
+ shrink_ratio: 0.4
102
+ min_text_size: 8
103
+ - NormalizeImage:
104
+ scale: 1./255.
105
+ mean:
106
+ - 0.485
107
+ - 0.456
108
+ - 0.406
109
+ std:
110
+ - 0.229
111
+ - 0.224
112
+ - 0.225
113
+ order: hwc
114
+ - ToCHWImage: null
115
+ - KeepKeys:
116
+ keep_keys:
117
+ - image
118
+ - threshold_map
119
+ - threshold_mask
120
+ - shrink_map
121
+ - shrink_mask
122
+ loader:
123
+ shuffle: true
124
+ drop_last: false
125
+ batch_size_per_card: 8
126
+ num_workers: 4
127
+ Eval:
128
+ dataset:
129
+ name: SimpleDataSet
130
+ data_dir: ./train_data/icdar2015/text_localization/
131
+ label_file_list:
132
+ - ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
133
+ transforms:
134
+ - DecodeImage:
135
+ img_mode: BGR
136
+ channel_first: false
137
+ - DetLabelEncode: null
138
+ - DetResizeForTest: null
139
+ - NormalizeImage:
140
+ scale: 1./255.
141
+ mean:
142
+ - 0.485
143
+ - 0.456
144
+ - 0.406
145
+ std:
146
+ - 0.229
147
+ - 0.224
148
+ - 0.225
149
+ order: hwc
150
+ - ToCHWImage: null
151
+ - KeepKeys:
152
+ keep_keys:
153
+ - image
154
+ - shape
155
+ - polys
156
+ - ignore_tags
157
+ loader:
158
+ shuffle: false
159
+ drop_last: false
160
+ batch_size_per_card: 1
161
+ num_workers: 2
configs/det/ch_PP-OCRv4/ch_PP-OCRv4_det_cml.yml ADDED
@@ -0,0 +1,234 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: &epoch_num 500
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/det/ch_PP-OCRv4_cml
7
+ eval_epoch_step: [0, 1]
8
+ cal_metric_during_train: false
9
+ pretrained_model:
10
+ checkpoints:
11
+ use_tensorboard: false
12
+ infer_img: img
13
+
14
+ Export:
15
+ export_dir:
16
+ export_shape: [ 1, 3, 640, 640 ]
17
+ dynamic_axes: [ 0, 2, 3 ]
18
+
19
+ Architecture:
20
+ name: DistillationModel
21
+ algorithm: Distillation
22
+ model_type: det
23
+ Models:
24
+ Student:
25
+ pretrained:
26
+ model_type: det
27
+ algorithm: DB
28
+ Transform: null
29
+ Backbone:
30
+ name: PPLCNetV3
31
+ scale: 0.75
32
+ det: True
33
+ Neck:
34
+ name: RSEFPN
35
+ out_channels: 96
36
+ shortcut: True
37
+ Head:
38
+ name: DBHead
39
+ k: 50
40
+ Student2:
41
+ pretrained:
42
+ model_type: det
43
+ algorithm: DB
44
+ Transform: null
45
+ Backbone:
46
+ name: PPLCNetV3
47
+ scale: 0.75
48
+ det: True
49
+ Neck:
50
+ name: RSEFPN
51
+ out_channels: 96
52
+ shortcut: True
53
+ Head:
54
+ name: DBHead
55
+ k: 50
56
+ Teacher:
57
+ freeze_params: true
58
+ return_all_feats: false
59
+ pretrained:
60
+ model_type: det
61
+ algorithm: DB
62
+ Transform: null
63
+ Backbone:
64
+ name: PPHGNet_small
65
+ det: True
66
+ Neck:
67
+ name: LKPAN
68
+ out_channels: 256
69
+ intracl: true
70
+ Head:
71
+ name: PFHeadLocal
72
+ k: 50
73
+ mode: "large"
74
+
75
+ Loss:
76
+ name: CombinedLoss
77
+ loss_config_list:
78
+ - DistillationDilaDBLoss:
79
+ weight: 1.0
80
+ model_name_pairs:
81
+ - ["Student", "Teacher"]
82
+ - ["Student2", "Teacher"]
83
+ key: res
84
+ balance_loss: true
85
+ main_loss_type: DiceLoss
86
+ alpha: 5
87
+ beta: 10
88
+ ohem_ratio: 3
89
+ kd_loss:
90
+ name: KnowledgeDistillationKLDivLoss
91
+ loss_weight: 1.0e8
92
+ T: 10
93
+ - DistillationDMLLoss:
94
+ model_name_pairs:
95
+ - ["Student", "Student2"]
96
+ maps_name: "thrink_maps"
97
+ weight: 1.0
98
+ key: res
99
+ - DistillationDBLoss:
100
+ weight: 1.0
101
+ model_name_list: ["Student", "Student2"]
102
+ balance_loss: true
103
+ main_loss_type: DiceLoss
104
+ alpha: 5
105
+ beta: 10
106
+ ohem_ratio: 3
107
+
108
+ Optimizer:
109
+ name: Adam
110
+ lr: 0.001 #(8*8c)
111
+ weight_decay: 1.0e-6
112
+
113
+ LRScheduler:
114
+ name: CosineAnnealingLR
115
+ warmup_epoch: 2
116
+
117
+ PostProcess:
118
+ name: DistillationDBPostProcess
119
+ model_name: ["Student"]
120
+ key: head_out
121
+ thresh: 0.3
122
+ box_thresh: 0.6
123
+ max_candidates: 1000
124
+ unclip_ratio: 1.5
125
+
126
+ Metric:
127
+ name: DistillationMetric
128
+ base_metric_name: DetMetric
129
+ main_indicator: hmean
130
+ key: "Student"
131
+
132
+ Train:
133
+ dataset:
134
+ name: SimpleDataSet
135
+ data_dir: ./train_data/icdar2015/text_localization/
136
+ label_file_list:
137
+ - ./train_data/icdar2015/text_localization/train_icdar2015_label.txt
138
+ ratio_list: [1.0]
139
+ transforms:
140
+ - DecodeImage:
141
+ img_mode: BGR
142
+ channel_first: false
143
+ - DetLabelEncode: null
144
+ - CopyPaste: null
145
+ - IaaAugment:
146
+ augmenter_args:
147
+ - type: Fliplr
148
+ args:
149
+ p: 0.5
150
+ - type: Affine
151
+ args:
152
+ rotate:
153
+ - -10
154
+ - 10
155
+ - type: Resize
156
+ args:
157
+ size:
158
+ - 0.5
159
+ - 3
160
+ - EastRandomCropData:
161
+ size:
162
+ - 640
163
+ - 640
164
+ max_tries: 50
165
+ keep_ratio: true
166
+ - MakeBorderMap:
167
+ shrink_ratio: 0.4
168
+ thresh_min: 0.3
169
+ thresh_max: 0.7
170
+ total_epoch: *epoch_num
171
+ - MakeShrinkMap:
172
+ shrink_ratio: 0.4
173
+ min_text_size: 8
174
+ total_epoch: *epoch_num
175
+ - NormalizeImage:
176
+ scale: 1./255.
177
+ mean:
178
+ - 0.485
179
+ - 0.456
180
+ - 0.406
181
+ std:
182
+ - 0.229
183
+ - 0.224
184
+ - 0.225
185
+ order: hwc
186
+ - ToCHWImage: null
187
+ - KeepKeys:
188
+ keep_keys:
189
+ - image
190
+ - threshold_map
191
+ - threshold_mask
192
+ - shrink_map
193
+ - shrink_mask
194
+ loader:
195
+ shuffle: true
196
+ drop_last: false
197
+ batch_size_per_card: 8
198
+ num_workers: 8
199
+
200
+ Eval:
201
+ dataset:
202
+ name: SimpleDataSet
203
+ data_dir: ./train_data/icdar2015/text_localization/
204
+ label_file_list:
205
+ - ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
206
+ transforms:
207
+ - DecodeImage:
208
+ img_mode: BGR
209
+ channel_first: false
210
+ - DetLabelEncode: null
211
+ - DetResizeForTest:
212
+ - NormalizeImage:
213
+ scale: 1./255.
214
+ mean:
215
+ - 0.485
216
+ - 0.456
217
+ - 0.406
218
+ std:
219
+ - 0.229
220
+ - 0.224
221
+ - 0.225
222
+ order: hwc
223
+ - ToCHWImage: null
224
+ - KeepKeys:
225
+ keep_keys:
226
+ - image
227
+ - shape
228
+ - polys
229
+ - ignore_tags
230
+ loader:
231
+ shuffle: false
232
+ drop_last: false
233
+ batch_size_per_card: 1
234
+ num_workers: 2
configs/det/ch_PP-OCRv4/ch_PP-OCRv4_det_student.yml ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: &epoch_num 500
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/det/ch_PP-OCRv4/
7
+ eval_epoch_step: [0, 1]
8
+ cal_metric_during_train: false
9
+ pretrained_model:
10
+ checkpoints:
11
+ use_tensorboard: false
12
+ infer_img: img
13
+
14
+ Export:
15
+ export_dir:
16
+ export_shape: [ 1, 3, 640, 640 ]
17
+ dynamic_axes: [ 0, 2, 3 ]
18
+
19
+ Architecture:
20
+ model_type: det
21
+ algorithm: DB
22
+ Transform: null
23
+ Backbone:
24
+ name: PPLCNetV3
25
+ scale: 0.75
26
+ det: True
27
+ Neck:
28
+ name: RSEFPN
29
+ out_channels: 96
30
+ shortcut: True
31
+ Head:
32
+ name: DBHead
33
+ k: 50
34
+
35
+ Loss:
36
+ name: DBLoss
37
+ balance_loss: true
38
+ main_loss_type: DiceLoss
39
+ alpha: 5
40
+ beta: 10
41
+ ohem_ratio: 3
42
+
43
+ Optimizer:
44
+ name: Adam
45
+ lr: 0.001 #(8*8c)
46
+ weight_decay: 5.0e-05
47
+
48
+ LRScheduler:
49
+ name: CosineAnnealingLR
50
+ warmup_epoch: 2
51
+
52
+
53
+ PostProcess:
54
+ name: DBPostProcess
55
+ thresh: 0.3
56
+ box_thresh: 0.6
57
+ max_candidates: 1000
58
+ unclip_ratio: 1.5
59
+
60
+ Metric:
61
+ name: DetMetric
62
+ main_indicator: hmean
63
+
64
+ Train:
65
+ dataset:
66
+ name: SimpleDataSet
67
+ data_dir: ./train_data/icdar2015/text_localization/
68
+ label_file_list:
69
+ - ./train_data/icdar2015/text_localization/train_icdar2015_label.txt
70
+ ratio_list: [1.0]
71
+ transforms:
72
+ - DecodeImage:
73
+ img_mode: BGR
74
+ channel_first: false
75
+ - DetLabelEncode: null
76
+ - CopyPaste: null
77
+ - IaaAugment:
78
+ augmenter_args:
79
+ - type: Fliplr
80
+ args:
81
+ p: 0.5
82
+ - type: Affine
83
+ args:
84
+ rotate:
85
+ - -10
86
+ - 10
87
+ - type: Resize
88
+ args:
89
+ size:
90
+ - 0.5
91
+ - 3
92
+ - EastRandomCropData:
93
+ size:
94
+ - 640
95
+ - 640
96
+ max_tries: 50
97
+ keep_ratio: true
98
+ - MakeBorderMap:
99
+ shrink_ratio: 0.4
100
+ thresh_min: 0.3
101
+ thresh_max: 0.7
102
+ total_epoch: *epoch_num
103
+ - MakeShrinkMap:
104
+ shrink_ratio: 0.4
105
+ min_text_size: 8
106
+ total_epoch: *epoch_num
107
+ - NormalizeImage:
108
+ scale: 1./255.
109
+ mean:
110
+ - 0.485
111
+ - 0.456
112
+ - 0.406
113
+ std:
114
+ - 0.229
115
+ - 0.224
116
+ - 0.225
117
+ order: hwc
118
+ - ToCHWImage: null
119
+ - KeepKeys:
120
+ keep_keys:
121
+ - image
122
+ - threshold_map
123
+ - threshold_mask
124
+ - shrink_map
125
+ - shrink_mask
126
+ loader:
127
+ shuffle: true
128
+ drop_last: false
129
+ batch_size_per_card: 8
130
+ num_workers: 8
131
+
132
+ Eval:
133
+ dataset:
134
+ name: SimpleDataSet
135
+ data_dir: ./train_data/icdar2015/text_localization/
136
+ label_file_list:
137
+ - ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
138
+ transforms:
139
+ - DecodeImage:
140
+ img_mode: BGR
141
+ channel_first: false
142
+ - DetLabelEncode: null
143
+ - DetResizeForTest:
144
+ - NormalizeImage:
145
+ scale: 1./255.
146
+ mean:
147
+ - 0.485
148
+ - 0.456
149
+ - 0.406
150
+ std:
151
+ - 0.229
152
+ - 0.224
153
+ - 0.225
154
+ order: hwc
155
+ - ToCHWImage: null
156
+ - KeepKeys:
157
+ keep_keys:
158
+ - image
159
+ - shape
160
+ - polys
161
+ - ignore_tags
162
+ loader:
163
+ shuffle: false
164
+ drop_last: false
165
+ batch_size_per_card: 1
166
+ num_workers: 2
167
+ profiler_options: null
configs/det/ch_PP-OCRv4/ch_PP-OCRv4_det_teacher.yml ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: &epoch_num 500
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/det/h_PP-OCRv4_hgnet/
7
+ eval_epoch_step: [0, 1]
8
+ cal_metric_during_train: false
9
+ pretrained_model:
10
+ checkpoints:
11
+ use_tensorboard: false
12
+ infer_img: img
13
+
14
+ Export:
15
+ export_dir:
16
+ export_shape: [ 1, 3, 640, 640 ]
17
+ dynamic_axes: [ 0, 2, 3 ]
18
+
19
+ Architecture:
20
+ model_type: det
21
+ algorithm: DB
22
+ Transform: null
23
+ Backbone:
24
+ name: PPHGNet_small
25
+ det: True
26
+ Neck:
27
+ name: LKPAN
28
+ out_channels: 256
29
+ intracl: true
30
+ Head:
31
+ name: PFHeadLocal
32
+ k: 50
33
+ mode: "large"
34
+
35
+
36
+ Loss:
37
+ name: DBLoss
38
+ balance_loss: true
39
+ main_loss_type: DiceLoss
40
+ alpha: 5
41
+ beta: 10
42
+ ohem_ratio: 3
43
+
44
+ Optimizer:
45
+ name: Adam
46
+ lr: 0.001 #(8*8c)
47
+ weight_decay: 1.0e-6
48
+
49
+ LRScheduler:
50
+ name: CosineAnnealingLR
51
+ warmup_epoch: 2
52
+
53
+ PostProcess:
54
+ name: DBPostProcess
55
+ thresh: 0.3
56
+ box_thresh: 0.6
57
+ max_candidates: 1000
58
+ unclip_ratio: 1.5
59
+
60
+ Metric:
61
+ name: DetMetric
62
+ main_indicator: hmean
63
+
64
+ Train:
65
+ dataset:
66
+ name: SimpleDataSet
67
+ data_dir: ./train_data/icdar2015/text_localization/
68
+ label_file_list:
69
+ - ./train_data/icdar2015/text_localization/train_icdar2015_label.txt
70
+ ratio_list: [1.0]
71
+ transforms:
72
+ - DecodeImage:
73
+ img_mode: BGR
74
+ channel_first: false
75
+ - DetLabelEncode: null
76
+ - CopyPaste: null
77
+ - IaaAugment:
78
+ augmenter_args:
79
+ - type: Fliplr
80
+ args:
81
+ p: 0.5
82
+ - type: Affine
83
+ args:
84
+ rotate:
85
+ - -10
86
+ - 10
87
+ - type: Resize
88
+ args:
89
+ size:
90
+ - 0.5
91
+ - 3
92
+ - EastRandomCropData:
93
+ size:
94
+ - 640
95
+ - 640
96
+ max_tries: 50
97
+ keep_ratio: true
98
+ - MakeBorderMap:
99
+ shrink_ratio: 0.4
100
+ thresh_min: 0.3
101
+ thresh_max: 0.7
102
+ total_epoch: *epoch_num
103
+ - MakeShrinkMap:
104
+ shrink_ratio: 0.4
105
+ min_text_size: 8
106
+ total_epoch: *epoch_num
107
+ - NormalizeImage:
108
+ scale: 1./255.
109
+ mean:
110
+ - 0.485
111
+ - 0.456
112
+ - 0.406
113
+ std:
114
+ - 0.229
115
+ - 0.224
116
+ - 0.225
117
+ order: hwc
118
+ - ToCHWImage: null
119
+ - KeepKeys:
120
+ keep_keys:
121
+ - image
122
+ - threshold_map
123
+ - threshold_mask
124
+ - shrink_map
125
+ - shrink_mask
126
+ loader:
127
+ shuffle: true
128
+ drop_last: false
129
+ batch_size_per_card: 8
130
+ num_workers: 8
131
+
132
+ Eval:
133
+ dataset:
134
+ name: SimpleDataSet
135
+ data_dir: ./train_data/icdar2015/text_localization/
136
+ label_file_list:
137
+ - ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
138
+ transforms:
139
+ - DecodeImage:
140
+ img_mode: BGR
141
+ channel_first: false
142
+ - DetLabelEncode: null
143
+ - DetResizeForTest:
144
+ - NormalizeImage:
145
+ scale: 1./255.
146
+ mean:
147
+ - 0.485
148
+ - 0.456
149
+ - 0.406
150
+ std:
151
+ - 0.229
152
+ - 0.224
153
+ - 0.225
154
+ order: hwc
155
+ - ToCHWImage: null
156
+ - KeepKeys:
157
+ keep_keys:
158
+ - image
159
+ - shape
160
+ - polys
161
+ - ignore_tags
162
+ loader:
163
+ shuffle: false
164
+ drop_last: false
165
+ batch_size_per_card: 1
166
+ num_workers: 2
167
+ profiler_options: null
configs/det/ch_ppocr_v2.0/ch_det_mv3_db_v2.0.yml ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: true
3
+ epoch_num: 1200
4
+ log_smooth_window: 20
5
+ print_batch_step: 2
6
+ output_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
+
18
+ Architecture:
19
+ model_type: det
20
+ algorithm: DB
21
+ Transform:
22
+ Backbone:
23
+ name: MobileNetV3
24
+ scale: 0.5
25
+ model_name: large
26
+ disable_se: True
27
+ Neck:
28
+ name: DBFPN
29
+ out_channels: 96
30
+ Head:
31
+ name: DBHead
32
+ k: 50
33
+
34
+ Loss:
35
+ name: DBLoss
36
+ balance_loss: true
37
+ main_loss_type: DiceLoss
38
+ alpha: 5
39
+ beta: 10
40
+ ohem_ratio: 3
41
+
42
+ Optimizer:
43
+ name: Adam
44
+ beta1: 0.9
45
+ beta2: 0.999
46
+ lr:
47
+ name: Cosine
48
+ learning_rate: 0.001
49
+ warmup_epoch: 2
50
+ regularizer:
51
+ name: 'L2'
52
+ factor: 0
53
+
54
+ PostProcess:
55
+ name: DBPostProcess
56
+ thresh: 0.3
57
+ box_thresh: 0.6
58
+ max_candidates: 1000
59
+ unclip_ratio: 1.5
60
+
61
+ Metric:
62
+ name: DetMetric
63
+ main_indicator: hmean
64
+
65
+ Train:
66
+ dataset:
67
+ name: SimpleDataSet
68
+ data_dir: ./train_data/icdar2015/text_localization/
69
+ label_file_list:
70
+ - ./train_data/icdar2015/text_localization/train_icdar2015_label.txt
71
+ ratio_list: [1.0]
72
+ transforms:
73
+ - DecodeImage: # load image
74
+ img_mode: BGR
75
+ channel_first: False
76
+ - DetLabelEncode: # Class handling label
77
+ - IaaAugment:
78
+ augmenter_args:
79
+ - { 'type': Fliplr, 'args': { 'p': 0.5 } }
80
+ - { 'type': Affine, 'args': { 'rotate': [-10, 10] } }
81
+ - { 'type': Resize, 'args': { 'size': [0.5, 3] } }
82
+ - EastRandomCropData:
83
+ size: [960, 960]
84
+ max_tries: 50
85
+ keep_ratio: true
86
+ - MakeBorderMap:
87
+ shrink_ratio: 0.4
88
+ thresh_min: 0.3
89
+ thresh_max: 0.7
90
+ - MakeShrinkMap:
91
+ shrink_ratio: 0.4
92
+ min_text_size: 8
93
+ - NormalizeImage:
94
+ scale: 1./255.
95
+ mean: [0.485, 0.456, 0.406]
96
+ std: [0.229, 0.224, 0.225]
97
+ order: 'hwc'
98
+ - ToCHWImage:
99
+ - KeepKeys:
100
+ keep_keys: ['image', 'threshold_map', 'threshold_mask', 'shrink_map', 'shrink_mask'] # the order of the dataloader list
101
+ loader:
102
+ shuffle: True
103
+ drop_last: False
104
+ batch_size_per_card: 8
105
+ num_workers: 4
106
+
107
+ Eval:
108
+ dataset:
109
+ name: SimpleDataSet
110
+ data_dir: ./train_data/icdar2015/text_localization/
111
+ label_file_list:
112
+ - ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
113
+ transforms:
114
+ - DecodeImage: # load image
115
+ img_mode: BGR
116
+ channel_first: False
117
+ - DetLabelEncode: # Class handling label
118
+ - DetResizeForTest:
119
+ # image_shape: [736, 1280]
120
+ - NormalizeImage:
121
+ scale: 1./255.
122
+ mean: [0.485, 0.456, 0.406]
123
+ std: [0.229, 0.224, 0.225]
124
+ order: 'hwc'
125
+ - ToCHWImage:
126
+ - KeepKeys:
127
+ keep_keys: ['image', 'shape', 'polys', 'ignore_tags']
128
+ loader:
129
+ shuffle: False
130
+ drop_last: False
131
+ batch_size_per_card: 1 # must be 1
132
+ num_workers: 2
configs/det/ch_ppocr_v2.0/ch_det_res18_db_v2.0.yml ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: true
3
+ epoch_num: 1200
4
+ log_smooth_window: 20
5
+ print_batch_step: 2
6
+ output_dir: ./output/ch_db_res18/
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/ResNet18_vd_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
+
18
+ Architecture:
19
+ model_type: det
20
+ algorithm: DB
21
+ Transform:
22
+ Backbone:
23
+ name: ResNet_vd
24
+ layers: 18
25
+ disable_se: True
26
+ Neck:
27
+ name: DBFPN
28
+ out_channels: 256
29
+ Head:
30
+ name: DBHead
31
+ k: 50
32
+
33
+ Loss:
34
+ name: DBLoss
35
+ balance_loss: true
36
+ main_loss_type: DiceLoss
37
+ alpha: 5
38
+ beta: 10
39
+ ohem_ratio: 3
40
+
41
+ Optimizer:
42
+ name: Adam
43
+ beta1: 0.9
44
+ beta2: 0.999
45
+ lr:
46
+ name: Cosine
47
+ learning_rate: 0.001
48
+ warmup_epoch: 2
49
+ regularizer:
50
+ name: 'L2'
51
+ factor: 0
52
+
53
+ PostProcess:
54
+ name: DBPostProcess
55
+ thresh: 0.3
56
+ box_thresh: 0.6
57
+ max_candidates: 1000
58
+ unclip_ratio: 1.5
59
+
60
+ Metric:
61
+ name: DetMetric
62
+ main_indicator: hmean
63
+
64
+ Train:
65
+ dataset:
66
+ name: SimpleDataSet
67
+ data_dir: ./train_data/icdar2015/text_localization/
68
+ label_file_list:
69
+ - ./train_data/icdar2015/text_localization/train_icdar2015_label.txt
70
+ ratio_list: [1.0]
71
+ transforms:
72
+ - DecodeImage: # load image
73
+ img_mode: BGR
74
+ channel_first: False
75
+ - DetLabelEncode: # Class handling label
76
+ - IaaAugment:
77
+ augmenter_args:
78
+ - { 'type': Fliplr, 'args': { 'p': 0.5 } }
79
+ - { 'type': Affine, 'args': { 'rotate': [-10, 10] } }
80
+ - { 'type': Resize, 'args': { 'size': [0.5, 3] } }
81
+ - EastRandomCropData:
82
+ size: [960, 960]
83
+ max_tries: 50
84
+ keep_ratio: true
85
+ - MakeBorderMap:
86
+ shrink_ratio: 0.4
87
+ thresh_min: 0.3
88
+ thresh_max: 0.7
89
+ - MakeShrinkMap:
90
+ shrink_ratio: 0.4
91
+ min_text_size: 8
92
+ - NormalizeImage:
93
+ scale: 1./255.
94
+ mean: [0.485, 0.456, 0.406]
95
+ std: [0.229, 0.224, 0.225]
96
+ order: 'hwc'
97
+ - ToCHWImage:
98
+ - KeepKeys:
99
+ keep_keys: ['image', 'threshold_map', 'threshold_mask', 'shrink_map', 'shrink_mask'] # the order of the dataloader list
100
+ loader:
101
+ shuffle: True
102
+ drop_last: False
103
+ batch_size_per_card: 8
104
+ num_workers: 4
105
+
106
+ Eval:
107
+ dataset:
108
+ name: SimpleDataSet
109
+ data_dir: ./train_data/icdar2015/text_localization/
110
+ label_file_list:
111
+ - ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
112
+ transforms:
113
+ - DecodeImage: # load image
114
+ img_mode: BGR
115
+ channel_first: False
116
+ - DetLabelEncode: # Class handling label
117
+ - DetResizeForTest:
118
+ # image_shape: [736, 1280]
119
+ - NormalizeImage:
120
+ scale: 1./255.
121
+ mean: [0.485, 0.456, 0.406]
122
+ std: [0.229, 0.224, 0.225]
123
+ order: 'hwc'
124
+ - ToCHWImage:
125
+ - KeepKeys:
126
+ keep_keys: ['image', 'shape', 'polys', 'ignore_tags']
127
+ loader:
128
+ shuffle: False
129
+ drop_last: False
130
+ batch_size_per_card: 1 # must be 1
131
+ num_workers: 2
configs/det/det_mv3_db.yml ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: true
3
+ use_xpu: false
4
+ use_mlu: false
5
+ epoch_num: 1200
6
+ log_smooth_window: 20
7
+ print_batch_step: 10
8
+ output_dir: ./output/db_mv3/
9
+ save_epoch_step: 1200
10
+ # evaluation is run every 2000 iterations
11
+ eval_batch_step: [0, 2000]
12
+ cal_metric_during_train: False
13
+ pretrained_model: ./pretrain_models/MobileNetV3_large_x0_5_pretrained
14
+ checkpoints:
15
+ save_inference_dir:
16
+ use_visualdl: False
17
+ infer_img: doc/imgs_en/img_10.jpg
18
+ save_res_path: ./output/det_db/predicts_db.txt
19
+
20
+ Architecture:
21
+ model_type: det
22
+ algorithm: DB
23
+ Transform:
24
+ Backbone:
25
+ name: MobileNetV3
26
+ scale: 0.5
27
+ model_name: large
28
+ Neck:
29
+ name: DBFPN
30
+ out_channels: 256
31
+ Head:
32
+ name: DBHead
33
+ k: 50
34
+
35
+ Loss:
36
+ name: DBLoss
37
+ balance_loss: true
38
+ main_loss_type: DiceLoss
39
+ alpha: 5
40
+ beta: 10
41
+ ohem_ratio: 3
42
+
43
+ Optimizer:
44
+ name: Adam
45
+ beta1: 0.9
46
+ beta2: 0.999
47
+ lr:
48
+ learning_rate: 0.001
49
+ regularizer:
50
+ name: 'L2'
51
+ factor: 0
52
+
53
+ PostProcess:
54
+ name: DBPostProcess
55
+ thresh: 0.3
56
+ box_thresh: 0.6
57
+ max_candidates: 1000
58
+ unclip_ratio: 1.5
59
+
60
+ Metric:
61
+ name: DetMetric
62
+ main_indicator: hmean
63
+
64
+ Train:
65
+ dataset:
66
+ name: SimpleDataSet
67
+ data_dir: ./train_data/icdar2015/text_localization/
68
+ label_file_list:
69
+ - ./train_data/icdar2015/text_localization/train_icdar2015_label.txt
70
+ ratio_list: [1.0]
71
+ transforms:
72
+ - DecodeImage: # load image
73
+ img_mode: BGR
74
+ channel_first: False
75
+ - DetLabelEncode: # Class handling label
76
+ - IaaAugment:
77
+ augmenter_args:
78
+ - { 'type': Fliplr, 'args': { 'p': 0.5 } }
79
+ - { 'type': Affine, 'args': { 'rotate': [-10, 10] } }
80
+ - { 'type': Resize, 'args': { 'size': [0.5, 3] } }
81
+ - EastRandomCropData:
82
+ size: [640, 640]
83
+ max_tries: 50
84
+ keep_ratio: true
85
+ - MakeBorderMap:
86
+ shrink_ratio: 0.4
87
+ thresh_min: 0.3
88
+ thresh_max: 0.7
89
+ - MakeShrinkMap:
90
+ shrink_ratio: 0.4
91
+ min_text_size: 8
92
+ - NormalizeImage:
93
+ scale: 1./255.
94
+ mean: [0.485, 0.456, 0.406]
95
+ std: [0.229, 0.224, 0.225]
96
+ order: 'hwc'
97
+ - ToCHWImage:
98
+ - KeepKeys:
99
+ keep_keys: ['image', 'threshold_map', 'threshold_mask', 'shrink_map', 'shrink_mask'] # the order of the dataloader list
100
+ loader:
101
+ shuffle: True
102
+ drop_last: False
103
+ batch_size_per_card: 16
104
+ num_workers: 8
105
+
106
+ Eval:
107
+ dataset:
108
+ name: SimpleDataSet
109
+ data_dir: ./train_data/icdar2015/text_localization/
110
+ label_file_list:
111
+ - ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
112
+ transforms:
113
+ - DecodeImage: # load image
114
+ img_mode: BGR
115
+ channel_first: False
116
+ - DetLabelEncode: # Class handling label
117
+ - DetResizeForTest:
118
+ image_shape: [736, 1280]
119
+ - NormalizeImage:
120
+ scale: 1./255.
121
+ mean: [0.485, 0.456, 0.406]
122
+ std: [0.229, 0.224, 0.225]
123
+ order: 'hwc'
124
+ - ToCHWImage:
125
+ - KeepKeys:
126
+ keep_keys: ['image', 'shape', 'polys', 'ignore_tags']
127
+ loader:
128
+ shuffle: False
129
+ drop_last: False
130
+ batch_size_per_card: 1 # must be 1
131
+ num_workers: 8
configs/det/det_mv3_east.yml ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: true
3
+ epoch_num: 10000
4
+ log_smooth_window: 20
5
+ print_batch_step: 2
6
+ output_dir: ./output/east_mv3/
7
+ save_epoch_step: 1000
8
+ # evaluation is run every 5000 iterations after the 4000th iteration
9
+ eval_batch_step: [4000, 5000]
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:
16
+ save_res_path: ./output/det_east/predicts_east.txt
17
+
18
+ Architecture:
19
+ model_type: det
20
+ algorithm: EAST
21
+ Transform:
22
+ Backbone:
23
+ name: MobileNetV3
24
+ scale: 0.5
25
+ model_name: large
26
+ Neck:
27
+ name: EASTFPN
28
+ model_name: small
29
+ Head:
30
+ name: EASTHead
31
+ model_name: small
32
+
33
+ Loss:
34
+ name: EASTLoss
35
+
36
+ Optimizer:
37
+ name: Adam
38
+ beta1: 0.9
39
+ beta2: 0.999
40
+ lr:
41
+ # name: Cosine
42
+ learning_rate: 0.001
43
+ # warmup_epoch: 0
44
+ regularizer:
45
+ name: 'L2'
46
+ factor: 0
47
+
48
+ PostProcess:
49
+ name: EASTPostProcess
50
+ score_thresh: 0.8
51
+ cover_thresh: 0.1
52
+ nms_thresh: 0.2
53
+
54
+ Metric:
55
+ name: DetMetric
56
+ main_indicator: hmean
57
+
58
+ Train:
59
+ dataset:
60
+ name: SimpleDataSet
61
+ data_dir: ./train_data/icdar2015/text_localization/
62
+ label_file_list:
63
+ - ./train_data/icdar2015/text_localization/train_icdar2015_label.txt
64
+ ratio_list: [1.0]
65
+ transforms:
66
+ - DecodeImage: # load image
67
+ img_mode: BGR
68
+ channel_first: False
69
+ - DetLabelEncode: # Class handling label
70
+ - EASTProcessTrain:
71
+ image_shape: [512, 512]
72
+ background_ratio: 0.125
73
+ min_crop_side_ratio: 0.1
74
+ min_text_size: 10
75
+ - KeepKeys:
76
+ keep_keys: ['image', 'score_map', 'geo_map', 'training_mask'] # dataloader will return list in this order
77
+ loader:
78
+ shuffle: True
79
+ drop_last: False
80
+ batch_size_per_card: 16
81
+ num_workers: 8
82
+
83
+ Eval:
84
+ dataset:
85
+ name: SimpleDataSet
86
+ data_dir: ./train_data/icdar2015/text_localization/
87
+ label_file_list:
88
+ - ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
89
+ transforms:
90
+ - DecodeImage: # load image
91
+ img_mode: BGR
92
+ channel_first: False
93
+ - DetLabelEncode: # Class handling label
94
+ - DetResizeForTest:
95
+ limit_side_len: 2400
96
+ limit_type: max
97
+ - NormalizeImage:
98
+ scale: 1./255.
99
+ mean: [0.485, 0.456, 0.406]
100
+ std: [0.229, 0.224, 0.225]
101
+ order: 'hwc'
102
+ - ToCHWImage:
103
+ - KeepKeys:
104
+ keep_keys: ['image', 'shape', 'polys', 'ignore_tags']
105
+ loader:
106
+ shuffle: False
107
+ drop_last: False
108
+ batch_size_per_card: 1 # must be 1
109
+ num_workers: 2
configs/det/det_mv3_pse.yml ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: true
3
+ epoch_num: 600
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/det_mv3_pse/
7
+ save_epoch_step: 600
8
+ # evaluation is run every 63 iterations
9
+ eval_batch_step: [ 0,63 ]
10
+ cal_metric_during_train: False
11
+ pretrained_model: ./pretrain_models/MobileNetV3_large_x0_5_pretrained
12
+ checkpoints: #./output/det_r50_vd_pse_batch8_ColorJitter/best_accuracy
13
+ save_inference_dir:
14
+ use_visualdl: False
15
+ infer_img: doc/imgs_en/img_10.jpg
16
+ save_res_path: ./output/det_pse/predicts_pse.txt
17
+
18
+ Architecture:
19
+ model_type: det
20
+ algorithm: PSE
21
+ Transform: null
22
+ Backbone:
23
+ name: MobileNetV3
24
+ scale: 0.5
25
+ model_name: large
26
+ Neck:
27
+ name: FPN
28
+ out_channels: 96
29
+ Head:
30
+ name: PSEHead
31
+ hidden_dim: 96
32
+ out_channels: 7
33
+
34
+ Loss:
35
+ name: PSELoss
36
+ alpha: 0.7
37
+ ohem_ratio: 3
38
+ kernel_sample_mask: pred
39
+ reduction: none
40
+
41
+ Optimizer:
42
+ name: Adam
43
+ beta1: 0.9
44
+ beta2: 0.999
45
+ lr:
46
+ name: Step
47
+ learning_rate: 0.001
48
+ step_size: 200
49
+ gamma: 0.1
50
+ regularizer:
51
+ name: 'L2'
52
+ factor: 0.0005
53
+
54
+ PostProcess:
55
+ name: PSEPostProcess
56
+ thresh: 0
57
+ box_thresh: 0.85
58
+ min_area: 16
59
+ box_type: quad # 'quad' or 'poly'
60
+ scale: 1
61
+
62
+ Metric:
63
+ name: DetMetric
64
+ main_indicator: hmean
65
+
66
+ Train:
67
+ dataset:
68
+ name: SimpleDataSet
69
+ data_dir: ./train_data/icdar2015/text_localization/
70
+ label_file_list:
71
+ - ./train_data/icdar2015/text_localization/train_icdar2015_label.txt
72
+ ratio_list: [ 1.0 ]
73
+ transforms:
74
+ - DecodeImage: # load image
75
+ img_mode: BGR
76
+ channel_first: False
77
+ - DetLabelEncode: # Class handling label
78
+ - ColorJitter:
79
+ brightness: 0.12549019607843137
80
+ saturation: 0.5
81
+ - IaaAugment:
82
+ augmenter_args:
83
+ - { 'type': Resize, 'args': { 'size': [ 0.5, 3 ] } }
84
+ - { 'type': Fliplr, 'args': { 'p': 0.5 } }
85
+ - { 'type': Affine, 'args': { 'rotate': [ -10, 10 ] } }
86
+ - MakePseGt:
87
+ kernel_num: 7
88
+ min_shrink_ratio: 0.4
89
+ size: 640
90
+ - RandomCropImgMask:
91
+ size: [ 640,640 ]
92
+ main_key: gt_text
93
+ crop_keys: [ 'image', 'gt_text', 'gt_kernels', 'mask' ]
94
+ - NormalizeImage:
95
+ scale: 1./255.
96
+ mean: [ 0.485, 0.456, 0.406 ]
97
+ std: [ 0.229, 0.224, 0.225 ]
98
+ order: 'hwc'
99
+ - ToCHWImage:
100
+ - KeepKeys:
101
+ keep_keys: [ 'image', 'gt_text', 'gt_kernels', 'mask' ] # the order of the dataloader list
102
+ loader:
103
+ shuffle: True
104
+ drop_last: False
105
+ batch_size_per_card: 16
106
+ num_workers: 8
107
+
108
+ Eval:
109
+ dataset:
110
+ name: SimpleDataSet
111
+ data_dir: ./train_data/icdar2015/text_localization/
112
+ label_file_list:
113
+ - ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
114
+ ratio_list: [ 1.0 ]
115
+ transforms:
116
+ - DecodeImage: # load image
117
+ img_mode: BGR
118
+ channel_first: False
119
+ - DetLabelEncode: # Class handling label
120
+ - DetResizeForTest:
121
+ limit_side_len: 736
122
+ limit_type: min
123
+ - NormalizeImage:
124
+ scale: 1./255.
125
+ mean: [ 0.485, 0.456, 0.406 ]
126
+ std: [ 0.229, 0.224, 0.225 ]
127
+ order: 'hwc'
128
+ - ToCHWImage:
129
+ - KeepKeys:
130
+ keep_keys: [ 'image', 'shape', 'polys', 'ignore_tags' ]
131
+ loader:
132
+ shuffle: False
133
+ drop_last: False
134
+ batch_size_per_card: 1 # must be 1
135
+ num_workers: 8
configs/det/det_r18_vd_ct.yml ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: true
3
+ epoch_num: 600
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/det_ct/
7
+ save_epoch_step: 10
8
+ # evaluation is run every 2000 iterations
9
+ eval_batch_step: [0,1000]
10
+ cal_metric_during_train: False
11
+ pretrained_model: ./pretrain_models/ResNet18_vd_pretrained.pdparams
12
+ checkpoints:
13
+ save_inference_dir:
14
+ use_visualdl: False
15
+ infer_img: doc/imgs_en/img623.jpg
16
+ save_res_path: ./output/det_ct/predicts_ct.txt
17
+
18
+ Architecture:
19
+ model_type: det
20
+ algorithm: CT
21
+ Transform:
22
+ Backbone:
23
+ name: ResNet_vd
24
+ layers: 18
25
+ Neck:
26
+ name: CTFPN
27
+ Head:
28
+ name: CT_Head
29
+ in_channels: 512
30
+ hidden_dim: 128
31
+ num_classes: 3
32
+
33
+ Loss:
34
+ name: CTLoss
35
+
36
+ Optimizer:
37
+ name: Adam
38
+ lr: #PolynomialDecay
39
+ name: Linear
40
+ learning_rate: 0.001
41
+ end_lr: 0.
42
+ epochs: 600
43
+ step_each_epoch: 1254
44
+ power: 0.9
45
+
46
+ PostProcess:
47
+ name: CTPostProcess
48
+ box_type: poly
49
+
50
+ Metric:
51
+ name: CTMetric
52
+ main_indicator: f_score
53
+
54
+ Train:
55
+ dataset:
56
+ name: SimpleDataSet
57
+ data_dir: ./train_data/total_text/train
58
+ label_file_list:
59
+ - ./train_data/total_text/train/train.txt
60
+ ratio_list: [1.0]
61
+ transforms:
62
+ - DecodeImage:
63
+ img_mode: RGB
64
+ channel_first: False
65
+ - CTLabelEncode: # Class handling label
66
+ - RandomScale:
67
+ - MakeShrink:
68
+ - GroupRandomHorizontalFlip:
69
+ - GroupRandomRotate:
70
+ - GroupRandomCropPadding:
71
+ - MakeCentripetalShift:
72
+ - ColorJitter:
73
+ brightness: 0.125
74
+ saturation: 0.5
75
+ - ToCHWImage:
76
+ - NormalizeImage:
77
+ - KeepKeys:
78
+ keep_keys: ['image', 'gt_kernel', 'training_mask', 'gt_instance', 'gt_kernel_instance', 'training_mask_distance', 'gt_distance'] # the order of the dataloader list
79
+ loader:
80
+ shuffle: True
81
+ drop_last: True
82
+ batch_size_per_card: 4
83
+ num_workers: 8
84
+
85
+ Eval:
86
+ dataset:
87
+ name: SimpleDataSet
88
+ data_dir: ./train_data/total_text/test
89
+ label_file_list:
90
+ - ./train_data/total_text/test/test.txt
91
+ ratio_list: [1.0]
92
+ transforms:
93
+ - DecodeImage:
94
+ img_mode: RGB
95
+ channel_first: False
96
+ - CTLabelEncode: # Class handling label
97
+ - ScaleAlignedShort:
98
+ - NormalizeImage:
99
+ order: 'hwc'
100
+ - ToCHWImage:
101
+ - KeepKeys:
102
+ keep_keys: ['image', 'shape', 'polys', 'texts'] # the order of the dataloader list
103
+ loader:
104
+ shuffle: False
105
+ drop_last: False
106
+ batch_size_per_card: 1
107
+ num_workers: 2
configs/det/det_r50_db++_icdar15.yml ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ debug: false
3
+ use_gpu: true
4
+ epoch_num: 1000
5
+ log_smooth_window: 20
6
+ print_batch_step: 10
7
+ output_dir: ./output/det_r50_icdar15/
8
+ save_epoch_step: 200
9
+ eval_batch_step:
10
+ - 0
11
+ - 2000
12
+ cal_metric_during_train: false
13
+ pretrained_model: ./pretrain_models/ResNet50_dcn_asf_synthtext_pretrained
14
+ checkpoints: null
15
+ save_inference_dir: null
16
+ use_visualdl: false
17
+ infer_img: doc/imgs_en/img_10.jpg
18
+ save_res_path: ./checkpoints/det_db/predicts_db.txt
19
+ Architecture:
20
+ model_type: det
21
+ algorithm: DB++
22
+ Transform: null
23
+ Backbone:
24
+ name: ResNet
25
+ layers: 50
26
+ dcn_stage: [False, True, True, True]
27
+ Neck:
28
+ name: DBFPN
29
+ out_channels: 256
30
+ use_asf: True
31
+ Head:
32
+ name: DBHead
33
+ k: 50
34
+ Loss:
35
+ name: DBLoss
36
+ balance_loss: true
37
+ main_loss_type: BCELoss
38
+ alpha: 5
39
+ beta: 10
40
+ ohem_ratio: 3
41
+ Optimizer:
42
+ name: Momentum
43
+ momentum: 0.9
44
+ lr:
45
+ name: DecayLearningRate
46
+ learning_rate: 0.007
47
+ epochs: 1000
48
+ factor: 0.9
49
+ end_lr: 0
50
+ weight_decay: 0.0001
51
+ PostProcess:
52
+ name: DBPostProcess
53
+ thresh: 0.3
54
+ box_thresh: 0.6
55
+ max_candidates: 1000
56
+ unclip_ratio: 1.5
57
+ det_box_type: 'quad' # 'quad' or 'poly'
58
+ Metric:
59
+ name: DetMetric
60
+ main_indicator: hmean
61
+ Train:
62
+ dataset:
63
+ name: SimpleDataSet
64
+ data_dir: ./train_data/icdar2015/text_localization/
65
+ label_file_list:
66
+ - ./train_data/icdar2015/text_localization/train_icdar2015_label.txt
67
+ ratio_list:
68
+ - 1.0
69
+ transforms:
70
+ - DecodeImage:
71
+ img_mode: BGR
72
+ channel_first: false
73
+ - DetLabelEncode: null
74
+ - IaaAugment:
75
+ augmenter_args:
76
+ - type: Fliplr
77
+ args:
78
+ p: 0.5
79
+ - type: Affine
80
+ args:
81
+ rotate:
82
+ - -10
83
+ - 10
84
+ - type: Resize
85
+ args:
86
+ size:
87
+ - 0.5
88
+ - 3
89
+ - EastRandomCropData:
90
+ size:
91
+ - 640
92
+ - 640
93
+ max_tries: 10
94
+ keep_ratio: true
95
+ - MakeShrinkMap:
96
+ shrink_ratio: 0.4
97
+ min_text_size: 8
98
+ - MakeBorderMap:
99
+ shrink_ratio: 0.4
100
+ thresh_min: 0.3
101
+ thresh_max: 0.7
102
+ - NormalizeImage:
103
+ scale: 1./255.
104
+ mean:
105
+ - 0.48109378172549
106
+ - 0.45752457890196
107
+ - 0.40787054090196
108
+ std:
109
+ - 1.0
110
+ - 1.0
111
+ - 1.0
112
+ order: hwc
113
+ - ToCHWImage: null
114
+ - KeepKeys:
115
+ keep_keys:
116
+ - image
117
+ - threshold_map
118
+ - threshold_mask
119
+ - shrink_map
120
+ - shrink_mask
121
+ loader:
122
+ shuffle: true
123
+ drop_last: false
124
+ batch_size_per_card: 4
125
+ num_workers: 8
126
+ Eval:
127
+ dataset:
128
+ name: SimpleDataSet
129
+ data_dir: ./train_data/icdar2015/text_localization
130
+ label_file_list:
131
+ - ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
132
+ transforms:
133
+ - DecodeImage:
134
+ img_mode: BGR
135
+ channel_first: false
136
+ - DetLabelEncode: null
137
+ - DetResizeForTest:
138
+ image_shape:
139
+ - 1152
140
+ - 2048
141
+ - NormalizeImage:
142
+ scale: 1./255.
143
+ mean:
144
+ - 0.48109378172549
145
+ - 0.45752457890196
146
+ - 0.40787054090196
147
+ std:
148
+ - 1.0
149
+ - 1.0
150
+ - 1.0
151
+ order: hwc
152
+ - ToCHWImage: null
153
+ - KeepKeys:
154
+ keep_keys:
155
+ - image
156
+ - shape
157
+ - polys
158
+ - ignore_tags
159
+ loader:
160
+ shuffle: false
161
+ drop_last: false
162
+ batch_size_per_card: 1
163
+ num_workers: 2
164
+ profiler_options: null
configs/det/det_r50_db++_td_tr.yml ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ debug: false
3
+ use_gpu: true
4
+ epoch_num: 1000
5
+ log_smooth_window: 20
6
+ print_batch_step: 10
7
+ output_dir: ./output/det_r50_td_tr/
8
+ save_epoch_step: 200
9
+ eval_batch_step:
10
+ - 0
11
+ - 2000
12
+ cal_metric_during_train: false
13
+ pretrained_model: ./pretrain_models/ResNet50_dcn_asf_synthtext_pretrained
14
+ checkpoints: null
15
+ save_inference_dir: null
16
+ use_visualdl: false
17
+ infer_img: doc/imgs_en/img_10.jpg
18
+ save_res_path: ./checkpoints/det_db/predicts_db.txt
19
+ Architecture:
20
+ model_type: det
21
+ algorithm: DB++
22
+ Transform: null
23
+ Backbone:
24
+ name: ResNet
25
+ layers: 50
26
+ dcn_stage: [False, True, True, True]
27
+ Neck:
28
+ name: DBFPN
29
+ out_channels: 256
30
+ use_asf: True
31
+ Head:
32
+ name: DBHead
33
+ k: 50
34
+ Loss:
35
+ name: DBLoss
36
+ balance_loss: true
37
+ main_loss_type: BCELoss
38
+ alpha: 5
39
+ beta: 10
40
+ ohem_ratio: 3
41
+ Optimizer:
42
+ name: Momentum
43
+ momentum: 0.9
44
+ lr:
45
+ name: DecayLearningRate
46
+ learning_rate: 0.007
47
+ epochs: 1000
48
+ factor: 0.9
49
+ end_lr: 0
50
+ weight_decay: 0.0001
51
+ PostProcess:
52
+ name: DBPostProcess
53
+ thresh: 0.3
54
+ box_thresh: 0.5
55
+ max_candidates: 1000
56
+ unclip_ratio: 1.5
57
+ det_box_type: 'quad' # 'quad' or 'poly'
58
+ Metric:
59
+ name: DetMetric
60
+ main_indicator: hmean
61
+ Train:
62
+ dataset:
63
+ name: SimpleDataSet
64
+ data_dir: ./train_data/
65
+ label_file_list:
66
+ - ./train_data/TD_TR/TD500/train_gt_labels.txt
67
+ - ./train_data/TD_TR/TR400/gt_labels.txt
68
+ ratio_list:
69
+ - 1.0
70
+ - 1.0
71
+ transforms:
72
+ - DecodeImage:
73
+ img_mode: BGR
74
+ channel_first: false
75
+ - DetLabelEncode: null
76
+ - IaaAugment:
77
+ augmenter_args:
78
+ - type: Fliplr
79
+ args:
80
+ p: 0.5
81
+ - type: Affine
82
+ args:
83
+ rotate:
84
+ - -10
85
+ - 10
86
+ - type: Resize
87
+ args:
88
+ size:
89
+ - 0.5
90
+ - 3
91
+ - EastRandomCropData:
92
+ size:
93
+ - 640
94
+ - 640
95
+ max_tries: 10
96
+ keep_ratio: true
97
+ - MakeShrinkMap:
98
+ shrink_ratio: 0.4
99
+ min_text_size: 8
100
+ - MakeBorderMap:
101
+ shrink_ratio: 0.4
102
+ thresh_min: 0.3
103
+ thresh_max: 0.7
104
+ - NormalizeImage:
105
+ scale: 1./255.
106
+ mean:
107
+ - 0.48109378172549
108
+ - 0.45752457890196
109
+ - 0.40787054090196
110
+ std:
111
+ - 1.0
112
+ - 1.0
113
+ - 1.0
114
+ order: hwc
115
+ - ToCHWImage: null
116
+ - KeepKeys:
117
+ keep_keys:
118
+ - image
119
+ - threshold_map
120
+ - threshold_mask
121
+ - shrink_map
122
+ - shrink_mask
123
+ loader:
124
+ shuffle: true
125
+ drop_last: false
126
+ batch_size_per_card: 4
127
+ num_workers: 8
128
+ Eval:
129
+ dataset:
130
+ name: SimpleDataSet
131
+ data_dir: ./train_data/
132
+ label_file_list:
133
+ - ./train_data/TD_TR/TD500/test_gt_labels.txt
134
+ transforms:
135
+ - DecodeImage:
136
+ img_mode: BGR
137
+ channel_first: false
138
+ - DetLabelEncode: null
139
+ - DetResizeForTest:
140
+ image_shape:
141
+ - 736
142
+ - 736
143
+ keep_ratio: True
144
+ - NormalizeImage:
145
+ scale: 1./255.
146
+ mean:
147
+ - 0.48109378172549
148
+ - 0.45752457890196
149
+ - 0.40787054090196
150
+ std:
151
+ - 1.0
152
+ - 1.0
153
+ - 1.0
154
+ order: hwc
155
+ - ToCHWImage: null
156
+ - KeepKeys:
157
+ keep_keys:
158
+ - image
159
+ - shape
160
+ - polys
161
+ - ignore_tags
162
+ loader:
163
+ shuffle: false
164
+ drop_last: false
165
+ batch_size_per_card: 1
166
+ num_workers: 2
167
+ profiler_options: null
configs/det/det_r50_drrg_ctw.yml ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: true
3
+ epoch_num: 1200
4
+ log_smooth_window: 20
5
+ print_batch_step: 5
6
+ output_dir: ./output/det_r50_drrg_ctw/
7
+ save_epoch_step: 100
8
+ # evaluation is run every 1260 iterations
9
+ eval_batch_step: [37800, 1260]
10
+ cal_metric_during_train: False
11
+ pretrained_model: ./pretrain_models/ResNet50_vd_ssld_pretrained.pdparams
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_drrg/predicts_drrg.txt
17
+
18
+
19
+ Architecture:
20
+ model_type: det
21
+ algorithm: DRRG
22
+ Transform:
23
+ Backbone:
24
+ name: ResNet_vd
25
+ layers: 50
26
+ Neck:
27
+ name: FPN_UNet
28
+ in_channels: [256, 512, 1024, 2048]
29
+ out_channels: 32
30
+ Head:
31
+ name: DRRGHead
32
+ in_channels: 32
33
+ text_region_thr: 0.3
34
+ center_region_thr: 0.4
35
+ Loss:
36
+ name: DRRGLoss
37
+
38
+ Optimizer:
39
+ name: Momentum
40
+ momentum: 0.9
41
+ lr:
42
+ name: DecayLearningRate
43
+ learning_rate: 0.028
44
+ epochs: 1200
45
+ factor: 0.9
46
+ end_lr: 0.0000001
47
+ weight_decay: 0.0001
48
+
49
+ PostProcess:
50
+ name: DRRGPostprocess
51
+ link_thr: 0.8
52
+
53
+ Metric:
54
+ name: DetFCEMetric
55
+ main_indicator: hmean
56
+
57
+ Train:
58
+ dataset:
59
+ name: SimpleDataSet
60
+ data_dir: ./train_data/ctw1500/imgs/
61
+ label_file_list:
62
+ - ./train_data/ctw1500/imgs/training.txt
63
+ transforms:
64
+ - DecodeImage: # load image
65
+ img_mode: BGR
66
+ channel_first: False
67
+ ignore_orientation: True
68
+ - DetLabelEncode: # Class handling label
69
+ - ColorJitter:
70
+ brightness: 0.12549019607843137
71
+ saturation: 0.5
72
+ - RandomScaling:
73
+ - RandomCropFlip:
74
+ crop_ratio: 0.5
75
+ - RandomCropPolyInstances:
76
+ crop_ratio: 0.8
77
+ min_side_ratio: 0.3
78
+ - RandomRotatePolyInstances:
79
+ rotate_ratio: 0.5
80
+ max_angle: 60
81
+ pad_with_fixed_color: False
82
+ - SquareResizePad:
83
+ target_size: 800
84
+ pad_ratio: 0.6
85
+ - IaaAugment:
86
+ augmenter_args:
87
+ - { 'type': Fliplr, 'args': { 'p': 0.5 } }
88
+ - DRRGTargets:
89
+ - NormalizeImage:
90
+ scale: 1./255.
91
+ mean: [0.485, 0.456, 0.406]
92
+ std: [0.229, 0.224, 0.225]
93
+ order: 'hwc'
94
+ - ToCHWImage:
95
+ - KeepKeys:
96
+ keep_keys: ['image', 'gt_text_mask', 'gt_center_region_mask', 'gt_mask',
97
+ 'gt_top_height_map', 'gt_bot_height_map', 'gt_sin_map',
98
+ 'gt_cos_map', 'gt_comp_attribs'] # dataloader will return list in this order
99
+ loader:
100
+ shuffle: True
101
+ drop_last: False
102
+ batch_size_per_card: 4
103
+ num_workers: 8
104
+
105
+ Eval:
106
+ dataset:
107
+ name: SimpleDataSet
108
+ data_dir: ./train_data/ctw1500/imgs/
109
+ label_file_list:
110
+ - ./train_data/ctw1500/imgs/test.txt
111
+ transforms:
112
+ - DecodeImage: # load image
113
+ img_mode: BGR
114
+ channel_first: False
115
+ ignore_orientation: True
116
+ - DetLabelEncode: # Class handling label
117
+ - DetResizeForTest:
118
+ limit_type: 'min'
119
+ limit_side_len: 640
120
+ - NormalizeImage:
121
+ scale: 1./255.
122
+ mean: [0.485, 0.456, 0.406]
123
+ std: [0.229, 0.224, 0.225]
124
+ order: 'hwc'
125
+ - Pad:
126
+ - ToCHWImage:
127
+ - KeepKeys:
128
+ keep_keys: ['image', 'shape', 'polys', 'ignore_tags']
129
+ loader:
130
+ shuffle: False
131
+ drop_last: False
132
+ batch_size_per_card: 1 # must be 1
133
+ num_workers: 2
configs/det/det_r50_vd_db.yml ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: true
3
+ epoch_num: 1200
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/det_r50_vd/
7
+ save_epoch_step: 1200
8
+ # evaluation is run every 2000 iterations
9
+ eval_batch_step: [0,2000]
10
+ cal_metric_during_train: False
11
+ pretrained_model: ./pretrain_models/ResNet50_vd_ssld_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
+
18
+ Architecture:
19
+ model_type: det
20
+ algorithm: DB
21
+ Transform:
22
+ Backbone:
23
+ name: ResNet_vd
24
+ layers: 50
25
+ Neck:
26
+ name: DBFPN
27
+ out_channels: 256
28
+ Head:
29
+ name: DBHead
30
+ k: 50
31
+
32
+ Loss:
33
+ name: DBLoss
34
+ balance_loss: true
35
+ main_loss_type: DiceLoss
36
+ alpha: 5
37
+ beta: 10
38
+ ohem_ratio: 3
39
+
40
+ Optimizer:
41
+ name: Adam
42
+ beta1: 0.9
43
+ beta2: 0.999
44
+ lr:
45
+ learning_rate: 0.001
46
+ regularizer:
47
+ name: 'L2'
48
+ factor: 0
49
+
50
+ PostProcess:
51
+ name: DBPostProcess
52
+ thresh: 0.3
53
+ box_thresh: 0.7
54
+ max_candidates: 1000
55
+ unclip_ratio: 1.5
56
+
57
+ Metric:
58
+ name: DetMetric
59
+ main_indicator: hmean
60
+
61
+ Train:
62
+ dataset:
63
+ name: SimpleDataSet
64
+ data_dir: ./train_data/icdar2015/text_localization/
65
+ label_file_list:
66
+ - ./train_data/icdar2015/text_localization/train_icdar2015_label.txt
67
+ ratio_list: [1.0]
68
+ transforms:
69
+ - DecodeImage: # load image
70
+ img_mode: BGR
71
+ channel_first: False
72
+ - DetLabelEncode: # Class handling label
73
+ - IaaAugment:
74
+ augmenter_args:
75
+ - { 'type': Fliplr, 'args': { 'p': 0.5 } }
76
+ - { 'type': Affine, 'args': { 'rotate': [-10, 10] } }
77
+ - { 'type': Resize, 'args': { 'size': [0.5, 3] } }
78
+ - EastRandomCropData:
79
+ size: [640, 640]
80
+ max_tries: 50
81
+ keep_ratio: true
82
+ - MakeBorderMap:
83
+ shrink_ratio: 0.4
84
+ thresh_min: 0.3
85
+ thresh_max: 0.7
86
+ - MakeShrinkMap:
87
+ shrink_ratio: 0.4
88
+ min_text_size: 8
89
+ - NormalizeImage:
90
+ scale: 1./255.
91
+ mean: [0.485, 0.456, 0.406]
92
+ std: [0.229, 0.224, 0.225]
93
+ order: 'hwc'
94
+ - ToCHWImage:
95
+ - KeepKeys:
96
+ keep_keys: ['image', 'threshold_map', 'threshold_mask', 'shrink_map', 'shrink_mask'] # the order of the dataloader list
97
+ loader:
98
+ shuffle: True
99
+ drop_last: False
100
+ batch_size_per_card: 16
101
+ num_workers: 4
102
+
103
+ Eval:
104
+ dataset:
105
+ name: SimpleDataSet
106
+ data_dir: ./train_data/icdar2015/text_localization/
107
+ label_file_list:
108
+ - ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
109
+ transforms:
110
+ - DecodeImage: # load image
111
+ img_mode: BGR
112
+ channel_first: False
113
+ - DetLabelEncode: # Class handling label
114
+ - DetResizeForTest:
115
+ image_shape: [736, 1280]
116
+ - NormalizeImage:
117
+ scale: 1./255.
118
+ mean: [0.485, 0.456, 0.406]
119
+ std: [0.229, 0.224, 0.225]
120
+ order: 'hwc'
121
+ - ToCHWImage:
122
+ - KeepKeys:
123
+ keep_keys: ['image', 'shape', 'polys', 'ignore_tags']
124
+ loader:
125
+ shuffle: False
126
+ drop_last: False
127
+ batch_size_per_card: 1 # must be 1
128
+ num_workers: 8
configs/det/det_r50_vd_dcn_fce_ctw.yml ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: true
3
+ epoch_num: 1500
4
+ log_smooth_window: 20
5
+ print_batch_step: 20
6
+ output_dir: ./output/det_r50_dcn_fce_ctw/
7
+ save_epoch_step: 100
8
+ # evaluation is run every 835 iterations
9
+ eval_batch_step: [0, 835]
10
+ cal_metric_during_train: False
11
+ pretrained_model: ./pretrain_models/ResNet50_vd_ssld_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_fce/predicts_fce.txt
17
+
18
+
19
+ Architecture:
20
+ model_type: det
21
+ algorithm: FCE
22
+ Transform:
23
+ Backbone:
24
+ name: ResNet_vd
25
+ layers: 50
26
+ dcn_stage: [False, True, True, True]
27
+ out_indices: [1,2,3]
28
+ Neck:
29
+ name: FCEFPN
30
+ out_channels: 256
31
+ has_extra_convs: False
32
+ extra_stage: 0
33
+ Head:
34
+ name: FCEHead
35
+ fourier_degree: 5
36
+ Loss:
37
+ name: FCELoss
38
+ fourier_degree: 5
39
+ num_sample: 50
40
+
41
+ Optimizer:
42
+ name: Adam
43
+ beta1: 0.9
44
+ beta2: 0.999
45
+ lr:
46
+ learning_rate: 0.0001
47
+ regularizer:
48
+ name: 'L2'
49
+ factor: 0
50
+
51
+ PostProcess:
52
+ name: FCEPostProcess
53
+ scales: [8, 16, 32]
54
+ alpha: 1.0
55
+ beta: 1.0
56
+ fourier_degree: 5
57
+ box_type: 'poly'
58
+
59
+ Metric:
60
+ name: DetFCEMetric
61
+ main_indicator: hmean
62
+
63
+ Train:
64
+ dataset:
65
+ name: SimpleDataSet
66
+ data_dir: ./train_data/ctw1500/imgs/
67
+ label_file_list:
68
+ - ./train_data/ctw1500/imgs/training.txt
69
+ transforms:
70
+ - DecodeImage: # load image
71
+ img_mode: BGR
72
+ channel_first: False
73
+ ignore_orientation: True
74
+ - DetLabelEncode: # Class handling label
75
+ - ColorJitter:
76
+ brightness: 0.142
77
+ saturation: 0.5
78
+ contrast: 0.5
79
+ - RandomScaling:
80
+ - RandomCropFlip:
81
+ crop_ratio: 0.5
82
+ - RandomCropPolyInstances:
83
+ crop_ratio: 0.8
84
+ min_side_ratio: 0.3
85
+ - RandomRotatePolyInstances:
86
+ rotate_ratio: 0.5
87
+ max_angle: 30
88
+ pad_with_fixed_color: False
89
+ - SquareResizePad:
90
+ target_size: 800
91
+ pad_ratio: 0.6
92
+ - IaaAugment:
93
+ augmenter_args:
94
+ - { 'type': Fliplr, 'args': { 'p': 0.5 } }
95
+ - FCENetTargets:
96
+ fourier_degree: 5
97
+ - NormalizeImage:
98
+ scale: 1./255.
99
+ mean: [0.485, 0.456, 0.406]
100
+ std: [0.229, 0.224, 0.225]
101
+ order: 'hwc'
102
+ - ToCHWImage:
103
+ - KeepKeys:
104
+ keep_keys: ['image', 'p3_maps', 'p4_maps', 'p5_maps'] # dataloader will return list in this order
105
+ loader:
106
+ shuffle: True
107
+ drop_last: False
108
+ batch_size_per_card: 6
109
+ num_workers: 8
110
+
111
+ Eval:
112
+ dataset:
113
+ name: SimpleDataSet
114
+ data_dir: ./train_data/ctw1500/imgs/
115
+ label_file_list:
116
+ - ./train_data/ctw1500/imgs/test.txt
117
+ transforms:
118
+ - DecodeImage: # load image
119
+ img_mode: BGR
120
+ channel_first: False
121
+ ignore_orientation: True
122
+ - DetLabelEncode: # Class handling label
123
+ - DetResizeForTest:
124
+ limit_type: 'min'
125
+ limit_side_len: 736
126
+ - NormalizeImage:
127
+ scale: 1./255.
128
+ mean: [0.485, 0.456, 0.406]
129
+ std: [0.229, 0.224, 0.225]
130
+ order: 'hwc'
131
+ - Pad:
132
+ - ToCHWImage:
133
+ - KeepKeys:
134
+ keep_keys: ['image', 'shape', 'polys', 'ignore_tags']
135
+ loader:
136
+ shuffle: False
137
+ drop_last: False
138
+ batch_size_per_card: 1 # must be 1
139
+ num_workers: 2
configs/det/det_r50_vd_east.yml ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: true
3
+ epoch_num: 10000
4
+ log_smooth_window: 20
5
+ print_batch_step: 2
6
+ output_dir: ./output/east_r50_vd/
7
+ save_epoch_step: 1000
8
+ # evaluation is run every 5000 iterations after the 4000th iteration
9
+ eval_batch_step: [4000, 5000]
10
+ cal_metric_during_train: False
11
+ pretrained_model: ./pretrain_models/ResNet50_vd_pretrained
12
+ checkpoints:
13
+ save_inference_dir:
14
+ use_visualdl: False
15
+ infer_img:
16
+ save_res_path: ./output/det_east/predicts_east.txt
17
+
18
+ Architecture:
19
+ model_type: det
20
+ algorithm: EAST
21
+ Transform:
22
+ Backbone:
23
+ name: ResNet_vd
24
+ layers: 50
25
+ Neck:
26
+ name: EASTFPN
27
+ model_name: large
28
+ Head:
29
+ name: EASTHead
30
+ model_name: large
31
+
32
+ Loss:
33
+ name: EASTLoss
34
+
35
+ Optimizer:
36
+ name: Adam
37
+ beta1: 0.9
38
+ beta2: 0.999
39
+ lr:
40
+ # name: Cosine
41
+ learning_rate: 0.001
42
+ # warmup_epoch: 0
43
+ regularizer:
44
+ name: 'L2'
45
+ factor: 0
46
+
47
+ PostProcess:
48
+ name: EASTPostProcess
49
+ score_thresh: 0.8
50
+ cover_thresh: 0.1
51
+ nms_thresh: 0.2
52
+
53
+ Metric:
54
+ name: DetMetric
55
+ main_indicator: hmean
56
+
57
+ Train:
58
+ dataset:
59
+ name: SimpleDataSet
60
+ data_dir: ./train_data/icdar2015/text_localization/
61
+ label_file_list:
62
+ - ./train_data/icdar2015/text_localization/train_icdar2015_label.txt
63
+ ratio_list: [1.0]
64
+ transforms:
65
+ - DecodeImage: # load image
66
+ img_mode: BGR
67
+ channel_first: False
68
+ - DetLabelEncode: # Class handling label
69
+ - EASTProcessTrain:
70
+ image_shape: [512, 512]
71
+ background_ratio: 0.125
72
+ min_crop_side_ratio: 0.1
73
+ min_text_size: 10
74
+ - KeepKeys:
75
+ keep_keys: ['image', 'score_map', 'geo_map', 'training_mask'] # dataloader will return list in this order
76
+ loader:
77
+ shuffle: True
78
+ drop_last: False
79
+ batch_size_per_card: 8
80
+ num_workers: 8
81
+
82
+ Eval:
83
+ dataset:
84
+ name: SimpleDataSet
85
+ data_dir: ./train_data/icdar2015/text_localization/
86
+ label_file_list:
87
+ - ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
88
+ transforms:
89
+ - DecodeImage: # load image
90
+ img_mode: BGR
91
+ channel_first: False
92
+ - DetLabelEncode: # Class handling label
93
+ - DetResizeForTest:
94
+ limit_side_len: 2400
95
+ limit_type: max
96
+ - NormalizeImage:
97
+ scale: 1./255.
98
+ mean: [0.485, 0.456, 0.406]
99
+ std: [0.229, 0.224, 0.225]
100
+ order: 'hwc'
101
+ - ToCHWImage:
102
+ - KeepKeys:
103
+ keep_keys: ['image', 'shape', 'polys', 'ignore_tags']
104
+ loader:
105
+ shuffle: False
106
+ drop_last: False
107
+ batch_size_per_card: 1 # must be 1
108
+ num_workers: 2
configs/det/det_r50_vd_pse.yml ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: true
3
+ epoch_num: 600
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/det_r50_vd_pse/
7
+ save_epoch_step: 600
8
+ # evaluation is run every 125 iterations
9
+ eval_batch_step: [ 0,125 ]
10
+ cal_metric_during_train: False
11
+ pretrained_model: ./pretrain_models/ResNet50_vd_ssld_pretrained
12
+ checkpoints: #./output/det_r50_vd_pse_batch8_ColorJitter/best_accuracy
13
+ save_inference_dir:
14
+ use_visualdl: False
15
+ infer_img: doc/imgs_en/img_10.jpg
16
+ save_res_path: ./output/det_pse/predicts_pse.txt
17
+
18
+ Architecture:
19
+ model_type: det
20
+ algorithm: PSE
21
+ Transform:
22
+ Backbone:
23
+ name: ResNet_vd
24
+ layers: 50
25
+ Neck:
26
+ name: FPN
27
+ out_channels: 256
28
+ Head:
29
+ name: PSEHead
30
+ hidden_dim: 256
31
+ out_channels: 7
32
+
33
+ Loss:
34
+ name: PSELoss
35
+ alpha: 0.7
36
+ ohem_ratio: 3
37
+ kernel_sample_mask: pred
38
+ reduction: none
39
+
40
+ Optimizer:
41
+ name: Adam
42
+ beta1: 0.9
43
+ beta2: 0.999
44
+ lr:
45
+ name: Step
46
+ learning_rate: 0.0001
47
+ step_size: 200
48
+ gamma: 0.1
49
+ regularizer:
50
+ name: 'L2'
51
+ factor: 0.0005
52
+
53
+ PostProcess:
54
+ name: PSEPostProcess
55
+ thresh: 0
56
+ box_thresh: 0.85
57
+ min_area: 16
58
+ box_type: quad # 'quad' or 'poly'
59
+ scale: 1
60
+
61
+ Metric:
62
+ name: DetMetric
63
+ main_indicator: hmean
64
+
65
+ Train:
66
+ dataset:
67
+ name: SimpleDataSet
68
+ data_dir: ./train_data/icdar2015/text_localization/
69
+ label_file_list:
70
+ - ./train_data/icdar2015/text_localization/train_icdar2015_label.txt
71
+ ratio_list: [ 1.0 ]
72
+ transforms:
73
+ - DecodeImage: # load image
74
+ img_mode: BGR
75
+ channel_first: False
76
+ - DetLabelEncode: # Class handling label
77
+ - ColorJitter:
78
+ brightness: 0.12549019607843137
79
+ saturation: 0.5
80
+ - IaaAugment:
81
+ augmenter_args:
82
+ - { 'type': Resize, 'args': { 'size': [ 0.5, 3 ] } }
83
+ - { 'type': Fliplr, 'args': { 'p': 0.5 } }
84
+ - { 'type': Affine, 'args': { 'rotate': [ -10, 10 ] } }
85
+ - MakePseGt:
86
+ kernel_num: 7
87
+ min_shrink_ratio: 0.4
88
+ size: 640
89
+ - RandomCropImgMask:
90
+ size: [ 640,640 ]
91
+ main_key: gt_text
92
+ crop_keys: [ 'image', 'gt_text', 'gt_kernels', 'mask' ]
93
+ - NormalizeImage:
94
+ scale: 1./255.
95
+ mean: [ 0.485, 0.456, 0.406 ]
96
+ std: [ 0.229, 0.224, 0.225 ]
97
+ order: 'hwc'
98
+ - ToCHWImage:
99
+ - KeepKeys:
100
+ keep_keys: [ 'image', 'gt_text', 'gt_kernels', 'mask' ] # the order of the dataloader list
101
+ loader:
102
+ shuffle: True
103
+ drop_last: False
104
+ batch_size_per_card: 8
105
+ num_workers: 8
106
+
107
+ Eval:
108
+ dataset:
109
+ name: SimpleDataSet
110
+ data_dir: ./train_data/icdar2015/text_localization/
111
+ label_file_list:
112
+ - ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
113
+ ratio_list: [ 1.0 ]
114
+ transforms:
115
+ - DecodeImage: # load image
116
+ img_mode: BGR
117
+ channel_first: False
118
+ - DetLabelEncode: # Class handling label
119
+ - DetResizeForTest:
120
+ limit_side_len: 736
121
+ limit_type: min
122
+ - NormalizeImage:
123
+ scale: 1./255.
124
+ mean: [ 0.485, 0.456, 0.406 ]
125
+ std: [ 0.229, 0.224, 0.225 ]
126
+ order: 'hwc'
127
+ - ToCHWImage:
128
+ - KeepKeys:
129
+ keep_keys: [ 'image', 'shape', 'polys', 'ignore_tags' ]
130
+ loader:
131
+ shuffle: False
132
+ drop_last: False
133
+ batch_size_per_card: 1 # must be 1
134
+ num_workers: 8
configs/det/det_r50_vd_sast_icdar15.yml ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: true
3
+ epoch_num: 5000
4
+ log_smooth_window: 20
5
+ print_batch_step: 2
6
+ output_dir: ./output/sast_r50_vd_ic15/
7
+ save_epoch_step: 1000
8
+ # evaluation is run every 5000 iterations after the 4000th iteration
9
+ eval_batch_step: [4000, 5000]
10
+ cal_metric_during_train: False
11
+ pretrained_model: ./pretrain_models/ResNet50_vd_ssld_pretrained
12
+ checkpoints:
13
+ save_inference_dir:
14
+ use_visualdl: False
15
+ infer_img:
16
+ save_res_path: ./output/sast_r50_vd_ic15/predicts_sast.txt
17
+
18
+
19
+ Architecture:
20
+ model_type: det
21
+ algorithm: SAST
22
+ Transform:
23
+ Backbone:
24
+ name: ResNet_SAST
25
+ layers: 50
26
+ Neck:
27
+ name: SASTFPN
28
+ with_cab: True
29
+ Head:
30
+ name: SASTHead
31
+
32
+ Loss:
33
+ name: SASTLoss
34
+
35
+ Optimizer:
36
+ name: Adam
37
+ beta1: 0.9
38
+ beta2: 0.999
39
+ lr:
40
+ # name: Cosine
41
+ learning_rate: 0.001
42
+ # warmup_epoch: 0
43
+ regularizer:
44
+ name: 'L2'
45
+ factor: 0
46
+
47
+ PostProcess:
48
+ name: SASTPostProcess
49
+ score_thresh: 0.5
50
+ sample_pts_num: 2
51
+ nms_thresh: 0.2
52
+ expand_scale: 1.0
53
+ shrink_ratio_of_width: 0.3
54
+
55
+ Metric:
56
+ name: DetMetric
57
+ main_indicator: hmean
58
+
59
+ Train:
60
+ dataset:
61
+ name: SimpleDataSet
62
+ data_dir: ./train_data/
63
+ label_file_list: [./train_data/icdar2013/train_label_json.txt, ./train_data/icdar2015/train_label_json.txt, ./train_data/icdar17_mlt_latin/train_label_json.txt, ./train_data/coco_text_icdar_4pts/train_label_json.txt]
64
+ ratio_list: [0.1, 0.45, 0.3, 0.15]
65
+ transforms:
66
+ - DecodeImage: # load image
67
+ img_mode: BGR
68
+ channel_first: False
69
+ - DetLabelEncode: # Class handling label
70
+ - SASTProcessTrain:
71
+ image_shape: [512, 512]
72
+ min_crop_side_ratio: 0.3
73
+ min_crop_size: 24
74
+ min_text_size: 4
75
+ max_text_size: 512
76
+ - KeepKeys:
77
+ keep_keys: ['image', 'score_map', 'border_map', 'training_mask', 'tvo_map', 'tco_map'] # dataloader will return list in this order
78
+ loader:
79
+ shuffle: True
80
+ drop_last: False
81
+ batch_size_per_card: 4
82
+ num_workers: 4
83
+
84
+ Eval:
85
+ dataset:
86
+ name: SimpleDataSet
87
+ data_dir: ./train_data/icdar2015/text_localization/
88
+ label_file_list:
89
+ - ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
90
+ transforms:
91
+ - DecodeImage: # load image
92
+ img_mode: BGR
93
+ channel_first: False
94
+ - DetLabelEncode: # Class handling label
95
+ - DetResizeForTest:
96
+ resize_long: 1536
97
+ - NormalizeImage:
98
+ scale: 1./255.
99
+ mean: [0.485, 0.456, 0.406]
100
+ std: [0.229, 0.224, 0.225]
101
+ order: 'hwc'
102
+ - ToCHWImage:
103
+ - KeepKeys:
104
+ keep_keys: ['image', 'shape', 'polys', 'ignore_tags']
105
+ loader:
106
+ shuffle: False
107
+ drop_last: False
108
+ batch_size_per_card: 1 # must be 1
109
+ num_workers: 2
configs/det/det_r50_vd_sast_totaltext.yml ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: true
3
+ epoch_num: 5000
4
+ log_smooth_window: 20
5
+ print_batch_step: 2
6
+ output_dir: ./output/sast_r50_vd_tt/
7
+ save_epoch_step: 1000
8
+ # evaluation is run every 5000 iterations after the 4000th iteration
9
+ eval_batch_step: [4000, 5000]
10
+ cal_metric_during_train: False
11
+ pretrained_model: ./pretrain_models/ResNet50_vd_ssld_pretrained
12
+ checkpoints:
13
+ save_inference_dir:
14
+ use_visualdl: False
15
+ infer_img:
16
+ save_res_path: ./output/sast_r50_vd_tt/predicts_sast.txt
17
+
18
+ Architecture:
19
+ model_type: det
20
+ algorithm: SAST
21
+ Transform:
22
+ Backbone:
23
+ name: ResNet_SAST
24
+ layers: 50
25
+ Neck:
26
+ name: SASTFPN
27
+ with_cab: True
28
+ Head:
29
+ name: SASTHead
30
+
31
+ Loss:
32
+ name: SASTLoss
33
+
34
+ Optimizer:
35
+ name: Adam
36
+ beta1: 0.9
37
+ beta2: 0.999
38
+ lr:
39
+ # name: Cosine
40
+ learning_rate: 0.001
41
+ # warmup_epoch: 0
42
+ regularizer:
43
+ name: 'L2'
44
+ factor: 0
45
+
46
+ PostProcess:
47
+ name: SASTPostProcess
48
+ score_thresh: 0.5
49
+ sample_pts_num: 6
50
+ nms_thresh: 0.2
51
+ expand_scale: 1.2
52
+ shrink_ratio_of_width: 0.2
53
+
54
+ Metric:
55
+ name: DetMetric
56
+ main_indicator: hmean
57
+
58
+ Train:
59
+ dataset:
60
+ name: SimpleDataSet
61
+ data_dir: ./train_data/
62
+ label_file_list: [./train_data/art_latin_icdar_14pt/train_no_tt_test/train_label_json.txt, ./train_data/total_text_icdar_14pt/train_label_json.txt]
63
+ ratio_list: [0.5, 0.5]
64
+ transforms:
65
+ - DecodeImage: # load image
66
+ img_mode: BGR
67
+ channel_first: False
68
+ - DetLabelEncode: # Class handling label
69
+ - SASTProcessTrain:
70
+ image_shape: [512, 512]
71
+ min_crop_side_ratio: 0.3
72
+ min_crop_size: 24
73
+ min_text_size: 4
74
+ max_text_size: 512
75
+ - KeepKeys:
76
+ keep_keys: ['image', 'score_map', 'border_map', 'training_mask', 'tvo_map', 'tco_map'] # dataloader will return list in this order
77
+ loader:
78
+ shuffle: True
79
+ drop_last: False
80
+ batch_size_per_card: 4
81
+ num_workers: 4
82
+
83
+ Eval:
84
+ dataset:
85
+ name: SimpleDataSet
86
+ data_dir: ./train_data/
87
+ label_file_list:
88
+ - ./train_data/total_text_icdar_14pt/test_label_json.txt
89
+ transforms:
90
+ - DecodeImage: # load image
91
+ img_mode: BGR
92
+ channel_first: False
93
+ - DetLabelEncode: # Class handling label
94
+ - DetResizeForTest:
95
+ resize_long: 768
96
+ - NormalizeImage:
97
+ scale: 1./255.
98
+ mean: [0.485, 0.456, 0.406]
99
+ std: [0.229, 0.224, 0.225]
100
+ order: 'hwc'
101
+ - ToCHWImage:
102
+ - KeepKeys:
103
+ keep_keys: ['image', 'shape', 'polys', 'ignore_tags']
104
+ loader:
105
+ shuffle: False
106
+ drop_last: False
107
+ batch_size_per_card: 1 # must be 1
108
+ num_workers: 2
configs/det/det_res18_db_v2.0.yml ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: true
3
+ epoch_num: 1200
4
+ log_smooth_window: 20
5
+ print_batch_step: 2
6
+ output_dir: ./output/ch_db_res18/
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/ResNet18_vd_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
+
18
+ Architecture:
19
+ model_type: det
20
+ algorithm: DB
21
+ Transform:
22
+ Backbone:
23
+ name: ResNet_vd
24
+ layers: 18
25
+ disable_se: True
26
+ Neck:
27
+ name: DBFPN
28
+ out_channels: 256
29
+ Head:
30
+ name: DBHead
31
+ k: 50
32
+
33
+ Loss:
34
+ name: DBLoss
35
+ balance_loss: true
36
+ main_loss_type: DiceLoss
37
+ alpha: 5
38
+ beta: 10
39
+ ohem_ratio: 3
40
+
41
+ Optimizer:
42
+ name: Adam
43
+ beta1: 0.9
44
+ beta2: 0.999
45
+ lr:
46
+ name: Cosine
47
+ learning_rate: 0.001
48
+ warmup_epoch: 2
49
+ regularizer:
50
+ name: 'L2'
51
+ factor: 0
52
+
53
+ PostProcess:
54
+ name: DBPostProcess
55
+ thresh: 0.3
56
+ box_thresh: 0.6
57
+ max_candidates: 1000
58
+ unclip_ratio: 1.5
59
+
60
+ Metric:
61
+ name: DetMetric
62
+ main_indicator: hmean
63
+
64
+ Train:
65
+ dataset:
66
+ name: SimpleDataSet
67
+ data_dir: ./train_data/icdar2015/text_localization/
68
+ label_file_list:
69
+ - ./train_data/icdar2015/text_localization/train_icdar2015_label.txt
70
+ ratio_list: [1.0]
71
+ transforms:
72
+ - DecodeImage: # load image
73
+ img_mode: BGR
74
+ channel_first: False
75
+ - DetLabelEncode: # Class handling label
76
+ - IaaAugment:
77
+ augmenter_args:
78
+ - { 'type': Fliplr, 'args': { 'p': 0.5 } }
79
+ - { 'type': Affine, 'args': { 'rotate': [-10, 10] } }
80
+ - { 'type': Resize, 'args': { 'size': [0.5, 3] } }
81
+ - EastRandomCropData:
82
+ size: [960, 960]
83
+ max_tries: 50
84
+ keep_ratio: true
85
+ - MakeBorderMap:
86
+ shrink_ratio: 0.4
87
+ thresh_min: 0.3
88
+ thresh_max: 0.7
89
+ - MakeShrinkMap:
90
+ shrink_ratio: 0.4
91
+ min_text_size: 8
92
+ - NormalizeImage:
93
+ scale: 1./255.
94
+ mean: [0.485, 0.456, 0.406]
95
+ std: [0.229, 0.224, 0.225]
96
+ order: 'hwc'
97
+ - ToCHWImage:
98
+ - KeepKeys:
99
+ keep_keys: ['image', 'threshold_map', 'threshold_mask', 'shrink_map', 'shrink_mask'] # the order of the dataloader list
100
+ loader:
101
+ shuffle: True
102
+ drop_last: False
103
+ batch_size_per_card: 8
104
+ num_workers: 4
105
+
106
+ Eval:
107
+ dataset:
108
+ name: SimpleDataSet
109
+ data_dir: ./train_data/icdar2015/text_localization/
110
+ label_file_list:
111
+ - ./train_data/icdar2015/text_localization/test_icdar2015_label.txt
112
+ transforms:
113
+ - DecodeImage: # load image
114
+ img_mode: BGR
115
+ channel_first: False
116
+ - DetLabelEncode: # Class handling label
117
+ - DetResizeForTest:
118
+ # image_shape: [736, 1280]
119
+ - NormalizeImage:
120
+ scale: 1./255.
121
+ mean: [0.485, 0.456, 0.406]
122
+ std: [0.229, 0.224, 0.225]
123
+ order: 'hwc'
124
+ - ToCHWImage:
125
+ - KeepKeys:
126
+ keep_keys: ['image', 'shape', 'polys', 'ignore_tags']
127
+ loader:
128
+ shuffle: False
129
+ drop_last: False
130
+ batch_size_per_card: 1 # must be 1
131
+ num_workers: 2
configs/e2e/e2e_r50_vd_pg.yml ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: True
3
+ epoch_num: 600
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/pgnet_r50_vd_totaltext/
7
+ save_epoch_step: 10
8
+ # evaluation is run every 0 iterationss after the 1000th iteration
9
+ eval_batch_step: [ 0, 1000 ]
10
+ cal_metric_during_train: False
11
+ pretrained_model:
12
+ checkpoints:
13
+ save_inference_dir:
14
+ use_visualdl: False
15
+ infer_img:
16
+ infer_visual_type: EN # two mode: EN is for english datasets, CN is for chinese datasets
17
+ valid_set: totaltext # two mode: totaltext valid curved words, partvgg valid non-curved words
18
+ save_res_path: ./output/pgnet_r50_vd_totaltext/predicts_pgnet.txt
19
+ character_dict_path: ppocr/utils/ic15_dict.txt
20
+ character_type: EN
21
+ max_text_length: 50 # the max length in seq
22
+ max_text_nums: 30 # the max seq nums in a pic
23
+ tcl_len: 64
24
+
25
+ Architecture:
26
+ model_type: e2e
27
+ algorithm: PGNet
28
+ Transform:
29
+ Backbone:
30
+ name: ResNet
31
+ layers: 50
32
+ Neck:
33
+ name: PGFPN
34
+ Head:
35
+ name: PGHead
36
+ character_dict_path: ppocr/utils/ic15_dict.txt # the same as Global:character_dict_path
37
+
38
+ Loss:
39
+ name: PGLoss
40
+ tcl_bs: 64
41
+ max_text_length: 50 # the same as Global: max_text_length
42
+ max_text_nums: 30 # the same as Global:max_text_nums
43
+ pad_num: 36 # the length of dict for pad
44
+
45
+ Optimizer:
46
+ name: Adam
47
+ beta1: 0.9
48
+ beta2: 0.999
49
+ lr:
50
+ name: Cosine
51
+ learning_rate: 0.001
52
+ warmup_epoch: 50
53
+ regularizer:
54
+ name: 'L2'
55
+ factor: 0.0001
56
+
57
+ PostProcess:
58
+ name: PGPostProcess
59
+ score_thresh: 0.5
60
+ mode: fast # fast or slow two ways
61
+ point_gather_mode: align # same as PGProcessTrain: point_gather_mode
62
+
63
+ Metric:
64
+ name: E2EMetric
65
+ mode: A # two ways for eval, A: label from txt, B: label from gt_mat
66
+ gt_mat_dir: ./train_data/total_text/gt # the dir of gt_mat
67
+ character_dict_path: ppocr/utils/ic15_dict.txt
68
+ main_indicator: f_score_e2e
69
+
70
+ Train:
71
+ dataset:
72
+ name: PGDataSet
73
+ data_dir: ./train_data/total_text/train
74
+ label_file_list: [./train_data/total_text/train/train.txt]
75
+ ratio_list: [1.0]
76
+ transforms:
77
+ - DecodeImage: # load image
78
+ img_mode: BGR
79
+ channel_first: False
80
+ - E2ELabelEncodeTrain:
81
+ - PGProcessTrain:
82
+ batch_size: 14 # same as loader: batch_size_per_card
83
+ use_resize: True
84
+ use_random_crop: False
85
+ min_crop_size: 24
86
+ min_text_size: 4
87
+ max_text_size: 512
88
+ point_gather_mode: align # two mode: align and none, align mode is better than none mode
89
+ - KeepKeys:
90
+ keep_keys: [ 'images', 'tcl_maps', 'tcl_label_maps', 'border_maps','direction_maps', 'training_masks', 'label_list', 'pos_list', 'pos_mask' ] # dataloader will return list in this order
91
+ loader:
92
+ shuffle: True
93
+ drop_last: True
94
+ batch_size_per_card: 14
95
+ num_workers: 16
96
+
97
+ Eval:
98
+ dataset:
99
+ name: PGDataSet
100
+ data_dir: ./train_data/total_text/test
101
+ label_file_list: [./train_data/total_text/test/test.txt]
102
+ transforms:
103
+ - DecodeImage: # load image
104
+ img_mode: BGR
105
+ channel_first: False
106
+ - E2ELabelEncodeTest:
107
+ - E2EResizeForTest:
108
+ max_side_len: 768
109
+ - NormalizeImage:
110
+ scale: 1./255.
111
+ mean: [ 0.485, 0.456, 0.406 ]
112
+ std: [ 0.229, 0.224, 0.225 ]
113
+ order: 'hwc'
114
+ - ToCHWImage:
115
+ - KeepKeys:
116
+ keep_keys: [ 'image', 'shape', 'polys', 'texts', 'ignore_tags', 'img_id']
117
+ loader:
118
+ shuffle: False
119
+ drop_last: False
120
+ batch_size_per_card: 1 # must be 1
121
+ num_workers: 2
configs/kie/layoutlm_series/re_layoutlmv2_xfund_zh.yml ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: True
3
+ epoch_num: &epoch_num 200
4
+ log_smooth_window: 10
5
+ print_batch_step: 10
6
+ output_dir: ./output/re_layoutlmv2_xfund_zh
7
+ save_epoch_step: 2000
8
+ # evaluation is run every 10 iterations after the 0th iteration
9
+ eval_batch_step: [ 0, 19 ]
10
+ cal_metric_during_train: False
11
+ save_inference_dir:
12
+ use_visualdl: False
13
+ seed: 2022
14
+ infer_img: ppstructure/docs/kie/input/zh_val_21.jpg
15
+ save_res_path: ./output/re_layoutlmv2_xfund_zh/res/
16
+
17
+ Architecture:
18
+ model_type: kie
19
+ algorithm: &algorithm "LayoutLMv2"
20
+ Transform:
21
+ Backbone:
22
+ name: LayoutLMv2ForRe
23
+ pretrained: True
24
+ checkpoints:
25
+
26
+ Loss:
27
+ name: LossFromOutput
28
+ key: loss
29
+ reduction: mean
30
+
31
+ Optimizer:
32
+ name: AdamW
33
+ beta1: 0.9
34
+ beta2: 0.999
35
+ clip_norm: 10
36
+ lr:
37
+ learning_rate: 0.00005
38
+ warmup_epoch: 10
39
+ regularizer:
40
+ name: L2
41
+ factor: 0.00000
42
+
43
+ PostProcess:
44
+ name: VQAReTokenLayoutLMPostProcess
45
+
46
+ Metric:
47
+ name: VQAReTokenMetric
48
+ main_indicator: hmean
49
+
50
+ Train:
51
+ dataset:
52
+ name: SimpleDataSet
53
+ data_dir: train_data/XFUND/zh_train/image
54
+ label_file_list:
55
+ - train_data/XFUND/zh_train/train.json
56
+ ratio_list: [ 1.0 ]
57
+ transforms:
58
+ - DecodeImage: # load image
59
+ img_mode: RGB
60
+ channel_first: False
61
+ - VQATokenLabelEncode: # Class handling label
62
+ contains_re: True
63
+ algorithm: *algorithm
64
+ class_path: &class_path train_data/XFUND/class_list_xfun.txt
65
+ - VQATokenPad:
66
+ max_seq_len: &max_seq_len 512
67
+ return_attention_mask: True
68
+ - VQAReTokenRelation:
69
+ - VQAReTokenChunk:
70
+ max_seq_len: *max_seq_len
71
+ - Resize:
72
+ size: [224,224]
73
+ - NormalizeImage:
74
+ scale: 1./255.
75
+ mean: [0.485, 0.456, 0.406]
76
+ std: [0.229, 0.224, 0.225]
77
+ order: 'hwc'
78
+ - ToCHWImage:
79
+ - KeepKeys:
80
+ keep_keys: [ 'input_ids', 'bbox', 'attention_mask', 'token_type_ids','image', 'entities', 'relations'] # dataloader will return list in this order
81
+ loader:
82
+ shuffle: True
83
+ drop_last: False
84
+ batch_size_per_card: 8
85
+ num_workers: 8
86
+ collate_fn: ListCollator
87
+
88
+ Eval:
89
+ dataset:
90
+ name: SimpleDataSet
91
+ data_dir: train_data/XFUND/zh_val/image
92
+ label_file_list:
93
+ - train_data/XFUND/zh_val/val.json
94
+ transforms:
95
+ - DecodeImage: # load image
96
+ img_mode: RGB
97
+ channel_first: False
98
+ - VQATokenLabelEncode: # Class handling label
99
+ contains_re: True
100
+ algorithm: *algorithm
101
+ class_path: *class_path
102
+ - VQATokenPad:
103
+ max_seq_len: *max_seq_len
104
+ return_attention_mask: True
105
+ - VQAReTokenRelation:
106
+ - VQAReTokenChunk:
107
+ max_seq_len: *max_seq_len
108
+ - Resize:
109
+ size: [224,224]
110
+ - NormalizeImage:
111
+ scale: 1./255.
112
+ mean: [0.485, 0.456, 0.406]
113
+ std: [0.229, 0.224, 0.225]
114
+ order: 'hwc'
115
+ - ToCHWImage:
116
+ - KeepKeys:
117
+ keep_keys: [ 'input_ids', 'bbox', 'attention_mask', 'token_type_ids', 'image','entities', 'relations'] # dataloader will return list in this order
118
+ loader:
119
+ shuffle: False
120
+ drop_last: False
121
+ batch_size_per_card: 8
122
+ num_workers: 8
123
+ collate_fn: ListCollator
configs/kie/layoutlm_series/re_layoutxlm_xfund_zh.yml ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: True
3
+ epoch_num: &epoch_num 130
4
+ log_smooth_window: 10
5
+ print_batch_step: 10
6
+ output_dir: ./output/re_layoutxlm_xfund_zh
7
+ save_epoch_step: 2000
8
+ # evaluation is run every 10 iterations after the 0th iteration
9
+ eval_batch_step: [ 0, 19 ]
10
+ cal_metric_during_train: False
11
+ save_inference_dir:
12
+ use_visualdl: False
13
+ seed: 2022
14
+ infer_img: ppstructure/docs/kie/input/zh_val_21.jpg
15
+ save_res_path: ./output/re_layoutxlm_xfund_zh/res/
16
+
17
+ Architecture:
18
+ model_type: kie
19
+ algorithm: &algorithm "LayoutXLM"
20
+ Transform:
21
+ Backbone:
22
+ name: LayoutXLMForRe
23
+ pretrained: True
24
+ checkpoints:
25
+
26
+ Loss:
27
+ name: LossFromOutput
28
+ key: loss
29
+ reduction: mean
30
+
31
+ Optimizer:
32
+ name: AdamW
33
+ beta1: 0.9
34
+ beta2: 0.999
35
+ clip_norm: 10
36
+ lr:
37
+ learning_rate: 0.00005
38
+ warmup_epoch: 10
39
+ regularizer:
40
+ name: L2
41
+ factor: 0.00000
42
+
43
+ PostProcess:
44
+ name: VQAReTokenLayoutLMPostProcess
45
+
46
+ Metric:
47
+ name: VQAReTokenMetric
48
+ main_indicator: hmean
49
+
50
+ Train:
51
+ dataset:
52
+ name: SimpleDataSet
53
+ data_dir: train_data/XFUND/zh_train/image
54
+ label_file_list:
55
+ - train_data/XFUND/zh_train/train.json
56
+ ratio_list: [ 1.0 ]
57
+ transforms:
58
+ - DecodeImage: # load image
59
+ img_mode: RGB
60
+ channel_first: False
61
+ - VQATokenLabelEncode: # Class handling label
62
+ contains_re: True
63
+ algorithm: *algorithm
64
+ class_path: &class_path train_data/XFUND/class_list_xfun.txt
65
+ - VQATokenPad:
66
+ max_seq_len: &max_seq_len 512
67
+ return_attention_mask: True
68
+ - VQAReTokenRelation:
69
+ - VQAReTokenChunk:
70
+ max_seq_len: *max_seq_len
71
+ - TensorizeEntitiesRelations:
72
+ - Resize:
73
+ size: [224,224]
74
+ - NormalizeImage:
75
+ scale: 1
76
+ mean: [ 123.675, 116.28, 103.53 ]
77
+ std: [ 58.395, 57.12, 57.375 ]
78
+ order: 'hwc'
79
+ - ToCHWImage:
80
+ - KeepKeys:
81
+ keep_keys: [ 'input_ids', 'bbox','attention_mask', 'token_type_ids', 'image', 'entities', 'relations'] # dataloader will return list in this order
82
+ loader:
83
+ shuffle: True
84
+ drop_last: False
85
+ batch_size_per_card: 2
86
+ num_workers: 8
87
+
88
+ Eval:
89
+ dataset:
90
+ name: SimpleDataSet
91
+ data_dir: train_data/XFUND/zh_val/image
92
+ label_file_list:
93
+ - train_data/XFUND/zh_val/val.json
94
+ transforms:
95
+ - DecodeImage: # load image
96
+ img_mode: RGB
97
+ channel_first: False
98
+ - VQATokenLabelEncode: # Class handling label
99
+ contains_re: True
100
+ algorithm: *algorithm
101
+ class_path: *class_path
102
+ - VQATokenPad:
103
+ max_seq_len: *max_seq_len
104
+ return_attention_mask: True
105
+ - VQAReTokenRelation:
106
+ - VQAReTokenChunk:
107
+ max_seq_len: *max_seq_len
108
+ - TensorizeEntitiesRelations:
109
+ - Resize:
110
+ size: [224,224]
111
+ - NormalizeImage:
112
+ scale: 1
113
+ mean: [ 123.675, 116.28, 103.53 ]
114
+ std: [ 58.395, 57.12, 57.375 ]
115
+ order: 'hwc'
116
+ - ToCHWImage:
117
+ - KeepKeys:
118
+ keep_keys: [ 'input_ids', 'bbox', 'attention_mask', 'token_type_ids', 'image', 'entities', 'relations'] # dataloader will return list in this order
119
+ loader:
120
+ shuffle: False
121
+ drop_last: False
122
+ batch_size_per_card: 8
123
+ num_workers: 8
configs/kie/layoutlm_series/ser_layoutlm_xfund_zh.yml ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: True
3
+ epoch_num: &epoch_num 200
4
+ log_smooth_window: 10
5
+ print_batch_step: 10
6
+ output_dir: ./output/ser_layoutlm_xfund_zh
7
+ save_epoch_step: 2000
8
+ # evaluation is run every 10 iterations after the 0th iteration
9
+ eval_batch_step: [ 0, 19 ]
10
+ cal_metric_during_train: False
11
+ save_inference_dir:
12
+ use_visualdl: False
13
+ seed: 2022
14
+ infer_img: ppstructure/docs/kie/input/zh_val_42.jpg
15
+ save_res_path: ./output/re_layoutlm_xfund_zh/res
16
+
17
+ Architecture:
18
+ model_type: kie
19
+ algorithm: &algorithm "LayoutLM"
20
+ Transform:
21
+ Backbone:
22
+ name: LayoutLMForSer
23
+ pretrained: True
24
+ checkpoints:
25
+ num_classes: &num_classes 7
26
+
27
+ Loss:
28
+ name: VQASerTokenLayoutLMLoss
29
+ num_classes: *num_classes
30
+
31
+ Optimizer:
32
+ name: AdamW
33
+ beta1: 0.9
34
+ beta2: 0.999
35
+ lr:
36
+ name: Linear
37
+ learning_rate: 0.00005
38
+ epochs: *epoch_num
39
+ warmup_epoch: 2
40
+ regularizer:
41
+ name: L2
42
+ factor: 0.00000
43
+
44
+ PostProcess:
45
+ name: VQASerTokenLayoutLMPostProcess
46
+ class_path: &class_path train_data/XFUND/class_list_xfun.txt
47
+
48
+ Metric:
49
+ name: VQASerTokenMetric
50
+ main_indicator: hmean
51
+
52
+ Train:
53
+ dataset:
54
+ name: SimpleDataSet
55
+ data_dir: train_data/XFUND/zh_train/image
56
+ label_file_list:
57
+ - train_data/XFUND/zh_train/train.json
58
+ ratio_list: [ 1.0 ]
59
+ transforms:
60
+ - DecodeImage: # load image
61
+ img_mode: RGB
62
+ channel_first: False
63
+ - VQATokenLabelEncode: # Class handling label
64
+ contains_re: False
65
+ algorithm: *algorithm
66
+ class_path: *class_path
67
+ - VQATokenPad:
68
+ max_seq_len: &max_seq_len 512
69
+ return_attention_mask: True
70
+ - VQASerTokenChunk:
71
+ max_seq_len: *max_seq_len
72
+ - Resize:
73
+ size: [224,224]
74
+ - NormalizeImage:
75
+ scale: 1
76
+ mean: [ 123.675, 116.28, 103.53 ]
77
+ std: [ 58.395, 57.12, 57.375 ]
78
+ order: 'hwc'
79
+ - ToCHWImage:
80
+ - KeepKeys:
81
+ keep_keys: [ 'input_ids', 'bbox', 'attention_mask', 'token_type_ids', 'image', 'labels'] # dataloader will return list in this order
82
+ loader:
83
+ shuffle: True
84
+ drop_last: False
85
+ batch_size_per_card: 8
86
+ num_workers: 16
87
+
88
+ Eval:
89
+ dataset:
90
+ name: SimpleDataSet
91
+ data_dir: train_data/XFUND/zh_val/image
92
+ label_file_list:
93
+ - train_data/XFUND/zh_val/val.json
94
+ transforms:
95
+ - DecodeImage: # load image
96
+ img_mode: RGB
97
+ channel_first: False
98
+ - VQATokenLabelEncode: # Class handling label
99
+ contains_re: False
100
+ algorithm: *algorithm
101
+ class_path: *class_path
102
+ - VQATokenPad:
103
+ max_seq_len: *max_seq_len
104
+ return_attention_mask: True
105
+ - VQASerTokenChunk:
106
+ max_seq_len: *max_seq_len
107
+ - Resize:
108
+ size: [224,224]
109
+ - NormalizeImage:
110
+ scale: 1
111
+ mean: [ 123.675, 116.28, 103.53 ]
112
+ std: [ 58.395, 57.12, 57.375 ]
113
+ order: 'hwc'
114
+ - ToCHWImage:
115
+ - KeepKeys:
116
+ keep_keys: [ 'input_ids', 'bbox', 'attention_mask', 'token_type_ids', 'image', 'labels'] # dataloader will return list in this order
117
+ loader:
118
+ shuffle: False
119
+ drop_last: False
120
+ batch_size_per_card: 8
121
+ num_workers: 4
configs/kie/layoutlm_series/ser_layoutlmv2_xfund_zh.yml ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: True
3
+ epoch_num: &epoch_num 200
4
+ log_smooth_window: 10
5
+ print_batch_step: 10
6
+ output_dir: ./output/ser_layoutlmv2_xfund_zh/
7
+ save_epoch_step: 2000
8
+ # evaluation is run every 10 iterations after the 0th iteration
9
+ eval_batch_step: [ 0, 19 ]
10
+ cal_metric_during_train: False
11
+ save_inference_dir:
12
+ use_visualdl: False
13
+ seed: 2022
14
+ infer_img: ppstructure/docs/kie/input/zh_val_42.jpg
15
+ save_res_path: ./output/ser_layoutlmv2_xfund_zh/res/
16
+
17
+ Architecture:
18
+ model_type: kie
19
+ algorithm: &algorithm "LayoutLMv2"
20
+ Transform:
21
+ Backbone:
22
+ name: LayoutLMv2ForSer
23
+ pretrained: True
24
+ checkpoints:
25
+ num_classes: &num_classes 7
26
+
27
+ Loss:
28
+ name: VQASerTokenLayoutLMLoss
29
+ num_classes: *num_classes
30
+ key: "backbone_out"
31
+
32
+ Optimizer:
33
+ name: AdamW
34
+ beta1: 0.9
35
+ beta2: 0.999
36
+ lr:
37
+ name: Linear
38
+ learning_rate: 0.00005
39
+ epochs: *epoch_num
40
+ warmup_epoch: 2
41
+ regularizer:
42
+
43
+ name: L2
44
+ factor: 0.00000
45
+
46
+ PostProcess:
47
+ name: VQASerTokenLayoutLMPostProcess
48
+ class_path: &class_path train_data/XFUND/class_list_xfun.txt
49
+
50
+ Metric:
51
+ name: VQASerTokenMetric
52
+ main_indicator: hmean
53
+
54
+ Train:
55
+ dataset:
56
+ name: SimpleDataSet
57
+ data_dir: train_data/XFUND/zh_train/image
58
+ label_file_list:
59
+ - train_data/XFUND/zh_train/train.json
60
+ transforms:
61
+ - DecodeImage: # load image
62
+ img_mode: RGB
63
+ channel_first: False
64
+ - VQATokenLabelEncode: # Class handling label
65
+ contains_re: False
66
+ algorithm: *algorithm
67
+ class_path: *class_path
68
+ - VQATokenPad:
69
+ max_seq_len: &max_seq_len 512
70
+ return_attention_mask: True
71
+ - VQASerTokenChunk:
72
+ max_seq_len: *max_seq_len
73
+ - Resize:
74
+ size: [224,224]
75
+ - NormalizeImage:
76
+ scale: 1
77
+ mean: [ 123.675, 116.28, 103.53 ]
78
+ std: [ 58.395, 57.12, 57.375 ]
79
+ order: 'hwc'
80
+ - ToCHWImage:
81
+ - KeepKeys:
82
+ keep_keys: [ 'input_ids', 'bbox', 'attention_mask', 'token_type_ids', 'image', 'labels'] # dataloader will return list in this order
83
+ loader:
84
+ shuffle: True
85
+ drop_last: False
86
+ batch_size_per_card: 8
87
+ num_workers: 4
88
+
89
+ Eval:
90
+ dataset:
91
+ name: SimpleDataSet
92
+ data_dir: train_data/XFUND/zh_val/image
93
+ label_file_list:
94
+ - train_data/XFUND/zh_val/val.json
95
+ transforms:
96
+ - DecodeImage: # load image
97
+ img_mode: RGB
98
+ channel_first: False
99
+ - VQATokenLabelEncode: # Class handling label
100
+ contains_re: False
101
+ algorithm: *algorithm
102
+ class_path: *class_path
103
+ - VQATokenPad:
104
+ max_seq_len: *max_seq_len
105
+ return_attention_mask: True
106
+ - VQASerTokenChunk:
107
+ max_seq_len: *max_seq_len
108
+ - Resize:
109
+ size: [224,224]
110
+ - NormalizeImage:
111
+ scale: 1
112
+ mean: [ 123.675, 116.28, 103.53 ]
113
+ std: [ 58.395, 57.12, 57.375 ]
114
+ order: 'hwc'
115
+ - ToCHWImage:
116
+ - KeepKeys:
117
+ keep_keys: [ 'input_ids', 'bbox', 'attention_mask', 'token_type_ids', 'image', 'labels'] # dataloader will return list in this order
118
+ loader:
119
+ shuffle: False
120
+ drop_last: False
121
+ batch_size_per_card: 8
122
+ num_workers: 4
configs/kie/layoutlm_series/ser_layoutxlm_xfund_zh.yml ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: True
3
+ epoch_num: &epoch_num 200
4
+ log_smooth_window: 10
5
+ print_batch_step: 10
6
+ output_dir: ./output/ser_layoutxlm_xfund_zh
7
+ save_epoch_step: 2000
8
+ # evaluation is run every 10 iterations after the 0th iteration
9
+ eval_batch_step: [ 0, 19 ]
10
+ cal_metric_during_train: False
11
+ save_inference_dir:
12
+ use_visualdl: False
13
+ seed: 2022
14
+ infer_img: ppstructure/docs/kie/input/zh_val_42.jpg
15
+ save_res_path: ./output/ser_layoutxlm_xfund_zh/res
16
+
17
+ Architecture:
18
+ model_type: kie
19
+ algorithm: &algorithm "LayoutXLM"
20
+ Transform:
21
+ Backbone:
22
+ name: LayoutXLMForSer
23
+ pretrained: True
24
+ checkpoints:
25
+ num_classes: &num_classes 7
26
+
27
+ Loss:
28
+ name: VQASerTokenLayoutLMLoss
29
+ num_classes: *num_classes
30
+ key: "backbone_out"
31
+
32
+ Optimizer:
33
+ name: AdamW
34
+ beta1: 0.9
35
+ beta2: 0.999
36
+ lr:
37
+ name: Linear
38
+ learning_rate: 0.00005
39
+ epochs: *epoch_num
40
+ warmup_epoch: 2
41
+ regularizer:
42
+ name: L2
43
+ factor: 0.00000
44
+
45
+ PostProcess:
46
+ name: VQASerTokenLayoutLMPostProcess
47
+ class_path: &class_path train_data/XFUND/class_list_xfun.txt
48
+
49
+ Metric:
50
+ name: VQASerTokenMetric
51
+ main_indicator: hmean
52
+
53
+ Train:
54
+ dataset:
55
+ name: SimpleDataSet
56
+ data_dir: train_data/XFUND/zh_train/image
57
+ label_file_list:
58
+ - train_data/XFUND/zh_train/train.json
59
+ ratio_list: [ 1.0 ]
60
+ transforms:
61
+ - DecodeImage: # load image
62
+ img_mode: RGB
63
+ channel_first: False
64
+ - VQATokenLabelEncode: # Class handling label
65
+ contains_re: False
66
+ algorithm: *algorithm
67
+ class_path: *class_path
68
+ - VQATokenPad:
69
+ max_seq_len: &max_seq_len 512
70
+ return_attention_mask: True
71
+ - VQASerTokenChunk:
72
+ max_seq_len: *max_seq_len
73
+ - Resize:
74
+ size: [224,224]
75
+ - NormalizeImage:
76
+ scale: 1
77
+ mean: [ 123.675, 116.28, 103.53 ]
78
+ std: [ 58.395, 57.12, 57.375 ]
79
+ order: 'hwc'
80
+ - ToCHWImage:
81
+ - KeepKeys:
82
+ keep_keys: [ 'input_ids', 'bbox', 'attention_mask', 'token_type_ids', 'image', 'labels'] # dataloader will return list in this order
83
+ loader:
84
+ shuffle: True
85
+ drop_last: False
86
+ batch_size_per_card: 8
87
+ num_workers: 4
88
+
89
+ Eval:
90
+ dataset:
91
+ name: SimpleDataSet
92
+ data_dir: train_data/XFUND/zh_val/image
93
+ label_file_list:
94
+ - train_data/XFUND/zh_val/val.json
95
+ transforms:
96
+ - DecodeImage: # load image
97
+ img_mode: RGB
98
+ channel_first: False
99
+ - VQATokenLabelEncode: # Class handling label
100
+ contains_re: False
101
+ algorithm: *algorithm
102
+ class_path: *class_path
103
+ - VQATokenPad:
104
+ max_seq_len: *max_seq_len
105
+ return_attention_mask: True
106
+ - VQASerTokenChunk:
107
+ max_seq_len: *max_seq_len
108
+ - Resize:
109
+ size: [224,224]
110
+ - NormalizeImage:
111
+ scale: 1
112
+ mean: [ 123.675, 116.28, 103.53 ]
113
+ std: [ 58.395, 57.12, 57.375 ]
114
+ order: 'hwc'
115
+ - ToCHWImage:
116
+ - KeepKeys:
117
+ keep_keys: [ 'input_ids', 'bbox', 'attention_mask', 'token_type_ids', 'image', 'labels'] # dataloader will return list in this order
118
+ loader:
119
+ shuffle: False
120
+ drop_last: False
121
+ batch_size_per_card: 8
122
+ num_workers: 4
configs/kie/sdmgr/kie_unet_sdmgr.yml ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: True
3
+ epoch_num: 60
4
+ log_smooth_window: 20
5
+ print_batch_step: 50
6
+ output_dir: ./output/kie_5/
7
+ save_epoch_step: 50
8
+ # evaluation is run every 5000 iterations after the 4000th iteration
9
+ eval_batch_step: [ 0, 80 ]
10
+ # 1. If pretrained_model is saved in static mode, such as classification pretrained model
11
+ # from static branch, load_static_weights must be set as True.
12
+ # 2. If you want to finetune the pretrained models we provide in the docs,
13
+ # you should set load_static_weights as False.
14
+ load_static_weights: False
15
+ cal_metric_during_train: False
16
+ pretrained_model:
17
+ checkpoints:
18
+ save_inference_dir:
19
+ use_visualdl: False
20
+ class_path: &class_path ./train_data/wildreceipt/class_list.txt
21
+ infer_img: ./train_data/wildreceipt/1.txt
22
+ save_res_path: ./output/sdmgr_kie/predicts_kie.txt
23
+ img_scale: [ 1024, 512 ]
24
+
25
+ Architecture:
26
+ model_type: kie
27
+ algorithm: SDMGR
28
+ Transform:
29
+ Backbone:
30
+ name: Kie_backbone
31
+ Head:
32
+ name: SDMGRHead
33
+
34
+ Loss:
35
+ name: SDMGRLoss
36
+
37
+ Optimizer:
38
+ name: Adam
39
+ beta1: 0.9
40
+ beta2: 0.999
41
+ lr:
42
+ name: Piecewise
43
+ learning_rate: 0.001
44
+ decay_epochs: [ 60, 80, 100]
45
+ values: [ 0.001, 0.0001, 0.00001]
46
+ warmup_epoch: 2
47
+ regularizer:
48
+ name: 'L2'
49
+ factor: 0.00005
50
+
51
+ PostProcess:
52
+ name: None
53
+
54
+ Metric:
55
+ name: KIEMetric
56
+ main_indicator: hmean
57
+
58
+ Train:
59
+ dataset:
60
+ name: SimpleDataSet
61
+ data_dir: ./train_data/wildreceipt/
62
+ label_file_list: [ './train_data/wildreceipt/wildreceipt_train.txt' ]
63
+ ratio_list: [ 1.0 ]
64
+ transforms:
65
+ - DecodeImage: # load image
66
+ img_mode: RGB
67
+ channel_first: False
68
+ - NormalizeImage:
69
+ scale: 1
70
+ mean: [ 123.675, 116.28, 103.53 ]
71
+ std: [ 58.395, 57.12, 57.375 ]
72
+ order: 'hwc'
73
+ - KieLabelEncode: # Class handling label
74
+ character_dict_path: ./train_data/wildreceipt/dict.txt
75
+ class_path: *class_path
76
+ - KieResize:
77
+ - ToCHWImage:
78
+ - KeepKeys:
79
+ keep_keys: [ 'image', 'relations', 'texts', 'points', 'labels', 'tag', 'shape'] # dataloader will return list in this order
80
+ loader:
81
+ shuffle: True
82
+ drop_last: False
83
+ batch_size_per_card: 4
84
+ num_workers: 4
85
+
86
+ Eval:
87
+ dataset:
88
+ name: SimpleDataSet
89
+ data_dir: ./train_data/wildreceipt
90
+ label_file_list:
91
+ - ./train_data/wildreceipt/wildreceipt_test.txt
92
+ transforms:
93
+ - DecodeImage: # load image
94
+ img_mode: RGB
95
+ channel_first: False
96
+ - KieLabelEncode: # Class handling label
97
+ character_dict_path: ./train_data/wildreceipt/dict.txt
98
+ - KieResize:
99
+ - NormalizeImage:
100
+ scale: 1
101
+ mean: [ 123.675, 116.28, 103.53 ]
102
+ std: [ 58.395, 57.12, 57.375 ]
103
+ order: 'hwc'
104
+ - ToCHWImage:
105
+ - KeepKeys:
106
+ keep_keys: [ 'image', 'relations', 'texts', 'points', 'labels', 'tag', 'ori_image', 'ori_boxes', 'shape']
107
+ loader:
108
+ shuffle: False
109
+ drop_last: False
110
+ batch_size_per_card: 1 # must be 1
111
+ num_workers: 4
configs/kie/vi_layoutxlm/re_vi_layoutxlm_xfund_zh.yml ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: True
3
+ epoch_num: &epoch_num 130
4
+ log_smooth_window: 10
5
+ print_batch_step: 10
6
+ output_dir: ./output/re_vi_layoutxlm_xfund_zh
7
+ save_epoch_step: 2000
8
+ # evaluation is run every 10 iterations after the 0th iteration
9
+ eval_batch_step: [ 0, 19 ]
10
+ cal_metric_during_train: False
11
+ save_inference_dir:
12
+ use_visualdl: False
13
+ seed: 2022
14
+ infer_img: ppstructure/docs/kie/input/zh_val_21.jpg
15
+ save_res_path: ./output/re/xfund_zh/with_gt
16
+ kie_rec_model_dir:
17
+ kie_det_model_dir:
18
+
19
+ Architecture:
20
+ model_type: kie
21
+ algorithm: &algorithm "LayoutXLM"
22
+ Transform:
23
+ Backbone:
24
+ name: LayoutXLMForRe
25
+ pretrained: True
26
+ mode: vi
27
+ checkpoints:
28
+
29
+ Loss:
30
+ name: LossFromOutput
31
+ key: loss
32
+ reduction: mean
33
+
34
+ Optimizer:
35
+ name: AdamW
36
+ beta1: 0.9
37
+ beta2: 0.999
38
+ clip_norm: 10
39
+ lr:
40
+ learning_rate: 0.00005
41
+ warmup_epoch: 10
42
+ regularizer:
43
+ name: L2
44
+ factor: 0.00000
45
+
46
+ PostProcess:
47
+ name: VQAReTokenLayoutLMPostProcess
48
+
49
+ Metric:
50
+ name: VQAReTokenMetric
51
+ main_indicator: hmean
52
+
53
+ Train:
54
+ dataset:
55
+ name: SimpleDataSet
56
+ data_dir: train_data/XFUND/zh_train/image
57
+ label_file_list:
58
+ - train_data/XFUND/zh_train/train.json
59
+ ratio_list: [ 1.0 ]
60
+ transforms:
61
+ - DecodeImage: # load image
62
+ img_mode: RGB
63
+ channel_first: False
64
+ - VQATokenLabelEncode: # Class handling label
65
+ contains_re: True
66
+ algorithm: *algorithm
67
+ class_path: &class_path train_data/XFUND/class_list_xfun.txt
68
+ use_textline_bbox_info: &use_textline_bbox_info True
69
+ order_method: &order_method "tb-yx"
70
+ - VQATokenPad:
71
+ max_seq_len: &max_seq_len 512
72
+ return_attention_mask: True
73
+ - VQAReTokenRelation:
74
+ - VQAReTokenChunk:
75
+ max_seq_len: *max_seq_len
76
+ - TensorizeEntitiesRelations:
77
+ - Resize:
78
+ size: [224,224]
79
+ - NormalizeImage:
80
+ scale: 1
81
+ mean: [ 123.675, 116.28, 103.53 ]
82
+ std: [ 58.395, 57.12, 57.375 ]
83
+ order: 'hwc'
84
+ - ToCHWImage:
85
+ - KeepKeys:
86
+ keep_keys: [ 'input_ids', 'bbox','attention_mask', 'token_type_ids', 'entities', 'relations'] # dataloader will return list in this order
87
+ loader:
88
+ shuffle: True
89
+ drop_last: False
90
+ batch_size_per_card: 2
91
+ num_workers: 4
92
+
93
+ Eval:
94
+ dataset:
95
+ name: SimpleDataSet
96
+ data_dir: train_data/XFUND/zh_val/image
97
+ label_file_list:
98
+ - train_data/XFUND/zh_val/val.json
99
+ transforms:
100
+ - DecodeImage: # load image
101
+ img_mode: RGB
102
+ channel_first: False
103
+ - VQATokenLabelEncode: # Class handling label
104
+ contains_re: True
105
+ algorithm: *algorithm
106
+ class_path: *class_path
107
+ use_textline_bbox_info: *use_textline_bbox_info
108
+ order_method: *order_method
109
+ - VQATokenPad:
110
+ max_seq_len: *max_seq_len
111
+ return_attention_mask: True
112
+ - VQAReTokenRelation:
113
+ - VQAReTokenChunk:
114
+ max_seq_len: *max_seq_len
115
+ - TensorizeEntitiesRelations:
116
+ - Resize:
117
+ size: [224,224]
118
+ - NormalizeImage:
119
+ scale: 1
120
+ mean: [ 123.675, 116.28, 103.53 ]
121
+ std: [ 58.395, 57.12, 57.375 ]
122
+ order: 'hwc'
123
+ - ToCHWImage:
124
+ - KeepKeys:
125
+ keep_keys: [ 'input_ids', 'bbox', 'attention_mask', 'token_type_ids', 'entities', 'relations'] # dataloader will return list in this order
126
+ loader:
127
+ shuffle: False
128
+ drop_last: False
129
+ batch_size_per_card: 8
130
+ num_workers: 8
configs/kie/vi_layoutxlm/re_vi_layoutxlm_xfund_zh_udml.yml ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: True
3
+ epoch_num: &epoch_num 130
4
+ log_smooth_window: 10
5
+ print_batch_step: 10
6
+ output_dir: ./output/re_vi_layoutxlm_xfund_zh_udml
7
+ save_epoch_step: 2000
8
+ # evaluation is run every 10 iterations after the 0th iteration
9
+ eval_batch_step: [ 0, 19 ]
10
+ cal_metric_during_train: False
11
+ save_inference_dir:
12
+ use_visualdl: False
13
+ seed: 2022
14
+ infer_img: ppstructure/docs/kie/input/zh_val_21.jpg
15
+ save_res_path: ./output/re/xfund_zh/with_gt
16
+
17
+ Architecture:
18
+ model_type: &model_type "kie"
19
+ name: DistillationModel
20
+ algorithm: Distillation
21
+ Models:
22
+ Teacher:
23
+ pretrained:
24
+ freeze_params: false
25
+ return_all_feats: true
26
+ model_type: *model_type
27
+ algorithm: &algorithm "LayoutXLM"
28
+ Transform:
29
+ Backbone:
30
+ name: LayoutXLMForRe
31
+ pretrained: True
32
+ mode: vi
33
+ checkpoints:
34
+ Student:
35
+ pretrained:
36
+ freeze_params: false
37
+ return_all_feats: true
38
+ model_type: *model_type
39
+ algorithm: *algorithm
40
+ Transform:
41
+ Backbone:
42
+ name: LayoutXLMForRe
43
+ pretrained: True
44
+ mode: vi
45
+ checkpoints:
46
+
47
+ Loss:
48
+ name: CombinedLoss
49
+ loss_config_list:
50
+ - DistillationLossFromOutput:
51
+ weight: 1.0
52
+ model_name_list: ["Student", "Teacher"]
53
+ key: loss
54
+ reduction: mean
55
+ - DistillationVQADistanceLoss:
56
+ weight: 0.5
57
+ mode: "l2"
58
+ model_name_pairs:
59
+ - ["Student", "Teacher"]
60
+ key: hidden_states
61
+ index: 5
62
+ name: "loss_5"
63
+ - DistillationVQADistanceLoss:
64
+ weight: 0.5
65
+ mode: "l2"
66
+ model_name_pairs:
67
+ - ["Student", "Teacher"]
68
+ key: hidden_states
69
+ index: 8
70
+ name: "loss_8"
71
+
72
+
73
+ Optimizer:
74
+ name: AdamW
75
+ beta1: 0.9
76
+ beta2: 0.999
77
+ clip_norm: 10
78
+ lr:
79
+ learning_rate: 0.00005
80
+ warmup_epoch: 10
81
+ regularizer:
82
+ name: L2
83
+ factor: 0.00000
84
+
85
+ PostProcess:
86
+ name: DistillationRePostProcess
87
+ model_name: ["Student", "Teacher"]
88
+ key: null
89
+
90
+
91
+ Metric:
92
+ name: DistillationMetric
93
+ base_metric_name: VQAReTokenMetric
94
+ main_indicator: hmean
95
+ key: "Student"
96
+
97
+ Train:
98
+ dataset:
99
+ name: SimpleDataSet
100
+ data_dir: train_data/XFUND/zh_train/image
101
+ label_file_list:
102
+ - train_data/XFUND/zh_train/train.json
103
+ ratio_list: [ 1.0 ]
104
+ transforms:
105
+ - DecodeImage: # load image
106
+ img_mode: RGB
107
+ channel_first: False
108
+ - VQATokenLabelEncode: # Class handling label
109
+ contains_re: True
110
+ algorithm: *algorithm
111
+ class_path: &class_path train_data/XFUND/class_list_xfun.txt
112
+ use_textline_bbox_info: &use_textline_bbox_info True
113
+ # [None, "tb-yx"]
114
+ order_method: &order_method "tb-yx"
115
+ - VQATokenPad:
116
+ max_seq_len: &max_seq_len 512
117
+ return_attention_mask: True
118
+ - VQAReTokenRelation:
119
+ - VQAReTokenChunk:
120
+ max_seq_len: *max_seq_len
121
+ - TensorizeEntitiesRelations:
122
+ - Resize:
123
+ size: [224,224]
124
+ - NormalizeImage:
125
+ scale: 1
126
+ mean: [ 123.675, 116.28, 103.53 ]
127
+ std: [ 58.395, 57.12, 57.375 ]
128
+ order: 'hwc'
129
+ - ToCHWImage:
130
+ - KeepKeys:
131
+ keep_keys: [ 'input_ids', 'bbox','attention_mask', 'token_type_ids', 'entities', 'relations'] # dataloader will return list in this order
132
+ loader:
133
+ shuffle: True
134
+ drop_last: False
135
+ batch_size_per_card: 2
136
+ num_workers: 4
137
+
138
+ Eval:
139
+ dataset:
140
+ name: SimpleDataSet
141
+ data_dir: train_data/XFUND/zh_val/image
142
+ label_file_list:
143
+ - train_data/XFUND/zh_val/val.json
144
+ transforms:
145
+ - DecodeImage: # load image
146
+ img_mode: RGB
147
+ channel_first: False
148
+ - VQATokenLabelEncode: # Class handling label
149
+ contains_re: True
150
+ algorithm: *algorithm
151
+ class_path: *class_path
152
+ use_textline_bbox_info: *use_textline_bbox_info
153
+ order_method: *order_method
154
+ - VQATokenPad:
155
+ max_seq_len: *max_seq_len
156
+ return_attention_mask: True
157
+ - VQAReTokenRelation:
158
+ - VQAReTokenChunk:
159
+ max_seq_len: *max_seq_len
160
+ - TensorizeEntitiesRelations:
161
+ - Resize:
162
+ size: [224,224]
163
+ - NormalizeImage:
164
+ scale: 1
165
+ mean: [ 123.675, 116.28, 103.53 ]
166
+ std: [ 58.395, 57.12, 57.375 ]
167
+ order: 'hwc'
168
+ - ToCHWImage:
169
+ - KeepKeys:
170
+ keep_keys: [ 'input_ids', 'bbox', 'attention_mask', 'token_type_ids', 'entities', 'relations'] # dataloader will return list in this order
171
+ loader:
172
+ shuffle: False
173
+ drop_last: False
174
+ batch_size_per_card: 8
175
+ num_workers: 8
176
+
177
+
configs/kie/vi_layoutxlm/ser_vi_layoutxlm_xfund_zh.yml ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: True
3
+ epoch_num: &epoch_num 200
4
+ log_smooth_window: 10
5
+ print_batch_step: 10
6
+ output_dir: ./output/ser_vi_layoutxlm_xfund_zh
7
+ save_epoch_step: 2000
8
+ # evaluation is run every 10 iterations after the 0th iteration
9
+ eval_batch_step: [ 0, 19 ]
10
+ cal_metric_during_train: False
11
+ save_inference_dir:
12
+ use_visualdl: False
13
+ seed: 2022
14
+ infer_img: ppstructure/docs/kie/input/zh_val_42.jpg
15
+ d2s_train_image_shape: [3, 224, 224]
16
+ # if you want to predict using the groundtruth ocr info,
17
+ # you can use the following config
18
+ # infer_img: train_data/XFUND/zh_val/val.json
19
+ # infer_mode: False
20
+
21
+ save_res_path: ./output/ser/xfund_zh/res
22
+ kie_rec_model_dir:
23
+ kie_det_model_dir:
24
+ amp_custom_white_list: ['scale', 'concat', 'elementwise_add']
25
+
26
+ Architecture:
27
+ model_type: kie
28
+ algorithm: &algorithm "LayoutXLM"
29
+ Transform:
30
+ Backbone:
31
+ name: LayoutXLMForSer
32
+ pretrained: True
33
+ checkpoints:
34
+ # one of base or vi
35
+ mode: vi
36
+ num_classes: &num_classes 7
37
+
38
+ Loss:
39
+ name: VQASerTokenLayoutLMLoss
40
+ num_classes: *num_classes
41
+ key: "backbone_out"
42
+
43
+ Optimizer:
44
+ name: AdamW
45
+ beta1: 0.9
46
+ beta2: 0.999
47
+ lr:
48
+ name: Linear
49
+ learning_rate: 0.00005
50
+ epochs: *epoch_num
51
+ warmup_epoch: 2
52
+ regularizer:
53
+ name: L2
54
+ factor: 0.00000
55
+
56
+ PostProcess:
57
+ name: VQASerTokenLayoutLMPostProcess
58
+ class_path: &class_path train_data/XFUND/class_list_xfun.txt
59
+
60
+ Metric:
61
+ name: VQASerTokenMetric
62
+ main_indicator: hmean
63
+
64
+ Train:
65
+ dataset:
66
+ name: SimpleDataSet
67
+ data_dir: train_data/XFUND/zh_train/image
68
+ label_file_list:
69
+ - train_data/XFUND/zh_train/train.json
70
+ ratio_list: [ 1.0 ]
71
+ transforms:
72
+ - DecodeImage: # load image
73
+ img_mode: RGB
74
+ channel_first: False
75
+ - VQATokenLabelEncode: # Class handling label
76
+ contains_re: False
77
+ algorithm: *algorithm
78
+ class_path: *class_path
79
+ use_textline_bbox_info: &use_textline_bbox_info True
80
+ # one of [None, "tb-yx"]
81
+ order_method: &order_method "tb-yx"
82
+ - VQATokenPad:
83
+ max_seq_len: &max_seq_len 512
84
+ return_attention_mask: True
85
+ - VQASerTokenChunk:
86
+ max_seq_len: *max_seq_len
87
+ - Resize:
88
+ size: [224,224]
89
+ - NormalizeImage:
90
+ scale: 1
91
+ mean: [ 123.675, 116.28, 103.53 ]
92
+ std: [ 58.395, 57.12, 57.375 ]
93
+ order: 'hwc'
94
+ - ToCHWImage:
95
+ - KeepKeys:
96
+ keep_keys: [ 'input_ids', 'bbox', 'attention_mask', 'token_type_ids', 'image', 'labels'] # dataloader will return list in this order
97
+ loader:
98
+ shuffle: True
99
+ drop_last: False
100
+ batch_size_per_card: 8
101
+ num_workers: 4
102
+
103
+ Eval:
104
+ dataset:
105
+ name: SimpleDataSet
106
+ data_dir: train_data/XFUND/zh_val/image
107
+ label_file_list:
108
+ - train_data/XFUND/zh_val/val.json
109
+ transforms:
110
+ - DecodeImage: # load image
111
+ img_mode: RGB
112
+ channel_first: False
113
+ - VQATokenLabelEncode: # Class handling label
114
+ contains_re: False
115
+ algorithm: *algorithm
116
+ class_path: *class_path
117
+ use_textline_bbox_info: *use_textline_bbox_info
118
+ order_method: *order_method
119
+ - VQATokenPad:
120
+ max_seq_len: *max_seq_len
121
+ return_attention_mask: True
122
+ - VQASerTokenChunk:
123
+ max_seq_len: *max_seq_len
124
+ - Resize:
125
+ size: [224,224]
126
+ - NormalizeImage:
127
+ scale: 1
128
+ mean: [ 123.675, 116.28, 103.53 ]
129
+ std: [ 58.395, 57.12, 57.375 ]
130
+ order: 'hwc'
131
+ - ToCHWImage:
132
+ - KeepKeys:
133
+ keep_keys: [ 'input_ids', 'bbox', 'attention_mask', 'token_type_ids', 'image', 'labels'] # dataloader will return list in this order
134
+ loader:
135
+ shuffle: False
136
+ drop_last: False
137
+ batch_size_per_card: 8
138
+ num_workers: 4
configs/kie/vi_layoutxlm/ser_vi_layoutxlm_xfund_zh_udml.yml ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: True
3
+ epoch_num: &epoch_num 200
4
+ log_smooth_window: 10
5
+ print_batch_step: 10
6
+ output_dir: ./output/ser_vi_layoutxlm_xfund_zh_udml
7
+ save_epoch_step: 2000
8
+ # evaluation is run every 10 iterations after the 0th iteration
9
+ eval_batch_step: [ 0, 19 ]
10
+ cal_metric_during_train: False
11
+ save_inference_dir:
12
+ use_visualdl: False
13
+ seed: 2022
14
+ infer_img: ppstructure/docs/kie/input/zh_val_42.jpg
15
+ save_res_path: ./output/ser_layoutxlm_xfund_zh/res
16
+
17
+
18
+ Architecture:
19
+ model_type: &model_type "kie"
20
+ name: DistillationModel
21
+ algorithm: Distillation
22
+ Models:
23
+ Teacher:
24
+ pretrained:
25
+ freeze_params: false
26
+ return_all_feats: true
27
+ model_type: *model_type
28
+ algorithm: &algorithm "LayoutXLM"
29
+ Transform:
30
+ Backbone:
31
+ name: LayoutXLMForSer
32
+ pretrained: True
33
+ # one of base or vi
34
+ mode: vi
35
+ checkpoints:
36
+ num_classes: &num_classes 7
37
+ Student:
38
+ pretrained:
39
+ freeze_params: false
40
+ return_all_feats: true
41
+ model_type: *model_type
42
+ algorithm: *algorithm
43
+ Transform:
44
+ Backbone:
45
+ name: LayoutXLMForSer
46
+ pretrained: True
47
+ # one of base or vi
48
+ mode: vi
49
+ checkpoints:
50
+ num_classes: *num_classes
51
+
52
+
53
+ Loss:
54
+ name: CombinedLoss
55
+ loss_config_list:
56
+ - DistillationVQASerTokenLayoutLMLoss:
57
+ weight: 1.0
58
+ model_name_list: ["Student", "Teacher"]
59
+ key: backbone_out
60
+ num_classes: *num_classes
61
+ - DistillationSERDMLLoss:
62
+ weight: 1.0
63
+ act: "softmax"
64
+ use_log: true
65
+ model_name_pairs:
66
+ - ["Student", "Teacher"]
67
+ key: backbone_out
68
+ - DistillationVQADistanceLoss:
69
+ weight: 0.5
70
+ mode: "l2"
71
+ model_name_pairs:
72
+ - ["Student", "Teacher"]
73
+ key: hidden_states_5
74
+ name: "loss_5"
75
+ - DistillationVQADistanceLoss:
76
+ weight: 0.5
77
+ mode: "l2"
78
+ model_name_pairs:
79
+ - ["Student", "Teacher"]
80
+ key: hidden_states_8
81
+ name: "loss_8"
82
+
83
+
84
+
85
+ Optimizer:
86
+ name: AdamW
87
+ beta1: 0.9
88
+ beta2: 0.999
89
+ lr:
90
+ name: Linear
91
+ learning_rate: 0.00005
92
+ epochs: *epoch_num
93
+ warmup_epoch: 10
94
+ regularizer:
95
+ name: L2
96
+ factor: 0.00000
97
+
98
+ PostProcess:
99
+ name: DistillationSerPostProcess
100
+ model_name: ["Student", "Teacher"]
101
+ key: backbone_out
102
+ class_path: &class_path train_data/XFUND/class_list_xfun.txt
103
+
104
+ Metric:
105
+ name: DistillationMetric
106
+ base_metric_name: VQASerTokenMetric
107
+ main_indicator: hmean
108
+ key: "Student"
109
+
110
+ Train:
111
+ dataset:
112
+ name: SimpleDataSet
113
+ data_dir: train_data/XFUND/zh_train/image
114
+ label_file_list:
115
+ - train_data/XFUND/zh_train/train.json
116
+ ratio_list: [ 1.0 ]
117
+ transforms:
118
+ - DecodeImage: # load image
119
+ img_mode: RGB
120
+ channel_first: False
121
+ - VQATokenLabelEncode: # Class handling label
122
+ contains_re: False
123
+ algorithm: *algorithm
124
+ class_path: *class_path
125
+ # one of [None, "tb-yx"]
126
+ order_method: &order_method "tb-yx"
127
+ - VQATokenPad:
128
+ max_seq_len: &max_seq_len 512
129
+ return_attention_mask: True
130
+ - VQASerTokenChunk:
131
+ max_seq_len: *max_seq_len
132
+ - Resize:
133
+ size: [224,224]
134
+ - NormalizeImage:
135
+ scale: 1
136
+ mean: [ 123.675, 116.28, 103.53 ]
137
+ std: [ 58.395, 57.12, 57.375 ]
138
+ order: 'hwc'
139
+ - ToCHWImage:
140
+ - KeepKeys:
141
+ keep_keys: [ 'input_ids', 'bbox', 'attention_mask', 'token_type_ids', 'image', 'labels'] # dataloader will return list in this order
142
+ loader:
143
+ shuffle: True
144
+ drop_last: False
145
+ batch_size_per_card: 4
146
+ num_workers: 4
147
+
148
+ Eval:
149
+ dataset:
150
+ name: SimpleDataSet
151
+ data_dir: train_data/XFUND/zh_val/image
152
+ label_file_list:
153
+ - train_data/XFUND/zh_val/val.json
154
+ transforms:
155
+ - DecodeImage: # load image
156
+ img_mode: RGB
157
+ channel_first: False
158
+ - VQATokenLabelEncode: # Class handling label
159
+ contains_re: False
160
+ algorithm: *algorithm
161
+ class_path: *class_path
162
+ order_method: *order_method
163
+ - VQATokenPad:
164
+ max_seq_len: *max_seq_len
165
+ return_attention_mask: True
166
+ - VQASerTokenChunk:
167
+ max_seq_len: *max_seq_len
168
+ - Resize:
169
+ size: [224,224]
170
+ - NormalizeImage:
171
+ scale: 1
172
+ mean: [ 123.675, 116.28, 103.53 ]
173
+ std: [ 58.395, 57.12, 57.375 ]
174
+ order: 'hwc'
175
+ - ToCHWImage:
176
+ - KeepKeys:
177
+ keep_keys: [ 'input_ids', 'bbox', 'attention_mask', 'token_type_ids', 'image', 'labels'] # dataloader will return list in this order
178
+ loader:
179
+ shuffle: False
180
+ drop_last: False
181
+ batch_size_per_card: 8
182
+ num_workers: 4
configs/rec/PP-OCRv3/ch_PP-OCRv3_rec.yml ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 500
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/rec_ppocr_v3
7
+ eval_epoch_step: [0, 1]
8
+ cal_metric_during_train: true
9
+ pretrained_model:
10
+ checkpoints:
11
+ use_tensorboard: false
12
+ infer_mode: false
13
+ infer_img: doc/imgs_words/ch/word_1.jpg
14
+ character_dict_path: &character_dict_path ppocr/utils/ppocr_keys_v1.txt
15
+ max_text_length: &max_text_length 25
16
+ use_space_char: &use_space_char true
17
+
18
+ Export:
19
+ export_dir:
20
+ export_shape: [ 1, 3, 48, 320 ]
21
+ dynamic_axes: [ 0, 2, 3 ]
22
+
23
+ Optimizer:
24
+ name: Adam
25
+ lr: 0.001
26
+ weight_decay: 3.0e-05
27
+
28
+ LRScheduler:
29
+ name: CosineAnnealingLR
30
+ warmup_epoch: 5
31
+
32
+ Architecture:
33
+ model_type: rec
34
+ algorithm: SVTR_LCNet
35
+ Transform:
36
+ Backbone:
37
+ name: MobileNetV1Enhance
38
+ scale: 0.5
39
+ last_conv_stride: [1, 2]
40
+ last_pool_type: avg
41
+ last_pool_kernel_size: [2, 2]
42
+ Head:
43
+ name: MultiHead
44
+ head_list:
45
+ - CTCHead:
46
+ Neck:
47
+ name: svtr
48
+ dims: 64
49
+ depth: 2
50
+ hidden_dims: 120
51
+ use_guide: True
52
+ - SARHead:
53
+ enc_dim: 512
54
+ max_text_length: *max_text_length
55
+
56
+ Loss:
57
+ name: MultiLoss
58
+ loss_config_list:
59
+ - CTCLoss:
60
+ - SARLoss:
61
+
62
+ PostProcess:
63
+ name: CTCLabelDecode
64
+ character_dict_path: *character_dict_path
65
+ use_space_char: *use_space_char
66
+
67
+ Metric:
68
+ name: RecMetric
69
+ main_indicator: acc
70
+ ignore_space: False
71
+
72
+ Train:
73
+ dataset:
74
+ name: SimpleDataSet
75
+ data_dir: ./train_data
76
+ label_file_list:
77
+ - ./train_data/train_list.txt
78
+ ext_op_transform_idx: 1
79
+ transforms:
80
+ - DecodeImage:
81
+ img_mode: BGR
82
+ channel_first: false
83
+ - RecConAug:
84
+ prob: 0.5
85
+ ext_data_num: 2
86
+ image_shape: [48, 320, 3]
87
+ max_text_length: *max_text_length
88
+ - RecAug:
89
+ - MultiLabelEncode:
90
+ - RecResizeImg:
91
+ image_shape: [3, 48, 320]
92
+ - KeepKeys:
93
+ keep_keys: [image, label_ctc, label_sar, length, valid_ratio]
94
+ loader:
95
+ shuffle: true
96
+ batch_size_per_card: 128
97
+ drop_last: true
98
+ num_workers: 4
99
+ Eval:
100
+ dataset:
101
+ name: SimpleDataSet
102
+ data_dir: ./train_data/
103
+ ext_op_transform_idx: 1
104
+ label_file_list:
105
+ - ./train_data/val_list.txt
106
+ transforms:
107
+ - DecodeImage:
108
+ img_mode: BGR
109
+ channel_first: false
110
+ - MultiLabelEncode:
111
+ - RecResizeImg:
112
+ image_shape: [3, 48, 320]
113
+ - KeepKeys:
114
+ keep_keys: [ image, label_ctc, label_sar, length, valid_ratio ]
115
+ loader:
116
+ shuffle: false
117
+ drop_last: false
118
+ batch_size_per_card: 128
119
+ num_workers: 4
configs/rec/PP-OCRv3/ch_PP-OCRv3_rec_distillation.yml ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 800
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/rec_ppocr_v3_distillation
7
+ eval_epoch_step: [0, 1]
8
+ cal_metric_during_train: true
9
+ pretrained_model:
10
+ checkpoints:
11
+ use_tensorboard: false
12
+ infer_mode: false
13
+ infer_img: doc/imgs_words/ch/word_1.jpg
14
+ character_dict_path: &character_dict_path ppocr/utils/ppocr_keys_v1.txt
15
+ max_text_length: &max_text_length 25
16
+ use_space_char: &use_space_char true
17
+
18
+ Export:
19
+ export_dir:
20
+ export_shape: [ 1, 3, 48, 320 ]
21
+ dynamic_axes: [ 0, 2, 3 ]
22
+
23
+ Optimizer:
24
+ name: Adam
25
+ lr: 0.0005
26
+ weight_decay: 3.0e-05
27
+ amsgrad: true
28
+
29
+ LRScheduler:
30
+ name: MultiStepLR
31
+ milestones: [700]
32
+ warmup_epoch: 5
33
+
34
+ Architecture:
35
+ model_type: &model_type "rec"
36
+ name: DistillationModel
37
+ algorithm: Distillation
38
+ Models:
39
+ Teacher:
40
+ pretrained:
41
+ freeze_params: false
42
+ return_all_feats: true
43
+ model_type: *model_type
44
+ algorithm: SVTR_LCNet
45
+ Transform:
46
+ Backbone:
47
+ name: MobileNetV1Enhance
48
+ scale: 0.5
49
+ last_conv_stride: [1, 2]
50
+ last_pool_type: avg
51
+ last_pool_kernel_size: [2, 2]
52
+ Head:
53
+ name: MultiHead
54
+ head_list:
55
+ - CTCHead:
56
+ Neck:
57
+ name: svtr
58
+ dims: 64
59
+ depth: 2
60
+ hidden_dims: 120
61
+ use_guide: True
62
+ - SARHead:
63
+ enc_dim: 512
64
+ max_text_length: *max_text_length
65
+ Student:
66
+ pretrained:
67
+ freeze_params: false
68
+ return_all_feats: true
69
+ model_type: *model_type
70
+ algorithm: SVTR_LCNet
71
+ Transform:
72
+ Backbone:
73
+ name: MobileNetV1Enhance
74
+ scale: 0.5
75
+ last_conv_stride: [1, 2]
76
+ last_pool_type: avg
77
+ last_pool_kernel_size: [2, 2]
78
+ Head:
79
+ name: MultiHead
80
+ head_list:
81
+ - CTCHead:
82
+ Neck:
83
+ name: svtr
84
+ dims: 64
85
+ depth: 2
86
+ hidden_dims: 120
87
+ use_guide: True
88
+ Head:
89
+ fc_decay: 0.00001
90
+ - SARHead:
91
+ enc_dim: 512
92
+ max_text_length: *max_text_length
93
+ Loss:
94
+ name: CombinedLoss
95
+ loss_config_list:
96
+ - DistillationDMLLoss:
97
+ weight: 1.0
98
+ act: "softmax"
99
+ use_log: true
100
+ model_name_pairs:
101
+ - ["Student", "Teacher"]
102
+ key: head_out
103
+ multi_head: True
104
+ dis_head: ctc
105
+ name: dml_ctc
106
+ - DistillationDMLLoss:
107
+ weight: 0.5
108
+ act: "softmax"
109
+ use_log: true
110
+ model_name_pairs:
111
+ - ["Student", "Teacher"]
112
+ key: head_out
113
+ multi_head: True
114
+ dis_head: sar
115
+ name: dml_sar
116
+ - DistillationDistanceLoss:
117
+ weight: 1.0
118
+ mode: "l2"
119
+ model_name_pairs:
120
+ - ["Student", "Teacher"]
121
+ key: backbone_out
122
+ - DistillationCTCLoss:
123
+ weight: 1.0
124
+ model_name_list: ["Student", "Teacher"]
125
+ key: head_out
126
+ multi_head: True
127
+ - DistillationSARLoss:
128
+ weight: 1.0
129
+ model_name_list: ["Student", "Teacher"]
130
+ key: head_out
131
+ multi_head: True
132
+
133
+ PostProcess:
134
+ name: DistillationCTCLabelDecode
135
+ model_name: ["Student", "Teacher"]
136
+ key: head_out
137
+ multi_head: True
138
+ character_dict_path: *character_dict_path
139
+ use_space_char: *use_space_char
140
+
141
+
142
+ Metric:
143
+ name: DistillationMetric
144
+ base_metric_name: RecMetric
145
+ main_indicator: acc
146
+ key: "Student"
147
+ ignore_space: False
148
+
149
+ Train:
150
+ dataset:
151
+ name: SimpleDataSet
152
+ data_dir: ./train_data
153
+ ext_op_transform_idx: 1
154
+ label_file_list:
155
+ - ./train_data/train_list.txt
156
+ transforms:
157
+ - DecodeImage:
158
+ img_mode: BGR
159
+ channel_first: false
160
+ - RecConAug:
161
+ prob: 0.5
162
+ ext_data_num: 2
163
+ image_shape: [48, 320, 3]
164
+ max_text_length: *max_text_length
165
+ - RecAug:
166
+ - MultiLabelEncode:
167
+ - RecResizeImg:
168
+ image_shape: [3, 48, 320]
169
+ - KeepKeys:
170
+ keep_keys:
171
+ - image
172
+ - label_ctc
173
+ - label_sar
174
+ - length
175
+ - valid_ratio
176
+ loader:
177
+ shuffle: true
178
+ batch_size_per_card: 128
179
+ drop_last: true
180
+ num_workers: 4
181
+ Eval:
182
+ dataset:
183
+ name: SimpleDataSet
184
+ data_dir: ./train_data
185
+ label_file_list:
186
+ - ./train_data/train_list.txt
187
+ transforms:
188
+ - DecodeImage:
189
+ img_mode: BGR
190
+ channel_first: false
191
+ - MultiLabelEncode:
192
+ - RecResizeImg:
193
+ image_shape: [3, 48, 320]
194
+ - KeepKeys:
195
+ keep_keys:
196
+ - image
197
+ - label_ctc
198
+ - label_sar
199
+ - length
200
+ - valid_ratio
201
+ loader:
202
+ shuffle: false
203
+ drop_last: false
204
+ batch_size_per_card: 128
205
+ num_workers: 4
configs/rec/PP-OCRv4/ch_PP-OCRv4_rec.yml ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 200
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/rec_ppocr_v4
7
+ eval_epoch_step: [0, 1]
8
+ cal_metric_during_train: true
9
+ pretrained_model:
10
+ checkpoints:
11
+ use_tensorboard: false
12
+ infer_mode: false
13
+ infer_img: doc/imgs_words/ch/word_1.jpg
14
+ character_dict_path: &character_dict_path ppocr/utils/ppocr_keys_v1.txt
15
+ max_text_length: &max_text_length 25
16
+ use_space_char: &use_space_char true
17
+
18
+ Export:
19
+ export_dir:
20
+ export_shape: [ 1, 3, 48, 320 ]
21
+ dynamic_axes: [ 0, 2, 3 ]
22
+
23
+ Optimizer:
24
+ name: Adam
25
+ lr: 0.001
26
+ weight_decay: 3.0e-05
27
+
28
+ LRScheduler:
29
+ name: CosineAnnealingLR
30
+ warmup_epoch: 5
31
+
32
+ Architecture:
33
+ model_type: rec
34
+ algorithm: SVTR_LCNet
35
+ Transform:
36
+ Backbone:
37
+ name: PPLCNetV3
38
+ scale: 0.95
39
+ Head:
40
+ name: MultiHead
41
+ head_list:
42
+ - CTCHead:
43
+ Neck:
44
+ name: svtr
45
+ dims: 120
46
+ depth: 2
47
+ hidden_dims: 120
48
+ kernel_size: [1, 3]
49
+ use_guide: True
50
+ - NRTRHead:
51
+ nrtr_dim: 384
52
+ max_text_length: *max_text_length
53
+
54
+ Loss:
55
+ name: MultiLoss
56
+ loss_config_list:
57
+ - CTCLoss:
58
+ - NRTRLoss:
59
+
60
+ PostProcess:
61
+ name: CTCLabelDecode
62
+ character_dict_path: *character_dict_path
63
+ use_space_char: *use_space_char
64
+
65
+ Metric:
66
+ name: RecMetric
67
+ main_indicator: acc
68
+
69
+ Train:
70
+ dataset:
71
+ name: MultiScaleDataSet
72
+ ds_width: false
73
+ data_dir: ./train_data/
74
+ ext_op_transform_idx: 1
75
+ label_file_list:
76
+ - ./train_data/train_list.txt
77
+ transforms:
78
+ - DecodeImage:
79
+ img_mode: BGR
80
+ channel_first: false
81
+ - RecConAug:
82
+ prob: 0.5
83
+ ext_data_num: 2
84
+ image_shape: [48, 320, 3]
85
+ max_text_length: *max_text_length
86
+ - RecAug:
87
+ - MultiLabelEncode:
88
+ gtc_encode: NRTRLabelEncode
89
+ - KeepKeys:
90
+ keep_keys:
91
+ - image
92
+ - label_ctc
93
+ - label_gtc
94
+ - length
95
+ - valid_ratio
96
+ sampler:
97
+ name: MultiScaleSampler
98
+ scales: [[320, 32], [320, 48], [320, 64]]
99
+ first_bs: &bs 192
100
+ fix_bs: false
101
+ divided_factor: [8, 16] # w, h
102
+ is_training: True
103
+ loader:
104
+ shuffle: true
105
+ batch_size_per_card: *bs
106
+ drop_last: true
107
+ num_workers: 8
108
+ Eval:
109
+ dataset:
110
+ name: SimpleDataSet
111
+ data_dir: ./train_data
112
+ label_file_list:
113
+ - ./train_data/val_list.txt
114
+ transforms:
115
+ - DecodeImage:
116
+ img_mode: BGR
117
+ channel_first: false
118
+ - MultiLabelEncode:
119
+ gtc_encode: NRTRLabelEncode
120
+ - RecResizeImg:
121
+ image_shape: [3, 48, 320]
122
+ - KeepKeys:
123
+ keep_keys:
124
+ - image
125
+ - label_ctc
126
+ - label_gtc
127
+ - length
128
+ - valid_ratio
129
+ loader:
130
+ shuffle: false
131
+ drop_last: false
132
+ batch_size_per_card: 128
133
+ num_workers: 4
configs/rec/PP-OCRv4/ch_PP-OCRv4_rec_distill.yml ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 200
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/rec_ppocr_v4__distill
7
+ eval_epoch_step: [0, 1]
8
+ cal_metric_during_train: true
9
+ pretrained_model:
10
+ checkpoints:
11
+ use_tensorboard: false
12
+ infer_mode: false
13
+ infer_img: doc/imgs_words/ch/word_1.jpg
14
+ character_dict_path: &character_dict_path ppocr/utils/ppocr_keys_v1.txt
15
+ max_text_length: &max_text_length 25
16
+ use_space_char: &use_space_char true
17
+
18
+ Export:
19
+ export_dir:
20
+ export_shape: [ 1, 3, 48, 320 ]
21
+ dynamic_axes: [ 0, 2, 3 ]
22
+
23
+ Optimizer:
24
+ name: Adam
25
+ lr: 0.001
26
+ weight_decay: 3.0e-05
27
+
28
+ LRScheduler:
29
+ name: CosineAnnealingLR
30
+ warmup_epoch: 5
31
+
32
+ Architecture:
33
+ model_type: rec
34
+ name: DistillationModel
35
+ algorithm: Distillation
36
+ Models:
37
+ Teacher:
38
+ pretrained:
39
+ freeze_params: true
40
+ return_all_feats: true
41
+ model_type: rec
42
+ algorithm: SVTR
43
+ Transform: null
44
+ Backbone:
45
+ name: PPHGNet_small
46
+ Head:
47
+ name: MultiHead
48
+ head_list:
49
+ - CTCHead:
50
+ Neck:
51
+ name: svtr
52
+ dims: 120
53
+ depth: 2
54
+ hidden_dims: 120
55
+ kernel_size: [1, 3]
56
+ use_guide: True
57
+ Head:
58
+ fc_decay: 0.00001
59
+ - NRTRHead:
60
+ nrtr_dim: 384
61
+ max_text_length: *max_text_length
62
+ Student:
63
+ pretrained:
64
+ freeze_params: false
65
+ return_all_feats: true
66
+ model_type: rec
67
+ algorithm: SVTR
68
+ Transform: null
69
+ Backbone:
70
+ name: PPLCNetV3
71
+ scale: 0.95
72
+ Head:
73
+ name: MultiHead
74
+ head_list:
75
+ - CTCHead:
76
+ Neck:
77
+ name: svtr
78
+ dims: 120
79
+ depth: 2
80
+ hidden_dims: 120
81
+ kernel_size: [1, 3]
82
+ use_guide: True
83
+ - NRTRHead:
84
+ nrtr_dim: 384
85
+ max_text_length: *max_text_length
86
+ Loss:
87
+ name: CombinedLoss
88
+ loss_config_list:
89
+ - DistillationDKDLoss:
90
+ weight: 0.1
91
+ model_name_pairs:
92
+ - - Student
93
+ - Teacher
94
+ key: head_out
95
+ multi_head: true
96
+ alpha: 1.0
97
+ beta: 2.0
98
+ dis_head: nrtr
99
+ name: dkd
100
+ - DistillationCTCLoss:
101
+ weight: 1.0
102
+ model_name_list:
103
+ - Student
104
+ key: head_out
105
+ multi_head: true
106
+ - DistillCTCLogits:
107
+ weight: 1.0
108
+ reduction: mean
109
+ model_name_pairs:
110
+ - - Student
111
+ - Teacher
112
+ key: head_out
113
+ - DistillationNRTRLoss:
114
+ weight: 1.0
115
+ smoothing: false
116
+ model_name_list:
117
+ - Student
118
+ key: head_out
119
+ multi_head: true
120
+
121
+ PostProcess:
122
+ name: DistillationCTCLabelDecode
123
+ model_name:
124
+ - Student
125
+ key: head_out
126
+ multi_head: true
127
+ character_dict_path: *character_dict_path
128
+ use_space_char: *use_space_char
129
+
130
+ Metric:
131
+ name: DistillationMetric
132
+ base_metric_name: RecMetric
133
+ main_indicator: acc
134
+ key: Student
135
+ ignore_space: false
136
+ Train:
137
+ dataset:
138
+ name: MultiScaleDataSet
139
+ ds_width: false
140
+ data_dir: ./train_data/
141
+ ext_op_transform_idx: 1
142
+ label_file_list:
143
+ - ./train_data/train_list.txt
144
+ transforms:
145
+ - DecodeImage:
146
+ img_mode: BGR
147
+ channel_first: false
148
+ - RecConAug:
149
+ prob: 0.5
150
+ ext_data_num: 2
151
+ image_shape: [48, 320, 3]
152
+ max_text_length: *max_text_length
153
+ - RecAug:
154
+ - MultiLabelEncode:
155
+ gtc_encode: NRTRLabelEncode
156
+ - KeepKeys:
157
+ keep_keys:
158
+ - image
159
+ - label_ctc
160
+ - label_gtc
161
+ - length
162
+ - valid_ratio
163
+ sampler:
164
+ name: MultiScaleSampler
165
+ scales: [[320, 32], [320, 48], [320, 64]]
166
+ first_bs: &bs 192
167
+ fix_bs: false
168
+ divided_factor: [8, 16] # w, h
169
+ is_training: True
170
+ loader:
171
+ shuffle: true
172
+ batch_size_per_card: *bs
173
+ drop_last: true
174
+ num_workers: 8
175
+ Eval:
176
+ dataset:
177
+ name: SimpleDataSet
178
+ data_dir: ./train_data
179
+ label_file_list:
180
+ - ./train_data/val_list.txt
181
+ transforms:
182
+ - DecodeImage:
183
+ img_mode: BGR
184
+ channel_first: false
185
+ - MultiLabelEncode:
186
+ gtc_encode: NRTRLabelEncode
187
+ - RecResizeImg:
188
+ image_shape: [3, 48, 320]
189
+ - KeepKeys:
190
+ keep_keys:
191
+ - image
192
+ - label_ctc
193
+ - label_gtc
194
+ - length
195
+ - valid_ratio
196
+ loader:
197
+ shuffle: false
198
+ drop_last: false
199
+ batch_size_per_card: 128
200
+ num_workers: 4
configs/rec/PP-OCRv4/ch_PP-OCRv4_rec_hgnet.yml ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 200
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/rec_ppocr_v4_hgnet
7
+ eval_epoch_step: [0, 1]
8
+ cal_metric_during_train: true
9
+ pretrained_model:
10
+ checkpoints:
11
+ use_tensorboard: false
12
+ infer_mode: false
13
+ infer_img: img
14
+ character_dict_path: &character_dict_path ppocr/utils/ppocr_keys_v1.txt
15
+ max_text_length: &max_text_length 25
16
+ use_space_char: &use_space_char true
17
+
18
+ Export:
19
+ export_dir:
20
+ export_shape: [ 1, 3, 48, 320 ]
21
+ dynamic_axes: [ 0, 2, 3 ]
22
+
23
+
24
+
25
+ Optimizer:
26
+ name: Adam
27
+ lr: 0.001
28
+ weight_decay: 3.0e-05
29
+
30
+ LRScheduler:
31
+ name: CosineAnnealingLR
32
+ warmup_epoch: 5
33
+
34
+ Architecture:
35
+ model_type: rec
36
+ algorithm: SVTR_HGNet
37
+ Transform:
38
+ Backbone:
39
+ name: PPHGNet_small
40
+ Head:
41
+ name: MultiHead
42
+ head_list:
43
+ - CTCHead:
44
+ Neck:
45
+ name: svtr
46
+ dims: 120
47
+ depth: 2
48
+ hidden_dims: 120
49
+ kernel_size: [1, 3]
50
+ use_guide: True
51
+ - NRTRHead:
52
+ nrtr_dim: 384
53
+ max_text_length: *max_text_length
54
+
55
+ Loss:
56
+ name: MultiLoss
57
+ loss_config_list:
58
+ - CTCLoss:
59
+ - NRTRLoss:
60
+
61
+ PostProcess:
62
+ name: CTCLabelDecode
63
+ character_dict_path: *character_dict_path
64
+ use_space_char: *use_space_char
65
+
66
+ Metric:
67
+ name: RecMetric
68
+ main_indicator: acc
69
+
70
+ Train:
71
+ dataset:
72
+ name: MultiScaleDataSet
73
+ ds_width: false
74
+ data_dir: ./train_data/
75
+ ext_op_transform_idx: 1
76
+ label_file_list:
77
+ - ./train_data/train_list.txt
78
+ transforms:
79
+ - DecodeImage:
80
+ img_mode: BGR
81
+ channel_first: false
82
+ - RecConAug:
83
+ prob: 0.5
84
+ ext_data_num: 2
85
+ image_shape: [48, 320, 3]
86
+ max_text_length: *max_text_length
87
+ - RecAug:
88
+ - MultiLabelEncode:
89
+ gtc_encode: NRTRLabelEncode
90
+ - KeepKeys:
91
+ keep_keys:
92
+ - image
93
+ - label_ctc
94
+ - label_gtc
95
+ - length
96
+ - valid_ratio
97
+ sampler:
98
+ name: MultiScaleSampler
99
+ scales: [[320, 32], [320, 48], [320, 64]]
100
+ first_bs: &bs 128
101
+ fix_bs: false
102
+ divided_factor: [8, 16] # w, h
103
+ is_training: True
104
+ loader:
105
+ shuffle: true
106
+ batch_size_per_card: *bs
107
+ drop_last: true
108
+ num_workers: 8
109
+ Eval:
110
+ dataset:
111
+ name: SimpleDataSet
112
+ data_dir: ./train_data
113
+ label_file_list:
114
+ - ./train_data/val_list.txt
115
+ transforms:
116
+ - DecodeImage:
117
+ img_mode: BGR
118
+ channel_first: false
119
+ - MultiLabelEncode:
120
+ gtc_encode: NRTRLabelEncode
121
+ - RecResizeImg:
122
+ image_shape: [3, 48, 320]
123
+ - KeepKeys:
124
+ keep_keys:
125
+ - image
126
+ - label_ctc
127
+ - label_gtc
128
+ - length
129
+ - valid_ratio
130
+ loader:
131
+ shuffle: false
132
+ drop_last: false
133
+ batch_size_per_card: 128
134
+ num_workers: 4
configs/rec/ch_PP-OCRv2/ch_PP-OCRv2_rec.yml ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ debug: false
3
+ use_gpu: true
4
+ epoch_num: 800
5
+ log_smooth_window: 20
6
+ print_batch_step: 10
7
+ output_dir: ./output/rec_mobile_pp-OCRv2
8
+ save_epoch_step: 3
9
+ eval_batch_step: [0, 2000]
10
+ cal_metric_during_train: true
11
+ pretrained_model:
12
+ checkpoints:
13
+ save_inference_dir:
14
+ use_visualdl: false
15
+ infer_img: doc/imgs_words/ch/word_1.jpg
16
+ character_dict_path: ppocr/utils/ppocr_keys_v1.txt
17
+ max_text_length: 25
18
+ infer_mode: false
19
+ use_space_char: true
20
+ distributed: true
21
+ save_res_path: ./output/rec/predicts_mobile_pp-OCRv2.txt
22
+
23
+
24
+ Optimizer:
25
+ name: Adam
26
+ beta1: 0.9
27
+ beta2: 0.999
28
+ lr:
29
+ name: Piecewise
30
+ decay_epochs : [700]
31
+ values : [0.001, 0.0001]
32
+ warmup_epoch: 5
33
+ regularizer:
34
+ name: L2
35
+ factor: 2.0e-05
36
+
37
+
38
+ Architecture:
39
+ model_type: rec
40
+ algorithm: CRNN
41
+ Transform:
42
+ Backbone:
43
+ name: MobileNetV1Enhance
44
+ scale: 0.5
45
+ Neck:
46
+ name: SequenceEncoder
47
+ encoder_type: rnn
48
+ hidden_size: 64
49
+ Head:
50
+ name: CTCHead
51
+ mid_channels: 96
52
+ fc_decay: 0.00002
53
+
54
+ Loss:
55
+ name: CTCLoss
56
+
57
+ PostProcess:
58
+ name: CTCLabelDecode
59
+
60
+ Metric:
61
+ name: RecMetric
62
+ main_indicator: acc
63
+
64
+ Train:
65
+ dataset:
66
+ name: SimpleDataSet
67
+ data_dir: ./train_data/
68
+ label_file_list:
69
+ - ./train_data/train_list.txt
70
+ transforms:
71
+ - DecodeImage:
72
+ img_mode: BGR
73
+ channel_first: false
74
+ - RecAug:
75
+ - CTCLabelEncode:
76
+ - RecResizeImg:
77
+ image_shape: [3, 32, 320]
78
+ - KeepKeys:
79
+ keep_keys:
80
+ - image
81
+ - label
82
+ - length
83
+ loader:
84
+ shuffle: true
85
+ batch_size_per_card: 128
86
+ drop_last: true
87
+ num_workers: 8
88
+ Eval:
89
+ dataset:
90
+ name: SimpleDataSet
91
+ data_dir: ./train_data
92
+ label_file_list:
93
+ - ./train_data/val_list.txt
94
+ transforms:
95
+ - DecodeImage:
96
+ img_mode: BGR
97
+ channel_first: false
98
+ - CTCLabelEncode:
99
+ - RecResizeImg:
100
+ image_shape: [3, 32, 320]
101
+ - KeepKeys:
102
+ keep_keys:
103
+ - image
104
+ - label
105
+ - length
106
+ loader:
107
+ shuffle: false
108
+ drop_last: false
109
+ batch_size_per_card: 128
110
+ num_workers: 8
configs/rec/ch_PP-OCRv2/ch_PP-OCRv2_rec_distillation.yml ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ debug: false
3
+ use_gpu: true
4
+ epoch_num: 800
5
+ log_smooth_window: 20
6
+ print_batch_step: 10
7
+ output_dir: ./output/rec_pp-OCRv2_distillation
8
+ save_epoch_step: 3
9
+ eval_batch_step: [0, 2000]
10
+ cal_metric_during_train: true
11
+ pretrained_model:
12
+ checkpoints:
13
+ save_inference_dir:
14
+ use_visualdl: false
15
+ infer_img: doc/imgs_words/ch/word_1.jpg
16
+ character_dict_path: ppocr/utils/ppocr_keys_v1.txt
17
+ max_text_length: 25
18
+ infer_mode: false
19
+ use_space_char: true
20
+ distributed: true
21
+ save_res_path: ./output/rec/predicts_pp-OCRv2_distillation.txt
22
+ amp_custom_black_list: ['matmul','matmul_v2','elementwise_add']
23
+
24
+
25
+ Optimizer:
26
+ name: Adam
27
+ beta1: 0.9
28
+ beta2: 0.999
29
+ lr:
30
+ name: Piecewise
31
+ decay_epochs : [700]
32
+ values : [0.001, 0.0001]
33
+ warmup_epoch: 5
34
+ regularizer:
35
+ name: L2
36
+ factor: 2.0e-05
37
+
38
+ Architecture:
39
+ model_type: &model_type "rec"
40
+ name: DistillationModel
41
+ algorithm: Distillation
42
+ Models:
43
+ Teacher:
44
+ pretrained:
45
+ freeze_params: false
46
+ return_all_feats: true
47
+ model_type: *model_type
48
+ algorithm: CRNN
49
+ Transform:
50
+ Backbone:
51
+ name: MobileNetV1Enhance
52
+ scale: 0.5
53
+ Neck:
54
+ name: SequenceEncoder
55
+ encoder_type: rnn
56
+ hidden_size: 64
57
+ Head:
58
+ name: CTCHead
59
+ mid_channels: 96
60
+ fc_decay: 0.00002
61
+ Student:
62
+ pretrained:
63
+ freeze_params: false
64
+ return_all_feats: true
65
+ model_type: *model_type
66
+ algorithm: CRNN
67
+ Transform:
68
+ Backbone:
69
+ name: MobileNetV1Enhance
70
+ scale: 0.5
71
+ Neck:
72
+ name: SequenceEncoder
73
+ encoder_type: rnn
74
+ hidden_size: 64
75
+ Head:
76
+ name: CTCHead
77
+ mid_channels: 96
78
+ fc_decay: 0.00002
79
+
80
+
81
+ Loss:
82
+ name: CombinedLoss
83
+ loss_config_list:
84
+ - DistillationCTCLoss:
85
+ weight: 1.0
86
+ model_name_list: ["Student", "Teacher"]
87
+ key: head_out
88
+ - DistillationDMLLoss:
89
+ weight: 1.0
90
+ act: "softmax"
91
+ use_log: true
92
+ model_name_pairs:
93
+ - ["Student", "Teacher"]
94
+ key: head_out
95
+ - DistillationDistanceLoss:
96
+ weight: 1.0
97
+ mode: "l2"
98
+ model_name_pairs:
99
+ - ["Student", "Teacher"]
100
+ key: backbone_out
101
+
102
+ PostProcess:
103
+ name: DistillationCTCLabelDecode
104
+ model_name: ["Student", "Teacher"]
105
+ key: head_out
106
+
107
+ Metric:
108
+ name: DistillationMetric
109
+ base_metric_name: RecMetric
110
+ main_indicator: acc
111
+ key: "Student"
112
+
113
+ Train:
114
+ dataset:
115
+ name: SimpleDataSet
116
+ data_dir: ./train_data/
117
+ label_file_list:
118
+ - ./train_data/train_list.txt
119
+ transforms:
120
+ - DecodeImage:
121
+ img_mode: BGR
122
+ channel_first: false
123
+ - RecAug:
124
+ - CTCLabelEncode:
125
+ - RecResizeImg:
126
+ image_shape: [3, 32, 320]
127
+ - KeepKeys:
128
+ keep_keys:
129
+ - image
130
+ - label
131
+ - length
132
+ loader:
133
+ shuffle: true
134
+ batch_size_per_card: 128
135
+ drop_last: true
136
+ num_sections: 1
137
+ num_workers: 8
138
+ Eval:
139
+ dataset:
140
+ name: SimpleDataSet
141
+ data_dir: ./train_data
142
+ label_file_list:
143
+ - ./train_data/val_list.txt
144
+ transforms:
145
+ - DecodeImage:
146
+ img_mode: BGR
147
+ channel_first: false
148
+ - CTCLabelEncode:
149
+ - RecResizeImg:
150
+ image_shape: [3, 32, 320]
151
+ - KeepKeys:
152
+ keep_keys:
153
+ - image
154
+ - label
155
+ - length
156
+ loader:
157
+ shuffle: false
158
+ drop_last: false
159
+ batch_size_per_card: 128
160
+ num_workers: 8
configs/rec/ch_PP-OCRv2/ch_PP-OCRv2_rec_enhanced_ctc_loss.yml ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ debug: false
3
+ use_gpu: true
4
+ epoch_num: 800
5
+ log_smooth_window: 20
6
+ print_batch_step: 10
7
+ output_dir: ./output/rec_mobile_pp-OCRv2_enhanced_ctc_loss
8
+ save_epoch_step: 3
9
+ eval_batch_step: [0, 2000]
10
+ cal_metric_during_train: true
11
+ pretrained_model:
12
+ checkpoints:
13
+ save_inference_dir:
14
+ use_visualdl: false
15
+ infer_img: doc/imgs_words/ch/word_1.jpg
16
+ character_dict_path: ppocr/utils/ppocr_keys_v1.txt
17
+ max_text_length: 25
18
+ infer_mode: false
19
+ use_space_char: true
20
+ distributed: true
21
+ save_res_path: ./output/rec/predicts_mobile_pp-OCRv2_enhanced_ctc_loss.txt
22
+
23
+
24
+ Optimizer:
25
+ name: Adam
26
+ beta1: 0.9
27
+ beta2: 0.999
28
+ lr:
29
+ name: Piecewise
30
+ decay_epochs : [700]
31
+ values : [0.001, 0.0001]
32
+ warmup_epoch: 5
33
+ regularizer:
34
+ name: L2
35
+ factor: 2.0e-05
36
+
37
+
38
+ Architecture:
39
+ model_type: rec
40
+ algorithm: CRNN
41
+ Transform:
42
+ Backbone:
43
+ name: MobileNetV1Enhance
44
+ scale: 0.5
45
+ Neck:
46
+ name: SequenceEncoder
47
+ encoder_type: rnn
48
+ hidden_size: 64
49
+ Head:
50
+ name: CTCHead
51
+ mid_channels: 96
52
+ fc_decay: 0.00002
53
+ return_feats: true
54
+
55
+ Loss:
56
+ name: CombinedLoss
57
+ loss_config_list:
58
+ - CTCLoss:
59
+ use_focal_loss: false
60
+ weight: 1.0
61
+ - CenterLoss:
62
+ weight: 0.05
63
+ num_classes: 6625
64
+ feat_dim: 96
65
+ center_file_path:
66
+ # you can also try to add ace loss on your own dataset
67
+ # - ACELoss:
68
+ # weight: 0.1
69
+
70
+ PostProcess:
71
+ name: CTCLabelDecode
72
+
73
+ Metric:
74
+ name: RecMetric
75
+ main_indicator: acc
76
+
77
+ Train:
78
+ dataset:
79
+ name: SimpleDataSet
80
+ data_dir: ./train_data/
81
+ label_file_list:
82
+ - ./train_data/train_list.txt
83
+ transforms:
84
+ - DecodeImage:
85
+ img_mode: BGR
86
+ channel_first: false
87
+ - RecAug:
88
+ - CTCLabelEncode:
89
+ - RecResizeImg:
90
+ image_shape: [3, 32, 320]
91
+ - KeepKeys:
92
+ keep_keys:
93
+ - image
94
+ - label
95
+ - length
96
+ - label_ace
97
+ loader:
98
+ shuffle: true
99
+ batch_size_per_card: 128
100
+ drop_last: true
101
+ num_workers: 8
102
+ Eval:
103
+ dataset:
104
+ name: SimpleDataSet
105
+ data_dir: ./train_data
106
+ label_file_list:
107
+ - ./train_data/val_list.txt
108
+ transforms:
109
+ - DecodeImage:
110
+ img_mode: BGR
111
+ channel_first: false
112
+ - CTCLabelEncode:
113
+ - RecResizeImg:
114
+ image_shape: [3, 32, 320]
115
+ - KeepKeys:
116
+ keep_keys:
117
+ - image
118
+ - label
119
+ - length
120
+ loader:
121
+ shuffle: false
122
+ drop_last: false
123
+ batch_size_per_card: 128
124
+ num_workers: 8
configs/rec/ch_ppocr_v2.0/rec_chinese_common_train_v2.0.yml ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: true
3
+ epoch_num: 500
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec_chinese_common_v2.0
7
+ save_epoch_step: 3
8
+ # evaluation is run every 5000 iterations after the 4000th iteration
9
+ eval_batch_step: [0, 2000]
10
+ cal_metric_during_train: True
11
+ pretrained_model:
12
+ checkpoints:
13
+ save_inference_dir:
14
+ use_visualdl: False
15
+ infer_img: doc/imgs_words/ch/word_1.jpg
16
+ # for data or label process
17
+ character_dict_path: ppocr/utils/ppocr_keys_v1.txt
18
+ max_text_length: 25
19
+ infer_mode: False
20
+ use_space_char: True
21
+ save_res_path: ./output/rec/predicts_chinese_common_v2.0.txt
22
+
23
+
24
+ Optimizer:
25
+ name: Adam
26
+ beta1: 0.9
27
+ beta2: 0.999
28
+ lr:
29
+ name: Cosine
30
+ learning_rate: 0.001
31
+ warmup_epoch: 5
32
+ regularizer:
33
+ name: 'L2'
34
+ factor: 0.00004
35
+
36
+ Architecture:
37
+ model_type: rec
38
+ algorithm: CRNN
39
+ Transform:
40
+ Backbone:
41
+ name: ResNet
42
+ layers: 34
43
+ Neck:
44
+ name: SequenceEncoder
45
+ encoder_type: rnn
46
+ hidden_size: 256
47
+ Head:
48
+ name: CTCHead
49
+ fc_decay: 0.00004
50
+
51
+ Loss:
52
+ name: CTCLoss
53
+
54
+ PostProcess:
55
+ name: CTCLabelDecode
56
+
57
+ Metric:
58
+ name: RecMetric
59
+ main_indicator: acc
60
+
61
+ Train:
62
+ dataset:
63
+ name: SimpleDataSet
64
+ data_dir: ./train_data/
65
+ label_file_list: ["./train_data/train_list.txt"]
66
+ transforms:
67
+ - DecodeImage: # load image
68
+ img_mode: BGR
69
+ channel_first: False
70
+ - RecAug:
71
+ - CTCLabelEncode: # Class handling label
72
+ - RecResizeImg:
73
+ image_shape: [3, 32, 320]
74
+ - KeepKeys:
75
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
76
+ loader:
77
+ shuffle: True
78
+ batch_size_per_card: 256
79
+ drop_last: True
80
+ num_workers: 8
81
+
82
+ Eval:
83
+ dataset:
84
+ name: SimpleDataSet
85
+ data_dir: ./train_data/
86
+ label_file_list: ["./train_data/val_list.txt"]
87
+ transforms:
88
+ - DecodeImage: # load image
89
+ img_mode: BGR
90
+ channel_first: False
91
+ - CTCLabelEncode: # Class handling label
92
+ - RecResizeImg:
93
+ image_shape: [3, 32, 320]
94
+ - KeepKeys:
95
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
96
+ loader:
97
+ shuffle: False
98
+ drop_last: False
99
+ batch_size_per_card: 256
100
+ num_workers: 8
configs/rec/ch_ppocr_v2.0/rec_chinese_lite_train_v2.0.yml ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ use_gpu: true
3
+ epoch_num: 500
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec_chinese_lite_v2.0
7
+ save_epoch_step: 3
8
+ # evaluation is run every 5000 iterations after the 4000th iteration
9
+ eval_batch_step: [0, 2000]
10
+ cal_metric_during_train: True
11
+ pretrained_model:
12
+ checkpoints:
13
+ save_inference_dir:
14
+ use_visualdl: False
15
+ infer_img: doc/imgs_words/ch/word_1.jpg
16
+ # for data or label process
17
+ character_dict_path: ppocr/utils/ppocr_keys_v1.txt
18
+ max_text_length: 25
19
+ infer_mode: False
20
+ use_space_char: True
21
+ save_res_path: ./output/rec/predicts_chinese_lite_v2.0.txt
22
+
23
+
24
+ Optimizer:
25
+ name: Adam
26
+ beta1: 0.9
27
+ beta2: 0.999
28
+ lr:
29
+ name: Cosine
30
+ learning_rate: 0.001
31
+ warmup_epoch: 5
32
+ regularizer:
33
+ name: 'L2'
34
+ factor: 0.00001
35
+
36
+ Architecture:
37
+ model_type: rec
38
+ algorithm: CRNN
39
+ Transform:
40
+ Backbone:
41
+ name: MobileNetV3
42
+ scale: 0.5
43
+ model_name: small
44
+ small_stride: [1, 2, 2, 2]
45
+ Neck:
46
+ name: SequenceEncoder
47
+ encoder_type: rnn
48
+ hidden_size: 48
49
+ Head:
50
+ name: CTCHead
51
+ fc_decay: 0.00001
52
+
53
+ Loss:
54
+ name: CTCLoss
55
+
56
+ PostProcess:
57
+ name: CTCLabelDecode
58
+
59
+ Metric:
60
+ name: RecMetric
61
+ main_indicator: acc
62
+
63
+ Train:
64
+ dataset:
65
+ name: SimpleDataSet
66
+ data_dir: ./train_data/
67
+ label_file_list: ["./train_data/train_list.txt"]
68
+ transforms:
69
+ - DecodeImage: # load image
70
+ img_mode: BGR
71
+ channel_first: False
72
+ - RecAug:
73
+ - CTCLabelEncode: # Class handling label
74
+ - RecResizeImg:
75
+ image_shape: [3, 32, 320]
76
+ - KeepKeys:
77
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
78
+ loader:
79
+ shuffle: True
80
+ batch_size_per_card: 256
81
+ drop_last: True
82
+ num_workers: 8
83
+
84
+ Eval:
85
+ dataset:
86
+ name: SimpleDataSet
87
+ data_dir: ./train_data
88
+ label_file_list: ["./train_data/val_list.txt"]
89
+ transforms:
90
+ - DecodeImage: # load image
91
+ img_mode: BGR
92
+ channel_first: False
93
+ - CTCLabelEncode: # Class handling label
94
+ - RecResizeImg:
95
+ image_shape: [3, 32, 320]
96
+ - KeepKeys:
97
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
98
+ loader:
99
+ shuffle: False
100
+ drop_last: False
101
+ batch_size_per_card: 256
102
+ num_workers: 8
configs/rec/multi_language/generate_multi_language_configs.py ADDED
@@ -0,0 +1,226 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ import yaml
16
+ from argparse import ArgumentParser, RawDescriptionHelpFormatter
17
+ import os.path
18
+ import logging
19
+ logging.basicConfig(level=logging.INFO)
20
+
21
+ support_list = {
22
+ 'it': 'italian',
23
+ 'xi': 'spanish',
24
+ 'pu': 'portuguese',
25
+ 'ru': 'russian',
26
+ 'ar': 'arabic',
27
+ 'ta': 'tamil',
28
+ 'ug': 'uyghur',
29
+ 'fa': 'persian',
30
+ 'ur': 'urdu',
31
+ 'rs': 'serbian latin',
32
+ 'oc': 'occitan',
33
+ 'rsc': 'serbian cyrillic',
34
+ 'bg': 'bulgarian',
35
+ 'uk': 'ukranian',
36
+ 'be': 'belarusian',
37
+ 'te': 'telugu',
38
+ 'ka': 'kannada',
39
+ 'chinese_cht': 'chinese tradition',
40
+ 'hi': 'hindi',
41
+ 'mr': 'marathi',
42
+ 'ne': 'nepali',
43
+ }
44
+
45
+ latin_lang = [
46
+ 'af', 'az', 'bs', 'cs', 'cy', 'da', 'de', 'es', 'et', 'fr', 'ga', 'hr',
47
+ 'hu', 'id', 'is', 'it', 'ku', 'la', 'lt', 'lv', 'mi', 'ms', 'mt', 'nl',
48
+ 'no', 'oc', 'pi', 'pl', 'pt', 'ro', 'rs_latin', 'sk', 'sl', 'sq', 'sv',
49
+ 'sw', 'tl', 'tr', 'uz', 'vi', 'latin'
50
+ ]
51
+ arabic_lang = ['ar', 'fa', 'ug', 'ur']
52
+ cyrillic_lang = [
53
+ 'ru', 'rs_cyrillic', 'be', 'bg', 'uk', 'mn', 'abq', 'ady', 'kbd', 'ava',
54
+ 'dar', 'inh', 'che', 'lbe', 'lez', 'tab', 'cyrillic'
55
+ ]
56
+ devanagari_lang = [
57
+ 'hi', 'mr', 'ne', 'bh', 'mai', 'ang', 'bho', 'mah', 'sck', 'new', 'gom',
58
+ 'sa', 'bgc', 'devanagari'
59
+ ]
60
+ multi_lang = latin_lang + arabic_lang + cyrillic_lang + devanagari_lang
61
+
62
+ assert (os.path.isfile("./rec_multi_language_lite_train.yml")
63
+ ), "Loss basic configuration file rec_multi_language_lite_train.yml.\
64
+ You can download it from \
65
+ https://github.com/PaddlePaddle/PaddleOCR/tree/dygraph/configs/rec/multi_language/"
66
+
67
+ global_config = yaml.load(
68
+ open("./rec_multi_language_lite_train.yml", 'rb'), Loader=yaml.Loader)
69
+ project_path = os.path.abspath(os.path.join(os.getcwd(), "../../../"))
70
+
71
+
72
+ class ArgsParser(ArgumentParser):
73
+ def __init__(self):
74
+ super(ArgsParser, self).__init__(
75
+ formatter_class=RawDescriptionHelpFormatter)
76
+ self.add_argument(
77
+ "-o", "--opt", nargs='+', help="set configuration options")
78
+ self.add_argument(
79
+ "-l",
80
+ "--language",
81
+ nargs='+',
82
+ help="set language type, support {}".format(support_list))
83
+ self.add_argument(
84
+ "--train",
85
+ type=str,
86
+ help="you can use this command to change the train dataset default path"
87
+ )
88
+ self.add_argument(
89
+ "--val",
90
+ type=str,
91
+ help="you can use this command to change the eval dataset default path"
92
+ )
93
+ self.add_argument(
94
+ "--dict",
95
+ type=str,
96
+ help="you can use this command to change the dictionary default path"
97
+ )
98
+ self.add_argument(
99
+ "--data_dir",
100
+ type=str,
101
+ help="you can use this command to change the dataset default root path"
102
+ )
103
+
104
+ def parse_args(self, argv=None):
105
+ args = super(ArgsParser, self).parse_args(argv)
106
+ args.opt = self._parse_opt(args.opt)
107
+ args.language = self._set_language(args.language)
108
+ return args
109
+
110
+ def _parse_opt(self, opts):
111
+ config = {}
112
+ if not opts:
113
+ return config
114
+ for s in opts:
115
+ s = s.strip()
116
+ k, v = s.split('=')
117
+ config[k] = yaml.load(v, Loader=yaml.Loader)
118
+ return config
119
+
120
+ def _set_language(self, type):
121
+ lang = type[0]
122
+ assert (type), "please use -l or --language to choose language type"
123
+ assert(
124
+ lang in support_list.keys() or lang in multi_lang
125
+ ),"the sub_keys(-l or --language) can only be one of support list: \n{},\nbut get: {}, " \
126
+ "please check your running command".format(multi_lang, type)
127
+ if lang in latin_lang:
128
+ lang = "latin"
129
+ elif lang in arabic_lang:
130
+ lang = "arabic"
131
+ elif lang in cyrillic_lang:
132
+ lang = "cyrillic"
133
+ elif lang in devanagari_lang:
134
+ lang = "devanagari"
135
+ global_config['Global'][
136
+ 'character_dict_path'] = 'ppocr/utils/dict/{}_dict.txt'.format(lang)
137
+ global_config['Global'][
138
+ 'output_dir'] = './output/rec_{}_lite'.format(lang)
139
+ global_config['Train']['dataset'][
140
+ 'label_file_list'] = ["train_data/{}_train.txt".format(lang)]
141
+ global_config['Eval']['dataset'][
142
+ 'label_file_list'] = ["train_data/{}_val.txt".format(lang)]
143
+ global_config['Global']['character_type'] = lang
144
+ assert (
145
+ os.path.isfile(
146
+ os.path.join(project_path, global_config['Global'][
147
+ 'character_dict_path']))
148
+ ), "Loss default dictionary file {}_dict.txt.You can download it from \
149
+ https://github.com/PaddlePaddle/PaddleOCR/tree/dygraph/ppocr/utils/dict/".format(
150
+ lang)
151
+ return lang
152
+
153
+
154
+ def merge_config(config):
155
+ """
156
+ Merge config into global config.
157
+ Args:
158
+ config (dict): Config to be merged.
159
+ Returns: global config
160
+ """
161
+ for key, value in config.items():
162
+ if "." not in key:
163
+ if isinstance(value, dict) and key in global_config:
164
+ global_config[key].update(value)
165
+ else:
166
+ global_config[key] = value
167
+ else:
168
+ sub_keys = key.split('.')
169
+ assert (
170
+ sub_keys[0] in global_config
171
+ ), "the sub_keys can only be one of global_config: {}, but get: {}, please check your running command".format(
172
+ global_config.keys(), sub_keys[0])
173
+ cur = global_config[sub_keys[0]]
174
+ for idx, sub_key in enumerate(sub_keys[1:]):
175
+ if idx == len(sub_keys) - 2:
176
+ cur[sub_key] = value
177
+ else:
178
+ cur = cur[sub_key]
179
+
180
+
181
+ def loss_file(path):
182
+ assert (
183
+ os.path.exists(path)
184
+ ), "There is no such file:{},Please do not forget to put in the specified file".format(
185
+ path)
186
+
187
+
188
+ if __name__ == '__main__':
189
+ FLAGS = ArgsParser().parse_args()
190
+ merge_config(FLAGS.opt)
191
+ save_file_path = 'rec_{}_lite_train.yml'.format(FLAGS.language)
192
+ if os.path.isfile(save_file_path):
193
+ os.remove(save_file_path)
194
+
195
+ if FLAGS.train:
196
+ global_config['Train']['dataset']['label_file_list'] = [FLAGS.train]
197
+ train_label_path = os.path.join(project_path, FLAGS.train)
198
+ loss_file(train_label_path)
199
+ if FLAGS.val:
200
+ global_config['Eval']['dataset']['label_file_list'] = [FLAGS.val]
201
+ eval_label_path = os.path.join(project_path, FLAGS.val)
202
+ loss_file(eval_label_path)
203
+ if FLAGS.dict:
204
+ global_config['Global']['character_dict_path'] = FLAGS.dict
205
+ dict_path = os.path.join(project_path, FLAGS.dict)
206
+ loss_file(dict_path)
207
+ if FLAGS.data_dir:
208
+ global_config['Eval']['dataset']['data_dir'] = FLAGS.data_dir
209
+ global_config['Train']['dataset']['data_dir'] = FLAGS.data_dir
210
+ data_dir = os.path.join(project_path, FLAGS.data_dir)
211
+ loss_file(data_dir)
212
+
213
+ with open(save_file_path, 'w') as f:
214
+ yaml.dump(
215
+ dict(global_config), f, default_flow_style=False, sort_keys=False)
216
+ logging.info("Project path is :{}".format(project_path))
217
+ logging.info("Train list path set to :{}".format(global_config['Train'][
218
+ 'dataset']['label_file_list'][0]))
219
+ logging.info("Eval list path set to :{}".format(global_config['Eval'][
220
+ 'dataset']['label_file_list'][0]))
221
+ logging.info("Dataset root path set to :{}".format(global_config['Eval'][
222
+ 'dataset']['data_dir']))
223
+ logging.info("Dict path set to :{}".format(global_config['Global'][
224
+ 'character_dict_path']))
225
+ logging.info("Config file set to :configs/rec/multi_language/{}".
226
+ format(save_file_path))