diff --git a/ppocr/data/imaug/operators.py b/ppocr/data/imaug/operators.py index ed81d41a59c131014bb98569c5cef2b1512cfb41..2535b4420c503f2e9e9cc5a677ef70c4dd9c36be 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 907548e77fb88f39e7e63b1dcf5451baa3b479a6..2cdfcce2eb3ad4abe4407f781eb99e3591ecebde 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 b21db4c7f7c25c7327fd5fc374c3a9bd91c2db3d..265ab592f7d93af8ad7c766412842d5921d47711 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 9fb2e8e5f9ac608ea12fa902aca30b2ea5f03b2f..a558f490f941ab0dd940329ff7c82c49b6eb31e7 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)