ziad:

Does it expect subfolders to be labelled such as test, train etc or is the requirement that images only exist in a subfolder?


ImageFolder will assign a class index to each subfolder. Usually you would thus have subfolders in the train and test folders. If you pass the root folder of train and test to ImageFolder these two folders will have a target value of 0 and 1, respectively.



 ziad:

The confusion occurs when it states the …ImageFolder dataset class, which requires there to be subdirectories in the dataset’s root folder.


As you can see in the tutorial, the target is never used and the input sample is used via data[0].
If you don’t want to use the targets, ImageFolder would still be a valid approach as it would still load all samples in the subfolder(s).