- Python >= 3.6 (Recommend to use Anaconda or Miniconda)
- PyTorch >= 1.4
- At least two V100 GPUs are required.
-
Clone repo
git clone https://github.com/MC-E/TransCL.git cd TransCL-main
-
Install dependent packages
pip install tensorboardX conda install pytorch=1.6.0 torchvision cudatoolkit=10.1 -c pytorch -y pip install mmcv-full==1.2.2 -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.6.0/index.html
Please run the commands in the folder of classification
.
- Prepare the training data of ImageNet1K
- Download the pre-trained checkpoints of vision transformer from link-ImageNet and link-CIFAR.
- The training support ViT-base with patch size being 16 (
-a B_16_imagenet1k
) and 32 (-a B_32_imagenet1k
).
python main_imagenet.py -a 'B_32_imagenet1k' -b 128 --image_size 384 --gpu 0 --lr 1e-3 --log_dir logs/transcl_384_imagenet_p32_01 --cs=1 --mm=1 --save_path=transcl_384_imagenet_p32_01 --devices=4 --rat 0.1 --data /group/30042/public_datasets/imagenet1k
python main_arb.py -a 'B_32_imagenet1k' -b 128 --image_size 384 --gpu 0 --lr 1e-3 --log_dir logs/transcl_384_imagenet_p32_01 --cs=1 --mm=1 --save_path=transcl_384_imagenet_p32_01 --devices=4 --rat 0.1 --data /group/30042/public_datasets/imagenet1k
python main_cifar10.py -a 'B_32_imagenet1k' -b 128 --image_size 384 --gpu 0 --lr 1e-3 --log_dir logs/transcl_384_cifar10_p32_01 --cs=1 --mm=1 --save_path=transcl_384_cifar10_p32_01 --devices=4 --rat 0.1
python main_cifar100.py -a 'B_32_imagenet1k' -b 128 --image_size 384 --gpu 0 --lr 1e-3 --log_dir logs/transcl_384_cifar100_p32_01 --cs=1 --mm=1 --save_path=transcl_384_cifar100_p32_01 --devices=4 --rat 0.1
Coming soon
You can download the pre-trained checkpoints from our model zoo.
python test_imagenet.py -a 'B_32_imagenet1k' -b 128 --image_size 384
python test_arb.py -a 'B_32_imagenet1k' -b 128 --image_size 384
Coming soon
Mode | Download link |
---|---|
Pre-trained ViT | ImageNet, CIFAR |
ImageNet classification (patch size=16, ratio={0.1, 0.05, 0.025, 0.01}) | URL |
ImageNet classification (patch size=32, ratio={0.1, 0.05, 0.025, 0.01}) | URL |
Distilled ImageNet classification (patch size=16, ratio={0.1, 0.05, 0.025, 0.01}) | URL |
Cifar10 classification | URL |
Cifar100 classification | URL |
Arbitrary ratio classification (patch size=32) | URL |
Binary sampling classification | URL |
Shuffled classification | URL |
Mode | Download link |
---|---|
Pre-trained ViT-large | URL |
Segmentation on ADE20K with fixed ratio (patch size=16, ratio={0.1, 0.05, 0.025, 0.01}) | URL |
Segmentation on Cityscapes with fixed ratio (patch size=16, ratio={0.1, 0.05, 0.025, 0.01}) | URL |
Segmentation on Pascal Context with fixed ratio (patch size=16, ratio={0.1, 0.05, 0.025, 0.01}) | URL |
Segmentation with arbitrary ratios | URL |
Segmentation with binary sampling | URL |
@article{mou2022transcl,
title={TransCL: Transformer makes strong and flexible compressive learning},
author={Mou, Chong and Zhang, Jian},
journal={IEEE Transactions on Pattern Analysis and Machine Intelligence},
year={2022},
publisher={IEEE}
}