StateFarm example : question about input_shape

I am working on the statefarm dataset to learn how to build keras models from scratch. In the ‘statefarm-sample.ipynb’ file, I saw this code (in the ‘Linear model’ section):

model = Sequential([
        BatchNormalization(axis=1, input_shape=(3,224,224)),
        Dense(10, activation='softmax')

But the dimension of all state farm images are 640 by 480. How could this input_shape of 224 by 224 work? I guess the images have been pro-processed/scaled, but I don’t see where this happens.

I have this question because eventually I want to work on the cervix cancer competition, and those images are having quite different dimensions, for example, some small ones are 640 by 480, and some large ones are 3096 by 4128. So, in this case, how can I set a constant input_shape in a model?

Any hints/tips/answers are highly appreciated!

Check out the parameters of the flow_from_directory() method on the Keras ImageDataGenerator class. You can specify the exact target size all images will be rescaled to.

1 Like

Thank you!