Skip to content

Commit

Permalink
del pad
Browse files Browse the repository at this point in the history
  • Loading branch information
WenmuZhou committed Jun 8, 2021
1 parent 4290c69 commit 0ee6137
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 15 deletions.
14 changes: 5 additions & 9 deletions ppocr/data/imaug/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ def __init__(self, **kwargs):
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)
Expand Down Expand Up @@ -174,18 +172,20 @@ def resize_image_type0(self, img):
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
else:
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)

Expand All @@ -201,10 +201,6 @@ def resize_image_type0(self, img):
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):
Expand Down
3 changes: 1 addition & 2 deletions ppstructure/predict_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@

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)
Expand Down
2 changes: 0 additions & 2 deletions tools/infer/predict_det.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ def __init__(self, args):
'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': {
Expand Down
2 changes: 0 additions & 2 deletions tools/infer/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0ee6137

Please sign in to comment.