diff --git a/configs/det/det_mv3_db.yml b/configs/det/det_mv3_db.yml index 8efa66a92d6e8c031efef48d738d9690bcc5554c..75500f9e1c0f40be56b2494f8ea7ddcc167913e9 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 b6f37256291912757cd1d5b98d1f745d08452fd6..efb32d4987538099fb4d5ea7d823132480ededa2 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 6e3b3b9e264b29fcac2b2b9b20ee2f88d5c975f3..eaad7fbda4978951acff06801d5710a23a60dbb9 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 bb16f9fa12424db293ba498e78b00f279f1a7ff6..e05bce3f5965c9831c51cda9d7ba96d6a45256b2 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 bbd2590c4843377ee4dc954cfd487f067ca6faf0..4517f3e26a6440b7ca2ad2d006e8083167ad6eae 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 1cca2defb936a212eb262a402753534f387cbaa7..b783cc2fb27dce2bd635a279b71b4a4cd79a94cf 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 7bae1bd1f136e27a900e1425c6d9231d331e1a68..35b5206c90e35c544c42167dc3758b0ec5c0377e 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 3f8a67b9b9333eb283b9f1c956917c07dd4d9eff..7219134983d930a78989fc5f7c1df3a996edb6cc 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 2dbb9d0780aee8e1d9b5eb93a46ea66b1fa54486..c4f64f0ae7a0a98a08efc4d80eddf211775e468c 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 2892452b7539721a7a8d5279650b32832f441883..8236dd8ab8bf5bedc8797c89700a0d6097dcd6d6 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 5f1437fc3fecf9c24374b758d2c819a3845195d5..c234cbb7adc1b392baa85ad05a6aeef74e1896aa 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 ae608755ac271d49627c129f7a91bf34b2d1ecb1..457c79adc41abae0a41a9d2a5f30345162ea4734 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 989fbb462274a085f53abd4def4da1bb174e3a2c..2f351ae4324be2c208cb5c56f711c0a9bfaaef85 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 50f0ff63a585c116d27d41d02183971f0aa47e10..9302170921c9f797d3c981cbd8773b56185f98f6 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 272d7317c9a98a695dad3451bfc108cc29e74bce..76fa6408fee93a25cdebdd1cca05e1dfaab4169c 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 21fdc352281dda842ad5958ed473efbe9ca90635..6c2b7a1aeeb26a70f8b632afb299837e17b96d58 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: