removing sample from a Pytorch dataset object
I'm loading images to pytorch using:
train_data = torchvision.datasets.ImageFolder(train_dir, transform=transform)

Which has some samples I want to omit.
Can i remove certain images from the loader? (by index? by name?)
Thx

You can modify the imgs attribute of an ImageFolder as follows:
train_data.imgs.remove((PATH, INDEX))

where you should replace PATH with the path to the image you wish to remove and INDEX should be replaced with the respective class index (starting from 0 to the number of classes you have).
In case you are not sure about the INDEX you can print train_data.imgs to obtain the list of all image paths with their classes in tuples.
