Skip to main content
Deploy your fine-tuned RF-DETR model to Roboflow to run cloud inference and build multi-step computer vision applications.

Deploy your model

1

Upload your model to Roboflow

Call deploy_to_roboflow() with your workspace ID, project ID, version number, and API key.
from rfdetr import RFDETRNano

x = RFDETRNano(pretrain_weights="<path/to/pretrain/weights/dir>")
x.deploy_to_roboflow(
    workspace="<your-workspace>",
    project_id="<your-project-id>",
    version=1,
    api_key="<YOUR_API_KEY>",
)
2

Run inference with Roboflow Inference

Use get_model from the inference package to load your deployed model and run predictions.
import supervision as sv
from inference import get_model
from PIL import Image
from io import BytesIO
import requests

url = "https://media.roboflow.com/dog.jpeg"
image = Image.open(BytesIO(requests.get(url).content))

model = get_model("rfdetr-large")  # replace with your Roboflow model ID

predictions = model.infer(image, confidence=0.5)[0]

detections = sv.Detections.from_inference(predictions)

labels = [prediction.class_name for prediction in predictions.predictions]

annotated_image = image.copy()
annotated_image = sv.BoxAnnotator().annotate(annotated_image, detections)
annotated_image = sv.LabelAnnotator().annotate(annotated_image, detections, labels)

sv.plot_image(annotated_image)
The first time you run your model, Inference downloads and caches the model weights locally. Subsequent runs use the cached weights and start faster.

deploy_to_roboflow() parameters

workspace
string
required
Your Roboflow workspace ID. Find this in your workspace URL or dashboard settings.
project_id
string
required
The ID of the Roboflow project to upload your model to.
version
integer
required
The version number to assign to the deployed model.
api_key
string
Your Roboflow API key. When omitted, the value of the ROBOFLOW_API_KEY environment variable is used. Raises ValueError if neither is set.

Finding your workspace, project ID, and API key

After deployment, your model ID appears in the Models list in your Roboflow dashboard. Use this ID as the argument to get_model() when running inference.

Next steps

Export to ONNX

Export your model to ONNX for local or edge deployment.

Training overview

Learn how to fine-tune RF-DETR on your own dataset.