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

Hi Everyone , when i pass the ‘pat’ parameter in the ImageDataBunch.from_name_re function i get this Error :

Failed to find “re.compile(’([^\\]+)_\d+.jpg$’)” in “/content/drive/My Drive/911_Class/1. image-full-width-s0.jpg”

any suggestions ? , thank U .

1 Like

Hey mididou, You need of correct matching characters,
in your case:
pat = r’([\w\s.-]).jpg’
maybe works, but for more information read

Regular Expression HOWTO

Sir , i can not thank u enough for U help , it worked perfeclty.
knowing that i had to tweak the ‘PAT’ argument a bit , i used this one ,
pat = r’([\w\s.-]).[jpg]’

1000 thanks .

1 Like

I also have the same problem
From /content/data/apples_1.jpg
I have been trying to extract “apples” and “tomatoes” with pat = r"/([^/]+)\d+.jpg$", but this doest seem to work. When I run the line data = ImageDataBunch.from_name_re(path_img, fnamess, pat,
size=224, bs=bs )
I get the error : "Failed to find "re.compile(’/([^/]+)
\d+.jpg$’)" in “/content/data/apples_30.jpeg”
Can somebody please help me out to find RE that works for .jpg and .png as well.

1 Like