jeffheaton / t81_558_deep_learning

T81-558: Keras - Applications of Deep Neural Networks @Washington University in St. Louis
https://sites.wustl.edu/jeffheaton/t81-558/
Other
5.72k stars 3.03k forks source link

IsADirectoryError: [Errno 21] Is a directory: #40

Closed mihuzz closed 4 years ago

mihuzz commented 4 years ago

training_binary_path = os.path.join(DATA_PATH,f'trainingdata{GENERATESQUARE}{GENERATE_SQUARE}.npy')

print(f"Looking for file: {training_binary_path}")

if not os.path.isfile(training_binary_path): print("Loading training images...")

training_data = [] faces_path = os.path.join(DATA_PATH,'lfw') for filename in tqdm(os.listdir(faces_path)): path = os.path.join(faces_path, filename) image = Image.open(path).resize((GENERATE_SQUARE,GENERATE_SQUARE),Image.ANTIALIAS) training_data.append(np.asarray(image)) training_data = np.reshape(training_data,(-1,GENERATE_SQUARE,GENERATE_SQUARE,IMAGE_CHANNELS)) training_data = training_data / 127.5 - 1.

print("Saving training image binary...") np.save(training_binary_path,training_data) else: print("Loading previous training pickle...") training_data = np.load(training_binary_path) IsADirectoryError Traceback (most recent call last)

in 14 for filename in tqdm(os.listdir(faces_path)): 15 path = os.path.join(faces_path, filename) ---> 16 image = Image.open(path).resize((GENERATE_SQUARE,GENERATE_SQUARE),Image.ANTIALIAS) 17 training_data.append(np.asarray(image)) 18 training_data = np.reshape(training_data,(-1,GENERATE_SQUARE,GENERATE_SQUARE,IMAGE_CHANNELS)) ~/anaconda3/envs/tf/lib/python3.6/site-packages/PIL/Image.py in open(fp, mode) 2768 2769 if filename: -> 2770 fp = builtins.open(filename, "rb") 2771 exclusive_fp = True 2772 IsADirectoryError: [Errno 21] Is a directory: '/home/mihuzz/PycharmProjects/dcgan/lfw/Pham_Thi_Mai_Phuong'
jeffheaton commented 4 years ago

This looks like not all of the directories were created before running the example. I've also reworked much of the GAN code for TensorFlow 2.0, so I am closing the GAN related items. If you still believe there is an error in the code that would cause this, please reopen. But at this point, I cannot reproduce.