From 0ee6137d75c9b0fd6983ed103021b64a26944f0f Mon Sep 17 00:00:00 2001 From: WenmuZhou Date: Tue, 8 Jun 2021 15:28:40 +0800 Subject: [PATCH] del pad --- ppocr/data/imaug/operators.py | 14 +++++--------- ppstructure/predict_system.py | 3 +-- tools/infer/predict_det.py | 2 -- tools/infer/utility.py | 2 -- 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/ppocr/data/imaug/operators.py b/ppocr/data/imaug/operators.py index ed81d41a..2535b442 100644 --- a/ppocr/data/imaug/operators.py +++ b/ppocr/data/imaug/operators.py @@ -122,8 +122,6 @@ class DetResizeForTest(object): elif 'limit_side_len' in kwargs: self.limit_side_len = kwargs['limit_side_len'] self.limit_type = kwargs.get('limit_type', 'min') - self.pad = kwargs.get('pad', False) - self.pad_size = kwargs.get('pad_size', 480) elif 'resize_long' in kwargs: self.resize_type = 2 self.resize_long = kwargs.get('resize_long', 960) @@ -174,11 +172,9 @@ class DetResizeForTest(object): ratio = float(limit_side_len) / h else: ratio = float(limit_side_len) / w - elif self.pad: - ratio = float(self.pad_size) / max(h, w) else: ratio = 1. - else: + elif self.limit_type == 'min': if min(h, w) < limit_side_len: if h < w: ratio = float(limit_side_len) / h @@ -186,6 +182,10 @@ class DetResizeForTest(object): ratio = float(limit_side_len) / w else: ratio = 1. + elif self.limit_type == 'resize_long': + ratio = float(limit_side_len) / max(h,w) + else: + raise Exception('not support limit type, image ') resize_h = int(h * ratio) resize_w = int(w * ratio) @@ -201,10 +201,6 @@ class DetResizeForTest(object): sys.exit(0) ratio_h = resize_h / float(h) ratio_w = resize_w / float(w) - if self.limit_type == 'max' and self.pad: - padding_im = np.zeros((self.pad_size, self.pad_size, c), dtype=np.float32) - padding_im[:resize_h, :resize_w, :] = img - img = padding_im return img, [ratio_h, ratio_w] def resize_image_type2(self, img): diff --git a/ppstructure/predict_system.py b/ppstructure/predict_system.py index 907548e7..2cdfcce2 100644 --- a/ppstructure/predict_system.py +++ b/ppstructure/predict_system.py @@ -38,8 +38,7 @@ logger = get_logger() class OCRSystem(object): def __init__(self, args): - args.det_pad = True - args.det_pad_size = 960 + args.det_limit_type = 'resize_long' args.drop_score = 0 self.text_system = TextSystem(args) self.table_system = TableSystem(args, self.text_system.text_detector, self.text_system.text_recognizer) diff --git a/tools/infer/predict_det.py b/tools/infer/predict_det.py index b21db4c7..265ab592 100755 --- a/tools/infer/predict_det.py +++ b/tools/infer/predict_det.py @@ -42,8 +42,6 @@ class TextDetector(object): 'DetResizeForTest': { 'limit_side_len': args.det_limit_side_len, 'limit_type': args.det_limit_type, - 'pad':args.det_pad, - 'pad_size':args.det_pad_size } }, { 'NormalizeImage': { diff --git a/tools/infer/utility.py b/tools/infer/utility.py index 9fb2e8e5..a558f490 100755 --- a/tools/infer/utility.py +++ b/tools/infer/utility.py @@ -46,8 +46,6 @@ def init_args(): parser.add_argument("--det_model_dir", type=str) parser.add_argument("--det_limit_side_len", type=float, default=960) parser.add_argument("--det_limit_type", type=str, default='max') - parser.add_argument("--det_pad", type=str2bool, default=False) - parser.add_argument("--det_pad_size", type=int, default=640) # DB parmas parser.add_argument("--det_db_thresh", type=float, default=0.3) -- GitLab