whatisgithub

What is detr?

facebookresearch/detr — explained in plain English

Analysis updated 2026-06-24

15,266PythonAudience · researcherComplexity · 4/5Setup · hard

In one sentence

Research code from Facebook AI for end-to-end object detection using Transformers, detects objects and draws bounding boxes in one shot without a multi-stage pipeline, matching top detectors at half the compute.

Mindmap

mindmap
  root((detr))
    What it does
      End-to-end detection
      Bounding box prediction
      Panoptic segmentation
    How it works
      Transformer encoder-decoder
      Object queries
      Bipartite matching loss
      Set prediction
    Tech Stack
      Python
      PyTorch
      conda
    Included
      Pretrained models
      Colab notebooks
      Detectron2 wrapper
    Audience
      Researchers
      Vision ML engineers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Train a custom object detection model on your own dataset using DETR as a clean, pipeline-free PyTorch starting point.

USE CASE 2

Run panoptic segmentation on images using the pretrained DETR models included with the repo.

USE CASE 3

Experiment with Transformer-based vision architectures by studying DETR's roughly 50-line inference implementation.

USE CASE 4

Benchmark DETR against traditional detectors on the COCO dataset using the provided training scripts.

What is it built with?

PythonPyTorchconda

How does it compare?

facebookresearch/detrpre-commit/pre-commitencode/httpx
Stars15,26615,26715,264
LanguagePythonPythonPython
Setup difficultyhardeasyeasy
Complexity4/52/52/5
Audienceresearcherdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · hard Time to first run · 1h+

Requires a GPU and a conda environment, pretrained model weights must be downloaded separately before running inference.

Not specified in the explanation.

So what is it?

DETR, short for Detection Transformer, is research code from Facebook AI for end-to-end object detection. Object detection is the computer vision task of looking at an image and not just saying what is in it, but also drawing a box around each thing and labelling it (a dog here, a car there). The README explains that DETR replaces the usual hand-crafted detection pipeline (lots of stages and special-purpose tricks) with a single Transformer model that produces the whole set of boxes in one shot. The README describes how it works in plain terms: DETR treats detection as a direct set prediction problem. A small fixed set of learned object queries are fed through a Transformer encoder-decoder, and the network reasons about how the objects relate to each other and to the global image content, then outputs the final predictions in parallel. A set-based global loss using bipartite matching makes sure each ground-truth object is matched with exactly one prediction during training. The repo states that this approach matches a well-known baseline detector on the COCO benchmark while using half the computation. It also notes that the inference logic can be written in about 50 lines of code. You would use DETR if you are training or experimenting with object detection or panoptic segmentation models and want a clean, library-free starting point. The code is written in PyTorch (a Python deep learning framework named in the README), is installed via conda, and ships with pretrained models, Colab notebooks, and an optional Detectron2 wrapper. The full README is longer than what was provided.

Copy-paste prompts

Prompt 1
I want to run DETR inference on my own images using the pretrained model. Write me a Python script that loads the pretrained DETR model from the repo, runs it on a local image file, and draws the predicted bounding boxes with labels using matplotlib.
Prompt 2
I want to fine-tune DETR on a custom dataset with my own object categories. Explain what changes I need to make to the DETR codebase, number of classes, data loader, and training config, to train on my data.
Prompt 3
Explain how DETR's bipartite matching loss works in plain English, why does it need Hungarian matching instead of the anchor-based assignment used by traditional detectors?
Prompt 4
Show me how to use the Detectron2 wrapper included with DETR to integrate it into an existing Detectron2 training pipeline and evaluate it on a COCO-format dataset.

Frequently asked questions

What is detr?

Research code from Facebook AI for end-to-end object detection using Transformers, detects objects and draws bounding boxes in one shot without a multi-stage pipeline, matching top detectors at half the compute.

What language is detr written in?

Mainly Python. The stack also includes Python, PyTorch, conda.

What license does detr use?

Not specified in the explanation.

How hard is detr to set up?

Setup difficulty is rated hard, with roughly 1h+ to a first successful run.

Who is detr for?

Mainly researcher.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.