Skip to content

Commit

Permalink
[fbsync] Fix bbox scaling estimation for Large Scale Jitter (#5446)
Browse files Browse the repository at this point in the history
Summary:
* Fix bbox scaling estimation for Large Scale Jitter

* Fix linter

Reviewed By: jdsgomes

Differential Revision: D34475306

fbshipit-source-id: 717e7b09d5b2b01758711799ae1ef1bcb1f75050
  • Loading branch information
prabhat00155 authored and facebook-github-bot committed Feb 25, 2022
1 parent 793c3db commit 1c5c4aa
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion references/detection/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,17 @@ def forward(
elif image.ndimension() == 2:
image = image.unsqueeze(0)

orig_width, orig_height = F.get_image_size(image)

r = self.scale_range[0] + torch.rand(1) * (self.scale_range[1] - self.scale_range[0])
new_width = int(self.target_size[1] * r)
new_height = int(self.target_size[0] * r)

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

if target is not None:
target["boxes"] *= r
target["boxes"][:, 0::2] *= new_width / orig_width
target["boxes"][:, 1::2] *= new_height / orig_height
if "masks" in target:
target["masks"] = F.resize(
target["masks"], [new_height, new_width], interpolation=InterpolationMode.NEAREST
Expand Down

0 comments on commit 1c5c4aa

Please sign in to comment.