First you need to create a new Keras layer for input resize and here is how you can do it.
import tensorflow as tf from keras.engine.topology import Layer # The class is prepared to change the size of model's input dynamically class MyInput(Layer): def __init__(self, image_size=(512, 512), **kwargs): self.image_size = image_size, image_size super(MyInput, self).__init__(**kwargs) def call(self, inputs, **kwargs): return tf.image.resize_images(inputs, self.image_size) def compute_output_shape(self, input_shape): return input_shape, self.image_size, self.image_size, input_shape[-1]
Then you can just use this layer as any other regular keras layer and it will resize the inputs for you. (Remember this is just only for tensorflow. You can rewrite call function for other backends)