RT-DETR

A detection transformer built for real-time inference: it decodes a fixed set of queries rather than a dense grid, so it runs no NMS. LibreYOLO carries three versions of it, told apart by the checkpoint you load.

Tasks
detection
Sizes
rtdetr: r18, r34, r50, r50m, r101, l, x at 640 px; rtdetrv2: r18, r34, r50, r50m, r101 at 640 px; rtdetrv4: s, m, l, x at 640 px
Install
pip install "libreyolo[rtdetr]"
Support tier
Core, since v1.1.0. Core trainable detectors: features follow the flagships in the same release wave.
Upstream
RT-DETR, RT-DETRv2 and RT-DETRv4 by Baidu (versions 1 and 2), Peking University and Tsinghua University (version 4), Apache-2.0. Paper, source
Licenses
Code Apache-2.0, weights Apache-2.0. Commercial use

Install

RT-DETR needs no optional extra. Everything it imports is in the base install, and the rtdetr extra is a stable name that adds nothing to it.

bash
pip install libreyolo

Adapter fine-tuning with lora=True is the exception, and needs the lora extra.

bash
pip install "libreyolo[lora]"

Predict

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

Python
from libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("LibreRTDETRr18.pt")result = model(SAMPLE_IMAGE, save=True) for box in result.boxes:    print(box.cls, box.conf, box.xyxy)
CLI
libreyolo predict model=LibreRTDETRr18.pt save=True \  source=https://raw.githubusercontent.com/LibreYOLO/libreyolo/release/libreyolo/assets/parkour.jpg
Video
from libreyolo import LibreYOLO # The version is part of the file name, and the factory routes on the# checkpoint, so all three load the same way.model = LibreYOLO("LibreRTDETRv4s.pt") # Any source the library accepts: file, folder, URL, webcam index,# RTSP stream, or a .streams listfor result in model.predict("clip.mp4", stream=True, save=True):    print(len(result.boxes))

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 a top-k decode over queries and classes; there is no NMS step to tune, and iou is accepted but unused. See prediction for sources, streaming and result handling.

Variants

Three versions, one task between them, and the size codes do not run in a single series. Version 1 names its sizes after the backbone, ResNet or HGNetv2. Version 2 reuses the ResNet names only: version 1 already ships the two HGNetv2 sizes, and version 2's results there were close enough that LibreYOLO publishes no duplicate weights for them. Version 4 uses a plain letter series, which collides with version 1's HGNetv2 names, so a size code on its own does not identify a model. The version is written into the checkpoint file name.

CheckpointInput (px)mAP 50-95Params (M)
LibreRTDETRl64055.832.93
LibreRTDETRr10164056.876.56
LibreRTDETRr1864049.720.18
LibreRTDETRr3464052.231.44
LibreRTDETRr5064055.942.89
LibreRTDETRr50m64053.836.59
LibreRTDETRx64057.967.37
LibreRTDETRv2r10164056.876.56
LibreRTDETRv2r1864050.820.18
LibreRTDETRv2r3464053.231.44
LibreRTDETRv2r5064055.742.89
LibreRTDETRv2r50m64054.836.59
LibreRTDETRv4l64057.831.24
LibreRTDETRv4m64056.519.59
LibreRTDETRv4s64052.810.32
LibreRTDETRv4x64060.062.62

COCO val2017, 500 images. Measured by the LibreYOLO benchmark harness and published on Vision Analysis, where latency across hardware and runtimes is compared and the full run records live.

Version 2 keeps version 1's architecture and state dict layout and changes how the deformable attention samples, which is why the two are told apart by the metadata in the checkpoint rather than by shape. Version 4 is a different lineage: it reuses D-FINE's architecture and trainer, and its weights come from distilling a DINOv3 vision foundation model teacher into an HGNetv2 student. In LibreYOLO LibreRTDETRv4 is a subclass of LibreDFINE with the mask head pinned off, so it stays detection only.

Train

Training starts from a published checkpoint. pretrained is accepted and then dropped on all three versions, so pretrained=False does not give you a randomly initialized model.

Python
from libreyolo import LibreYOLO model = LibreYOLO("LibreRTDETRr18.pt") # coco128.yaml downloads a 128-image sample on first use. Point `data`# at your own dataset YAML for a real run.model.train(data="coco128.yaml", epochs=50, batch=4, lr0=1e-4)
CLI
libreyolo train model=LibreRTDETRr18.pt data=coco128.yaml \  epochs=50 batch=4 lr0=1e-4
LoRA
# Needs the lora extra: pip install "libreyolo[lora]"from libreyolo import LibreYOLO model = LibreYOLO("LibreRTDETRr18.pt")model.train(data="coco128.yaml", epochs=50, lora=True)
Multi-GPU
libreyolo train model=LibreRTDETRr18.pt data=coco128.yaml \  epochs=50 device=0,1

Learning rate is the argument to get right, and each version carries its own default rather than the library-wide one. The Python train() signature reads it from that version's training config, and the CLI resolves the same value when lr0 is not passed. Versions 1 and 2 also take lr_backbone and default it to a twentieth of lr0, following the original recipe; version 4 runs through the D-FINE trainer, which scales the backbone parameter group with backbone_lr_mult instead.

Leave imgsz at the checkpoint's native size unless you have a reason to change it. Validation and prediction at other sizes work, with one residual: a rectangular size whose token count matches the native size still reuses an embedding built for the wrong aspect ratio.

