Skip to main content
RF-DETR ships two families of models: detection models that return bounding boxes, and segmentation models that additionally return instance masks. Every variant inherits from the RFDETR base class and exposes the same predict(), train(), export(), and deploy_to_roboflow() methods.
Detection models return bounding boxes and class labels via supervision.Detections.
ClassResolutionPretrain weightsLicense
RFDETRNano384rf-detr-nano.pthApache-2.0
RFDETRSmall512rf-detr-small.pthApache-2.0
RFDETRMedium576rf-detr-medium.pthApache-2.0
RFDETRLarge704rf-detr-large-2026.pthApache-2.0
RFDETRXLargePML 1.0 (Plus)
RFDETR2XLargePML 1.0 (Plus)
RFDETRXLarge and RFDETR2XLarge are Plus models and require the separately licensed rfdetr_plus package. They are subject to the Roboflow Model License (PML 1.0) rather than Apache-2.0. Install the Plus package and review the license terms before use.
RFDETRNano — smallest model, best for edge devices and real-time applications.
from rfdetr import RFDETRNano

model = RFDETRNano()
detections = model.predict("image.jpg")
RFDETRSmall
from rfdetr import RFDETRSmall

model = RFDETRSmall()
detections = model.predict("image.jpg")
RFDETRMedium — recommended starting point for most use cases.
from rfdetr import RFDETRMedium

model = RFDETRMedium()
detections = model.predict("image.jpg")
RFDETRLarge
from rfdetr import RFDETRLarge

model = RFDETRLarge()
detections = model.predict("image.jpg")
RFDETRXLarge / RFDETR2XLarge (Plus)
from rfdetr import RFDETRXLarge, RFDETR2XLarge

model = RFDETRXLarge()
detections = model.predict("image.jpg")

Constructor parameters

All variant constructors accept the same keyword arguments. These correspond to fields on the underlying ModelConfig.
pretrain_weights
str
Path to a local .pth / .pt weights file, or the filename of a hosted weights file (e.g. "rf-detr-medium.pth"). When provided as a plain filename, RF-DETR downloads the weights from the Roboflow model hub automatically. Pass an absolute or relative path to load local weights.Defaults to the variant’s bundled pretrain weights (see the table above).
num_classes
int
default:"90"
Number of output classes. Override when loading a checkpoint trained on a custom dataset with a different class count.
device
str
Target device for the model. Accepts torch-style strings: "cpu", "cuda", "cuda:0", "mps". Defaults to the best available device.
resolution
int
Override the default input resolution (square side length in pixels). Must be divisible by patch_size × num_windows. It is rarely necessary to change this; the default value for each variant is shown in the table above.
gradient_checkpointing
boolean
default:"false"
Enable gradient checkpointing to reduce GPU memory usage during training at the cost of a small speed penalty.
backbone_lora
boolean
default:"false"
Apply LoRA adapters to the backbone encoder. Reduces the number of trainable parameters when fine-tuning.
freeze_encoder
boolean
default:"false"
Freeze the backbone encoder weights entirely, training only the detection head.

Load from a custom checkpoint

Use from_checkpoint() to load a model from a checkpoint produced by model.train(). The variant class is inferred automatically from the checkpoint’s metadata:
from rfdetr import RFDETRMedium

model = RFDETRMedium.from_checkpoint("output/checkpoint_best_total.pth")
You can also instantiate any variant directly with a local weights path:
model = RFDETRMedium(pretrain_weights="path/to/my-finetuned-weights.pth")
See RFDETR.from_checkpoint() for full documentation.

RFDETR class

Full method reference for predict, train, export, and deploy.

Run detection

Guide to running inference with detection models.

Run segmentation

Guide to running inference with segmentation models.

Pretrained models

Overview of all available pretrained weights.

Build docs developers (and LLMs) love