I've created and normalized my colored image dataset of 3716 sample and size 493*491 as x_train, its type is list I'm tring to convert it into numpy array as follows

from matplotlib import image
import numpy as np
import cv2

def prepro_resize(input_img):
  return cv2.resize(oimg, (IMG_HEIGHT, IMG_WIDTH),interpolation = cv2.INTER_AREA)

x_train_ = [(prepro_resize(x_train[i])).astype('float32')/255.0 for i in range(len(x_train))]

x_train_ = np.array(x_train_) #L1

but i get the following error when L1 runs MemoryError: Unable to allocate 10.1 GiB for an array with shape (3716, 493, 491, 3) and data type float32


1 Answer 1


You could try the following:

1.) Convert to greyscale images instead of RGB if your application does not need RGB. Colored images consume relatively more memory than greyscale ones.

2.) Resize the images to a lower resolution than the current one



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.