Home

Awesome

ImageNet-100 (IN100) PyTorch Implementation

PyTorch Implementation: Training ResNets on ImageNet-100 data

Prepare Datasets (ImageNet)

ImageNet-1K data could be accessed with ILSVRC 2012. If ImageNet-1K data is available already, jump to the Quick Start section below to generate ImageNet-100.

root
├── data
│   ├── imagenet
│   │   ├── train
│   │   ├── val
│   ├── imagenet-100 (would be generated, no need to specify)
│   │   ├── train
│   │   ├── val

Quick Start

Generate ImageNet-100 dataset based on selected class file randomly sampled from ImageNet-1K dataset. Simply run the generate_IN100.py could generate folder of ImageNet-100.

For example, run the following command to generate ImageNet-100 from ImageNet-1K data.

arguments:

python generate_IN100.py \
  --source_folder /path/to/ImageNet-1K data
  --target_folder /path/to/ImageNet-100 data

Note: Replace train with val to generate ImageNet-100 val data as well

Training ResNets on ImageNet-100

The implementation of training and validation code can be used in main_IN100.py, and run it for the usage.

python main_IN100.py --model resnet18 \
  --data_folder /path/to/ImageNet-100 main folder \
  --batch_size 256 \
  --epochs 200 \
  --learning_rate 0.2 \
  --cosine \

Note: Please set up the augment: --data_folder as main path (e.g., /root/data/imagenet-100) to ImageNet-100.

Cosine annealing schedule is applied as defult in the implementation (remove --cosine to switch to step learning schedule).

Results

Experiments on ImageNet-100:

ArchBatch SizeEpochLosskNN Accuracy(%)
ResNet18256200Cross Entropy-
ResNet50256200Cross Entropy-

Citation

If you use this toolbox in your work, please cite this project.

@misc{imagenet100pytorch,
    title={{IN100pytorch}: PyTorch Implementation: Training ResNets on ImageNet-100},
    author={Chun-Hsiao Yeh, Yubei Chen},
    howpublished={\url{https://github.com/danielchyeh/ImageNet-100-Pytorch}},
    year={2022}
}

Acknowledgements

Part of this code is based on HobbitLong/SupContrast.