choose aspect ration dependent on landscape or portrait
MODIFY
examples/efficientnet.py
examples/efficientnet.py
@@ -127,7 +127,9 @@ if __name__ == "__main__":
else:
url = "https://raw.githubusercontent.com/karpathy/micrograd/master/puppy.jpg"
img = Image.open(io.BytesIO(fetch(url)))
- aspect_ratio = img.size[0] / img.size[1]
+ aspect_ratio_landscape = img.size[0] / img.size[1]
+ aspect_ratio_portrait = img.size[1] / img.size[0]
+ aspect_ratio = max (aspect_ratio_landscape, aspect_ratio_portrait)
img = img.resize((int(224*max(aspect_ratio,1.0)), int(224*max(1.0/aspect_ratio,1.0))))
img = np.array(img)

choose aspect ration dependent on landscape or portrait (#48)