in baselines/gist_baseline.py [0:0]
def preproc_image(self, im):
""" resize to imsz in the largest dimension and crop out central part """
w, h = im.size
if w > h:
im = im.resize((self.imsz * w // h, self.imsz), Image.BILINEAR)
w2 = im.size[0]
pad = (w2 - self.imsz) / 2
im = im.crop((pad, 0, pad + self.imsz, self.imsz))
else:
im = im.resize((self.imsz * h // w, self.imsz), Image.BILINEAR)
h2 = im.size[1]
pad = (h2 - self.imsz) / 2
im = im.crop((0, pad, self.imsz, pad + self.imsz))
if self.transpose != -1:
im = im.transpose(self.transpose)
assert im.size == (self.imsz, self.imsz)
return im