Hi: I would like load some 2400 images from a folder into python 3.6 for Neural Networks, the following code works, however, it loads images in its original size, which is (2443, 320, 400, 3), after converting into an array. How do I resize it to 64x96? so it is (2443, 64, 96, 3) and less of a load on memory. Separately, how do I do it using parallel processing, so it is efficient.
Thank you!
IMAGE_PATH = 'drive/xyz/data/'
file_paths = glob.glob(path.join(IMAGE_PATH, '*.gif'))
# Load the images
images = [misc.imread(path) for path in file_paths]
images = np.asarray(images)
Inspired by this link, I tried to do the following:
from PIL import Image
basewidth = 96
IMAGE_PATH = 'drive/xyz/data/'
file_paths = glob.glob(path.join(IMAGE_PATH, '*.gif'))
# Load the images img = [misc.imread(path) for path in file_paths]
wpercent = (basewidth/float(img.size[0]))
hsize = int((float(img.size[1])*float(wpercent)))
img = img.resize((basewidth,hsize), Image.ANTIALIAS)
images = np.asarray(img)
however, it resulted in an error, written below. Any suggestions, would be greatly appreciated. Thank you.
AttributeError Traceback (most recent call last)
<ipython-input-7-56ac1d841c56> in <module>()
9 img = [misc.imread(path) for path in file_paths]
10
---> 11 wpercent = (basewidth/float(img.size[0]))
12 hsize = int((float(img.size[1])*float(wpercent)))
13 img = img.resize((basewidth,hsize), Image.ANTIALIAS)
AttributeError: 'list' object has no attribute 'size'