Awesome
📖TransCL: Transformer Makes Strong and Flexible Compressive Learning (TPAMI 2022)
<p align="center"> <img src="figs/network.PNG" width="80%"> </p><br> Chong Mou, Jian Zhang <br>
🔧 Dependencies and Installation
- Python >= 3.6 (Recommend to use Anaconda or Miniconda)
- PyTorch >= 1.4
- At least two V100 GPUs are required.
Installation
-
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
Training for Classification
Please run the commands in the folder of classification
. <br>
- 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
).
Training on ImageNet with a fixed CS ratio
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
Training on ImageNet with arbitrary CS ratios
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
Training on Cifar10 with a fixed CS ratio
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
Training on Cifar100 with a fixed CS ratio
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
Training for Segmentation
Coming soon
Testing for Classification
You can download the pre-trained checkpoints from our model zoo.
Testing on ImageNet with a fixed CS ratio
python test_imagenet.py -a 'B_32_imagenet1k' -b 128 --image_size 384
Testing on ImageNet with arbitrary CS ratios
python test_arb.py -a 'B_32_imagenet1k' -b 128 --image_size 384
Testing for Segmentation
Coming soon
:european_castle: Model Zoo
Classification
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 |
Segmentation
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 |
BibTeX
@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}
}