Use nn.AdaptiveAvgPool2d. Using this you can use any image size and your model will work. Also, if you want to get more performance you can use this you can concatenate nn.AdaptiveAvgPool2d and nn.AdaptiveMaxPool2d for more performance. After, this you can retrain your head of the model (linear layers) and it will all just work.