|
|
|
@ -321,7 +321,7 @@ def scale_image(masks, im0_shape, ratio_pad=None):
|
|
|
|
|
Takes a mask, and resizes it to the original image size
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
masks (torch.Tensor): resized and padded masks/images, [h, w, num]/[h, w, 3].
|
|
|
|
|
masks (np.ndarray): resized and padded masks/images, [h, w, num]/[h, w, 3].
|
|
|
|
|
im0_shape (tuple): the original image shape
|
|
|
|
|
ratio_pad (tuple): the ratio of the padding to the original image.
|
|
|
|
|
|
|
|
|
@ -344,9 +344,6 @@ def scale_image(masks, im0_shape, ratio_pad=None):
|
|
|
|
|
if len(masks.shape) < 2:
|
|
|
|
|
raise ValueError(f'"len of masks shape" should be 2 or 3, but got {len(masks.shape)}')
|
|
|
|
|
masks = masks[top:bottom, left:right]
|
|
|
|
|
# masks = masks.permute(2, 0, 1).contiguous()
|
|
|
|
|
# masks = F.interpolate(masks[None], im0_shape[:2], mode='bilinear', align_corners=False)[0]
|
|
|
|
|
# masks = masks.permute(1, 2, 0).contiguous()
|
|
|
|
|
masks = cv2.resize(masks, (im0_shape[1], im0_shape[0]))
|
|
|
|
|
if len(masks.shape) == 2:
|
|
|
|
|
masks = masks[:, :, None]
|
|
|
|
|