D3ETR: Decoder Distillation for Detection Transformer

Xiaokang Chen, Jiahui Chen, Yan Liu, Gang ZengarXiv 2022

Abstract

While various knowledge distillation (KD) methods in CNN-based detectors show their effectiveness in improving small students, the baselines and recipes for DETR-based detectors are yet to be built. In this paper, we focus on the transformer decoder of DETR-based detectors and explore KD methods for them. The outputs of the transformer decoder lie in random order, which gives no direct correspondence between the predictions of the teacher and the student, thus posing a challenge for knowledge distillation. To this end, we propose MixMatcher to align the decoder outputs of DETR-based teachers and students, which mixes two teacher-student matching strategies, i.e., Adaptive Matching and Fixed Matching. Specifically, Adaptive Matching applies bipartite matching to adaptively match the outputs of the teacher and the student in each decoder layer, while Fixed Matching fixes the correspondence between the outputs of the teacher and the student with the same object queries, with the teacher's fixed object queries fed to the decoder of the student as an auxiliary group. Based on MixMatcher, we build Decoder Distillation for DEtection TRansformer (D3ETR), which distills knowledge in decoder predictions and attention maps from the teachers to students. D3ETR shows superior performance on various DETR-based detectors with different backbones.

Introduction: The Challenge of DETR Distillation

Knowledge Distillation (KD) is a cornerstone technique for model compression, enabling compact "student" models to inherit the performance of large "teacher" models. While KD has matured for Convolutional Neural Networks (CNNs), its application to Detection Transformers (DETR) remains non-trivial.

The primary obstacle is the Transformer Decoder. Unlike traditional detectors that predict objects on a fixed grid, DETR formulates detection as a set prediction problem. The decoder outputs a set of objects in a permutation-invariant (random) order. Consequently, there is no inherent 1-to-1 mapping between the teacher's and the student's predictions. Without a stable alignment mechanism, the student cannot effectively learn from the teacher's rich internal representations.

Methodology: The D3ETR Framework

D3ETR addresses the alignment problem through a novel dual-strategy matching component called MixMatcher. This framework focuses on distilling the decoder, which empirical evidence suggests is the most critical component for performance in DETR-based architectures.

Overview of the D3ETR framework and the MixMatcher strategy.

MixMatcher Alignment

MixMatcher combines two distinct strategies to ensure robust teacher-student correspondence:

  1. Adaptive Matching: This utilizes bipartite matching—the same algorithm DETR uses for ground-truth assignment—to dynamically pair student outputs with teacher outputs at every decoder layer.
  2. Fixed Matching: To mitigate the instability of bipartite matching during early training, D3ETR introduces an auxiliary group. By feeding the teacher’s specific object queries directly into the student’s decoder, the model creates a guaranteed 1-to-1 correspondence, providing a stable "anchor" for learning.

Distillation Targets

Once aligned, D3ETR distills three critical types of knowledge:

  • Predictions: The student mimics the teacher’s classification logits and bounding box coordinates.
  • Self-Attention Maps: The student learns the structural relationships the teacher identifies between different object queries (e.g., how a "person" query relates to a "bicycle" query).
  • Cross-Attention Maps: The student learns to replicate the teacher's spatial focus on image features for specific detections.

Experimental Results

The researchers evaluated D3ETR on the MS COCO 2017 dataset using various backbones and DETR variants. The results demonstrate that D3ETR provides substantial performance boosts, particularly for smaller models and shorter training schedules.

Performance comparison showing significant mAP gains across different backbones.

Key Findings

  • Significant mAP Gains: For a Conditional DETR student with a ResNet-50 backbone, D3ETR improved performance by 7.8 mAP (from 32.4 to 40.2) in a 12-epoch cycle. A ResNet-18 student saw an even more impressive jump of 8.6 mAP. In some configurations, gains reached as high as +10.9 mAP.
  • Decoder Sensitivity: Analysis revealed that reducing decoder layers causes a much sharper performance drop than reducing encoder layers, justifying D3ETR's focus on decoder distillation.
  • Stability and Structure: Ablation studies confirmed that "Fixed Matching" acts as a vital stabilizer. Furthermore, distilling attention maps allows the student to learn the process of reasoning about object relationships rather than just the final output.
  • Efficiency: While distillation increases training overhead, the auxiliary groups and teacher model are discarded post-training, ensuring the student model remains fast and efficient during inference.

Conclusion

D3ETR establishes a powerful baseline for knowledge distillation in DETR-based detectors. By solving the decoder alignment problem with MixMatcher and distilling structural attention knowledge, it enables small models to achieve performance levels previously reserved for much larger architectures. Future work may explore unified frameworks that simultaneously distill the backbone, encoder, and decoder for even greater efficiency.

Summary updated

BibTeX
@misc{chen2022d,
  author = {Xiaokang Chen and Jiahui Chen and Yan Liu and Gang Zeng},
  title = {{D3ETR: Decoder Distillation for Detection Transformer}},
  year = {2022},
  eprint = {2211.09768},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2211.09768},
}
Figure