Skip to content

Commit ab5eae0

Browse files
authored
Merge branch 'main' into malfet/add-python-3.10
2 parents 684a48f + 034c222 commit ab5eae0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

references/detection/transforms.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,14 +317,17 @@ def forward(
317317
elif image.ndimension() == 2:
318318
image = image.unsqueeze(0)
319319

320+
orig_width, orig_height = F.get_image_size(image)
321+
320322
r = self.scale_range[0] + torch.rand(1) * (self.scale_range[1] - self.scale_range[0])
321323
new_width = int(self.target_size[1] * r)
322324
new_height = int(self.target_size[0] * r)
323325

324326
image = F.resize(image, [new_height, new_width], interpolation=self.interpolation)
325327

326328
if target is not None:
327-
target["boxes"] *= r
329+
target["boxes"][:, 0::2] *= new_width / orig_width
330+
target["boxes"][:, 1::2] *= new_height / orig_height
328331
if "masks" in target:
329332
target["masks"] = F.resize(
330333
target["masks"], [new_height, new_width], interpolation=InterpolationMode.NEAREST

0 commit comments

Comments
 (0)