Unleashing Vanilla Vision Transformer with Masked Image Modeling for Object Detection

Yuxin Fang, Shusheng Yang, Shijie Wang, Yixiao Ge, Ying Shan, Xinggang Wang

TL;DR

MIMDet demonstrates that "vanilla" Vision Transformers (ViTs) pre-trained with Masked Image Modeling (MIM) can be highly efficient object detectors. By feeding the encoder only a fraction of the input tokens and using a lightweight convolutional stem to build a feature pyramid, MIMDet outperforms hierarchical models like Swin Transformer while converging nearly 3x faster than previous ViT-based detectors.

What Problem Does This Paper Address?

While Vision Transformers (ViTs) have revolutionized image classification, adapting the "vanilla" (isotropic, single-scale) ViT for object detection has been notoriously difficult. Detection requires high-resolution inputs to find small objects, but the computational cost of ViT’s global self-attention scales quadratically with the number of input tokens.

Furthermore, standard detection frameworks like Feature Pyramid Networks (FPNs) rely on multi-scale feature hierarchies (pyramids), which vanilla ViTs lack. Previous attempts to fix this—such as using window-based attention or complex upsampling—often introduce a "gap" between how the model was pre-trained (on 1D sequences) and how it is fine-tuned (on 2D grids), leading to sub-optimal performance and slow training.

Methods

The authors introduce MIMDet, which adapts a MIM-pre-trained (specifically MAE) vanilla ViT using two main innovations:

  1. Partial Input Fine-tuning: Inspired by the masking used in pre-training, MIMDet feeds the ViT encoder only a randomly sampled subset (e.g., 25% to 50%) of the input embeddings during fine-tuning. The missing tokens are later filled in with learnable [MASK] tokens and processed by a lightweight pre-trained decoder to recover the full feature map. This drastically reduces the computational burden of global attention.
  2. Convolutional Stem (ConvStem): The authors replace the standard, aggressive 16x16 "patchify" layer with a compact, randomly initialized convolutional stem. This stem progressively downsamples the image, naturally providing the high-resolution features (at 1/4 and 1/8 strides) needed for an FPN. The ViT encoder then acts as the "3rd stage" of this hybrid backbone.
Figure 1: Overview of our MIMDET and comparisons with previous representative approaches adapting vanilla ViT for object detection (e.g., Li et al. [29]). In MIMDET, a randomly initialized compact convolutional stem (ConvStem) replaces the pre-trained large kernel patchify stem (PatchStem), and the ViT encoder only receives and processes sampled partial input embeddings. The intermediate features of ConvStem can directly serve as the higher resolution inputs for a standard FPN [32].

Datasets

The models were pre-trained on ImageNet-1K using the Masked Autoencoder (MAE) framework. For the primary detection and instance segmentation tasks, the authors used the COCO dataset (train2017 for training and val2017 for evaluation).

Key Insights and Ideas

  • Redundancy is a Feature: The most striking finding is that a ViT encoder can perform high-level object recognition even when seeing only 25% of the image tokens. This suggests that visual signals are spatially redundant enough that the model's pre-trained representations can "fill in the blanks" effectively for downstream tasks.
  • Closing the Pre-train/Fine-tune Gap: By using partial sequences during fine-tuning, the model operates in a regime similar to its MIM pre-training. This consistency is more effective than forcing the model to use 2D inductive biases like window attention that it never saw during pre-training.
  • ConvStem vs. Upsampling: Standard ViTs often use transposed convolutions to "fake" high-resolution features from low-resolution encoder outputs. The authors show that these suffer from "checkerboard artifacts." In contrast, a simple, randomly initialized ConvStem produces much cleaner, more detailed features that are better suited for precise object localization.
Figure 2: Visualizations and comparisons of some stride-4 backbone and FPN feature maps. The feature maps of Li et al. [29] is obtained from our re-implementation which successfully reproduces its reported results.

Key Results

  • Superior Accuracy: MIMDet-Base achieves 51.7 $AP^{box}$ and 46.1 $AP^{mask}$ on COCO, outperforming the hierarchical Swin Transformer by 2.5 and 2.6 points, respectively.
  • Efficiency Gains: Compared to the previous state-of-the-art adapted vanilla ViT (Li et al.), MIMDet converges 2.8x faster and uses a more modest fine-tuning recipe.
  • Sampling Trade-offs: As shown in the table below, even with only 25% training sampling, the model remains highly competitive, demonstrating the robustness of the approach.
Ablation study on sampling ratios
  • Scaling: The approach scales well; MIMDet-Large reaches 54.3 $AP^{box}$, outperforming strong hierarchical competitors.

Limitations and Future Work

The authors acknowledge that their study focused primarily on the MAE (Masked Autoencoder) family of MIM, which uses an asymmetric encoder-decoder architecture. It remains to be seen how well this approach generalizes to other MIM frameworks that don't allow the encoder to skip masked tokens (like BEiT).

Future work could involve exploring MIMDet for even more complex tasks like panoptic segmentation or extending the "partial observation" logic to multi-modal pre-training (e.g., vision-language models).

Summary updated

BibTeX
@inproceedings{fang2022unleashing,
  author = {Yuxin Fang and Shusheng Yang and Shijie Wang and Yixiao Ge and Ying Shan and Xinggang Wang},
  title = {{Unleashing Vanilla Vision Transformer with Masked Image Modeling for Object Detection}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2022},
  url = {https://openreview.net/forum?id=KUGwxVfB8G},
}
Figure