I have made a CNN model in Keras and saved it as 'model.h5'. It takes an input shape of 128x128. Now, I am in a new file and am trying to make predictions with this model.Here is what I have done so far:
import keras
from keras.preprocessing.image import load_img, img_to_array
from keras.models import load_model
import PIL
img = load_img("img.jpg")
img = img_to_array(img)
img = img.resize((128, 128))
model = load_model('model.h5')
model.summary()
abc = model.predict(img)
print(abc)
Here is my error:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-3-e23dbdb3fe22> in <module>()
14 model.summary()
15
---> 16 abc = model.predict(img)
17
18 print(abc)
3 frames
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/data_adapter.py in select_data_adapter(x, y)
969 "Failed to find data adapter that can handle "
970 "input: {}, {}".format(
--> 971 _type_name(x), _type_name(y)))
972 elif len(adapter_cls) > 1:
973 raise RuntimeError(
ValueError: Failed to find data adapter that can handle input: <class 'NoneType'>, <class 'NoneType'>
Any help would be appreciated.
Thanks in advance
imgis a 128x128 image. If you have Spyder, you can go to the variable explorer and see what it is. Other options would be printing it or printingimg.shape.