PeCo: Perceptual Codebook for BERT Pre-training of Vision Transformers

Xiaoyi Dong, Jianmin Bao, Ting Zhang, Dongdong Chen 0001, Weiming Zhang, Lu Yuan, Dong Chen 0003, Fang Wen, Nenghai Yu, Baining Guo

Introduction

The success of BERT in Natural Language Processing has inspired similar "Masked Modeling" approaches in computer vision, such as BEiT and MAE. These methods pre-train Vision Transformers (ViTs) by masking parts of an image and requiring the model to predict the missing content. However, unlike language, which has a discrete vocabulary of words, images lack a natural set of "visual words."

PeCo (Perceptual Codebook) addresses this by introducing a tokenizer that aligns discrete visual tokens with human perception. By incorporating a perceptual loss into the tokenizer's training, PeCo creates a vocabulary that captures semantic meaning rather than just low-level pixel statistics, leading to state-of-the-art performance across various vision benchmarks.

Bridging the Perceptual Gap

A significant challenge in Masked Image Modeling (MIM) is choosing the right prediction target. Existing methods typically use raw pixels or discrete tokens from a standard VQ-VAE. The authors argue that these targets often suffer from a "perceptual gap." Standard VQ-VAEs are trained using pixel-wise L2 loss, which is a poor proxy for human vision. For instance, a slight spatial shift can result in a high L2 error despite the images looking identical to a human, while a blur might have a low L2 error but be perceptually distinct.

Comparison of perceptual metrics across different models. PeCo (Ours) aligns more closely with human judgment than L2 or DALL-E tokens.

As shown in the figure above, traditional metrics like L2 and even the DALL-E codebook often fail to reflect human similarity judgments. PeCo's perceptual codebook is designed to bridge this gap, ensuring that the "visual words" used for pre-training are semantically consistent.

Methodology: Learning a Perceptual Codebook

The core of PeCo is a VQ-VAE trained with a specialized Perceptual Loss. Instead of relying solely on pixel reconstruction, PeCo ensures that the original and reconstructed images have similar deep features.

  1. Perceptual Loss: The model minimizes the distance between features extracted from a pre-trained "Perceptual Model."
  2. Self-Supervised Consistency: To maintain a purely self-supervised pipeline, the authors use a MoCo v3 pre-trained ViT-B as the perceptual teacher, rather than a supervised model like VGG.
  3. BERT-style Pre-training: After training the tokenizer, a ViT is trained to predict these perceptual tokens for masked image patches, following the standard BERT/BEiT framework.

To mitigate the computational overhead of the tokenizer, the authors also introduced PeCo-lite, a version with reduced channel counts that retains most of the performance benefits.

Experimental Results

PeCo was evaluated on several standard benchmarks, demonstrating superior performance over previous state-of-the-art MIM methods.

ImageNet-1K Classification

Using a ViT-Base backbone, PeCo achieved 84.5% Top-1 accuracy, outperforming BEiT by 1.3% and MAE by 0.9% under similar training conditions. When scaled to a ViT-Huge backbone, PeCo reached 88.3% accuracy using only ImageNet-1K data, setting a new benchmark at the time of publication.

Downstream Tasks

The benefits of perceptual tokens extend to dense prediction tasks:

  • ADE20K (Semantic Segmentation): PeCo reached 48.5 mIoU, significantly higher than supervised pre-training (47.4) and BEiT (47.1).
  • COCO (Object Detection): PeCo showed consistent improvements in object detection and instance segmentation metrics.

Key Insights

A critical finding is that perceptual loss implicitly forces the codebook to learn semantic concepts. Linear probing on PeCo tokens yielded 29.7% accuracy, nearly triple the 10.2% achieved by standard VQ-VAE tokens. This suggests that the "visual words" in PeCo are much closer to the semantic "words" used in NLP.

While the multi-stage pipeline (tokenizer training followed by ViT pre-training) adds complexity compared to end-to-end methods like MAE, the significant gains in semantic consistency and downstream performance justify the approach. Future work may explore extending this perceptual alignment to multi-modal models to better link visual tokens with linguistic concepts.

Summary updated

BibTeX
@inproceedings{dong2023peco,
  author = {Xiaoyi Dong and Jianmin Bao and Ting Zhang and Dongdong Chen and Weiming Zhang and Lu Yuan and Dong Chen and Fang Wen and Nenghai Yu and Baining Guo},
  title = {{PeCo: Perceptual Codebook for BERT Pre-training of Vision Transformers}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2023},
  doi = {10.1609/aaai.v37i1.25130},
}
Figure