What is the right approach to data augmentation when the dataset contains images of different sizes?

I am trying to carry out training for the task of segmentation. I have dataset containing images of size ranging from 192X183 to 3456X4000. And I am planing to train with input size (384, 512) as most of the images are of size (768, 1024).

My current strategy is to apply padding for smaller images so that they have same size to that of input size(384, 512). For larger image, I intend to first resize them to size (768, 1024) and then apply random cropping or maybe FiveCrop operation. I prefer to apply FiveCrop because it helps to increase data size.

  1. How would one combine these two operations(pad if small image and resize+fivecrop if large image) in dataloader? I think, this will cause batch size to vary.
  2. Is it preferred to carry both operation before the training starts? I mean do I have to create new dataset with both operation first and then perform training?

For 1, any tutorial or pseudo code would be very much appreciated.