我正在使用keras的预训练模型VGG16,遵循以下链接:Keras VGG16 我正在尝试将预测输出解码为图像中的内容:
model = VGG16(weights='imagenet', include_top=False)
img_path = 'elephant.jpg'
img = image.load_img(img_path, target_size=(224, 224))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)
features = model.predict(x)
(inID, label) = decode_predictions(features)[0] #ERROR HERE
Run Code Online (Sandbox Code Playgroud)
完整的错误是:
ValueError:
decode_predictions
期望一批预测(即2D形状阵列(样本,1000)).找到形状为:(1,7,7,512)的数组
任何意见或建议都非常感谢.谢谢.