Abstract
Traditional computer vision architectures rely on the pixel-array paradigm, where images are processed as grids of pixels using local convolutional filters. This approach often leads to spatial inefficiency and difficulty in modeling long-range dependencies. We present the Visual Transformer (VT), a novel framework that represents images as a compact set of semantic "visual tokens." By using Transformers to operate on these high-level concepts rather than raw pixels, VT achieves superior performance with reduced computational cost. On ImageNet classification, VT-based models improve top-1 accuracy by up to 7 points compared to ResNet baselines while using significantly fewer FLOPs.
Introduction
For decades, the "pixel-convolution paradigm" has dominated computer vision. However, this approach has inherent limitations. First, convolutions are spatially inefficient, treating all pixels (e.g., background sky vs. foreground objects) with equal importance. Second, they suffer from concept redundancy, applying the same filters regardless of image content. Finally, the local nature of convolutions makes it computationally expensive to relate distant image regions.
The Visual Transformer (VT) addresses these issues by shifting from pixel-level processing to token-level processing. By grouping pixels into semantic tokens, the model can focus computation on important regions and use self-attention to model global relationships efficiently.
Methods
The VT module consists of three primary components: the Tokenizer, the Transformer, and the Projector.
1. The Tokenizer
The tokenizer maps a feature map into a small set of visual tokens (typically $L=16$). Unlike the fixed-patch approach of the Vision Transformer (ViT), the VT tokenizer learns to group pixels semantically. Two variants are explored:
- Filter-based Tokenizer: Uses learnable convolutions to map pixels to groups.
- Recurrent Tokenizer: Leverages tokens from previous layers to guide the extraction of new tokens, ensuring temporal or depth-wise consistency.
2. The Transformer
The extracted tokens are processed by a standard Transformer block. Since the number of tokens is very small (e.g., 16), the self-attention mechanism can densely model all pairwise relationships between semantic concepts with minimal computational overhead.
3. The Projector
For tasks requiring dense output, such as semantic segmentation, the projector maps the refined semantic information from the tokens back onto the original pixel-grid feature map. This allows the network to maintain spatial resolution while benefiting from global semantic reasoning.
Experimental Results
The VT module was evaluated across classification and segmentation tasks.
ImageNet Classification
Integrating VT modules into the later stages of a ResNet-101 architecture yielded a top-1 accuracy increase of 4.6 to 7 points. Notably, the VT-based ResNet-101 achieved this while reducing the FLOPs of the final stage by 6.9x compared to the standard convolutional baseline.
Semantic Segmentation
In the context of Feature Pyramid Networks (FPN) for semantic segmentation on COCO-stuff and LIP datasets, VT modules replaced standard convolutions. This modification reduced the FPN's computational requirements by 6.5x while improving the mean Intersection over Union (mIoU) by 0.35 points.
Discussion and Conclusion
A key finding of this work is that a very small number of tokens (as few as 16) is sufficient to represent the high-level semantic content of an image. The dynamic, content-aware nature of the Transformer's self-attention allows these tokens to adapt to the specific objects present in an image.
The authors conclude that a hybrid approach—using convolutions for low-level feature extraction and Transformers for high-level semantic processing—offers the best balance of efficiency and accuracy. Future work will focus on more sophisticated tokenizer designs and deeper integration of token-based processing throughout the network.
Summary updated