From 0e9c6630eeab1533519c4bcea1808abc074eca5b Mon Sep 17 00:00:00 2001 From: huangjun12 <2399845970@qq.com> Date: Wed, 24 May 2023 14:59:36 +0800 Subject: [PATCH] fix det v4 bug in dynamic ratio (#9874) * fix set bug * refine 960 to 640 * fix details * add epoch num * add rep export * use db head --- .../det/ch_PP-OCRv4/ch_PP-OCRv4_det_student.yml | 15 +++++++-------- .../det/ch_PP-OCRv4/ch_PP-OCRv4_det_teacher.yml | 12 ++++++------ ppocr/data/simple_dataset.py | 8 ++++---- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/configs/det/ch_PP-OCRv4/ch_PP-OCRv4_det_student.yml b/configs/det/ch_PP-OCRv4/ch_PP-OCRv4_det_student.yml index 04caf850..39b260cf 100644 --- a/configs/det/ch_PP-OCRv4/ch_PP-OCRv4_det_student.yml +++ b/configs/det/ch_PP-OCRv4/ch_PP-OCRv4_det_student.yml @@ -1,10 +1,10 @@ Global: debug: false use_gpu: true - epoch_num: 500 + epoch_num: &epoch_num 500 log_smooth_window: 20 print_batch_step: 100 - save_model_dir: ./output/ch_PP-OCRv3_mv3_cbnlocal_shrink/ + save_model_dir: ./output/ch_PP-OCRv4 save_epoch_step: 10 eval_batch_step: - 0 @@ -31,9 +31,8 @@ Architecture: out_channels: 96 shortcut: True Head: - name: PFHeadLocal + name: DBHead k: 50 - mode: "small" Loss: name: DBLoss @@ -96,19 +95,19 @@ Train: - 3 - EastRandomCropData: size: - - 960 - - 960 + - 640 + - 640 max_tries: 50 keep_ratio: true - MakeBorderMap: shrink_ratio: 0.4 thresh_min: 0.3 thresh_max: 0.7 - total_epoch: 500 + total_epoch: *epoch_num - MakeShrinkMap: shrink_ratio: 0.4 min_text_size: 8 - total_epoch: 500 + total_epoch: *epoch_num - NormalizeImage: scale: 1./255. mean: diff --git a/configs/det/ch_PP-OCRv4/ch_PP-OCRv4_det_teacher.yml b/configs/det/ch_PP-OCRv4/ch_PP-OCRv4_det_teacher.yml index 5109f490..b58af1cc 100644 --- a/configs/det/ch_PP-OCRv4/ch_PP-OCRv4_det_teacher.yml +++ b/configs/det/ch_PP-OCRv4/ch_PP-OCRv4_det_teacher.yml @@ -1,10 +1,10 @@ Global: debug: false use_gpu: true - epoch_num: 500 + epoch_num: &epoch_num 500 log_smooth_window: 20 print_batch_step: 100 - save_model_dir: ./output/ch_PP-OCRv3_mv3_cbnlocal_shrink/ + save_model_dir: ./output/ch_PP-OCRv4 save_epoch_step: 10 eval_batch_step: - 0 @@ -96,19 +96,19 @@ Train: - 3 - EastRandomCropData: size: - - 960 - - 960 + - 640 + - 640 max_tries: 50 keep_ratio: true - MakeBorderMap: shrink_ratio: 0.4 thresh_min: 0.3 thresh_max: 0.7 - total_epoch: 500 + total_epoch: *epoch_num - MakeShrinkMap: shrink_ratio: 0.4 min_text_size: 8 - total_epoch: 500 + total_epoch: *epoch_num - NormalizeImage: scale: 1./255. mean: diff --git a/ppocr/data/simple_dataset.py b/ppocr/data/simple_dataset.py index 333ca67f..044eafe1 100644 --- a/ppocr/data/simple_dataset.py +++ b/ppocr/data/simple_dataset.py @@ -51,22 +51,22 @@ class SimpleDataSet(Dataset): if self.mode == "train" and self.do_shuffle: self.shuffle_data_random() - self.set_epoch_as_seed(self.seed) + self.set_epoch_as_seed(self.seed, dataset_config) self.ops = create_operators(dataset_config['transforms'], global_config) self.ext_op_transform_idx = dataset_config.get("ext_op_transform_idx", 2) self.need_reset = True in [x < 1 for x in ratio_list] - def set_epoch_as_seed(self, seed): - if self.mode is 'train': + def set_epoch_as_seed(self, seed, dataset_config): + if self.mode == 'train': try: dataset_config['transforms'][5]['MakeBorderMap'][ 'epoch'] = seed if seed is not None else 0 dataset_config['transforms'][6]['MakeShrinkMap'][ 'epoch'] = seed if seed is not None else 0 except Exception as E: - logger.info(E) + print(E) return def get_image_info_list(self, file_list, ratio_list): -- GitLab