RF-DETR

Use Roboflow's RF-DETR model through our Serverless Hosted API

RF-DETR is Roboflow's transformer-based real-time object detection and segmentation model. You can run inference against COCO-pretrained RF-DETR checkpoints through the Serverless Hosted API, or self-host using Roboflow Inference.

Code samples

The samples below run RF-DETR through the Serverless Hosted API and visualize results with supervision. Pass Roboflow's API Key via the API_KEY env variable.

Object detection

pip install inference-sdk supervision
import os
import urllib.request

import cv2
import supervision as sv
from inference_sdk import InferenceHTTPClient

image_url = "https://storage.googleapis.com/com-roboflow-marketing/notebooks/examples/cars-highway.png"
image_path = "cars-highway.png"
urllib.request.urlretrieve(image_url, image_path)

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key=os.getenv("API_KEY"),
)
result = client.infer(image_path, model_id="rfdetr-base")

image = cv2.imread(image_path)
detections = sv.Detections.from_inference(result)

box_annotator = sv.BoxAnnotator()
label_annotator = sv.LabelAnnotator()

annotated = box_annotator.annotate(scene=image.copy(), detections=detections)
annotated = label_annotator.annotate(scene=annotated, detections=detections)

cv2.imwrite("cars-highway-annotated.png", annotated)

Instance segmentation

Default COCO-trained models

Pass any of these aliases as the model_id when running inference. The SDK resolves each alias to the underlying Roboflow project version. Input resolution varies by variant.

Alias
Task
Input Size

rfdetr-base

Object Detection

560x560

rfdetr-nano

Object Detection

384x384

rfdetr-small

Object Detection

512x512

rfdetr-medium

Object Detection

576x576

rfdetr-large

Object Detection

704x704

rfdetr-xlarge

Object Detection

700x700

rfdetr-2xlarge

Object Detection

880x880

rfdetr-seg-preview

Instance Segmentation

560x560

rfdetr-seg-nano

Instance Segmentation

312x312

rfdetr-seg-small

Instance Segmentation

384x384

rfdetr-seg-medium

Instance Segmentation

432x432

rfdetr-seg-large

Instance Segmentation

504x504

rfdetr-seg-xlarge

Instance Segmentation

624x624

rfdetr-seg-2xlarge

Instance Segmentation

768x768

Set api_url to match your deployment target:

  • https://serverless.roboflow.com for the Serverless Hosted API.

  • http://localhost:9001 for a local Inference server.

  • Your Dedicated Deployment URL for a private endpoint.

Last updated

Was this helpful?