【发布时间】:2022-01-09 03:11:02
【问题描述】:
在尝试导入 VGG19 模型时,以下代码会生成非张量输入的错误。虽然我正在关注另一个这个代码 sn-p here.
代码:
from keras.applications.vgg19 import VGG19
import keras.backend as K
from keras.models import Model
import imageio as iio
image_shape = (384,384,3)
vgg19 = VGG19(include_top=False, weights='imagenet', input_shape=image_shape)
vgg19.trainable = False
# Make trainable as False
for l in vgg19.layers:
l.trainable = False
model = Model(inputs=vgg19.input, outputs=vgg19.get_layer('block5_conv4').output)
model.trainable = False
img1 = iio.imread('img1.jpg')
img2 = iio.imread('img2.jpg')
mean = K.mean(K.square(model(img1) - model(img2)))
错误:
...,
[164, 90, 0, 255],
[164, 90, 0, 255],
[164, 90, 0, 255]]]], dtype=uint8)]. All inputs to the layer should be tensors.
不知道为什么。
【问题讨论】:
标签: python tensorflow keras deep-learning vgg-net