# How do you deal with variable input sizes with an encoder-decoder net with skip connections in Keras?

I am currently getting into image segmentation with Keras, and I am using an encoder-decoder type as in the image below.

My problem is that applying a MaxPooling2D layer of size (2,2) cannot be reliably reversed by using an UpSampling2D layer of size (2,2), as the input and output sizes do not match if the input dimensions are odd. The same problem arises with a Conv2D layer with a stride >1 which I want to "reverse" with a Conv2DTranspose layer. This leads to the problem that the skip connections sometimes connect layers of differing sizes such that I cannot concatenate these layers.

Is any canonical way to deal with this problem in Keras, while maintaining skip connections and allowing arbitrary input sizes?