See training for datasets, augmentation, multi-GPU and loggers.

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
from libreyolo import LibreYOLO model = LibreYOLO("LibreRTDETRr18.pt") # val() returns a plain dict, not an objectmetrics = model.val(data="coco128.yaml") print(metrics["metrics/mAP50-95"])print(metrics["metrics/mAP50"])print(metrics["metrics/precision"], metrics["metrics/recall"])
CLI
libreyolo val model=LibreRTDETRr18.pt data=coco128.yaml
Against COCO
# coco-val-only.yaml fetches the 5000 val2017 images and skips the# training set. It carries an embedded download script, so it needs# explicit permission unless the dataset is already local.libreyolo val model=LibreRTDETRr18.pt data=coco-val-only.yaml \  allow_download_scripts=True

The rows in the benchmark table above come from the LibreYOLO benchmark harness; the note under that table records which dataset produced them and links the run records.

Export

TaskONNXTorchScriptExecuTorchTensorRTOpenVINOPaddleMNNRKNNncnnTFLiteCoreMLCore AI
DetectionDetection to ONNX: supported. Detection to TorchScript: supported. Detection to ExecuTorch: supported. Detection to TensorRT: supported. Detection to OpenVINO: supported. Detection to Paddle: not supportedDetection to MNN: supported. Detection to RKNN: not supportedDetection to ncnn: not supportedDetection to TFLite: not supportedDetection to CoreML: not supportedDetection to Core AI: supported.

The matrix covers the lineage as one page: where the three versions disagree about a format, the cell shows the weakest of the three, so nothing here is oversold for whichever version you load.

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.

Python
# Needs the onnx extra: pip install "libreyolo[onnx]"from libreyolo import LibreYOLO model = LibreYOLO("LibreRTDETRr18.pt")path = model.export(format="onnx")print(path)
CLI
libreyolo export model=LibreRTDETRr18.pt format=onnx
Use the exported file
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("LibreRTDETRr18.onnx")result = model(SAMPLE_IMAGE) print(result.boxes.xyxy)

Checkpoints

Every published weight file for this family.

FileInput (px)Weights license
Detection
LibreRTDETRr34.pt640apache-2.0
LibreRTDETRr18.pt640apache-2.0
LibreRTDETRr50.pt640apache-2.0
LibreRTDETRr50m.pt640apache-2.0
LibreRTDETRr101.pt640apache-2.0
LibreRTDETRl.pt640apache-2.0
LibreRTDETRx.pt640apache-2.0
LibreRTDETRv2r18.pt640apache-2.0
LibreRTDETRv2r34.pt640apache-2.0
LibreRTDETRv2r50m.pt640apache-2.0
LibreRTDETRv2r50.pt640apache-2.0
LibreRTDETRv2r101.pt640apache-2.0
LibreRTDETRv4s.pt640apache-2.0
LibreRTDETRv4m.pt640apache-2.0
LibreRTDETRv4l.pt640apache-2.0
LibreRTDETRv4x.pt640apache-2.0

Every file above exists in the LibreYOLO org today and downloads on first use.

Licensing

Check the license on the Hugging Face repository of the specific weights you download. Every checkpoint in the LibreYOLO org carries one, and they are not always the same across a family. That repository is the authoritative source; the summary below describes what applied when this page was last verified.

This is a description of the licenses involved, not legal advice. If the answer matters commercially, read the licenses yourself and take your own counsel.

Original work
RT-DETR, RT-DETRv2 and RT-DETRv4, Baidu (versions 1 and 2), Peking University and Tsinghua University (version 4)
Upstream license
Apache-2.0
LibreYOLO code
MIT
Weights
Apache-2.0, republished at 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. All three versions carry it, across two repositories and three papers: RT-DETR and RT-DETRv2 at github.com/lyuwenyu/RT-DETR, and RT-DETRv4 at github.com/RT-DETRs/RT-DETRv4, which is cited separately (arXiv 2510.25257). RT-DETRv4 distills from a DINOv3 teacher while training only; the released student weights hold no DINOv3 parameters, and the tensors that fed the teacher are dropped when a checkpoint is converted, so Meta's DINOv3 license does not reach them.

Citation

@misc{lv2023detrs,
      title={DETRs Beat YOLOs on Real-time Object Detection},
      author={Yian Zhao and Wenyu Lv and Shangliang Xu and Jinman Wei and Guanzhong Wang and Qingqing Dang and Yi Liu and Jie Chen},
      year={2023},
      eprint={2304.08069},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}

@misc{lv2024rtdetrv2improvedbaselinebagoffreebies,
      title={RT-DETRv2: Improved Baseline with Bag-of-Freebies for Real-Time Detection Transformer}, 
      author={Wenyu Lv and Yian Zhao and Qinyao Chang and Kui Huang and Guanzhong Wang and Yi Liu},
      year={2024},
      eprint={2407.17140},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2407.17140}, 
}

Copied from the authors' citation block at github.com/lyuwenyu/RT-DETR#citation.

The block above is what the authors publish for versions 1 and 2. Version 4 is a separate paper by a different group and has its own citation block at github.com/RT-DETRs/RT-DETRv4; cite that one if you used a version 4 checkpoint.

Verified against LibreYOLO v1.5.0. Support tables, checkpoints and benchmark numbers on this page are generated from the released library and the published weights, not written by hand.