From 524c89a7cf4541461bd75184ea959967e6960007 Mon Sep 17 00:00:00 2001 From: Vasilis Vryniotis Date: Mon, 7 Mar 2022 12:04:26 +0000 Subject: [PATCH] Make ScaleJitter proportional --- references/detection/transforms.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/references/detection/transforms.py b/references/detection/transforms.py index 1b39910d11e..48cc53d928c 100644 --- a/references/detection/transforms.py +++ b/references/detection/transforms.py @@ -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)