It seems pretty clear that I don’t know what I’m doing…
Here’s the code I’ve modified which appears to run successfully:
#=================================================
%reload_ext autoreload
%autoreload 2
%matplotlib inline
from fastai.vision import *
from fastai.metrics import error_rate
bs = 64
path = untar_data(URLs.MNIST)
data = ImageDataBunch.from_folder(path, train=‘training’, valid=‘testing’)
path.ls()
path_anno = path/‘annotations’
path_img = path/‘images’
path.ls()
Print success indicator
print(‘ready’)
#============================
It’s the next step that I’m not sure how to approach.
When I look at the images, I see that they are stored in directories named:
0
1
2
3
4
5
6
7
8
9
The png filenames seem to have no relationship to the images, which is fine. I would assume, for example, if I’m training to recognize the digit ‘0’ that I should pull all the files in the directory named ‘0’, but I don’t know how to do that.
When I run this line:
testing = get_image_files(path_img)
I would expect it to load all the images from this path:
PosixPath(’/notebooks/course-v3/nbs/dl1/data/mnist_png/training’
Instead, I get a file not found error:
FileNotFoundError Traceback (most recent call last)
in
----> 1 testing = get_image_files(path_img)
/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/vision/data.py in get_image_files(c, check_ext, recurse)
19 def get_image_files(c:PathOrStr, check_ext:bool=True, recurse=False)->FilePathList:
20 “Return list of files in c
that are images. check_ext
will filter to image_extensions
.”
—> 21 return get_files(c, extensions=(image_extensions if check_ext else None), recurse=recurse)
22
23 def get_annotations(fname, prefix=None):
/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/data_block.py in get_files(path, extensions, recurse, exclude, include, presort, followlinks)
42 return res
43 else:
—> 44 f = [o.name for o in os.scandir(path) if o.is_file()]
45 res = _get_files(path, path, f, extensions)
46 if presort: res = sorted(res, key=lambda p: _path_to_same_str§, reverse=False)
FileNotFoundError: [Errno 2] No such file or directory: ‘/notebooks/course-v3/nbs/dl1/data/mnist_png/images’
Perhaps I should spend the recommended year learning Python first?
I’ve spent quite a bit of time in VBA, but it may not be sufficient.
Thanks again for your help!
Thomas