Home

Awesome

MixPro: Data Augmentation with MaskMix and Progressive Attention Labeling for Vision Transformer [Official, ICLR 2023,paper] šŸ”„

Qihao Zhao<sup>1</sup>, Yangyu Huang<sup>2</sup>, Wei Hu<sup>1</sup>, Fan Zhang<sup>1</sup>, Jun Liu<sup>3</sup>

1 Beijing University of Chemical Technology

2 Microsoft Research Asia

3 Singapore University of Technology and Design

MixPro

Citation

If you find our work inspiring or use our codebase in your research, please consider giving a star ā­ļø and a citation.

@inproceedings{
zhao2023mixpro,
title={MixPro: Data Augmentation with MaskMix and Progressive Attention Labeling for Vision Transformer},
author={Qihao Zhao and Yangyu Huang and Wei Hu and Fan Zhang and Jun Liu},
booktitle={The Eleventh International Conference on Learning Representations },
year={2023},
url={https://openreview.net/forum?id=dRjWsd3gwsm} 
}

Install

We recommend using the pytorch docker nvcr>=21.05 by nvidia: https://catalog.ngc.nvidia.com/orgs/nvidia/containers/pytorch.

conda create -n mixpro python=3.7 -y
conda activate mixpro
conda install pytorch==1.8.0 torchvision==0.9.0 cudatoolkit=10.2 -c pytorch
pip install timm==0.4.12
pip install opencv-python==4.4.0.46 termcolor==1.1.0 yacs==0.1.8

Data preparation

For ImageNet-1K dataset, you can download it from http://image-net.org/. We provide the following two ways to load data:

Training from scratch on ImageNet-1K

To train a MixPro with Vision Transformer on ImageNet from scratch, run:

python -m torch.distributed.launch --nproc_per_node <num-of-gpus-to-use> --master_port 12345  main.py \
--cfg <config-file> --data-path <imagenet-path> [--batch-size <batch-size-per-gpu> --output <output-directory> --tag <job-tag>]

Notes:

For example, to train MixPro DeiT Transformer with 8 GPU on a single node for 300 epochs, run:

MixPro DeiT-T:

python -m torch.distributed.launch --nproc_per_node 8 --master_port 12345  main.py \
--cfg configs/deit/deit_tiny_patch14_mask56_224_alpha1.yaml --data-path <imagenet-path> --batch-size 128

MixPro DeiT-S:

python -m torch.distributed.launch --nproc_per_node 8 --master_port 12345  main.py \
--cfg configs/deit/deit_small_patch14_mask56_224_alpha1.yaml --data-path <imagenet-path> --batch-size 128

MixPro DeiT-B:

python -m torch.distributed.launch --nproc_per_node 8 --master_port 12345  main.py \
--cfg configs/deit_base_patch14_mask112_224_alpha1_attn_all.yaml --data-path <imagenet-path> --batch-size 64 \

Config

#in config.py
#Probability of switching to mixpro when both mixup and mixpro enabled
_C.AUG.MASKMIX_PROB = 0.5
# MaskMix alpha , maskmix enabled if > 0
_C.AUG.MASKMIX_ALPHA = 1.0
# PAL 
_C.AUG.PAL_ATTN = True

Acknowledgements

The project is based on Swin and Vit(unofficial)

License

The project is released under the MIT License