Skip to main content
RF-DETR supports instance segmentation with the same consistent API as its detection models. The segmentation models are trained on Microsoft COCO and produce pixel-level instance masks alongside bounding boxes and class labels.

Model sizes

RF-DETR-Seg offers model sizes from Nano to 2XLarge. All latency numbers were measured on an NVIDIA T4 using TensorRT, FP16, and batch size 1.
SizePython classInference aliasCOCO AP50COCO AP50:95Latency (ms)Params (M)ResolutionLicense
NRFDETRSegNanorfdetr-seg-nano63.040.33.433.6312x312Apache 2.0
SRFDETRSegSmallrfdetr-seg-small66.243.14.433.7384x384Apache 2.0
MRFDETRSegMediumrfdetr-seg-medium68.445.35.935.7432x432Apache 2.0
LRFDETRSegLargerfdetr-seg-large70.547.18.836.2504x504Apache 2.0
XLRFDETRSegXLargerfdetr-seg-xlarge72.248.813.538.1624x624Apache 2.0
2XLRFDETRSeg2XLargerfdetr-seg-2xlarge73.149.921.838.6768x768Apache 2.0
All segmentation model sizes are licensed under Apache 2.0.

Run on an image

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

model = RFDETRSegMedium()

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.MaskAnnotator().annotate(detections.data["source_image"], detections)
annotated_image = sv.LabelAnnotator().annotate(annotated_image, detections, labels)
Use sv.MaskAnnotator() to render instance masks. For detections without masks (e.g., when comparing with detection models), use sv.BoxAnnotator() instead.

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, each containing bounding boxes, class IDs, confidence scores, and instance masks.
import io
import requests
import supervision as sv
from PIL import Image
from rfdetr import RFDETRSegMedium
from rfdetr.assets.coco_classes import COCO_CLASSES

model = RFDETRSegMedium()

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.MaskAnnotator().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-Seg 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-seg-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.MaskAnnotator().annotate(image, detections)
annotated_image = sv.LabelAnnotator().annotate(annotated_image, detections)

Pretrained models

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

Object detection

Run RF-DETR for bounding box object detection.

Train a model

Fine-tune RF-DETR-Seg on your own dataset.

Deploy to Roboflow

Deploy your segmentation model to the Roboflow platform.

Build docs developers (and LLMs) love