0

I am slowly learning Tensorflow, but having problem with loading the data I have downloaded into the model.

Keep getting: [Errno 2] No such file or directory

The file 'data' contain both 'train' and 'test'. Inside these 'train' & 'test' folder contain images (jpg) respectively.

This ipynb file is created in the same folder as the 'data' file.

PATH = os.path.join(os.path.dirname('data'))

train_dir = os.path.join(PATH, 'train')
test_dir = os.path.join(PATH, 'test')

num_train = len(os.listdir(train_dir))
num_test = len(os.listdir(test_dir))
Jason
  • 79
  • 8
  • Your (assumption of) current working folder *must* be wrong – but we cannot see your screen so unfortunately there is not much to suggest, except "check again". Check, verify, and confirm every single step! See also [How to properly determine current script directory?](https://stackoverflow.com/questions/3718657/how-to-properly-determine-current-script-directory) – Jongware Mar 03 '20 at 14:08
  • Try printing out [os.getcwd()](https://docs.python.org/3/library/os.html#os.getcwd) for that^ – MCO Mar 03 '20 at 15:22

1 Answers1

1

Don't use any function to get a path just use the folder name.

PATH = 'data'

or

PATH = os.path.join(os.path.abspath(os.getcwd()),'data')
train_dir = os.path.join(PATH, 'train')
test_dir = os.path.join(PATH, 'test')

num_train = len(os.listdir(train_dir))
num_test = len(os.listdir(test_dir))
Rahul Verma
  • 2,988
  • 2
  • 11
  • 26