Skip to content

Commit

Permalink
Fixed padding error in ResizeMaxSize
Browse files Browse the repository at this point in the history
  • Loading branch information
nik-ko authored and rwightman committed Sep 14, 2023
1 parent a4b5bc3 commit f692ec9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/open_clip/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ def forward(self, img):
else:
width, height = img.size
scale = self.max_size / float(max(height, width))
new_size = tuple(round(dim * scale) for dim in (height, width))
if scale != 1.0:
new_size = tuple(round(dim * scale) for dim in (height, width))
img = F.resize(img, new_size, self.interpolation)
if not width == height:
pad_h = self.max_size - new_size[0]
pad_w = self.max_size - new_size[1]
img = F.pad(img, padding=[pad_w//2, pad_h//2, pad_w - pad_w//2, pad_h - pad_h//2], fill=self.fill)
Expand Down

0 comments on commit f692ec9

Please sign in to comment.