SparseFormer: Sparse Visual Recognition via Limited Latent Tokens

Ziteng Gao, Zhan Tong, Limin Wang, Mike Zheng Shou

TL;DR

SparseFormer is a novel vision transformer that challenges the "dense" processing paradigm by representing images with a tiny set of latent tokens (as few as 9). By mimicking human visual attention through iterative sparse feature sampling, it achieves competitive accuracy on ImageNet-1K with significantly lower computational costs and higher throughput than traditional models.

The Problem with Dense Vision Paradigms

Most modern vision architectures, whether CNNs or Transformers, follow a "dense" paradigm: they process every single pixel or patch in an image uniformly. This approach assumes foreground objects could be anywhere and treats backgrounds with the same computational intensity as the main subject.

However, human vision is naturally sparse. We don't examine every detail of a scene simultaneously; instead, our eyes quickly identify regions of interest and focus our "compute" there. The dense convention in AI leads to massive redundancy and computational waste, especially as input resolutions scale up. SparseFormer aims to bridge this gap by creating a model that learns where to look right from the start.

Dense vs. Sparse paradigms for visual recognition

How SparseFormer Works

The authors introduce SparseFormer, which operates primarily in a latent space using a highly limited number of tokens ($N \ll H \times W$). The architecture relies on a few key mechanisms:

  1. Latent Tokens: Each token consists of a content embedding and a Region of Interest (RoI) descriptor (defining its center, width, and height).
  2. Focusing Transformer: This acts as the "eye" of the model. Instead of dense cross-attention, it uses sparse feature sampling. It generates a set of sampling points within its RoI and extracts features via bilinear interpolation. Crucially, it iteratively adjusts its RoI to "zoom in" on important areas based on what it has already seen.
  3. Adaptive Feature Decoding: To make the most of limited samples, the model uses a lightweight network to generate conditional weights that decode sampled features, leveraging both spatial and channel semantics.
  4. Cortex Transformer: Once the latent tokens are refined, they are passed through a standard transformer encoder (the "brain") to perform the final recognition task.
The SparseFormer overall architecture and details of the focusing transformer block

Key Insights and Results

SparseFormer was primarily evaluated on ImageNet-1K for image classification and Kinetics-400 for video classification, yielding several notable insights:

  • Resolution Independence: Because the number of latent tokens is fixed and the sampling is sparse, the computational complexity of the transformer operations is largely independent of the input image resolution.
  • Emergent Localization: Remarkably, the model learns to focus on foreground objects using only classification labels. There is no explicit "bounding box" supervision during training; the RoI adjustment mechanism naturally gravitates toward discriminative regions to minimize classification loss.
  • Efficiency of "Glimpses": The paper shows that even with just 9 tokens, the model can achieve 74.5% top-1 accuracy on ImageNet, proving that a few well-placed "glimpses" are often enough for recognition.
  • Strong Performance: SparseFormer-T (Tiny) achieves 81.0% top-1 accuracy on ImageNet-1K with only 2.0G FLOPs. For comparison, the well-known Swin-T achieves 81.3% but requires more than double the compute (4.5G FLOPs) and has 74% lower throughput. On a V100 GPU, SparseFormer-T processes 1270 images per second, significantly outperforming dense counterparts like ResNet-50 (1179 img/s) and Swin-T (726 img/s).
  • Video Scalability: Extending the model to video is straightforward—RoIs become "tubes" in 3D space. VideoSparseFormer-S reaches 79.1% top-1 on Kinetics-400 with just 38G FLOPs, outperforming several established video models that use much more compute.

Limitations and Future Work

While SparseFormer offers an excellent accuracy-throughput trade-off, its absolute top-1 accuracy still trails behind the most massive dense models. Additionally, while it can be adapted for dense prediction tasks like object detection and segmentation (e.g., MS COCO and ADE20K), its performance in these areas is currently inferior to specialized dense architectures.

Future work could involve exploring better initialization strategies for tokens, scaling the architecture further, and refining the sparse sampling mechanism to better handle complex, dense downstream vision tasks.

Summary updated

BibTeX
@inproceedings{gao2024sparseformer,
  author = {Ziteng Gao and Zhan Tong and Limin Wang and Mike Zheng Shou},
  title = {{SparseFormer: Sparse Visual Recognition via Limited Latent Tokens}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=2pvECsmld3},
}
Figure