Skip to content

Commit 9c02164

Browse files
authored
Merge pull request #314 from JdeRobot/issue-313
Fix bug in image size setting in CustomResize transform
2 parents 482127c + 232ea93 commit 9c02164

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

detectionmetrics/models/torch.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,9 @@ def __init__(
190190
self.closest_divisor = closest_divisor
191191

192192
def forward(self, image: Image.Image) -> Image.Image:
193-
w, h = image.size
194-
old_size = (h, w)
195-
196-
if self.width is None:
197-
w = int((self.height / image.size[1]) * image.size[0])
198-
h = self.height
199-
if self.height is None:
200-
h = int((self.width / image.size[0]) * image.size[1])
201-
w = self.width
193+
old_size = image.size
194+
w = self.width or int((self.height / old_size[1]) * old_size[0])
195+
h = self.height or int((self.width / old_size[0]) * old_size[1])
202196

203197
h = round(h / self.closest_divisor) * self.closest_divisor
204198
w = round(w / self.closest_divisor) * self.closest_divisor

0 commit comments

Comments
 (0)