I have an image (480,640,3) and I am trying to resize it to (150,150,1). Since my Keras model has been trained on images of shape (150,150,1), unfortunately I cannot seem to resize it using the PIL library. Any suggestions on how to fix this?
This is the code I am using right now:
The error is caused on the line
stream.seek(0) data = numpy.fromstring(stream.getvalue() , dtype = numpy.uint8) image5 = cv.imdecode(data , 1) print(image5.shape) #cv.imwrite('uhhu.png',image5) img = image5.resize((150,150,1 ), Image.ANTIALIAS) cv.imwrite('hhh.png',img) x = img_to_array(img) x = x.reshape((1,) + x.shape) x = x/255 x = numpy.array(x) print(x.shape) #score = loaded_model.predict(img) #print(score)