16031aae96
CPU tests Workflow / Testing (ubuntu-latest, 3.12) (push) Failing after 1s
CPU tests Workflow / Testing (ubuntu-latest, 3.13) (push) Failing after 0s
Mypy Type Check / Type Check (push) Failing after 0s
Docs/Test WorkFlow / Test docs build (push) Failing after 1s
PR Conflict Labeler / labeling (push) Failing after 1s
Dependency resolution / Resolve [tflite] extra — Python 3.12 (push) Failing after 0s
Smoke Tests / try-all-models (ubuntu-latest, 3.10) (push) Failing after 0s
Smoke Tests / try-all-models (ubuntu-latest, 3.13) (push) Failing after 1s
CPU tests Workflow / build-pkg (push) Failing after 1s
CPU tests Workflow / Testing (ubuntu-latest, 3.10) (push) Failing after 0s
CPU tests Workflow / Testing (ubuntu-latest, 3.11) (push) Failing after 0s
Smoke Tests / try-all-models (macos-latest, 3.10) (push) Has been cancelled
Smoke Tests / try-all-models (macos-latest, 3.13) (push) Has been cancelled
Smoke Tests / try-all-models (windows-latest, 3.10) (push) Has been cancelled
Smoke Tests / try-all-models (windows-latest, 3.13) (push) Has been cancelled
CPU tests Workflow / Testing (macos-latest, 3.10) (push) Has been cancelled
CPU tests Workflow / Testing (macos-latest, 3.13) (push) Has been cancelled
CPU tests Workflow / Testing (windows-latest, 3.10) (push) Has been cancelled
CPU tests Workflow / Testing (windows-latest, 3.13) (push) Has been cancelled
CPU tests Workflow / testing-guardian (push) Has been cancelled
GPU tests Workflow / Testing (push) Has been cancelled
116 lines
3.7 KiB
Markdown
116 lines
3.7 KiB
Markdown
---
|
|
description: Deploy fine-tuned RF-DETR detection and segmentation models to Roboflow for cloud inference, edge hardware, and multi-step vision workflows.
|
|
---
|
|
|
|
# Deploy a Trained RF-DETR Model
|
|
|
|
!!! tip "Key Takeaways"
|
|
|
|
- Deploy fine-tuned RF-DETR models to Roboflow with a single `deploy_to_roboflow()` call
|
|
- Supports both detection and segmentation model deployment
|
|
- Run deployed models via Roboflow Inference on cloud, edge hardware, or NVIDIA Jetson
|
|
- Model weights are cached locally after the first inference run for fast subsequent predictions
|
|
|
|
You can deploy a fine-tuned RF-DETR model to Roboflow.
|
|
|
|
Deploying to Roboflow allows you to create multi-step computer vision applications that run both in the cloud and your own hardware.
|
|
|
|
To deploy your model to Roboflow, run:
|
|
|
|
=== "Object Detection"
|
|
|
|
```python
|
|
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>",
|
|
)
|
|
```
|
|
|
|
=== "Image Segmentation"
|
|
|
|
```python
|
|
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>",
|
|
)
|
|
```
|
|
|
|
Above, set your Roboflow Workspace ID, the ID of the project to which you want to upload your model, and your Roboflow API key.
|
|
|
|
- [Learn how to find your Workspace and Project ID.](https://docs.roboflow.com/developer/authentication/workspace-and-project-ids)
|
|
- [Learn how to find your API key.](https://docs.roboflow.com/developer/authentication/find-your-roboflow-api-key)
|
|
|
|
You can then run your model with Roboflow Inference:
|
|
|
|
=== "Object Detection"
|
|
|
|
```python
|
|
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)
|
|
```
|
|
|
|
=== "Image Segmentation"
|
|
|
|
```python
|
|
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)
|
|
```
|
|
|
|
Above, replace `rfdetr-large` with the your Roboflow model ID. You can find this ID from the "Models" list in your Roboflow dashboard:
|
|
|
|

|
|
|
|
When you first run this model, your model weights will be cached for local use with Inference.
|
|
|
|
You will then see the results from your fine-tuned model.
|