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'm trying to resize a set of images. I followed the code mentioned here, but I keep getting this error.
The code snippet which results in the above-mentioned error is as follows -
fromPILimportImagefromresizeimageimportresizeimagedefresize_images(root_image_path, resized_image_path):
forimage_folderinos.listdir(root_image_path):
# create corresponding folders in the resized_images folderifnotos.path.exists(os.path.join(resize_image_path, image_folder)):
os.makedirs(os.path.join(resize_image_path, image_folder))
# resize all images to 256 x 256forimageinos.listdir(os.path.join(root_image_path, image_folder)):
img=Image.open(os.path.join(root_image_path, image_folder, image), 'r')
# check if image can be resized i.e. if it is too small or notis_valid=resizeimage.resize_cover.validate(img, [256, 256])
ifis_valid:
# if image is valid, resize it to 256 x 256img=resizeimage.resize_cover(img, [256, 256], validate=False)
img=img.convert("RGB")
img.save(os.path.join(resized_image_path, image_folder, image), img.format)
else:
# if the image is too small, scale it upimg=resizeimage.resize_contain(img, [256, 256], validate=False)
img=img.convert("RGB")
img.save(os.path.join(resized_image_path, image_folder, image), img.format)
print('{} done!'.format(image_folder))
print('Resizing images complete!')
The error message that I get is shown below -
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-21-67bef302aaa0> in <module>
----> 1 resize_images(os.path.join(os.getcwd(), 'data/images/'), resize_image_path)
<ipython-input-18-2856c9fdcdb0> in resize_images(root_image_path, resized_image_path)
16
17 # check if image can be resized i.e. if it is too small or not
---> 18 is_valid = resizeimage.resize_cover.validate(img, [256, 256])
19
20 if is_valid:
AttributeError: 'function' object has no attribute 'validate'
Am I doing something wrong?
Thank you so much.
The text was updated successfully, but these errors were encountered:
I'm trying to resize a set of images. I followed the code mentioned here, but I keep getting this error.
The code snippet which results in the above-mentioned error is as follows -
The error message that I get is shown below -
Am I doing something wrong?
Thank you so much.
The text was updated successfully, but these errors were encountered: