Unverified Commit fccc5867 authored by Vasilis Vryniotis's avatar Vasilis Vryniotis Committed by GitHub
Browse files

Fix a bug on RandomZoomOut (#5278)

parent 067dc302
...@@ -189,7 +189,7 @@ class RandomZoomOut(nn.Module): ...@@ -189,7 +189,7 @@ class RandomZoomOut(nn.Module):
elif image.ndimension() == 2: elif image.ndimension() == 2:
image = image.unsqueeze(0) image = image.unsqueeze(0)
if torch.rand(1) < self.p: if torch.rand(1) >= self.p:
return image, target return image, target
orig_w, orig_h = F.get_image_size(image) orig_w, orig_h = F.get_image_size(image)
...@@ -211,6 +211,7 @@ class RandomZoomOut(nn.Module): ...@@ -211,6 +211,7 @@ class RandomZoomOut(nn.Module):
image = F.pad(image, [left, top, right, bottom], fill=fill) image = F.pad(image, [left, top, right, bottom], fill=fill)
if isinstance(image, torch.Tensor): if isinstance(image, torch.Tensor):
# PyTorch's pad supports only integers on fill. So we need to overwrite the colour
v = torch.tensor(self.fill, device=image.device, dtype=image.dtype).view(-1, 1, 1) v = torch.tensor(self.fill, device=image.device, dtype=image.dtype).view(-1, 1, 1)
image[..., :top, :] = image[..., :, :left] = image[..., (top + orig_h) :, :] = image[ image[..., :top, :] = image[..., :, :left] = image[..., (top + orig_h) :, :] = image[
..., :, (left + orig_w) : ..., :, (left + orig_w) :
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment