Preprint
Machine Learning

DETR

May 1, 2020

0

Citations

0

Influential Citations

Venue

2020

Year

Abstract

A novel object detection model that treats object detection as a set prediction problem, eliminating the need for hand-designed components.

Analysis

Why This Paper Matters

Object detection has long relied on hand-crafted components like anchor boxes, non-maximum suppression (NMS), and region proposal networks. These elements encode prior knowledge about the task but also introduce complexity and hyperparameter tuning. DETR (DEtection TRansformer) challenges this status quo by reframing object detection as a direct set prediction problem, using a transformer architecture to predict all objects in an image in one pass. This simplification not only streamlines the pipeline but also demonstrates that end-to-end learning can match the performance of highly optimized systems like Faster R-CNN. For AI practitioners, DETR represents a shift toward more unified and less engineered models, potentially reducing development time and improving generalization.

How It Works

Figure 1

DETR's core innovation is treating object detection as a set prediction problem. The model outputs a fixed-size set of N predictions (where N is larger than the typical number of objects) and uses a bipartite matching loss to assign each prediction to a ground-truth object or to a "no object" class. This eliminates the need for NMS because the matching process inherently enforces uniqueness.

DETR directly predicts (in parallel) the final set of detections by combining a common CNN with a transformer architecture.

Object Detection Set Prediction Loss

The loss function has two stages: matching and loss computation. First, the Hungarian algorithm finds the optimal permutation σ that minimizes the matching cost between ground-truth objects y_i and predictions ŷ_σ(i). The matching cost combines class prediction (negative log-likelihood) and bounding box similarity (L1 and generalized IoU loss). Once the optimal assignment is found, the Hungarian loss is computed as the sum of negative log-likelihood for class labels and the same box loss, with the class loss down-weighted for empty predictions to handle class imbalance.

Figure 3

Figure 4

Architecture

Figure 5

DETR consists of three components:

  • Backbone: A standard CNN (e.g., ResNet-50) extracts a feature map from the input image, reducing spatial resolution by 32x.
  • Transformer Encoder: A 1x1 convolution reduces the feature channels to d (e.g., 256), then the spatial dimensions are collapsed into a sequence. Fixed positional encodings are added to each attention layer to retain spatial information.
  • Transformer Decoder: The decoder takes N learned embeddings called "object queries" (also with positional encodings) and processes them through self-attention and cross-attention with the encoder output. Unlike the original transformer, DETR decodes all N objects in parallel at each layer.
  • Prediction Feed-Forward Networks (FFNs): Each decoder output is passed through a 3-layer MLP with ReLU to predict bounding box coordinates (center, height, width normalized to the image) and a linear layer with softmax for class labels.

Results

Figure 6

Experiments on COCO 2017 (118k training images, 5k validation) show DETR with ResNet-50 achieves 42.0 AP, comparable to Faster R-CNN (42.0 AP). With ResNet-101, DETR reaches 43.5 AP vs. Faster R-CNN's 44.0 AP. Notably, DETR excels on large objects (APL: 51.0 vs. 49.0) but underperforms on small objects (APS: 20.5 vs. 23.5). The model also extends to panoptic segmentation by adding a segmentation head, achieving competitive results.

Significance

DETR's impact extends beyond its immediate performance. It demonstrates that transformers can effectively replace complex hand-crafted pipelines in computer vision, paving the way for unified architectures like DINO and DAB-DETR. The set-prediction formulation also simplifies deployment by removing NMS and anchor tuning. However, DETR's slower convergence and weakness on small objects highlight areas for improvement. For practitioners, DETR offers a cleaner, more principled approach to object detection that is easier to extend to other tasks like panoptic segmentation and multi-object tracking.