path/directory issue (deep learning with python chollet)
I am using the textbook "Deep Learning with Python" by Chollet and am working through one of the examples.
My code is virtually identical to his yet I am getting an directory error. Here is my code:
import os, shutil
original_dataset_dir = '/Users/myusername/Downloads/dogscats_2'
base_dir = '/Users/myusername/Downloads/cats_and_dogs_small'
os.mkdir(base_dir)
train_dir = os.path.join(base_dir, 'train')
os.mkdir(train_dir)
validation_dir = os.path.join(base_dir, 'validation')
os.mkdir(validation_dir)
test_dir = os.path.join(base_dir, 'test')
os.mkdir(test_dir)
train_cats_dir = os.path.join(train_dir, 'cats')
os.mkdir(train_cats_dir)
train_dogs_dir = os.path.join(train_dir, 'dogs')
os.mkdir(train_dogs_dir)
validation_cats_dir = os.path.join(validation_dir, 'cats')
os.mkdir(validation_cats_dir)
validation_dogs_dir = os.path.join(validation_dir, 'dogs')
os.mkdir(validation_dogs_dir)
test_cats_dir = os.path.join(test_dir, 'cats')
os.mkdir(test_cats_dir)
test_dogs_dir = os.path.join(test_dir, 'dogs')
os.mkdir(test_dogs_dir)
fnames = ['cat.{}.jpg'.format(i) for i in range(1000)]
for fname in fnames:
src = os.path.join(original_dataset_dir, fname)
dst = os.path.join(train_cats_dir, fname)
shutil.copyfile(src, dst)
print(src, dst)
I am getting the error on the last cell:
[Errno 2] No such file or directory: '/Users/myusername/Downloads/dogscats_2/train/cat.0.jpg'
The way my folder is organized is as follows:
.
└── cats_and_dogs_small
├── test
│ ├── cats
│ └── dogs
├── train
│ ├── cats
│ └── dogs
└── valid
├── cats
└── dogs
The main folder contains three of the relevant folders (namely, train
, valid
, and test
folders), each with dog
and cat
folders in them.
I figured the cell preceding the last would add the appropriate paths for training, validating and testing the data so not sure what else is going on. The output of the last line is /Users/brasilgu/dogs-vs-cats/cat.0.jpg /Users/myusername/Downloads/dogs_and_cats_small/train/cats/cat.0.jpg
Comments
Post a Comment