From 8d9324cab134dd3982e5f9eac093fe4d1a54978c Mon Sep 17 00:00:00 2001 From: tink2123 Date: Wed, 3 Jun 2020 20:07:58 +0800 Subject: [PATCH] set drop_last=false --- configs/det/det_mv3_db.yml | 1 + configs/det/det_mv3_east.yml | 1 + configs/det/det_r50_vd_db.yml | 1 + configs/det/det_r50_vd_east.yml | 1 + configs/rec/rec_chinese_lite_train.yml | 2 +- configs/rec/rec_icdar15_train.yml | 4 ++-- configs/rec/rec_mv3_none_bilstm_ctc.yml | 2 +- configs/rec/rec_mv3_none_none_ctc.yml | 2 +- configs/rec/rec_mv3_tps_bilstm_attn.yml | 2 +- configs/rec/rec_mv3_tps_bilstm_ctc.yml | 2 +- configs/rec/rec_r34_vd_none_bilstm_ctc.yml | 2 +- configs/rec/rec_r34_vd_none_none_ctc.yml | 2 +- configs/rec/rec_r34_vd_tps_bilstm_attn.yml | 2 +- configs/rec/rec_r34_vd_tps_bilstm_ctc.yml | 2 +- ppocr/data/det/dataset_traversal.py | 6 ++++-- ppocr/data/rec/dataset_traversal.py | 10 ++++++++-- 16 files changed, 27 insertions(+), 15 deletions(-) diff --git a/configs/det/det_mv3_db.yml b/configs/det/det_mv3_db.yml index 8efa66a9..75500f9e 100755 --- a/configs/det/det_mv3_db.yml +++ b/configs/det/det_mv3_db.yml @@ -9,6 +9,7 @@ Global: eval_batch_step: 5000 train_batch_size_per_card: 16 test_batch_size_per_card: 16 + drop_last: false image_shape: [3, 640, 640] reader_yml: ./configs/det/det_db_icdar15_reader.yml pretrain_weights: ./pretrain_models/MobileNetV3_large_x0_5_pretrained/ diff --git a/configs/det/det_mv3_east.yml b/configs/det/det_mv3_east.yml index b6f37256..efb32d49 100755 --- a/configs/det/det_mv3_east.yml +++ b/configs/det/det_mv3_east.yml @@ -9,6 +9,7 @@ Global: eval_batch_step: 5000 train_batch_size_per_card: 16 test_batch_size_per_card: 16 + drop_last: false image_shape: [3, 512, 512] reader_yml: ./configs/det/det_east_icdar15_reader.yml pretrain_weights: ./pretrain_models/MobileNetV3_large_x0_5_pretrained/ diff --git a/configs/det/det_r50_vd_db.yml b/configs/det/det_r50_vd_db.yml index 6e3b3b9e..eaad7fbd 100755 --- a/configs/det/det_r50_vd_db.yml +++ b/configs/det/det_r50_vd_db.yml @@ -10,6 +10,7 @@ Global: train_batch_size_per_card: 8 test_batch_size_per_card: 16 image_shape: [3, 640, 640] + drop_last: false reader_yml: ./configs/det/det_db_icdar15_reader.yml pretrain_weights: ./pretrain_models/ResNet50_vd_ssld_pretrained/ save_res_path: ./output/det_db/predicts_db.txt diff --git a/configs/det/det_r50_vd_east.yml b/configs/det/det_r50_vd_east.yml index bb16f9fa..e05bce3f 100755 --- a/configs/det/det_r50_vd_east.yml +++ b/configs/det/det_r50_vd_east.yml @@ -10,6 +10,7 @@ Global: train_batch_size_per_card: 8 test_batch_size_per_card: 16 image_shape: [3, 512, 512] + drop_last: false reader_yml: ./configs/det/det_east_icdar15_reader.yml pretrain_weights: ./pretrain_models/ResNet50_vd_ssld_pretrained/ save_res_path: ./output/det_east/predicts_east.txt diff --git a/configs/rec/rec_chinese_lite_train.yml b/configs/rec/rec_chinese_lite_train.yml index bbd2590c..4517f3e2 100755 --- a/configs/rec/rec_chinese_lite_train.yml +++ b/configs/rec/rec_chinese_lite_train.yml @@ -8,8 +8,8 @@ Global: save_epoch_step: 3 eval_batch_step: 2000 train_batch_size_per_card: 256 - drop_last: true test_batch_size_per_card: 256 + drop_last: false image_shape: [3, 32, 320] max_text_length: 25 character_type: ch diff --git a/configs/rec/rec_icdar15_train.yml b/configs/rec/rec_icdar15_train.yml index 1cca2def..b783cc2f 100755 --- a/configs/rec/rec_icdar15_train.yml +++ b/configs/rec/rec_icdar15_train.yml @@ -8,14 +8,14 @@ Global: save_epoch_step: 300 eval_batch_step: 500 train_batch_size_per_card: 256 - drop_last: true test_batch_size_per_card: 256 + drop_last: false image_shape: [3, 32, 100] max_text_length: 25 character_type: en loss_type: ctc reader_yml: ./configs/rec/rec_icdar15_reader.yml - pretrain_weights: ./pretrain_models/rec_mv3_none_bilstm_ctc/best_accuracy + pretrain_weights: checkpoints: save_inference_dir: infer_img: diff --git a/configs/rec/rec_mv3_none_bilstm_ctc.yml b/configs/rec/rec_mv3_none_bilstm_ctc.yml index 7bae1bd1..35b5206c 100755 --- a/configs/rec/rec_mv3_none_bilstm_ctc.yml +++ b/configs/rec/rec_mv3_none_bilstm_ctc.yml @@ -8,8 +8,8 @@ Global: save_epoch_step: 3 eval_batch_step: 2000 train_batch_size_per_card: 256 - drop_last: true test_batch_size_per_card: 256 + drop_last: false image_shape: [3, 32, 100] max_text_length: 25 character_type: en diff --git a/configs/rec/rec_mv3_none_none_ctc.yml b/configs/rec/rec_mv3_none_none_ctc.yml index 3f8a67b9..72191349 100755 --- a/configs/rec/rec_mv3_none_none_ctc.yml +++ b/configs/rec/rec_mv3_none_none_ctc.yml @@ -8,8 +8,8 @@ Global: save_epoch_step: 3 eval_batch_step: 2000 train_batch_size_per_card: 256 - drop_last: true test_batch_size_per_card: 256 + drop_last: false image_shape: [3, 32, 100] max_text_length: 25 character_type: en diff --git a/configs/rec/rec_mv3_tps_bilstm_attn.yml b/configs/rec/rec_mv3_tps_bilstm_attn.yml index 2dbb9d07..c4f64f0a 100755 --- a/configs/rec/rec_mv3_tps_bilstm_attn.yml +++ b/configs/rec/rec_mv3_tps_bilstm_attn.yml @@ -8,8 +8,8 @@ Global: save_epoch_step: 3 eval_batch_step: 2000 train_batch_size_per_card: 256 - drop_last: true test_batch_size_per_card: 256 + drop_last: false image_shape: [3, 32, 100] max_text_length: 25 character_type: en diff --git a/configs/rec/rec_mv3_tps_bilstm_ctc.yml b/configs/rec/rec_mv3_tps_bilstm_ctc.yml index 2892452b..8236dd8a 100755 --- a/configs/rec/rec_mv3_tps_bilstm_ctc.yml +++ b/configs/rec/rec_mv3_tps_bilstm_ctc.yml @@ -8,8 +8,8 @@ Global: save_epoch_step: 3 eval_batch_step: 2000 train_batch_size_per_card: 256 - drop_last: true test_batch_size_per_card: 256 + drop_last: false image_shape: [3, 32, 100] max_text_length: 25 character_type: en diff --git a/configs/rec/rec_r34_vd_none_bilstm_ctc.yml b/configs/rec/rec_r34_vd_none_bilstm_ctc.yml index 5f1437fc..c234cbb7 100755 --- a/configs/rec/rec_r34_vd_none_bilstm_ctc.yml +++ b/configs/rec/rec_r34_vd_none_bilstm_ctc.yml @@ -8,8 +8,8 @@ Global: save_epoch_step: 3 eval_batch_step: 2000 train_batch_size_per_card: 256 - drop_last: true test_batch_size_per_card: 256 + drop_last: false image_shape: [3, 32, 100] max_text_length: 25 character_type: en diff --git a/configs/rec/rec_r34_vd_none_none_ctc.yml b/configs/rec/rec_r34_vd_none_none_ctc.yml index ae608755..457c79ad 100755 --- a/configs/rec/rec_r34_vd_none_none_ctc.yml +++ b/configs/rec/rec_r34_vd_none_none_ctc.yml @@ -8,8 +8,8 @@ Global: save_epoch_step: 3 eval_batch_step: 2000 train_batch_size_per_card: 256 - drop_last: true test_batch_size_per_card: 256 + drop_last: false image_shape: [3, 32, 100] max_text_length: 25 character_type: en diff --git a/configs/rec/rec_r34_vd_tps_bilstm_attn.yml b/configs/rec/rec_r34_vd_tps_bilstm_attn.yml index 989fbb46..2f351ae4 100755 --- a/configs/rec/rec_r34_vd_tps_bilstm_attn.yml +++ b/configs/rec/rec_r34_vd_tps_bilstm_attn.yml @@ -8,8 +8,8 @@ Global: save_epoch_step: 3 eval_batch_step: 2000 train_batch_size_per_card: 256 - drop_last: true test_batch_size_per_card: 256 + drop_last: false image_shape: [3, 32, 100] max_text_length: 25 character_type: en diff --git a/configs/rec/rec_r34_vd_tps_bilstm_ctc.yml b/configs/rec/rec_r34_vd_tps_bilstm_ctc.yml index 50f0ff63..93021709 100755 --- a/configs/rec/rec_r34_vd_tps_bilstm_ctc.yml +++ b/configs/rec/rec_r34_vd_tps_bilstm_ctc.yml @@ -8,8 +8,8 @@ Global: save_epoch_step: 3 eval_batch_step: 2000 train_batch_size_per_card: 256 - drop_last: true test_batch_size_per_card: 256 + drop_last: false image_shape: [3, 32, 100] max_text_length: 25 character_type: en diff --git a/ppocr/data/det/dataset_traversal.py b/ppocr/data/det/dataset_traversal.py index 272d7317..76fa6408 100644 --- a/ppocr/data/det/dataset_traversal.py +++ b/ppocr/data/det/dataset_traversal.py @@ -32,6 +32,7 @@ class TrainReader(object): self.num_workers = params['num_workers'] self.label_file_path = params['label_file_path'] self.batch_size = params['train_batch_size_per_card'] + self.drop_last = params['drop_last'] assert 'process_function' in params,\ "absence process_function in Reader" self.process = create_module(params['process_function'])(params) @@ -61,8 +62,9 @@ class TrainReader(object): if len(batch_outs) == self.batch_size: yield batch_outs batch_outs = [] - if len(batch_outs) != 0: - yield batch_outs + if not self.drop_last: + if len(batch_outs) != 0: + yield batch_outs return batch_iter_reader diff --git a/ppocr/data/rec/dataset_traversal.py b/ppocr/data/rec/dataset_traversal.py index 21fdc352..6c2b7a1a 100755 --- a/ppocr/data/rec/dataset_traversal.py +++ b/ppocr/data/rec/dataset_traversal.py @@ -42,6 +42,7 @@ class LMDBReader(object): self.max_text_length = params['max_text_length'] self.mode = params['mode'] self.drop_last = False + self.tps = False if "tps" in params: self.tps = True if params['mode'] == 'train': @@ -180,6 +181,9 @@ class SimpleReader(object): self.max_text_length = params['max_text_length'] self.mode = params['mode'] self.infer_img = params['infer_img'] + self.tps = False + if "tps" in params: + self.tps = True self.drop_last = False if params['mode'] == 'train': self.batch_size = params['train_batch_size_per_card'] @@ -192,7 +196,7 @@ class SimpleReader(object): process_id = 0 def sample_iter_reader(): - if self.infer_img is not None: + if self.mode != 'train' and self.infer_img is not None: image_file_list = get_image_file_list(self.infer_img) for single_img in image_file_list: img = cv2.imread(single_img) @@ -201,7 +205,9 @@ class SimpleReader(object): norm_img = process_image( img=img, image_shape=self.image_shape, - char_ops=self.char_ops) + char_ops=self.char_ops, + tps=self.tps, + infer_mode=True) yield norm_img else: with open(self.label_file_path, "rb") as fin: -- GitLab