Abstract
Detection Transformers (DETRs) have revolutionized object detection by simplifying the pipeline into a set-prediction problem. However, their high computational cost limits deployment on resource-constrained devices. While knowledge distillation (KD) is a standard compression technique, applying it to DETRs is challenging due to the sparse nature of object queries and the noise inherent in background predictions. This paper presents Query Selection Knowledge Distillation (QSKD), a framework that selectively distills "hard-negative" queries—those that are spatially close to the ground truth but not the primary match. By focusing on these informative queries and utilizing attention-guided feature alignment, QSKD achieves significant performance boosts, including a 5.3 AP improvement on the COCO dataset for lightweight models.
Introduction
Object detection has seen a paradigm shift with the introduction of Detection Transformers (DETRs), which eliminate the need for hand-crafted components like non-maximum suppression (NMS) and anchor generation. Despite their elegance, DETRs are typically large and slow. Compressing these models via Knowledge Distillation (KD) is non-trivial. Standard KD approaches often focus solely on the single "positive" query matched to a ground truth object, which provides limited spatial context. Conversely, attempting to distill all queries introduces significant noise from "easy negatives" (background regions) and incurs high computational costs due to the cubic complexity of global bipartite matching between teacher and student queries.
Methodology
The QSKD framework addresses these challenges through three primary components: Group Query Selection, Attention-Guided Feature Distillation, and Local Alignment Prediction Distillation.
Group Query Selection (GQS)
The core innovation of QSKD is the identification of "hard-negative" queries. Unlike easy negatives that represent clear background, hard negatives have a high Generalized Intersection over Union (GIoU) with ground truth objects. These queries are rich in information regarding object boundaries and foreground context. GQS ranks all queries by GIoU and selects a group consisting of the positive query and several top-ranked hard negatives for distillation, while discarding the noisy easy negatives.
Attention-Guided Feature Distillation (AGFD)
To improve the student's encoder features, AGFD leverages the teacher's cross-attention maps from the decoder. These maps act as a "foreground mask," pinpointing the regions the teacher model considers most relevant for detection. The student is trained to align its intermediate feature maps with the teacher's, but only within these high-importance masked regions, preventing the distillation process from being overwhelmed by background noise.
Local Alignment Prediction Distillation (LAPD)
To make prediction distillation efficient, LAPD replaces global bipartite matching with local matching. By only matching student queries to teacher queries within the small groups identified by GQS, the computational overhead is drastically reduced. This local alignment ensures the student learns the specific nuances of how the teacher predicts object boundaries and classes for the most relevant queries.
Encoder Adapter
To bridge the representational gap between a large teacher and a smaller student, the authors introduce a single transformer encoder layer as an "adapter." This component helps the student better mimic the teacher's high-level feature space, facilitating more effective knowledge transfer.
Experimental Results
The researchers evaluated QSKD on the MS-COCO 2017 dataset across various DETR architectures, including Conditional DETR, DAB DETR, and DINO.
- Performance Gains: QSKD consistently outperformed state-of-the-art distillation methods. For instance, a DAB DETR with a ResNet-18 backbone saw an improvement from 36.2 to 41.5 AP (+5.3).
- Efficiency: By utilizing LAPD, the training time for a DINO model was reduced from 15 hours per epoch to just 2 hours, representing a 6x speedup in the distillation process.
- Self-Distillation: The framework also proved effective for self-distillation (where teacher and student share the same backbone), providing a ~1.3 AP boost and helping models converge to superior local minima.
Conclusion
QSKD demonstrates that "hard negatives" are a vital source of information for distilling Detection Transformers. By selectively focusing on these queries and using attention-guided masks for feature alignment, the framework significantly enhances the performance of efficient student models. Future work may explore online distillation variants and the generalization of this query-selection logic to cross-architecture scenarios, such as distilling Transformers into convolutional neural networks.
Summary updated