Fastai v2 Vision Example regex error

Hey everyone, I’m just going through the new Fastai-v2 paper and it is amazing, really great work you guys! I keep running into a weird error though when I run the vision example shown in the paper, and was wondering where I went wrong. When I run:

path = untar_data(URLs.PETS)
dls = ImageDataLoaders.from_name_re(path=path, bs=64,
    fnames = get_image_files(path/"images"), pat = r'/([^/]+)_\d+.jpg$',
    item_tfms=RandomResizedCrop(450, min_scale=0.75), 
    batch_tfms=[*aug_transforms(size=224, max_warp=0.), Normalize.from_stats(*imagenet_stats)])

I get the error:

AssertionError: Failed to find "re.compile('/([^/]+)_\\d+.jpg$')" in "scottish_terrier_164.jpg"

I saw that a few people were having this error when running on windows, but I’m on Ubuntu 18.04.
I installed fastaiv2 using pip, and here are the relevant versions of the libraries I’m using, maybe one of them is out of date?

cudnn                     7.6.5                cuda10.0_0
fastai2                   0.0.10                   pypi_0
fastcore                  0.1.12                   pypi_0
fastprogress              0.2.2                      py_0
pytorch                   1.4.0           py3.7_cuda10.0.130_cudnn7.6.3_0

All of the other examples so far have run without a hitch.
Let me know if there’s any other info you think would be relevant.


You are using from_name_re so the method takes the name attribute of your file before searching for the re pattern. As a result, you don’t need r'/([^/]+)_\d+.jpg$' as a pattern but `r’(.*)_\d+.jpg$’,

Awesome, that makes sense, and works perfectly.
just so you know, that’s how it is in the paper (I just copy-pasted it).

Thanks for taking the time to help me out!

Ah, we will fix that code then :wink: