Centroid-centered Modeling for Efficient Vision Transformer Pre-training

Xin Yan, Zuchao Li, Lefei Zhang, Bo Du, Dacheng Tao

TL;DR

This paper introduces CCViT, a novel self-supervised learning framework for Vision Transformers (ViTs) that uses k-means clustering to create a non-parametric "centroid tokenizer." This approach efficiently generates visual tokens and allows for a more effective masked image modeling (MIM) strategy, achieving state-of-the-art results on image classification and semantic segmentation tasks without requiring external supervision or complex tokenization models.

What Problem Does This Paper Address?

Vision Transformers (ViTs) have shown great promise in computer vision, but they typically require massive datasets for effective pre-training. Self-supervised learning methods, particularly Masked Image Modeling (MIM), have emerged as a solution. However, existing MIM approaches fall into two categories: token-based MIM, which requires a computationally expensive parametric tokenizer, and pixel-based MIM, which needs a redundant decoder. Both methods have drawbacks, including high training costs, the need for additional datasets or supervision, and limitations in how well visual tokens represent image patches. This paper aims to bridge this gap by proposing an efficient and effective MIM approach that avoids these pitfalls.

Methods

The core innovation of CCViT is its centroid-based tokenizer. Instead of relying on complex, pre-trained parametric tokenizers, CCViT uses a simple k-means clustering algorithm on image patches to generate a set of "centroids." These centroids serve a dual purpose: they can be visualized as representative image patches and also act as discrete "token IDs" (their index in the cluster set). This non-parametric tokenizer is fast to train, requiring only a small fraction of the training data and a few seconds to construct.

CCViT then employs a centroid-based MIM strategy. This involves:

  • Blockwise Masking: A portion of image patches are masked out.
  • Centroid Replacing: Some of the remaining unmasked patches are replaced with their corresponding nearest centroid pixels. This strategy encourages the model to learn the relationship between centroid pixels and their indices, making it more robust to noise and improving alignment.
  • Dual-Objective Pre-training: The model is trained with two objectives: reconstructing the centroid indices (cross-entropy loss) and reconstructing the original image patch pixels (mean squared error loss). This is achieved using a stacked architecture with a "token ViT block" and a "pixel ViT block."

Datasets

  • ImageNet-1K: Used for pre-training the CCViT model and for fine-tuning on image classification tasks.
  • ADE20K: Used for fine-tuning on semantic segmentation tasks.

Key Insights and Ideas

  • Centroids as Dual-Natured Tokens: The key insight is that k-means centroids can effectively serve as both visual representations (pixels) and discrete identifiers (tokens) simultaneously. This dual nature simplifies the pre-training process and eliminates the need for separate tokenizers and decoders.
  • Efficiency of Non-Parametric Tokenization: The paper demonstrates that a simple k-means clustering can create a highly effective visual tokenizer much faster and with significantly fewer resources than parametric methods.
  • Centroid Replacing for Robustness: Replacing masked patches with their corresponding centroids during pre-training is crucial for learning robust representations and aligning pixel-level and token-level information.
  • Token and Pixel Objectives Complement Each Other: Training with both centroid index prediction and pixel reconstruction objectives leads to superior performance compared to using either objective alone.

Key Results

  • Image Classification: CCViT achieves 84.3% top-1 accuracy on ImageNet-1K with a ViT-Base model, outperforming previous MIM baselines like BEiT and MAE. With a ViT-Large model, it reaches 86.0% accuracy.
  • Semantic Segmentation: CCViT achieves 48.4% mIoU on ADE20K with a ViT-Base model, outperforming BEiT and MAE.
  • Tokenizer Efficiency: The centroid tokenizer training takes only ~158 seconds on a single GPU, compared to days for parametric tokenizers. Inference speed is also significantly faster (9.3ms vs. 15.7ms for BEiT).
  • Robustness: The centroid tokenizer shows superior robustness to image noise, maintaining a higher ratio of unchanged tokens compared to other methods.
  • Pixel Reconstruction: CCViT demonstrates the ability to reconstruct masked image regions effectively, even when trained solely on centroid tokens.

Limitations and Future Work

  • Limitations: While CCViT achieves competitive results, the paper notes that baselines using external data or strong supervision (like CLIP distillation) can achieve higher performance. The current work focuses on demonstrating the effectiveness of the centroid-based approach itself.
  • Future Work: The authors suggest exploring distillation approaches for further performance improvements, viewing it as orthogonal to their core contribution. They also plan to investigate how their centroid-based approach can be further leveraged for improved results.

Summary updated

BibTeX
@inproceedings{yan2023centroid,
  author = {Xin Yan and Zuchao Li and Lefei Zhang and Bo Du and Dacheng Tao},
  title = {{Centroid-centered Modeling for Efficient Vision Transformer Pre-training}},
  booktitle = {PRCV},
  year = {2023},
}
Figure