mko*_*bas 3 python deep-learning keras pre-trained-model vgg-net
我想使用VGG预训练模型提取368x368尺寸图像的特征。根据文档,VGGnet接受224x224尺寸的图像。有没有办法给Keras VGG提供可变大小的输入?
这是我的代码:
# VGG Feature Extraction
x_train = np.random.randint(0, 255, (100, 224, 224, 3))
base_model = VGG19(weights='imagenet')
modelVGG = Model(inputs=base_model.input, outputs=base_model.get_layer('block4_conv2').output)
block4_conv2_features = modelVGG.predict(x_train)
Run Code Online (Sandbox Code Playgroud)
编辑代码(有效!)
# VGG Feature Extraction
x_train = np.random.randint(0, 255, (100, 368, 368, 3))
base_model = VGG19(weights='imagenet', include_top=False)
modelVGG = Model(inputs=base_model.input, outputs=base_model.get_layer('block4_conv2').output)
block4_conv2_features = modelVGG.predict(x_train)
Run Code Online (Sandbox Code Playgroud)