mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-01-10 07:28:15 -05:00
choose aspect ration dependent on landscape or portrait (#48)
This commit is contained in:
committed by
GitHub
parent
d24363f421
commit
2808411421
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user