From 3337dee65a10252b8c978dbe233b45d9f74c5555 Mon Sep 17 00:00:00 2001 From: smilelite Date: Mon, 1 Aug 2022 22:09:12 +0800 Subject: [PATCH] fixed rec_img_aug 20220801 --- configs/rec/rec_r31_robustscanner.yml | 6 +++-- ppocr/data/imaug/rec_img_aug.py | 36 +++++++++++++-------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/configs/rec/rec_r31_robustscanner.yml b/configs/rec/rec_r31_robustscanner.yml index 40d39aee..6dd35394 100644 --- a/configs/rec/rec_r31_robustscanner.yml +++ b/configs/rec/rec_r31_robustscanner.yml @@ -66,7 +66,8 @@ Metric: Train: dataset: name: LMDBDataSet - data_dir: ./train_data/data_lmdb_release/training/ + # data_dir: ./train_data/data_lmdb_release/training/ + data_dir: I:/dataset/OCR/STR/evaluation/evaluation/CUTE80 transforms: - DecodeImage: # load image img_mode: BGR @@ -88,7 +89,8 @@ Train: Eval: dataset: name: LMDBDataSet - data_dir: ./train_data/data_lmdb_release/evaluation/ + # data_dir: ./train_data/data_lmdb_release/evaluation/ + data_dir: I:/dataset/OCR/STR/evaluation/evaluation/CUTE80 transforms: - DecodeImage: # load image img_mode: BGR diff --git a/ppocr/data/imaug/rec_img_aug.py b/ppocr/data/imaug/rec_img_aug.py index a5620f84..8b2309f4 100644 --- a/ppocr/data/imaug/rec_img_aug.py +++ b/ppocr/data/imaug/rec_img_aug.py @@ -259,24 +259,6 @@ class PRENResizeImg(object): data['image'] = resized_img.astype(np.float32) return data -<<<<<<< HEAD -class RobustScannerRecResizeImg(object): - def __init__(self, image_shape, max_text_length, width_downsample_ratio=0.25, **kwargs): - self.image_shape = image_shape - self.width_downsample_ratio = width_downsample_ratio - self.max_text_length = max_text_length - - def __call__(self, data): - img = data['image'] - norm_img, resize_shape, pad_shape, valid_ratio = resize_norm_img_sar( - img, self.image_shape, self.width_downsample_ratio) - word_positons = np.array(range(0, self.max_text_length)).astype('int64') - data['image'] = norm_img - data['resized_shape'] = resize_shape - data['pad_shape'] = pad_shape - data['valid_ratio'] = valid_ratio - data['word_positons'] = word_positons -======= class SPINRecResizeImg(object): def __init__(self, image_shape, @@ -319,7 +301,6 @@ class SPINRecResizeImg(object): img -= mean img *= stdinv data['image'] = img ->>>>>>> 1696b36bdb4152138ed5cb08a357df8fe03dc067 return data class GrayRecResizeImg(object): @@ -399,6 +380,23 @@ class SVTRRecResizeImg(object): data['valid_ratio'] = valid_ratio return data +class RobustScannerRecResizeImg(object): + def __init__(self, image_shape, max_text_length, width_downsample_ratio=0.25, **kwargs): + self.image_shape = image_shape + self.width_downsample_ratio = width_downsample_ratio + self.max_text_length = max_text_length + + def __call__(self, data): + img = data['image'] + norm_img, resize_shape, pad_shape, valid_ratio = resize_norm_img_sar( + img, self.image_shape, self.width_downsample_ratio) + word_positons = np.array(range(0, self.max_text_length)).astype('int64') + data['image'] = norm_img + data['resized_shape'] = resize_shape + data['pad_shape'] = pad_shape + data['valid_ratio'] = valid_ratio + data['word_positons'] = word_positons + return data def resize_norm_img_sar(img, image_shape, width_downsample_ratio=0.25): imgC, imgH, imgW_min, imgW_max = image_shape -- GitLab