How to create DataBunch object if training files are in the same folder with filenames as labels?

I want to create a DataBunch object from training files which are all in the same folder, and the labels are contained in the filenames. How do I do it?

Here’s the file structure.


ImageDataLoaders.from_name_func or ImageDataLoaders.from_name_re could be what you are looking for.

That doesn’t solve my problem.

I have files in one folder, but I want only the labels to be from filenames.