Implementation:Roboflow Rf detr RFDETR Size Variants
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Object_Detection, Model_Architecture |
| Last Updated | 2026-02-08 15:00 GMT |
Overview
Concrete tool for selecting object detection model size variants provided by the RF-DETR library.
Description
RF-DETR provides five detection model size classes (RFDETRNano, RFDETRSmall, RFDETRBase, RFDETRMedium, RFDETRLarge) and seven segmentation variants. Each subclass overrides get_model_config() to return a size-specific ModelConfig with architecture parameters. All inherit from the base RFDETR class and share the same API surface.
Usage
Import the appropriate size variant class when instantiating a model for inference or training. Choose based on your accuracy vs. speed requirements.
Code Reference
Source Location
- Repository: rf-detr
- File: rfdetr/detr.py
- Lines: L462-567 (size variant classes)
- Config File: rfdetr/config.py L57-141 (config classes)
Signature
class RFDETRBase(RFDETR):
"""Train an RF-DETR Base model (29M parameters)."""
size = "rfdetr-base"
def get_model_config(self, **kwargs) -> RFDETRBaseConfig: ...
class RFDETRNano(RFDETR):
"""Train an RF-DETR Nano model."""
size = "rfdetr-nano"
def get_model_config(self, **kwargs) -> RFDETRNanoConfig: ...
class RFDETRSmall(RFDETR):
"""Train an RF-DETR Small model."""
size = "rfdetr-small"
def get_model_config(self, **kwargs) -> RFDETRSmallConfig: ...
class RFDETRMedium(RFDETR):
"""Train an RF-DETR Medium model."""
size = "rfdetr-medium"
def get_model_config(self, **kwargs) -> RFDETRMediumConfig: ...
class RFDETRLarge(RFDETR):
"""Train an RF-DETR Large model."""
size = "rfdetr-large"
def get_model_config(self, **kwargs) -> RFDETRLargeConfig: ...
Import
from rfdetr import RFDETRBase, RFDETRNano, RFDETRSmall, RFDETRMedium, RFDETRLarge
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| pretrain_weights | Optional[str] | No | Path or hosted key for pretrained weights (e.g. "rf-detr-base.pth") |
| resolution | int | No | Input resolution (default varies by size: Nano=384, Small=512, Base=560, Medium=576, Large=704) |
| num_classes | int | No | Number of object classes (default: 90 for COCO) |
| device | str | No | Compute device: "cuda", "cpu", or "mps" |
Outputs
| Name | Type | Description |
|---|---|---|
| instance | RFDETR subclass | Initialized model with appropriate ModelConfig, ready for predict/train/export |
Usage Examples
Select Base Model
from rfdetr import RFDETRBase
# Default COCO-pretrained Base model
model = RFDETRBase()
# Custom weights and resolution
model = RFDETRBase(pretrain_weights="path/to/weights.pth", resolution=640)
Compare Model Sizes
from rfdetr import RFDETRNano, RFDETRBase, RFDETRLarge
# Fast inference on edge devices
nano_model = RFDETRNano() # resolution=384, 2 decoder layers
# Balanced performance
base_model = RFDETRBase() # resolution=560, 3 decoder layers
# Maximum accuracy
large_model = RFDETRLarge() # resolution=704, 4 decoder layers
Model Configurations
| Size | Resolution | Dec Layers | Patch Size | Num Windows | Pretrained Weights |
|---|---|---|---|---|---|
| Nano | 384 | 2 | 16 | 2 | rf-detr-nano.pth |
| Small | 512 | 3 | 16 | 2 | rf-detr-small.pth |
| Base | 560 | 3 | 14 | 4 | rf-detr-base.pth |
| Medium | 576 | 4 | 16 | 2 | rf-detr-medium.pth |
| Large | 704 | 4 | 16 | 2 | rf-detr-large-2026.pth |
Related Pages
Implements Principle
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment