I understand there are many posts about how to handle different sized images, but what I want to do is a bit different.
For each image, I want to crop a random location and create a batch of N crops in each iteration. The size of crops of course will have to be same per batch but I want to vary it randomly across different batches.
I want to avoid resizing.
I believe I can do this outside of the dataloader, like get a prepared batch and the do the random cropping before I feed the batch into the model, however, this won’t take advantage of the “num_workers” and the parralelization in the dataloader and hence will be a bit slow.
I am wondering if there is a way to do this inside the dataloader. Is there a way to randomly generate a size for each batch and share this size variable such that it is accessible to the transform function for each image inside a single batch?