
twins (MMPretrain)
Image classification86 ops731.4K params
A vision transformer backbone from the Twins pair, built around efficient spatial attention.
Image classification · 594 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('twins_svt_small', pretrained=False) This model is the small size of Twins-SVT, the design based on spatially separable self-attention, which interleaves local and global attention.
About this model's family
Twins is a pair of vision transformer architectures, Twins-PCPVT and Twins-SVT, that came out of a study of how spatial attention should be designed. The paper presents both as backbones for image classification as well as dense detection and segmentation.
Twins-PCPVT is built on PVT and CPVT and uses only global attention. It replaces the absolute positional encoding of PVT with the conditional position encoding from CPVT, produced by a 2D depth-wise convolution placed after the first encoder block of each stage. Twins-SVT uses spatially separable self-attention, which pairs locally-grouped self-attention for fine-grained, short-distance information with global sub-sampled attention for long-distance and global information. The authors named this attention after separable depthwise convolutions.
On ImageNet-1K the paper reports that Twins-PCPVT-S outperforms PVT-small by 1.4% and obtains a result similar to Swin-T with 18% fewer FLOPs, and that Twins-SVT-S is better than Swin-T with about 35% fewer FLOPs.
Key idea. Twins revisits spatial attention in vision transformers and proposes two architectures, Twins-PCPVT and Twins-SVT, whose attention involves only matrix multiplications.
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.