Home

Awesome

Vision Transformers in 2022: An Update on Tiny ImageNet

PWC

This is the official PyTorch repository of Vision Transformers in 2022: An Update on Tiny ImageNet with pretrained models and training and evaluation scripts.

Model Zoo

I provide the following models finetuned with a 384x384 image resolution on Tiny ImageNet.

nameacc@1#paramsurl
ViT-L86.43304Mmodel
CaiT-S3686.7468Mmodel
DeiT-B distilled87.2987Mmodel
Swin-L91.35195Mmodel

Usage

First, clone the repository:

git clone https://github.com/ehuynh1106/TinyImageNet-Transformers.git

Then install the dependencies:

pip install -r requirements.txt

Data Preparation

Download and extract Tiny ImageNet at https://image-net.org/ in the home directory of this repository.

Then run python fileio.py to format the data. This will convert the images into tensors and pickle them into two files, train_dataset.pkl and val_dataset.pkl that will be used in the main code.

Training

To train a Swin-L model on Tiny ImageNet run the following command:

python main.py --train --model swin

Note: Training checkpoints are automatically saved in /models and visualizations of predictions on the validation set are automically saved to /predictions after half of the epochs have passed.

To train DeiT, ViT, and CaiT, replace --model swin with --model deit/vit/cait.

To resume training a Swin-L model on Tiny ImageNet run the following command:

python main.py --train --model swin --resume /path/to/checkpoint

Evaluate

To evaluate a Swin-L model on the validation set of Tiny ImageNet run the following command:

python main.py --evaluate /path/to/model --model swin

Citing

@misc{huynh2022vision,
      title={Vision Transformers in 2022: An Update on Tiny ImageNet}, 
      author={Ethan Huynh},
      year={2022},
      eprint={2205.10660},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}