Datasets Preparation

July 14, 2024 ยท View on GitHub

We conduct experiments on ImageNet, CIFAR100, CelebA, and SUN397. Please follow the instructions to set up the dataset folders. By default, our ${DATASET}$ is set to be datasets.

${DATASET}/
|--- imagenet/
    |--- ILSCRC2012_devkit_t12
    |--- train/
    |--- val/
|--- cifar-100-python3/
    |--- meta/
    |--- train/
    |--- test/
|--- sun397/
    |--- Partitions/
    |--- SUN397/
        |--- a/
        |--- b/
        |--- ...
|--- celeba/
    |--- zips/
        |--- CelebA-20231025T061928Z-001.zip
        |--- CelebA-20231025T061928Z-002.zip
        |--- ...
    |--- img_align_celeba/
    |--- list_attr_celeba.txt

ImageNet

Download the dataset from ILSVRC2012. Please use the scripts/tools/prepare_imagenet_train.sh and scripts/tools/prepare_imagenet_val.sh modified from Preparation of ImageNet (ILSVRC2012) to prepare the imagenet folder.

bash scripts/tools/prepare_imagenet_train.sh ${DATASET} ILSVRC2012_img_train.tar
bash scripts/tools/prepare_imagenet_val.sh ${DATASET} ILSVRC2012_img_val.tar

We provide the superclass setting we used in data/imagenet/superclass-10.json. The split can be generated by running the following code.

python3 -m data.imagenet.generate_superclass \
    --image-dir ${DATASET}/imagenet \
    --num-superclasses 10

CIFAR100

python3 tools/download_datasets cifar100 ${DATASET}

We provide the superclass setting we used in data/cifar100/superclass-20.json. The split is acquired from the official CIFAR100 page.

SUN397

python3 tools/download_datasets sun397 ${DATASET}

We provide the superclass setting we used in data/sun397/superclass-15.json. The split can be generated by running the following code.

python3 -m data.sun397.generate_superclass

CelebA

Please download the dataset from Google Drive or other means. Run the following command to unsip the zip files to the destination.

7z x ${DATASET}/celeba/zips/CelebA-20231025T061928Z-001.zip -o${DATASET}