> This is the documentation for LibreYOLO 1.5.0. Current version: https://www.libreyolo.com/docs/models/detr

# DETR
DETR is the original detection transformer, predicting a fixed set of objects with a Hungarian-matched transformer decoder instead of anchors or a dense grid. LibreYOLO ships four sizes for detection, inference only.
Tasks: Detection. Install: pip install libreyolo.
Verified against LibreYOLO v1.5.0.

## Install

DETR needs no optional extra. Everything it imports is in the base install.

```bash
pip install libreyolo
```

## Predict

Weights download from Hugging Face on first use and are cached locally.

**Python**

```python
from libreyolo import LibreYOLO, SAMPLE_IMAGE

model = LibreYOLO("LibreDETRr50.pt")
result = model(SAMPLE_IMAGE, save=True)

for box in result.boxes:
    print(box.cls, box.conf, box.xyxy)
```

**CLI**

```bash
libreyolo predict model=LibreDETRr50.pt source=https://raw.githubusercontent.com/LibreYOLO/libreyolo/release/libreyolo/assets/parkour.jpg save=True
```

The returned `Results` object is the one every family returns, so swapping in a
different detector is a one line change. `conf` and `max_det` filter the query
selection; `iou` is accepted for API parity but has no effect, because the
decoder is a set predictor with no NMS step. See
[prediction](/docs/v1.5.0/predict) for sources, streaming and result handling.

DETR is inference-only in LibreYOLO. Upstream trains for 500 epochs with
Hungarian matching; that recipe is not implemented here, so `train()` raises
`NotImplementedError`.

## Variants

Four checkpoints combine two backbone depths, ResNet-50 or ResNet-101, with an
optional dilated C5 stage: the DC5 variants keep the last backbone stage at
full resolution instead of downsampling further, so the decoder reads a finer
feature map from the same input size. All four share 100 learned object
queries and a six-layer transformer encoder-decoder, and all run at the same
input resolution.

## Validate

`val()` returns a dictionary of `metrics/` keys covering precision, recall,
mAP 50 and mAP 50-95, measured against any dataset in the format you trained on.

**Python**

```python
from libreyolo import LibreYOLO

model = LibreYOLO("LibreDETRr50.pt")

# val() returns a plain dict, not an object
metrics = model.val(data="my-dataset.yaml")

print(metrics["metrics/mAP50-95"])
print(metrics["metrics/mAP50"])
print(metrics["metrics/precision"], metrics["metrics/recall"])
```

**CLI**

```bash
libreyolo val model=LibreDETRr50.pt data=my-dataset.yaml
```

## Export

| Task | ONNX | TorchScript | ExecuTorch | TensorRT | OpenVINO | Paddle | MNN | RKNN | ncnn | TFLite | CoreML | Core AI |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Detection | yes | yes | yes | yes | yes |  |  |  |  |  |  |  |

A "yes" means the export is supported. An empty cell means the exporter refuses that combination.

An exported artifact loads back through `LibreYOLO()` on its file suffix, so a
`.onnx` or `.engine` file behaves like a checkpoint and returns the same
`Results`. [Export](/docs/v1.5.0/export) lists the arguments every format accepts.

**Python**

```python
from libreyolo import LibreYOLO

model = LibreYOLO("LibreDETRr50.pt")
model.export(format="onnx", imgsz=800)
model.export(format="tensorrt", imgsz=800, half=True)
```

**CLI**

```bash
libreyolo export model=LibreDETRr50.pt format=onnx imgsz=800
libreyolo export model=LibreDETRr50.pt format=tensorrt imgsz=800 half=True
```

**Use the exported file**

```python
from libreyolo import LibreYOLO, SAMPLE_IMAGE

# The factory routes on the file suffix, so an exported artifact loads
# like any checkpoint and returns the same Results object.
model = LibreYOLO("LibreDETRr50.onnx")
result = model(SAMPLE_IMAGE)

print(result.boxes.xyxy)
```

## Checkpoints

Every published weight file for this family.

| File | Input (px) | Task | Weights license |
| --- | --- | --- | --- |
| `LibreDETRr50dc5.pt` | 800 | Detection | apache-2.0 |
| `LibreDETRr50.pt` | 800 | Detection | apache-2.0 |
| `LibreDETRr101dc5.pt` | 800 | Detection | apache-2.0 |
| `LibreDETRr101.pt` | 800 | Detection | apache-2.0 |

## Licensing

Check the license on the Hugging Face repository of the specific weights you download. That repository is authoritative and licenses are not always uniform across a family. This is a description of the licenses involved, not legal advice.

- Original work: DETR, Meta AI (FAIR)
- Upstream license: Apache-2.0
- Upstream source: https://github.com/facebookresearch/detr
- LibreYOLO code: Apache-2.0
- Weights: Apache-2.0, republished at https://huggingface.co/LibreYOLO
- Interpretation: Apache-2.0 is a permissive license, so these weights can be used in commercial and closed-source products. It asks you to keep its license text and attribution notices with any copy of the weights you redistribute, and it grants a patent license. It places no obligation on your own application code, and weights you train yourself on your own data are yours. The four checkpoints are the official releases linked from the Apache-2.0 repository's model zoo, and the official Hugging Face DETR card independently declares the same license.
