Skip to content

Commit

Permalink
Make ScaleJitter proportional
Browse files Browse the repository at this point in the history
  • Loading branch information
datumbox committed Mar 7, 2022
1 parent 350a3e8 commit 524c89a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions references/detection/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,10 @@ def forward(

_, orig_height, orig_width = F.get_dimensions(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)
scale = self.scale_range[0] + torch.rand(1) * (self.scale_range[1] - self.scale_range[0])
r = min(self.target_size[1] / orig_height, self.target_size[0] / orig_width) * scale
new_width = int(orig_width * r)
new_height = int(orig_height * r)

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

Expand Down

0 comments on commit 524c89a

Please sign in to comment.