How can I make imageFolder to return a dataset which contains datasets also

Here is our data’s address.
address
I want to get a set of volumes with labels not just some labeled images, like a list contains all the volumes and images in each volume.
How can I make it?

Do you want to load all images from the volume at once and return them?
I think the best approach would be to create a custom Dataset and implement the desired logic there.
Basically you could pass the volume paths to __init__, and load all images corresponding to a volume in __getitem__.
Have a look at the Data Loading Tutorial for more information.

thx, you really help me a lot. I override ImageFolder’s function init and getitem and achieve the goal.


But there are some new questions. After changing above part without changing dataloader, pycharm always warned me that ‘‘list index out of range’’. And if I set batch_size, I couldn’t get the expected output, such as the expected one is batch_size x 100x3x224x224, while what I got is like 100 x batch_size x 3x224x224.
So should I override dataloader? Could you give me some advece?