Can Keras deal with input images with different size?

Yes.
Just change your input shape to shape=(n_channels, None, None).
Where n_channels is the number of channels in your input image.

I’m using Theano backend though, so if you are using tensorflow you might have to change it to (None,None,n_channels)

You should use:

input_shape=(1, None, None)

None in a shape denotes a variable dimension. Note that not all layers
will work with such variable dimensions, since some layers require
shape information (such as Flatten).
https://github.com/fchollet/keras/issues/1920

For example, using keras’s functional API your input layer would be:

For a RGB dataset

inp = Input(shape=(3,None,None))

For a Gray dataset

inp = Input(shape=(1,None,None))

Leave a Comment