Can I add more than one folder to fastai data_block

I import my data into fastai / pytorch as follows:

src = ImageList.from_folder(path).split_subsets(train_size = train_size, valid_size = valid_size, seed = model).label_from_folder()

tfms = None # not the case but None for simplifying the code here 

data = src.transform(tfms=tfms, size=size, resize_method=ResizeMethod.SQUISH).databunch(bs=batch_size, num_workers=4).normalize()

I would like to know if its possible to have more than one folder something like:

src = ImageList.from_folder(path1, path2, path3).split_subsets(train_size = train_size, valid_size = valid_size, seed = model).label_from_folder()

tfms = None # not the case but None for simplifying the code here 

data = src.transform(tfms=tfms, size=size, resize_method=ResizeMethod.SQUISH).databunch(bs=batch_size, num_workers=4).normalize()

Where all the paths are organized the same way.

Thank you in advance.

As per the documentation, the recurse option is by default true and so if these folders share a common subdirectory and there are no other image files which you don’t want included as subdirectories, simply use a common parent directory as the path.

Otherwise, there is no way to do this as of yet.

You can of course use from_df and have a DataFrame where you add [file for file in os.listdir(path1) + os.listdir(path2) + os.listdir(path3) if ".jpg" in file as filename column values.