From 1f5cfb9c13ac1e793b5e99c418de5674784e4be5 Mon Sep 17 00:00:00 2001 From: Vasilis Vryniotis Date: Tue, 25 Jan 2022 13:03:28 +0000 Subject: [PATCH] Fix a bug on RandomZoomOut --- references/detection/transforms.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/references/detection/transforms.py b/references/detection/transforms.py index 4ab5a652539..16b9a8826a8 100644 --- a/references/detection/transforms.py +++ b/references/detection/transforms.py @@ -189,7 +189,7 @@ def forward( elif image.ndimension() == 2: image = image.unsqueeze(0) - if torch.rand(1) < self.p: + if torch.rand(1) >= self.p: return image, target orig_w, orig_h = F.get_image_size(image) @@ -211,6 +211,7 @@ def forward( image = F.pad(image, [left, top, right, bottom], fill=fill) 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) image[..., :top, :] = image[..., :, :left] = image[..., (top + orig_h) :, :] = image[ ..., :, (left + orig_w) :