在使用tensorflow的vgg16模型时进行小狗图像预测时显示输入格式不符,但使用.shape发现格式又是正确的
ValueError: Input 0 is incompatible with layer vgg19: expected shape=(None, 224, 224, 3), found shape=(32, 224, 3)
from tensorflow.python.keras.applications.vgg16 import VGG16
model = VGG16()
from tensorflow.python.keras.preprocessing.image import load_img
img_dog = load_img('C:\Users\n\Desktop\smy.jpg' ,target_size=(224,224))
from tensorflow.python.keras.preprocessing.image import img_to_array
arr_dog = img_to_array(img_dog)
from tensorflow.python.keras.applications.vgg16 import preprocess_input
arr_input=preprocess_input(arr_dog)
probs = model.predict(arr_input)
probs