Lesson1-pets: ImageDataBunch.from_name_re


I’m doing course-v3 lesson1-pets, would appreciate some help in understanding:

data = ImageDataBunch.from_name_re(path_img, fnames, pat, ds_tfms=get_transforms(), size=224, bs=bs).normalize(imagenet_stats)
data.show_batch(rows=3, figsize=(7,6))

How did data know the label for each subplot? I can’t see how info path_anno got passed to any of the arguments whether path_img, fnames, pat, get_transforms(), size or bs.

In fact I can’t see path_anno being used anywhere in the code. After commenting it out, data.show_batch still knows the labels for each image.

(BTW Shift-tab seems to find no documentation to show. I didn’t manage to find any under from_name_re method in fastai-master/fastai/vision/data.py either.)



Ok, I was stupid. data.show_batch got the labels from the filenames of individual jpgs!