"git@developer.sourcefind.cn:OpenDAS/torchaudio.git" did not exist on "a4036248fd4de3662f8fb61c8783bf6bc49b3de7"
Unverified Commit 034c2225 authored by Vasilis Vryniotis's avatar Vasilis Vryniotis Committed by GitHub
Browse files

Fix bbox scaling estimation for Large Scale Jitter (#5446)

* Fix bbox scaling estimation for Large Scale Jitter

* Fix linter
parent 7bb5e41b
...@@ -317,6 +317,8 @@ class ScaleJitter(nn.Module): ...@@ -317,6 +317,8 @@ class ScaleJitter(nn.Module):
elif image.ndimension() == 2: elif image.ndimension() == 2:
image = image.unsqueeze(0) 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]) 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_width = int(self.target_size[1] * r)
new_height = int(self.target_size[0] * r) new_height = int(self.target_size[0] * r)
...@@ -324,7 +326,8 @@ class ScaleJitter(nn.Module): ...@@ -324,7 +326,8 @@ class ScaleJitter(nn.Module):
image = F.resize(image, [new_height, new_width], interpolation=self.interpolation) image = F.resize(image, [new_height, new_width], interpolation=self.interpolation)
if target is not None: 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: if "masks" in target:
target["masks"] = F.resize( target["masks"] = F.resize(
target["masks"], [new_height, new_width], interpolation=InterpolationMode.NEAREST target["masks"], [new_height, new_width], interpolation=InterpolationMode.NEAREST
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment