Load unlabeld images from custom Dataset

Hello everyone!
I have a custom dataset with images in specific classes. I have saved this dataset on my computer using folders and subfolders.

  • Train Dataset :
    -5_1
    -5_2
    -5_3
    -etc…

Where the subfolders(5_1, 5_2, etc.) are the classes of the images. I want to use semi-supervised training where both labeled and unlabeled images must be used. But I don’t know how to “categorize” my unlabeled images in order to load them to my CNN. For the labeled images I use datasets.ImageFolder() and DataLoader() so I can load them for training.
Thanks for the help!
PS: I thought to save them in a different folder named as “Unlabeled” but I am afraid that it is gonna use the name of the folder as a new class and this is something that it’s gonna ruin the predictions in training as well in testing

You are right that the ImageFolder would create a new class index for this Unlabeled folder, but you could also replace it with your desired “invalid class index” and remap the other class indices if needed.
This would allow you to use the plain ImageFolder dataset with a DataLoader without writing a custom Dataset.

but you could also replace it with your desired “invalid class index” and remap the other class indices if needed

By this you mean that I can change the name of the class inside of ImageFolder() command? Or there is another way by characterize these images as unlabeled?

Yes, you could try to change the class indices in the internal ImageFolder .targets attribute or even better you could try to remap the class indices in a target_transform.