Need help - Downloading MNIST dataset

(Bhuvana Kundumani) #1

I am downloading the MNIST dataset using

path = untar_data(URLs.MNIST);

path.ls() gives
[‘training’, ‘testing’]

When i try running the code -
data = ImageDataBunch.from_folder(path, ds_tfms=tfms, size=26)

I get the following error -
_---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
in
1 tfms = get_transforms(do_flip=False)
----> 2 data = ImageDataBunch.from_folder(path, ds_tfms=tfms, size=26)

~/anaconda3/envs/fastai/lib/python3.7/site-packages/fastai/vision/data.py in from_folder(cls, path, train, valid, test, **kwargs)
277 “Create from imagenet style dataset in path with train,valid,test subfolders.”
278 path=Path(path)
–> 279 train_ds = ImageClassificationDataset.from_folder(path/train)
280 datasets = [train_ds, ImageClassificationDataset.from_folder(path/valid, classes=train_ds.classes)]
281 if test: datasets.append(ImageClassificationDataset.from_single_folder(

~/anaconda3/envs/fastai/lib/python3.7/site-packages/fastai/vision/data.py in from_folder(cls, folder, classes, valid_pct, check_ext)
98 )->Union[‘ImageClassificationDataset’, List[‘ImageClassificationDataset’]]:
99 “Dataset of classes labeled images in folder. Optional valid_pct split validation set.”
–> 100 if classes is None: classes = [cls.name for cls in find_classes(folder)]
101
102 fns,labels = [],[]

~/anaconda3/envs/fastai/lib/python3.7/site-packages/fastai/core.py in find_classes(folder)
61 def find_classes(folder:Path)->FilePathList:
62 “List of label subdirectories in imagenet-style folder.”
—> 63 classes = [d for d in folder.iterdir()
64 if d.is_dir() and not d.name.startswith(’.’)]
65 assert(len(classes)>0)

~/anaconda3/envs/fastai/lib/python3.7/site-packages/fastai/core.py in (.0)
61 def find_classes(folder:Path)->FilePathList:
62 “List of label subdirectories in imagenet-style folder.”
—> 63 classes = [d for d in folder.iterdir()
64 if d.is_dir() and not d.name.startswith(’.’)]
65 assert(len(classes)>0)

~/anaconda3/envs/fastai/lib/python3.7/pathlib.py in iterdir(self)
1061 if self._closed:
1062 self._raise_closed()
-> 1063 for name in self._accessor.listdir(self):
1064 if name in {’.’, ‘…’}:
1065 # Yielding a path object for these makes little sense

FileNotFoundError: [Errno 2] No such file or directory: ‘/home/ubuntu/.fastai/data/mnist_png/train’

Any help would be appreciated.
Thanks

2 Likes

(Jeremy Howard (Admin)) #2

The course uses MNIST_SAMPLE, which has a different format.

0 Likes

(Bhuvana Kundumani) #3

Thanks @jeremy. Am exploring the formats and trying to understand how do i use datasets from Kaggle or elsewhere with fastai v1.

0 Likes

(Md. Redwan Karim Sony) #4

Hello @Bhuvana_ka, were you able to find out about how to use the complete dataset using
path = untar_data(URLs.MNIST)

I am stuck with same problem. please share if you have worked it out…

Thanks in advance.

0 Likes

(Thomas) #5

This appear to solve the issue: (default values for train/valid folder)

path = untar_data(URLs.MNIST)
data = ImageDataBunch.from_folder(path, train='training', valid='testing')

You could also use the DataBlock API to have full control of what you are doing.

il = (ImageList.from_folder(path)
      .split_by_folder('training', 'testing')
      .label_from_folder())
2 Likes