5

I am using Python with Keras and Tensorflow as backend and I want to use input images as small as possible for my model.
The VGG19 application says that it allows input shapes as low as 32 for width and height. A few weeks ago this minimum value was 48 on Keras website. I used it with 48 without problems. Now, I want to try the 32, but I cannot do it because I get:

ValueError: Input size must be at least 48x48; got `input_shape=(32, 32, 3)`

I mention that I updated Keras to the version 2.2.2 and I also deleted the weights model file I had for VGG19 (from ~/.keras/models/). If I put the input_shape to (48, 48, 3), it downloads again the model, otherwise I get the error mentioned above.

In short, my code wants to just load the pre-trained model:

vgg_conv = VGG19(weights='imagenet', include_top=False, input_shape=(32, 32, 3)) 

Any idea to follow is appreciated.

dennlinger
  • 9,890
  • 1
  • 42
  • 63
Catalin Stoean
  • 131
  • 3
  • 6
  • VGG uses max pooling , so it has to have a certain input size , else by the final layer you will end up with no pixels. – harveyslash Sep 26 '18 at 03:03
  • You mean that certain input size should be at least 48 and not get as low as to 32? I just took this 32 value from the Keras Documentation. – Catalin Stoean Sep 26 '18 at 03:25
  • You can get around of this restriction by creating a new model without or with fewer pooling (downsampling) layers, and copy the pretrained weights to your new model. – pitfall Sep 26 '18 at 04:58
  • @user36624: Thanks, that is a good work-around. – Catalin Stoean Sep 26 '18 at 13:37
  • 3
    @dennlinger: "input_shape: optional shape tuple, only to be specified if include_top is False (otherwise the input shape has to be (224, 224, 3) (with 'channels_last' data format) or (3, 224, 224) (with 'channels_first' data format). It should have exactly 3 inputs channels, and width and height should be no smaller than 32. " – Catalin Stoean Sep 26 '18 at 13:38

0 Answers0