cxbxmxcx / GenReality

Repository for book Generating Reality source colabs.
Apache License 2.0
11 stars 8 forks source link

GEN_2_DCGAN.ipynb unzip zipurl file fail. #1

Open zhaosongyi opened 3 years ago

zhaosongyi commented 3 years ago

it has showed: Downloaded & Extracted https://www.dropbox.com/s/kgqofw91l8m1mk6/celeba.zip?dl=1 but excute the next cell : ... FileNotFoundError: Found no valid file for the classes celeba. Supported extensions are: .jpg, .jpeg, .png, .ppm, .bmp, .pgm, .tif, .tiff, .webp

john-sandall commented 2 years ago

The problem

The problem here is that torchvision.datasets.ImageFolder scans the directory provided assuming it contains subdirectories mapping to classes, containing images pertaining to those closes.

At some point, someone re-uploaded the celeba.zip generated from a folder called img_align_celeba/, so unzipping creates a folder with this name instead of putting the images into the celeba/ folder.

The next cell fails because it sees two folders, celeba/ and img_align_celeba/, treats these as distinct classes for prediction, and complains that the celeba class folder is empty of images.

Solutions

Quick fix for anyone seeing this: just add these two lines at the bottom of the DOWNLOAD IMAGES cell or in a new cell, but before the LOAD IMAGES cell.

os.rmdir('./data/celeba/')
os.rename('./data/img_align_celeba', './data/celeba')

Better fix for the notebook: no need to create the celeba directory in the first place, the folder renaming is still worth doing.