未验证 提交 2ae28aaf 编写于 作者: W wangguanzhong 提交者: GitHub

refine resize in YOLO & SSD (#234)

上级 b70a0f9b
...@@ -108,10 +108,11 @@ class Resize(object): ...@@ -108,10 +108,11 @@ class Resize(object):
self.max_size = max_size self.max_size = max_size
self.interp = interp self.interp = interp
def __call__(self, im): def __call__(self, im, arch):
origin_shape = im.shape[:2] origin_shape = im.shape[:2]
im_c = im.shape[2] im_c = im.shape[2]
if self.max_size != 0: scale_set = {'RCNN', 'RetinaNet'}
if self.max_size != 0 and arch in scale_set:
im_size_min = np.min(origin_shape[0:2]) im_size_min = np.min(origin_shape[0:2])
im_size_max = np.max(origin_shape[0:2]) im_size_max = np.max(origin_shape[0:2])
im_scale = float(self.target_size) / float(im_size_min) im_scale = float(self.target_size) / float(im_size_min)
...@@ -132,7 +133,7 @@ class Resize(object): ...@@ -132,7 +133,7 @@ class Resize(object):
fy=im_scale_y, fy=im_scale_y,
interpolation=self.interp) interpolation=self.interp)
# padding im # padding im
if self.max_size != 0: if self.max_size != 0 and arch in scale_set:
padding_im = np.zeros( padding_im = np.zeros(
(self.max_size, self.max_size, im_c), dtype=np.float32) (self.max_size, self.max_size, im_c), dtype=np.float32)
im_h, im_w = im.shape[:2] im_h, im_w = im.shape[:2]
...@@ -178,7 +179,7 @@ def Preprocess(img_path, arch, config): ...@@ -178,7 +179,7 @@ def Preprocess(img_path, arch, config):
obj = data_aug_conf.pop('type') obj = data_aug_conf.pop('type')
preprocess = eval(obj)(**data_aug_conf) preprocess = eval(obj)(**data_aug_conf)
if obj == 'Resize': if obj == 'Resize':
img, scale = preprocess(img) img, scale = preprocess(img, arch)
else: else:
img = preprocess(img) img = preprocess(img)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册