Abstract
Object detection has advanced significantly with Detection Transformers (DETRs). However, these models are computationally demanding, posing challenges for deployment in resource-constrained environments. Knowledge distillation (KD) is an effective compression method, but its application to DETR models has been limited. Most KD methods for DETRs fail to distill transformer-specific global context and often rely on potentially misleading teacher predictions. This paper proposes Consistent Location-and-Context-aware Knowledge Distillation (CLoCKDistill) for DETR detectors. By distilling the transformer encoder output (memory) enriched with object location details and utilizing target-aware queries for logit distillation, CLoCKDistill boosts student performance by 2.2% to 6.4% mAP on KITTI and COCO datasets.
Introduction
Detection Transformers (DETRs) have revolutionized computer vision by treating object detection as a set-prediction problem, eliminating the need for hand-crafted components like anchors or non-maximum suppression. Despite their performance, the high computational cost of DETRs hinders their use on edge devices, such as sensors in autonomous vehicles.
Knowledge Distillation (KD) is a standard technique for model compression, where a compact "student" model learns from a larger "teacher." However, applying KD to DETRs presents unique challenges:
- Context Mismatch: Standard KD focuses on CNN backbone features, neglecting the global context and long-range dependencies captured in the transformer's encoder.
- Unstable Alignment: DETRs produce unordered sets of predictions. Aligning student and teacher outputs for logit distillation is difficult, and relying on teacher predictions can lead to the "blind leading the blind" if the teacher is incorrect.
Methodology: CLoCKDistill
The proposed CLoCKDistill framework addresses these issues through two primary components:
Location-and-Context-aware Memory Distillation
Instead of focusing on the backbone, CLoCKDistill distills the transformer encoder memory. This memory contains the global context essential for DETR performance. To refine this process, two masks are applied:
- Location-aware Mask ($M$): Uses ground truth to guide the student's attention toward foreground objects.
- Scale Mask ($S$): Balances the influence of objects of different sizes, preventing large objects from dominating the learning signal.
Target-aware Consistent Logit Distillation
To stabilize logit distillation, the authors introduce target-aware queries. These queries are generated directly from ground truth labels and bounding boxes. By feeding these fixed queries into both the teacher and student decoders, both models are forced to attend to the same spatial regions. This provides a consistent, accurate signal for the student, bypassing the noise inherent in teacher-predicted boxes.
Experimental Results
The method was evaluated on the KITTI and MS COCO datasets across various DETR architectures, including DAB-DETR, Deformable DETR, and DINO.
Quantitative Performance
CLoCKDistill consistently outperformed state-of-the-art methods like MGD and KD-DETR. On KITTI, it improved a DINO (ResNet-18) student by 6.4% mAP. Furthermore, a student model with half the layers (3 encoder/3 decoder) distilled with CLoCKDistill outperformed the full-scale baseline while achieving a 1.6x speedup (44.8 FPS).
Qualitative Analysis
Visualizing the attention maps reveals that CLoCKDistill helps the student model focus more precisely on relevant objects while ignoring background clutter.
As shown in the figure above, the self-attention-based distillation (c) results in much cleaner and more object-centric attention maps compared to traditional CNN-based methods (b), which often highlight irrelevant background regions.
Conclusion
CLoCKDistill effectively bridges the gap between heavy teacher DETRs and lightweight students by focusing on global context and stable spatial guidance. The significant performance gains and improved attention focus suggest that this approach is highly suitable for real-time applications and could potentially extend to tasks like instance segmentation.
Summary updated