How to use pretrained vgg16 model for an imageset of 75x75 pixels?


#1

As the first layer of a pretrained vgg16 network is (3,224,224), is it possible to use VGG16 model for an imageset of (3,75,75) pixels?


(Alexandre Cadrin-Chênevert) #2

Hi,
I guess this is potentially for this Kaggle competition:

I didn’t work much on this challenge but you can just resize your image with cv2.resize. It will create a pixel interpolation but the data representation should still be valid. You can also just copy the 75x75 image matrix at the center of a 224x224 matrix if you want to keep the exact pixel representation.

I tried that with resnet50 and it gave a top 20% result with a single model and without ensemble strategy.


(Jon Gold) #3

You can use the same model! This is explained in lesson 7 and kind of blew my mind — convolutional networks don’t care about input size.


(Dennis Sakva) #4

VGG16 supports down to 48x48 images as an input. You need to instantiate your model with
keras.applications.vgg16.VGG16(include_top=True, weights=‘imagenet’, input_shape=(75,75,3))
and then add your own model head fully convolutional or dense.


#5

Smart! You are right. Thanks for the apt answer. I am trying with xception model trained on imagenet dataset.


#6

Okay. I was trying to run using the Vgg16model utilities built by Jeremy. I think your approach should be easier. Would you know in your case, which layers should be set trainable to false? As now, we are adding a different Dense layer in front of the original convolution nets.


(James Requa) #7

This is true except this line should be include_top=False if you want to add your own top layers to the base VGG model.


(Dennis Sakva) #8

Sure! I copied the code from Keras docs and forgot to change!