Skip to main content
RF-DETR is a real-time transformer architecture for object detection, built on a DINOv2 vision transformer backbone. The pretrained models are trained on the Microsoft COCO dataset and achieve state-of-the-art accuracy and latency trade-offs.

Model sizes

RF-DETR offers detection model sizes from Nano to 2XLarge. Choose a size based on your latency and accuracy requirements. To switch sizes, replace the class name or inference alias in your code.
SizePython classInference aliasCOCO AP50COCO AP50:95Latency (ms)Params (M)ResolutionLicense
NRFDETRNanorfdetr-nano67.648.42.330.5384x384Apache 2.0
SRFDETRSmallrfdetr-small72.153.03.532.1512x512Apache 2.0
MRFDETRMediumrfdetr-medium73.654.74.433.7576x576Apache 2.0
LRFDETRLargerfdetr-large75.156.56.833.9704x704Apache 2.0
XL △RFDETRXLargerfdetr-xlarge77.458.611.5126.4700x700PML 1.0
2XL △RFDETR2XLargerfdetr-2xlarge78.560.117.2126.9880x880PML 1.0
△ The XLarge and 2XLarge models require the rfdetr_plus extension. Install it with pip install rfdetr[plus]. These models are licensed under PML 1.0 and require a Roboflow account.

Run on an image

import supervision as sv
from rfdetr import RFDETRMedium
from rfdetr.assets.coco_classes import COCO_CLASSES

model = RFDETRMedium()

detections = model.predict("https://media.roboflow.com/dog.jpg", threshold=0.5)

labels = [f"{COCO_CLASSES[class_id]}" for class_id in detections.class_id]

annotated_image = sv.BoxAnnotator().annotate(detections.data["source_image"], detections)
annotated_image = sv.LabelAnnotator().annotate(annotated_image, detections, labels)
predict() returns a supervision.Detections object containing bounding box coordinates, confidence scores, and class IDs. Access the source image via detections.data["source_image"].

Batch inference

Pass a list of images to predict() to process multiple images in a single forward pass. The method returns a list of supervision.Detections objects in the same order as the input.
import io
import requests
import supervision as sv
from PIL import Image
from rfdetr import RFDETRMedium
from rfdetr.assets.coco_classes import COCO_CLASSES

model = RFDETRMedium()

urls = [
    "https://media.roboflow.com/notebooks/examples/dog-2.jpeg",
    "https://media.roboflow.com/notebooks/examples/dog-3.jpeg",
]

images = [Image.open(io.BytesIO(requests.get(url).content)) for url in urls]

detections_list = model.predict(images, threshold=0.5)

for image, detections in zip(images, detections_list):
    labels = [
        f"{COCO_CLASSES[class_id]} {confidence:.2f}"
        for class_id, confidence in zip(detections.class_id, detections.confidence)
    ]

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

    sv.plot_image(annotated_image)

Run with Roboflow Inference

You can also run RF-DETR using the Inference library. To switch model size, use the corresponding inference alias from the table above.
import requests
import supervision as sv
from PIL import Image
from inference import get_model

model = get_model("rfdetr-medium")

image = Image.open(requests.get("https://media.roboflow.com/dog.jpg", stream=True).raw)
predictions = model.infer(image, confidence=0.5)[0]
detections = sv.Detections.from_inference(predictions)

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

Pretrained models

Full model comparison table with accuracy, latency, and parameter counts.

Instance segmentation

Run RF-DETR for pixel-level instance segmentation.

Train a model

Fine-tune RF-DETR on your own dataset.

Deploy to Roboflow

Deploy your model to the Roboflow platform.

Build docs developers (and LLMs) love