RFDETR base class and exposes the same predict(), train(), export(), and deploy_to_roboflow() methods.
- Detection
- Segmentation
Detection models return bounding boxes and class labels via
RFDETRNano — smallest model, best for edge devices and real-time applications.RFDETRSmallRFDETRMedium — recommended starting point for most use cases.RFDETRLargeRFDETRXLarge / RFDETR2XLarge (Plus)
supervision.Detections.| Class | Resolution | Pretrain weights | License |
|---|---|---|---|
RFDETRNano | 384 | rf-detr-nano.pth | Apache-2.0 |
RFDETRSmall | 512 | rf-detr-small.pth | Apache-2.0 |
RFDETRMedium | 576 | rf-detr-medium.pth | Apache-2.0 |
RFDETRLarge | 704 | rf-detr-large-2026.pth | Apache-2.0 |
RFDETRXLarge | — | — | PML 1.0 (Plus) |
RFDETR2XLarge | — | — | PML 1.0 (Plus) |
Constructor parameters
All variant constructors accept the same keyword arguments. These correspond to fields on the underlyingModelConfig.
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).Number of output classes. Override when loading a checkpoint trained on a custom dataset with a different class count.
Target device for the model. Accepts torch-style strings:
"cpu", "cuda", "cuda:0", "mps". Defaults to the best available device.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.Enable gradient checkpointing to reduce GPU memory usage during training at the cost of a small speed penalty.
Apply LoRA adapters to the backbone encoder. Reduces the number of trainable parameters when fine-tuning.
Freeze the backbone encoder weights entirely, training only the detection head.
Load from a custom checkpoint
Usefrom_checkpoint() to load a model from a checkpoint produced by model.train(). The variant class is inferred automatically from the checkpoint’s metadata:
RFDETR.from_checkpoint() for full documentation.
Related
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.