I'm trying to create an input array for a functional Keras model. I have a set of images that I collect in a single np array, so the array has the shape: (nr_images,img_width,img_height,nr_channels)
I use this code:
files = glob.glob ("data/train/part2/*.png")
for myFile in files:
image = cv2.imread (myFile)
image=cv2.resize(image,(256,256))
train.append (image)
train = np.array(train,dtype='float32')
np.save('train',train)
The resulting array dimension is (426, 256, 256, 3)
. So it seems to work.
But if I look at the images stored in the array by:
image_train=np.load("train.npy")
image=image_train[0] #Look at the first image
img = Image.fromarray(image,'RGB')
img.show()
I get rubbish:
My Keras results are super bad, so I suspect that it has something to do with the input.
Am I doing something wrong?