RF-DETR Model Variants: Detection, Segmentation, and Keypoint Architectures Explained

RF-DETR provides seventeen distinct model variants across three computer vision tasks—object detection, instance segmentation, and keypoint detection—each inheriting from the core RFDETR class defined in src/rfdetr/detr.py.

The RF-DETR model variants are organized by task and computational scale in the roboflow/rf-detr repository. All variants specify unique size identifiers and configuration classes in src/rfdetr/variants.py, enabling fine-grained control over speed-accuracy tradeoffs. Whether you need a lightweight edge deployment or a high-accuracy segmentation model, the architecture provides standardized interfaces through the factory registry.

Detection-Only RF-DETR Model Variants

The detection variants focus exclusively on bounding box prediction. Each class extends the base RFDETR implementation with scaled encoder-decoder configurations.

Nano Detection Model

RFDETRNano (rfdetr-nano) represents the smallest footprint variant, configured via RFDETRNanoConfig. This model prioritizes inference speed on resource-constrained devices while maintaining competitive mAP scores. Instantiate it directly from src/rfdetr/variants.py:

from rfdetr import RFDETRNano

model = RFDETRNano()
predictions = model.predict(image)

Small Detection Model

RFDETRSmall (rfdetr-small) serves as the default detection architecture, utilizing RFDETRSmallConfig. This variant balances computational efficiency with accuracy, making it suitable for general-purpose production deployments. The small variant is the recommended starting point for new projects.

Medium Detection Model

RFDETRMedium (rfdetr-medium) scales up the encoder capacity via RFDETRMediumConfig. This middle-tier option targets applications requiring higher precision than Small while avoiding the latency costs of Large variants.

Large Detection Models

RFDETRLarge (rfdetr-large) delivers maximum detection accuracy through RFDETRLargeConfig, implementing deeper transformer layers and wider MLP dimensions.

Deprecated variants: The RFDETRBase class (rfdetr-base) and RFDETRLargeDeprecated are marked with @deprecated_class decorators in src/rfdetr/variants.py. These legacy implementations remain available for backward compatibility but will be removed in future major releases. Migrate existing code to the current RFDETRLarge implementation.

Segmentation RF-DETR Model Variants

These variants extend detection capabilities with mask prediction heads. All segmentation classes except the deprecated Preview are actively maintained.

Nano, Small, Medium Segmentation Models

The standard segmentation suite includes:

  • RFDETRSegNano (rfdetr-seg-nano) with RFDETRSegNanoConfig
  • RFDETRSegSmall (rfdetr-seg-small) with RFDETRSegSmallConfig
  • RFDETRSegMedium (rfdetr-seg-medium) with RFDETRSegMediumConfig

Each implements instance segmentation through dedicated mask heads attached to the DETR decoder outputs.

Large and Extra-Large Segmentation Models

RFDETRSegLarge (rfdetr-seg-large) provides high-resolution segmentation capabilities. For maximum accuracy, the repository offers Plus package variants:

  • RFDETRSegXLarge (rfdetr-seg-xlarge)
  • RFDETRSeg2XLarge (rfdetr-seg-2xlarge)

These models are lazily imported and require the optional Plus package installation. Attempting to instantiate them without the extra dependency raises an ImportError with installation instructions.

Deprecated variant: RFDETRSegPreview (rfdetr-seg-preview) is deprecated and scheduled for removal. Use RFDETRSegSmall or larger current variants instead.

Keypoint Detection RF-DETR Model Variants

The architecture currently provides one keypoint-specific implementation:

RFDETRKeypointPreview (rfdetr-keypoint-preview) handles pose estimation through RFDETRKeypointPreviewConfig. This variant utilizes a specialized KeypointTrainConfig defined in src/rfdetr/config.py to manage keypoint-specific augmentation and loss calculations. The model returns coordinate tensors for skeletal keypoints rather than bounding boxes or masks.

Instantiating RF-DETR Model Variants

All variants support direct instantiation and registry-based loading. The factory function rfdetr.get_model accepts size strings (e.g., "rfdetr-medium") for CLI and configuration file compatibility.


# Detection workflow

from rfdetr import RFDETRSmall

detector = RFDETRSmall()
detections = detector.predict(image_tensor)

# Segmentation with Plus package (requires extras installation)

from rfdetr import RFDETRSegXLarge

segmentor = RFDETRSegXLarge()
masks = segmentor.predict(image_array)

# Keypoint estimation

from rfdetr import RFDETRKeypointPreview

pose_model = RFDETRKeypointPreview()
keypoints = pose_model.predict(image)

Summary

  • Three task categories: RF-DETR organizes variants into detection (5 sizes), segmentation (7 sizes), and keypoint (1 model) architectures.
  • Size scalability: Variants range from Nano (edge-optimized) to 2XLarge (maximum accuracy), configured through paired *Config classes in src/rfdetr/variants.py.
  • Deprecation policy: Base, legacy Large, and SegPreview classes carry @deprecated_class warnings and will be removed in future releases.
  • Plus package requirement: Segmentation XLarge and 2XLarge models require optional dependencies and validate availability at import time.
  • Unified interface: All variants inherit from RFDETR in src/rfdetr/detr.py, providing consistent .predict() methods and state dict compatibility.

Frequently Asked Questions

What is the difference between RF-DETR Small and Medium variants?

RF-DETR Medium increases the hidden dimension and number of transformer encoder layers compared to Small, resulting in higher accuracy on COCO-style benchmarks at roughly 1.5–2x computational cost. According to the configuration classes in src/rfdetr/variants.py, Medium uses RFDETRMediumConfig with expanded feed-forward network dimensions, while Small uses the baseline RFDETRSmallConfig optimized for latency.

Are RF-DETR segmentation models included in the base package?

Standard segmentation variants (Nano through Large) ship with the base roboflow/rf-detr installation. However, the XLarge and 2XLarge segmentation models are gated behind the Plus package. The source code implements lazy imports for these classes, raising an ImportError if the extra rfdetr[plus] is not installed.

Which RF-DETR variant should I use for real-time inference?

For real-time applications on GPUs, start with RFDETRSmall or RFDETRNano depending on your frames-per-second requirements. Nano achieves the highest throughput with minimal accuracy degradation. For CPU or edge deployment, Nano is explicitly optimized for reduced memory bandwidth and cache utilization compared to larger variants.

How do I migrate from deprecated RF-DETR Base to current variants?

Replace RFDETRBase instantiations with RFDETRSmall or RFDETRMedium depending on your accuracy requirements. The deprecated Base class (marked in src/rfdetr/variants.py with @deprecated_class) shares identical forward pass signatures, requiring only class name changes in import statements and constructors. Update persisted configuration files referencing rfdetr-base to use rfdetr-small as the size identifier.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →