Why does ImageDataBunch.from_name_re() require a path argument?

I just finished Lesson 1 and had a quick API question:

The ImageDataBunch methods from_name_re, from_name_func, from_lists all require a path argument.

However, these methods also require the argument fnames, which is a list of fully-qualified filepaths to each image. fnames already provides all the information needed to find the entire dataset, so what is path used for?

After reading the source code, my current understanding is that path is a required property of the DataBunch parent class, since methods like DataBunch.save() will save directly to path.

Additionally, the Learner class usually copies Learner.path from its data.path. This is used for things like Learner.save(), Learner.load(), and Learner.export(), which write to self.path/self.model_dir or just self.path.

4 Likes