I'm using tensorflow-slim, and modified some of sample code to use my own data.
Below is the original code to set the directory to download the dataset(dataset_dir is given by user input, which was '/tmp/flowers' this time):
flower_root = os.path.join(dataset_dir, 'flower_photos')
directories = []
class_names = []
print('##################current dir is', flower_root) #original line for verification
for filename in os.listdir(flower_root):
path = os.path.join(flower_root, filename)
if os.path.isdir(path):
directories.append(path)
class_names.append(filename)
It prints '##################current dir is /tmp/flowers\flower_photos', which is correct, and it actually works well for the whole code.
Since it works well, I tried to customize the code as below, which is just replacing 'flowers' with 'MyData'(and therefore changing dataset_dir into '/tmp/MyData'):
MyData_root = os.path.join(dataset_dir, 'MyData_photos')
directories = []
class_names = []
print('##################current dir is', MyData_root)
for filename in os.listdir(MyData_root):
path = os.path.join(MyData_root, filename)
if os.path.isdir(path):
directories.append(path)
class_names.append(filename)
This time, it prints '##################current dir is /tmp/MyData\MyData_photos', which is also correct, but it raises an error:
FileNotFoundError: [WinError 3] The system cannot find the path specified: '/tmp/MyData\\MyData_photos'
I've been working on for this problem for a few hours, but I cannot understand what happened to that os.listdir(MyData_root) method. It suddenly inserts additional '\' between 'MyData' and 'MyData_photos' and causes an error.