I'm working in a notebook for fastai that previously worked correctly but now is generating an error.
I think the error is due to this newly added labeling function, RegexLabeller:
https://docs.fast.ai/data.transforms.html#regexlabeller
The cells in my notebook prior to the error are:
from fastai.vision.all import *
import timm
path = untar_data(URLs.PETS)/'images'
My third cell is
dls = ImageDataLoaders.from_name_func('.',
get_image_files(path), valid_pct=0.2, seed=42,
label_func=RegexLabeller(pat = r'^([^/]+)_\\d+'),
item_tfms=Resize(224))
... which throws a long assertion error starting with
AssertionError Traceback (most recent call last)
Input In [5], in <cell line: 1>()
----> 1 dls = ImageDataLoaders.from_name_func('.',
2 get_image_files(path), valid_pct=0.2, seed=42,
3 label_func=RegexLabeller(pat = r'^([^/]+)_\\d+'),
4 item_tfms=Resize(224))
File /usr/local/lib/python3.9/dist-packages/fastai/vision/data.py:149, in ImageDataLoaders.from_name_func(cls, path, fnames, label_func, **kwargs)
147 raise ValueError("label_func couldn't be lambda function on Windows")
148 f = using_attr(label_func, 'name')
--> 149 return cls.from_path_func(path, fnames, f, **kwargs)
... and ending with
AssertionError: Failed to find "re.compile('^([^/]+)_\\\\d+')" in "pug_130.jpg"
It was the RegexLabeller that changed in what was previously working code:
label_func=RegexLabeller(pat = r'^([^/]+)_\\d+'),
Any feedback appreciated!