2
下面是代码的Keras文档页面:如何将多个图像输入Keras特征提取?
from keras.applications.vgg16 import VGG16
from keras.preprocessing import image
from keras.applications.vgg16 import preprocess_input
import numpy as np
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)
这里的单个图像被馈送。
我已经提取了几个(12)图像到列表中,并将该列表转换为numpy数组。我想将图像列表提供给Keras特征提取器。
换句话说,我想喂它多个图像。我怎么能这样做呢?
你只是试图运行'model.predict(table_of_images)'? –
我试图将numpy数组作为一个整体。这并不奏效。当你说'model.predict(table_of_images)'时,你能详细说明吗? – TheTank
那么错误是什么? –