I see. The simplest fix would be to put your data into RAM / saving it in a variable but as this wasn’t what you were after lets try to get another solution.
You could artificially increase your dataset size. This can be done by returning a multiple of your data size in the len() method. Then you’d have high indexes in the getitem() method which you’d have to map to your actual data with a modulus operation for example.
With this approach the problem of putting the same image in the batch twice arises so you’d have to write a custom sampler to avoid this. Probably drop the last batch if it’s smaller than batch size as well