RF-DETR
RF-DETR is a real-time object detection and instance segmentation model from Roboflow, with keypoint detection and semantic segmentation variants. Train it on Roboflow, run it through the Serverless C
RF-DETR Object Detection
RF-DETR is Roboflow's transformer-based real-time detection model. Run inference against COCO-pretrained object detection checkpoints through the Serverless Cloud API, or self-host using Roboflow Inference.
RF-DETR Object Detection API
The steps below run RF-DETR through the Serverless Cloud API and visualize results with supervision.
Get your API Key
Create a Roboflow account, find your key on the Roboflow API settings page and make it available to your shell:
export ROBOFLOW_API_KEY="your-key-here"Install the dependencies
These two packages call the model and draw its results:
pip install -U inference-sdk supervisionRun the model
Run rfdetr-small on a sample image and annotate boxes and labels:
import os
import cv2
import supervision as sv
from inference_sdk import InferenceHTTPClient, InferenceConfiguration
image_url = "https://media.roboflow.com/quickstart/traffic.jpg"
image = sv.load_image_from_url(image_url)
client = InferenceHTTPClient(
api_url="https://serverless.roboflow.com",
api_key=os.environ["ROBOFLOW_API_KEY"],
).configure(InferenceConfiguration(api_key_transport="header"))
result = client.infer(image, model_id="rfdetr-small")
detections = sv.Detections.from_inference(result)
annotated = sv.BoxAnnotator().annotate(image.copy(), detections)
annotated = sv.LabelAnnotator().annotate(annotated, detections)
cv2.imwrite("traffic-annotated.png", annotated)
RF-DETR Object Detection models and benchmarks
Pass any of these aliases as the model_id when running inference. The SDK resolves each alias to the underlying Roboflow project version.
rfdetr-nano
384x384
48.4
9.7
6.2
rfdetr-small
512x512
53.0
12.9
8.3
rfdetr-medium
576x576
54.7
16.3
9.5
rfdetr-large
704x704
56.5
25.6
11.6
rfdetr-xlarge
700x700
58.6
41.6
14.9
rfdetr-2xlarge
880x880
60.1
53.4
21.7
RF-DETR Instance Segmentation
RF-DETR also provides instance segmentation checkpoints that predict masks alongside boxes. Run them through the Serverless Cloud API, or self-host using Roboflow Inference.
RF-DETR Instance Segmentation API
Set your API key and install the dependencies as shown above, then run a segmentation checkpoint and draw its masks:

RF-DETR Instance Segmentation models and benchmarks
Pass any of these aliases as the model_id when running inference. The SDK resolves each alias to the underlying Roboflow project version. Figures are mask mAP on COCO val.
rfdetr-seg-nano
312x312
40.3
15.8
10.5
rfdetr-seg-small
384x384
43.1
19.3
11.9
rfdetr-seg-medium
432x432
45.3
23.9
14.1
rfdetr-seg-large
504x504
47.1
30.1
15.4
rfdetr-seg-xlarge
624x624
48.8
51.2
19.1
rfdetr-seg-2xlarge
768x768
49.9
89.6
25.6
RF-DETR Semantic Segmentation
RF-DETR semantic segmentation assigns a class to each pixel. Regions of the same class share a label rather than being split into separate objects. Pretrained checkpoints cover the 150 ADE20K scene classes (ex: sky, building, road, car, person). Run them through the Serverless Cloud API, or self-host using Roboflow Inference.
RF-DETR Semantic Segmentation API
Set your API key and install the dependencies as shown above, then run a pretrained checkpoint and draw its classes:
The segmentation_mask is a base64-encoded PNG whose pixel values are class IDs. Use class_map to map those IDs to class names. Class ID 0 is the background, which the example leaves undrawn. The example turns each class into one supervision detection, so you can draw it with any mask annotator. Keep client-side downsizing disabled so the mask matches the input image size.

RF-DETR Semantic Segmentation models and training
Pass any of these model IDs as the model_id when running inference. Each one is pretrained on ADE20K.
rfdetr-pretrains/rfdetr-sem-nano-ade20k
312x312
rfdetr-pretrains/rfdetr-sem-small-ade20k
384x384
rfdetr-pretrains/rfdetr-sem-medium-ade20k
432x432
rfdetr-pretrains/rfdetr-sem-large-ade20k
500x500
rfdetr-pretrains/rfdetr-sem-xlarge-ade20k
560x560
rfdetr-pretrains/rfdetr-sem-2xlarge-ade20k
880x880
To segment your own classes, create a Semantic Segmentation project, then choose RF-DETR and a size in Custom Training. You can also use Neural Architecture Search to compare models for your accuracy and latency needs. Evaluate semantic segmentation accuracy with mean Intersection over Union (mIoU), rather than the box or mask mAP in the tables above.
RF-DETR Keypoint Detection
RF-DETR keypoint detection is a preview checkpoint, pretrained on COCO person keypoints. Run it through the Serverless Cloud API, or self-host using Roboflow Inference.
RF-DETR Keypoint Detection API
Set your API key and install the dependencies as shown above, then run rfdetr-keypoint-preview and annotate keypoints:

RF-DETR Keypoint Detection models and benchmarks
Pass the alias as the model_id when running inference. Accuracy is COCO val AP50-95 scored with object keypoint similarity (OKS), the standard COCO keypoint metric, so it does not compare to the box and mask mAP above.
rfdetr-keypoint-preview
576x576
71.8
126.4
9.7
Roboflow does not publish a prebuilt TensorRT engine for this checkpoint yet, so Inference runs it on ONNX Runtime even when you install the inference-models[trt10] extra. Reaching the latency in the table means building the engine yourself with the rfdetr package.
† Keypoint accuracy and latency are the figures published in the RF-DETR benchmarks: latency is TensorRT FP16 on 1x NVIDIA T4 at batch size 1, timing the model only. That is a different GPU and a different pipeline from the tables above, so the two sets of latencies do not compare directly.
* Latency is measured with Roboflow Inference on 1x NVIDIA L4, batch size 1, mean of 1,000 inferences (100 warmup). The default inference-gpu install runs ONNX on the CUDA execution provider; adding the inference-models[trt10] extra selects a prebuilt TensorRT FP16 engine automatically. FP16 matches FP32 accuracy within 0.2 mAP on COCO val2017. Accuracy is the published COCO val spec (see the RF-DETR announcement).
Upload Custom Weights
To run an RF-DETR model you trained outside Roboflow, upload its weights to a Project with the Roboflow CLI:
Set -t to the variant you trained (ex: rfdetr-small, rfdetr-seg-medium). See Upload Custom Weights for the Python SDK and training version requirements.
License
RF-DETR uses two licenses depending on the model size:
Apache 2.0 (Nano, Small, Medium, and Large detection, every segmentation size, and Keypoint): free for commercial use, including self-hosted and closed-source products. No license fee and no need to open-source your code.
PML 1.0 (XL and 2XL detection, every semantic segmentation size, and the Two-Stage keypoint model; the Roboflow Platform Model License): commercial use is included when you deploy on Roboflow; commercial self-hosting requires the Enterprise add-on.
See Model Licenses for details.
Last updated
Was this helpful?