Home

Awesome

📖TransCL: Transformer Makes Strong and Flexible Compressive Learning (TPAMI 2022)

arXiv<br> Chong Mou, Jian Zhang <br>

<p align="center"> <img src="figs/network.PNG" width="80%"> </p>

🔧 Dependencies and Installation

Installation

  1. Clone repo

    git clone https://github.com/MC-E/TransCL.git
    cd TransCL-main
    
  2. 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>

  1. Prepare the training data of ImageNet1K
  2. Download the pre-trained checkpoints of vision transformer from link-ImageNet and link-CIFAR.
  3. 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

ModeDownload link
Pre-trained ViTImageNet, 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 classificationURL
Cifar100 classificationURL
Arbitrary ratio classification (patch size=32)URL
Binary sampling classificationURL
Shuffled classificationURL

Segmentation

ModeDownload link
Pre-trained ViT-largeURL
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 ratiosURL
Segmentation with binary samplingURL

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}
}