I think the approach should be right, since you would need the loop at one point anyway to load and process each image, no?
In the standard approach, the DataLoader will load each image one by one and use the collate_fn to create the batch. Now you could push this loop into the __getitem__ to load each sample in the loop and copy the data into the preallocated tensor.
Let me know, if I misunderstood the use case.