提交 9746160e 编写于 作者: F FlyingQianMM

modify Padding in seg_transforms to support multi-channel input

上级 d6439b6d
...@@ -725,23 +725,27 @@ class Padding(SegTransform): ...@@ -725,23 +725,27 @@ class Padding(SegTransform):
pad_width = target_width - im_width pad_width = target_width - im_width
pad_height = max(pad_height, 0) pad_height = max(pad_height, 0)
pad_width = max(pad_width, 0) pad_width = max(pad_width, 0)
im = cv2.copyMakeBorder( if (pad_height > 0 or pad_width > 0):
im, im_channel = im.shape[2]
0, import copy
pad_height, orig_im = copy.deepcopy(im)
0, im = np.zeros((im_height + pad_height, im_width + pad_width,
pad_width, im_channel)).astype(orig_im.dtype)
cv2.BORDER_CONSTANT, for i in range(im_channel):
value=self.im_padding_value) im[:, :, i] = np.pad(
orig_im[:, :, i],
pad_width=((0, pad_height), (0, pad_width)),
mode='constant',
constant_values=(self.im_padding_value[i],
self.im_padding_value[i]))
if label is not None: if label is not None:
label = cv2.copyMakeBorder( label = np.pad(label,
label, pad_width=((0, pad_height), (0, pad_width)),
0, mode='constant',
pad_height, constant_values=(self.label_padding_value,
0, self.label_padding_value))
pad_width,
cv2.BORDER_CONSTANT,
value=self.label_padding_value)
if label is None: if label is None:
return (im, im_info) return (im, im_info)
else: else:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册