fastai / course-v3

The 3rd edition of course.fast.ai
https://course.fast.ai/
Apache License 2.0
4.91k stars 3.56k forks source link

Windows: pytorch 1.0 lesson1-pets #118

Closed geg00 closed 5 years ago

geg00 commented 5 years ago

'1.0.35.dev0' When running lesson1-pets

c:\users\gerar\fastai\fastai\vision\data.py in _get_label(fn) 152 "Create from list of fnames in path with re expression pat." 153 pat = re.compile(pat) --> 154 def _get_label(fn): return pat.search(str(fn)).group(1) 155 return cls.from_name_func(path, fnames, _get_label, valid_pct=valid_pct, **kwargs) 156

AttributeError: 'NoneType' object has no attribute 'group'

dinhju commented 5 years ago

Guess you've fixed it by now but just in case. For me it worked by changing the regex patter: from: pat = re.compile(r'/([^/]+)\d+.jpg$') to: pat = re.compile(r'\([^\]+)\d+.jpg$') (just a windows vs linux path sep)

Running: print(str(fnames[0])) re.search(r'\([^\]+)_\d+.jpg$',str(fnames[0])).group(1)

Should give you: C:\Users\USER.fastai\data\oxford-iiit-pet\images\Abyssinian_1.jpg 'Abyssinian'

Rebolforces commented 5 years ago

pat = re.compile(r'\\([^\\]+)_\d+.jpg$') #for windows

gopitk commented 5 years ago

This code seems to work on both Linux and Windows:

pat = re.compile(r'[/\\]([^/\\]+)\d+.jpg$')

Basically look for either forward or backward slash.