Augmenting Convolutional networks with attention-based aggregation

May 8, 2022 · View on GitHub

This repository contains PyTorch evaluation code, training code and pretrained models for the following projects:

  • DeiT (Data-Efficient Image Transformers), ICML 2021
  • CaiT (Going deeper with Image Transformers), ICCV 2021 (Oral)
  • ResMLP (ResMLP: Feedforward networks for image classification with data-efficient training)
  • PatchConvnet (Augmenting Convolutional networks with attention-based aggregation)
  • 3Things (Three things everyone should know about Vision Transformers)
  • DeiT III (DeiT III: Revenge of the ViT)

PatchConvnet provides interpretable attention maps to convnets:

For details see Augmenting Convolutional networks with attention-based aggregation by Hugo Touvron, Matthieu Cord, Alaaeldin El-Nouby, Matthieu Cord, Piotr Bojanowski, Armand Joulin, Gabriel Synnaeve and Hervé Jégou.

If you use this code for a paper please cite:

@article{touvron2021patchconvnet,
  title={Augmenting Convolutional networks with attention-based aggregation},
  author={Hugo Touvron and Matthieu Cord and Alaaeldin El-Nouby and Piotr Bojanowski and Armand Joulin and Gabriel Synnaeve and Jakob Verbeek and Herv'e J'egou},
  journal={arXiv preprint arXiv:2112.13692},
  year={2021},
}

Model Zoo

We provide PatchConvnet models pretrained on ImageNet-1k:

nameacc@1resFLOPs (B)#params (M)Peak Mem. (MB)throughput(im/s)url
S6082.12244.025.213221129model
S12083.22247.547.71450580model
B6083.522415.899.42790541model
B12084.122429.9188.63314280model

Model pretrained on ImageNet-21k with finetuning on ImageNet-1k:

nameacc@1resFLOPs (B)#params (M)Peak Mem. (MB)throughput(im/s)url
S6083.52244.025.213221129model
S6084.938411.825.23604388model
S6085.451220.925.26296216model
B6085.422415.899.42790541model
B6086.538446.599.47067185model
B12086.022429.8188.63314280model
B12086.938487.7188.6758796model

PatchConvnet models with multi-class tokens on ImageNet-1k:

nameacc@1resFLOPs (B)#params (M)url
S60 (scratch)81.12245.325.6model
S60 (finetune)82.02245.325.6model

The models are also available via torch hub. Before using it, make sure you have the latest pytorch-image-models package timm by Ross Wightman installed.

Notebook for visualization

Open In Colab We provide a notebook to visualize the attention maps of our networks.

License

This repository is released under the Apache 2.0 license as found in the LICENSE file.

Contributing

We actively welcome your pull requests! Please see CONTRIBUTING.md and CODE_OF_CONDUCT.md for more info.