
crossvit_tiny_240
Image classification661 ops7M params
Dual-branch vision transformer that mixes small-patch and large-patch tokens through cross-attention.
Image classification · 577 operations Checked
Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
How this diagram was made
timm.create_model('crossvit_9_240', pretrained=False) This model corresponds to the paper's CrossViT-9, where the final number is the total count of transformer encoders in the large branch.
About this model's family
CrossViT is a vision transformer for image classification that processes an image at two patch sizes in parallel. The motivation is a trade-off in ViT: with a finer patch size the model can perform better, but FLOPs and memory consumption rise.
Each multi-scale encoder has two branches: a large, primary branch that uses coarse patches with more transformer encoders and wider embeddings, and a small, complementary branch that uses fine patches with fewer encoders and smaller embeddings. The branches exchange information through cross-attention, in which the CLS token of one branch serves as a query over the patch tokens of the other. Because only the CLS token is used in the query, the computation and memory needed to build the attention map are linear rather than quadratic.
In the paper, CrossViT-Ti, CrossViT-S and CrossViT-B set their large branches identical to the tiny, small and base models of DeiT. In the other names the final number is the total count of transformer encoders in the large branch. The models marked with a dagger replace the linear patch embedding with three convolutional layers. The paper reports that CrossViT improves DeiT-Ti, DeiT-S and DeiT-B by 1.2%, 1.2% and 0.4% points on ImageNet1K when those models are used as its primary branch. In timm the model names were changed to show the actual input resolution, so the 224 models are named 240 and the 384 models are named 408.
Key idea. CrossViT is a dual-branch vision transformer that fuses small-patch and large-patch tokens with a cross-attention module whose cost is linear instead of quadratic.
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
@misc{chen2021crossvitcrossattentionmultiscalevision,
title={CrossViT: Cross-Attention Multi-Scale Vision Transformer for Image Classification},
author={Chun-Fu Chen and Quanfu Fan and Rameswar Panda},
year={2021},
eprint={2103.14899},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2103.14899},
}