Skip to main content

RF-DETR

Project description

RF-DETR: SOTA Real-Time Object Detection Model

colab roboflow discord

RF-DETR is a real-time, transformer-based object detection model architecture developed by Roboflow and released under the Apache 2.0 license.

RF-DETR is the first real-time model to exceed 60 AP on the Microsoft COCO benchmark alongside competitive performance at base sizes. It also achieves state-of-the-art performance on RF100-VL, an object detection benchmark that measures model domain adaptability to real world problems. RF-DETR is comparable speed to current real-time objection models.

RF-DETR is small enough to run on the edge, making it an ideal model for deployments that need both strong accuracy and real-time performance.

Results

We validated the performance of RF-DETR on both Microsoft COCO and the RF100-VL benchmarks.

rf-detr-coco-rf100-vl-8

Model mAPCOCO val
@0.50:0.95
mAPRF100-VL
Average @0.50
Total Latency
T4 bs=1
(ms)
D-FINE-M 55.1 N/A 6.3
LW-DETR-M 52.5 84.0 6.0
YOLO11m 51.5 84.9 5.7
YOLOv8m 50.6 85.0 6.3
RF-DETR-B 53.3 86.7 6.0
Benchmark notes

The "Total Latency" reported here is measured on a T4 GPU using TensorRT10 FP16 (ms/img) and was introduced by LW-DETR. Unlike transformer-based models, YOLO models perform Non-Maximum Suppression (NMS) after generating predictions to refine bounding box candidates. While NMS boosts accuracy, it also slightly reduces speed due to the additional computation required, which varies with the number of objects in an image. Notably, many YOLO benchmarks include NMS in accuracy measurements but exclude it from speed metrics. By contrast, our benchmarking—following LW-DETR’s approach—factors in NMS latency to provide a uniform measure of the total time needed to obtain a final result across all models on the same hardware.

D-FINE’s fine-tuning capability is currently unavailable, making its domain adaptability performance inaccessible. The authors caution that “if your categories are very simple, it might lead to overfitting and suboptimal performance.” Furthermore, several open issues (#146, #146, #169, #214) currently prevent successful fine-tuning. We have opened an additional issue in hopes of ultimately benchmarking D-FINE with RF100-VL.

News

  • 2025/03/20: We release RF-DETR real-time object detection model. Code and checkpoint are available!

Installation

pip install rfdetr

The rfdetr package will be distributed soon via PyPI.

Prediction

RF-DETR comes out of the box with a checkpoint trained from the Microsoft COCO dataset.

import io
import requests
import supervision as sv
from PIL import Image
from rfdetr import RFDETRBase

model = RFDETRBase()

url = "https://media.roboflow.com/notebooks/examples/dog-2.jpeg"

image = Image.open(io.BytesIO(requests.get(url).content))
detections = model.predict(image, threshold=0.5)

annotated_image = image.copy()
annotated_image = sv.BoxAnnotator().annotate(annotated_image, detections)
annotated_image = sv.LabelAnnotator().annotate(annotated_image, detections)

sv.plot_image(annotated_image)

rf-detr-coco-results-2

Training

Dataset structure

RF-DETR expects the dataset to be in COCO format. Divide your dataset into three subdirectories: train, valid, and test. Each subdirectory should contain its own _annotations.coco.json file that holds the annotations for that particular split, along with the corresponding image files. Below is an example of the directory structure:

dataset/
├── train/
│   ├── _annotations.coco.json
│   ├── image1.jpg
│   ├── image2.jpg
│   └── ... (other image files)
├── valid/
│   ├── _annotations.coco.json
│   ├── image1.jpg
│   ├── image2.jpg
│   └── ... (other image files)
└── test/
    ├── _annotations.coco.json
    ├── image1.jpg
    ├── image2.jpg
    └── ... (other image files)

Roboflow allows you to create object detection datasets from scratch or convert existing datasets from formats like YOLO, and then export them in COCO JSON format for training. You can also explore Roboflow Universe to find pre-labeled datasets for a range of use cases.

Fine-tuning

You can fine-tune RF-DETR from pre-trained COCO checkpoints. By default, the RF-DETR-B checkpoint will be used. To get started quickly, please refer to our fine-tuning Google Colab notebook.

from rfdetr import RFDETRBase

model = RFDETRBase()

model.train(dataset_dir=<DATASET_PATH>, epochs=10, batch_size=4, grad_accum_steps=4, lr=1e-4)

Result checkpoints

During training, two model checkpoints (the regular weights and an EMA-based set of weights) will be saved in the specified output directory. The EMA (Exponential Moving Average) file is a smoothed version of the model’s weights over time, often yielding better stability and generalization.

Load and run fine-tuned model

from rfdetr import RFDETRBase

model = RFDETRBase(pretrain_weights=<CHECKPOINT_PATH>)

detections = model.predict(<IMAGE_PATH>)

License

Both the code and the weights pretrained on the COCO dataset are released under the Apache 2.0 license.

Acknowledgements

Our work is built upon LW-DETR, DINOv2, and Deformable DETR. Thanks to their authors for their excellent work!

Citation

If you find our work helpful for your research, please consider citing the following BibTeX entry.

@software{rf-detr,
  author = {Robinson, Isaac and Robicheaux, Peter and Popov, Matvei},
  license = {Apache-2.0},
  title = {RF-DETR},
  howpublished = {\url{https://github.com/roboflow/rf-detr}},
  year = {2025},
  note = {SOTA Real-Time Object Detection Model}
}

Contribution

We welcome and appreciate all contributions! If you notice any issues or bugs, have questions, or would like to suggest new features, please open an issue or pull request. By sharing your ideas and improvements, you help make RF-DETR better for everyone.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rfdetr-1.0.1.tar.gz (93.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rfdetr-1.0.1-py3-none-any.whl (104.5 kB view details)

Uploaded Python 3

File details

Details for the file rfdetr-1.0.1.tar.gz.

File metadata

  • Download URL: rfdetr-1.0.1.tar.gz
  • Upload date:
  • Size: 93.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.1

File hashes

Hashes for rfdetr-1.0.1.tar.gz
Algorithm Hash digest
SHA256 1c12315c60174a8af0d2e5dc98ce5b58e6de73965e75e05f66777f80b162a3c3
MD5 119abe6fd4129ecdcc789dcb3a7fa58d
BLAKE2b-256 39440b997b1e5f01a146fa02779aa6019cadc33ee2f7b2fea6eca8cce8b32c00

See more details on using hashes here.

File details

Details for the file rfdetr-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: rfdetr-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 104.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.1

File hashes

Hashes for rfdetr-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b4c484cafe73398edbcd50bf7368771c9ecbd6e1f355854a233bbc283191096c
MD5 f323b76832dc77d6344a5c1b3c73bed7
BLAKE2b-256 05d80d6cd98f0849b594a61d0e489b9eac4c733902f411ca3e0e5e7a7961c766

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page