You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I suggest to modified transforms.Scale() to accept two type of size input:
1, If isinstance(self.size, int), resize the image short side to self.size
2. Else, resize the image each side according to self.size
The code looks like this:
class Scale(object):
def __init__(self, size, interpolation=Image.BILINEAR):
self.size = size
self.interpolation = interpolation
def __call__(self, img):
if isinstance(self.size, int):
w, h = img.size
if (w <= h and w == self.size) or (h <= w and h == self.size):
return img
if w < h:
ow = self.size
oh = int(self.size * h / w)
return img.resize((ow, oh), self.interpolation)
else:
oh = self.size
ow = int(self.size * w / h)
return img.resize((ow, oh), self.interpolation)
else:
return img.resize(self.size, self.interpolation)
The text was updated successfully, but these errors were encountered:
I suggest to modified transforms.Scale() to accept two type of size input:
1, If isinstance(self.size, int), resize the image short side to self.size
2. Else, resize the image each side according to self.size
The code looks like this:
The text was updated successfully, but these errors were encountered: