How to delete certain classes from your dataloader (or select classes)

Hello, I am trying to solve a problem where I do have have only the right to read files, my dataset got folders, each folder have the name of the class and inside it the images with that class.
that’s my data loader:

I don’t want some classes, because they are useless in my case and consume my computation time, how can I not include them into my datablock without deleting the folders?
Thank you

Create a folder in/kaggle/working for “your” dataset and use ln to create symlinks to the folders you want to include.


i was hoping for fastai method, but this is acceptable

You could write your own function which took a root folder and a list of child folders you want to include, and pass that to the get_items parameter, that would be the “fastai way to do it”, but it’s also ok to just do whatever is quickest and easiest tbh.

I’m not aware of a pre existing method to do this.

Thanks, I went with the command line solution,
here’s the code if anyone later wanted the answer and didn’t want to bother writing it down

!mkdir data
used_classes = [x for x in list(dls.vocab) if x[-7:] == "regular"]
main_path = "/kaggle/input/google-fonts-for-stefann/fannet/fannet/train/"
for e in used_classes:
    !ln -s {main_path + e} "./data"
1 Like