How to separate classes in a imagefolder

I have my dataset stored in 2 folders named test and train. I have read both of them under a single imagefolder as it was giving error when i specifically gave path for train or test folder.
Now I want to separate the imagefolder on the basis of its classes. Test and train.
How do i separate data on the basis of its class.
Please help
@ptrblck

I’m not sure I understand the use case completely.
Are test and train the two classes you would like to split or are they corresponding to the training and testing datasets and contain subfolders for each class inside of them?

In the latter case passing root=path_to_train_or_test to ImageFolder should work.
What kind of error are you seeing?

My data has 2 folders
Test and train
Inside each folder, we don’t have separate classes, it’s plain images.
To use image folder, we need to have classes.
I found a solution, I used image folder and then used subset call to separate them.
Thanks.