Deploy your fine-tuned RF-DETR model to Roboflow to run cloud inference and build multi-step computer vision applications.
Deploy your model
Upload your model to Roboflow
Call deploy_to_roboflow() with your workspace ID, project ID, version number, and API key. Object detection
Image segmentation
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>" ,
)
from rfdetr import RFDETRSegMedium
x = RFDETRSegMedium( 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>" ,
)
Run inference with Roboflow Inference
Use get_model from the inference package to load your deployed model and run predictions. Object detection
Image segmentation
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)
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-seg-small" ) # 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.MaskAnnotator().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
Your Roboflow workspace ID. Find this in your workspace URL or dashboard settings.
The ID of the Roboflow project to upload your model to.
The version number to assign to the deployed model.
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.