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

(Zobiri Mehdi) #1

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 .

0 Likes

(Wesley Nunes Monteiro) #2

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
https://docs.python.org/3/howto/regex.html#regex-howto

0 Likes

(Zobiri Mehdi) #3

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

(Jayen) #4

I also have the same problem
From /content/data/apples_1.jpg
/content/data/apples_2.png
/content/data/tomatoes_3.jpg
/content/data/tomatoes_4.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,
ds_tfms=get_transforms(),
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.

0 Likes