Extract Patches and Return in __getitem__()

I have created n patches (say) of an image. How do I return one patch at a time in getitem() of my Image_Dataset class?

If you’ve created the patches in __getitem__, you could return all of them and create another loop over these patches inside your DataLoader loop, if necessary.
Alternatively, if you’ve created the patches before and store them e.g. in a list, you could simply return a single patch by indexing the container (list).

1 Like

I returned the patches I created as a list in __getitem__() and accessed them individually in my training loop. Thank you for helping :slight_smile: