Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion references/detection/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) :
Expand Down