DETR Doesn't Need Multi-Scale or Locality Design

Yutong Lin, Yuhui Yuan, Zheng Zhang, Chen Li, Nanning Zheng, Han HuarXiv 2023 · DOI

Introduction

The DEtection TRansformer (DETR) originally introduced a streamlined approach to object detection using global attention and single-scale features. However, its initial versions struggled with slow convergence and poor performance on small objects. To address these issues, subsequent state-of-the-art (SOTA) models like Deformable DETR and DINO reintroduced complex inductive biases, such as multi-scale feature pyramids (FPNs) and localized attention.

This paper challenges the necessity of these complexities. The authors propose that a "plain" DETR architecture, when augmented with specific spatial biases and modern pre-training techniques, can achieve superior performance without the heavy, domain-specific overhead of multi-scale or local designs.

Methodology: Simplifying the Decoder

The researchers introduce a modernized "Plain DETR" that relies on two primary innovations to compensate for the absence of traditional multi-scale and local mechanisms.

Box-to-Pixel Relative Position Bias (BoxRPB)

Standard transformers often lack explicit spatial awareness. BoxRPB addresses this by adding a spatial bias term to the cross-attention calculation. It computes the relative distance between the predicted bounding box corners and every pixel in the feature map. This provides the model with a "soft" localization guide, encouraging it to attend to relevant regions while maintaining the benefits of global context. To ensure computational efficiency, the authors employ an axial decomposition strategy.

Mechanism of Box-to-Pixel Relative Position Bias (BoxRPB) using axial decomposition.

Masked Image Modeling (MIM) Pre-training

The second pillar of this approach is the use of Masked Image Modeling (specifically SimMIM) for backbone pre-training. By requiring the model to reconstruct missing image patches, MIM forces the backbone to learn fine-grained localization features. This inherent spatial awareness effectively replaces the need for the multi-scale feature maps typically used to handle objects of varying sizes.

Key Insights

  • Architecture vs. Pre-training: The "need" for multi-scale features (FPNs) is largely a byproduct of traditional training regimes. MIM pre-training provides the necessary localization cues that were previously hard-coded into the architecture.
  • Global Context for Large Objects: Unlike localized attention mechanisms (e.g., Deformable DETR) which can have restricted receptive fields, Plain DETR's global attention excels at capturing long-range context, which is particularly beneficial for large objects.
  • Efficiency through Decomposition: By decomposing the 2D spatial bias into x and y components, the model significantly reduces memory usage and FLOPs, making global attention practical for high-resolution feature maps.

Key Results

The proposed "Improved Plain DETR" demonstrates substantial performance gains over the baseline and remains highly competitive with more complex architectures.

Comparison of Plain DETR improvements against Deformable DETR across Swin-Small and Swin-Large backbones.
  • Performance Leap: Adding BoxRPB and MIM pre-training resulted in a cumulative improvement of over 16 mAP in some configurations compared to a vanilla baseline.
  • State-of-the-Art: Using a Swin-L backbone and Object365 pre-training, the model achieved 63.9 mAP on the COCO test-dev set, outperforming complex models like DINO-DETR.
  • Scalability: The approach scales effectively with larger backbones, as evidenced by the consistent gains seen when moving from Swin-Small to Swin-Large.

Conclusion

This work demonstrates that the trend toward architectural complexity in object detection is not strictly necessary. By focusing on powerful general-purpose backbones and efficient spatial biases, a plain DETR can match or exceed the performance of specialized, multi-scale models. This shift toward simplicity aligns computer vision more closely with the scaling trends observed in Natural Language Processing, potentially paving the way for more unified foundation models.

Summary updated

BibTeX
@misc{lin2023detr,
  author = {Yutong Lin and Yuhui Yuan and Zheng Zhang and Chen Li and Nanning Zheng and Han Hu},
  title = {{DETR Doesn't Need Multi-Scale or Locality Design}},
  year = {2023},
  eprint = {2308.01904},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2308.01904},
}
Figure