Know image number during data load

When “for i, data in enumerate(dataset):” called, dataloader call one image at time and do pre processing in “getitem” one image at time and create batch of 8 image in “data”. How can i track the number of the image in current process in “getitem”?

For example in first batch when first image process, i need number 1. When first image of next batch process, i need number 9 in “getitem” function.

If you are not shuffling the dataset, you could just use the index in __getitem__. However, I don’t know what exactly your use case is and how multiple workers and shuffling should be handled. You might be able to create a custom sampler, which could pass this additional information to the __getitem__.

1 Like

Thanks. Passing the index helps.