Skip to content

Commit 1c5c4aa

Browse files
prabhat00155facebook-github-bot
authored andcommitted
[fbsync] Fix bbox scaling estimation for Large Scale Jitter (#5446)
Summary: * Fix bbox scaling estimation for Large Scale Jitter * Fix linter Reviewed By: jdsgomes Differential Revision: D34475306 fbshipit-source-id: 717e7b09d5b2b01758711799ae1ef1bcb1f75050
1 parent 793c3db commit 1c5c4aa

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)