Why do we need `path` as a parameter in `imageDataBunch.from_name_re`?

Below is the line of code that Jeremy used to create ImageDataBunch from the IIIT Pet Dataset.

data = ImageDataBunch.from_name_re(path_img, fnames, pat, ds_tfms=get_transforms(), size=224, bs=bs)

Here, path_image is the path of the dataset, while fnames is a list containing the path of all the image files in the dataset. Since fnames already have the path information of all the image files, why do we still need to supply the path_image argument?

Hi, I wondered the same thing and came to the conclusion that it is to allow flexibility when saving the models and anything else specifically related to the data set you are training.

Doing is this way means that the data set and your models etc. do not need to be in the same location, but they are by “default” to save you typing an absolute path every time you want to save something.

If you have run through that workbook look inside path_img you will see a models folder containing stage-1.pth etc.

1 Like

Ah, that makes sense. We still need to specify the place to store the model.

Here in ImageDataBunch.from_name_re() function I am getting an empty set as my validation set.why?

Train: LabelList (14 items)
x: ImageList
Image (3, 224, 224),Image (3, 224, 224),Image (3, 224, 224),Image (3, 224, 224),Image (3, 224, 224)
y: CategoryList
d18,dove-beauty-cream-bar-soap-bucharest-romania-–-march-isolated-white-personal-care-brand-owned-unilever-92286356,g1,gift-habeshaw-9dRjj5_XeMg-unsplash,h13
Path: /gdrive/My Drive/phospheneAI/data;

Valid: LabelList (0 items)
x: ImageList

y: CategoryList

Path: /gdrive/My Drive/phospheneAI/data;

Test: None

How can I set my valid set by using this same function?