Rethinking Transformer-based Set Prediction for Object Detection

Zhiqing Sun, Shengcao Cao, Yiming Yang, Kris Kitani

Introduction

The DEtection TRansformer (DETR) introduced a paradigm shift in object detection by treating it as a direct set prediction problem. By utilizing a Transformer architecture and bipartite matching loss, DETR eliminated the need for hand-crafted components like Non-Maximum Suppression (NMS) and anchor generation. However, this elegance comes at a significant cost: a "training tax" of approximately 500 epochs to reach convergence. This paper investigates the root causes of this slow training and proposes two novel encoder-only architectures that achieve state-of-the-art performance with a 10x reduction in training time.

The Bottleneck: Diagnosing Slow Convergence

The authors identify two primary factors hindering DETR's convergence: the cross-attention module in the decoder and the instability of bipartite matching.

In the early stages of training, cross-attention maps are nearly uniform, meaning the model fails to localize objects effectively. As shown in the sparsity analysis below, it takes hundreds of epochs for these attention weights to become sparse and focused on specific image regions.

Sparsity of attention maps across layers over training epochs.

Furthermore, the Hungarian loss used for bipartite matching is highly unstable initially. Because early predictions are essentially random, a ground-truth object may be assigned to different queries in consecutive epochs, creating a noisy gradient that slows down the learning process.

Proposed Architectures: TSP-FCOS and TSP-RCNN

To address these issues, the researchers propose moving the primary computation into the Transformer encoder and utilizing multi-level feature pyramids. This "encoder-only" approach bypasses the slow-to-converge cross-attention decoder.

Comparison of original DETR with proposed encoder-only and TSP architectures.

Two specific models were developed:

  1. TSP-FCOS (Transformer-based Set Prediction with FCOS): This model adapts the one-stage FCOS detector. It introduces a "Feature of Interest" (FoI) selection mechanism to identify promising points within a feature pyramid, which are then processed by a Transformer encoder for final set prediction.
  2. TSP-RCNN (Transformer-based Set Prediction with RCNN): A two-stage approach that leverages a Region Proposal Network (RPN) to generate object proposals. These proposals are then refined through a Transformer encoder.

Both models utilize a revised bipartite matching scheme that incorporates spatial constraints. By restricting matching to candidates that are spatially relevant (e.g., points within a ground-truth box), the training signal becomes significantly more stable.

Experimental Results

Evaluated on the COCO 2017 benchmark, the TSP models demonstrate superior efficiency and accuracy:

  • Convergence Speed: TSP-RCNN achieves convergence in just 36 epochs, a 14x speedup over the original DETR's 500-epoch requirement.
  • Detection Accuracy: With a ResNet-50 backbone, TSP-RCNN reaches 45.0 AP, outperforming the original DETR (42.0 AP) and the improved DETR-DC5 (43.3 AP).
  • Scale Performance: The encoder-only design combined with feature pyramids leads to substantial gains in small object detection ($AP_s$), addressing a known weakness of the original DETR.

Conclusion

By rethinking the role of the Transformer decoder and stabilizing the matching process, this work demonstrates that end-to-end set prediction does not inherently require massive training budgets. The proposed TSP-FCOS and TSP-RCNN architectures provide a practical path forward for deploying Transformer-based detectors in resource-constrained environments. Future research will explore sparse attention mechanisms to further optimize the processing of high-resolution feature maps.

Summary updated

BibTeX
@inproceedings{sun2020rethinking,
  author = {Zhiqing Sun and Shengcao Cao and Yiming Yang and Kris Kitani},
  title = {{Rethinking Transformer-based Set Prediction for Object Detection}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2020},
  doi = {10.1109/iccv48922.2021.00359},
}
Figure