Adnan_Farooq:

The Functions you have defined is working like first readig the list of files in a folder then extracting from files from that folder one by one?


Yes, although using the Dataset class you can pass this to a DataLoader and use multiple workers to load and perform any pre-processing in parallel.



 Adnan_Farooq:

The other solution I was thinking In on main root directory I have 7 folder (7 classes). Each folder have 100 images. So reading each images folder by folder and putting it in one 4D array… 256x256x11x700 or seven different arrays


That’s also an option if you have enough memory to load the 256*256*11*n array at once, and will be much quicker than lazily loading images from disk.
Since you have your classes in separate folders, there is also the option of sub-classing ImageFolder 3 to load .mat files, though I’ve never tried this.