Add rfdetr model files
Browse files- README.md +192 -0
- prepare_model.py +653 -0
- rfdetr_large_config.yaml +152 -0
- rfdetr_medium_config.yaml +152 -0
- rfdetr_nano_config.yaml +152 -0
- rfdetr_small_config.yaml +152 -0
README.md
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
tags:
|
| 4 |
+
- vision
|
| 5 |
+
- image-detection
|
| 6 |
+
- image-segmentation
|
| 7 |
+
datasets:
|
| 8 |
+
- COCO
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
<div align="center">
|
| 12 |
+
|
| 13 |
+
# RF-DETR for TI EdgeAI
|
| 14 |
+
|
| 15 |
+
### Real-Time Transformer Detection with a DINOv2 Backbone
|
| 16 |
+
|
| 17 |
+
[](https://opensource.org/licenses/Apache-2.0)
|
| 18 |
+
[](https://onnx.ai/)
|
| 19 |
+
[](https://github.com/TexasInstruments/edgeai)
|
| 20 |
+
[](https://cocodataset.org/)
|
| 21 |
+
|
| 22 |
+
</div>
|
| 23 |
+
|
| 24 |
+
---
|
| 25 |
+
|
| 26 |
+
## Overview
|
| 27 |
+
|
| 28 |
+
**RF-DETR** is a real-time transformer-based object detection (and instance segmentation) architecture developed by Roboflow, achieving state-of-the-art accuracy/latency trade-offs on COCO (presented at ICLR 2026). It builds on a **DINOv2 ViT backbone** paired with a DETR-style decoder and a hierarchical feature pyramid, giving it strong small-object and dense-scene performance without the NMS and anchor-tuning overhead of traditional detectors.
|
| 29 |
+
|
| 30 |
+
RF-DETR ships in six size variants, Nano through 2XLarge, for flexible accuracy-speed trade-offs. The Nano through Large variants are released under Apache 2.0; XLarge and 2XLarge require the `rfdetr[plus]` extra and are licensed under PML 1.0. This folder packages the ONNX exports and TIDL configs for the Apache-licensed detection variants (Nano/Small/Medium/Large); the `prepare_model.py` script can additionally export the PML-licensed XLarge/2XLarge detection variants and the segmentation family on request.
|
| 31 |
+
|
| 32 |
+
---
|
| 33 |
+
|
| 34 |
+
## Model Variants
|
| 35 |
+
|
| 36 |
+
| Model | Input Size | mAP[.5:.95]% | mAP[.50]% | Validated Devices | Config |
|
| 37 |
+
|-------|-----------|--------------|-----------|--------------------|--------|
|
| 38 |
+
| `rfdetr_nano` | 384×384 | 48.4 | 67.6 | TDA4VH | [rfdetr_nano_config.yaml](rfdetr_nano_config.yaml) |
|
| 39 |
+
| `rfdetr_small` | 512×512 | 53.0 | 72.1 | TDA4VH | [rfdetr_small_config.yaml](rfdetr_small_config.yaml) |
|
| 40 |
+
| `rfdetr_medium` | 576×576 | 54.7 | 73.6 | TDA4VH | [rfdetr_medium_config.yaml](rfdetr_medium_config.yaml) |
|
| 41 |
+
| `rfdetr_large` | 704×704 | 56.5 | 75.1 | TDA4VH | [rfdetr_large_config.yaml](rfdetr_large_config.yaml) |
|
| 42 |
+
|
| 43 |
+
> mAP values are on COCO val2017. `rfdetr_xlarge` (700×700, mAP[.5:.95] 58.6) and `rfdetr_2xlarge` (880×880, mAP[.5:.95] 60.1) are available via `prepare_model.py --plus` but are licensed under PML 1.0 and are not shipped as ONNX/config files in this folder.
|
| 44 |
+
|
| 45 |
+
**Recommended for edge deployment:** `rfdetr_nano` (best accuracy/compute trade-off, smallest)
|
| 46 |
+
|
| 47 |
+
---
|
| 48 |
+
|
| 49 |
+
## Quick Start
|
| 50 |
+
|
| 51 |
+
### Prerequisites
|
| 52 |
+
|
| 53 |
+
```bash
|
| 54 |
+
# ONNX export dependencies
|
| 55 |
+
pip install "rfdetr[onnx]"
|
| 56 |
+
|
| 57 |
+
# For XLarge / 2XLarge variants (PML 1.0 license)
|
| 58 |
+
pip install "rfdetr[onnx,plus]"
|
| 59 |
+
|
| 60 |
+
# Inference and deployment
|
| 61 |
+
pip install onnx>=1.22.0
|
| 62 |
+
pip install onnxruntime>=1.23.2
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
### Export the Model
|
| 66 |
+
|
| 67 |
+
```bash
|
| 68 |
+
# List all available variants with accuracy and latency info
|
| 69 |
+
python prepare_model.py --list-models
|
| 70 |
+
|
| 71 |
+
# Export the default model (rfdetr_nano)
|
| 72 |
+
python prepare_model.py
|
| 73 |
+
|
| 74 |
+
# Export a specific model variant
|
| 75 |
+
python prepare_model.py --model rfdetr_medium
|
| 76 |
+
|
| 77 |
+
# Export multiple variants at once
|
| 78 |
+
python prepare_model.py --model rfdetr_nano rfdetr_small rfdetr_medium rfdetr_large
|
| 79 |
+
|
| 80 |
+
# Export XLarge / 2XLarge (requires rfdetr[plus], PML 1.0 license)
|
| 81 |
+
python prepare_model.py --model rfdetr_xlarge rfdetr_2xlarge --plus
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
The script automatically:
|
| 85 |
+
- Installs `rfdetr[onnx]` (or `rfdetr[onnx,plus]` for XLarge/2XLarge) if not already present
|
| 86 |
+
- Downloads pretrained COCO weights from HuggingFace on first use
|
| 87 |
+
- Exports the selected variant(s) to ONNX (opset 17 by default, static batch dimension)
|
| 88 |
+
- Saves the result as `rfdetr_<variant>.onnx` in the output directory
|
| 89 |
+
|
| 90 |
+
### Compile and Infer uing edgeai-tidlrunner
|
| 91 |
+
|
| 92 |
+
> **Note:** Run the commands below from inside the `tidlrunner` directory (the cloned [edgeai-tidlrunner](https://github.com/TexasInstruments/edgeai-tidlrunner) repository), with `--config_path` pointing to this model's config file.
|
| 93 |
+
|
| 94 |
+
**Compile using edgeai-tidlrunner - on PC**
|
| 95 |
+
|
| 96 |
+
```bash
|
| 97 |
+
cd /path/to/edgeai-tidlrunner
|
| 98 |
+
tidlrunner-cli compile --target_device J784S4 \
|
| 99 |
+
--config_path /path/to/rfdetr_nano_config.yaml
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
**Run Inference Benchmark - on device**
|
| 103 |
+
|
| 104 |
+
```bash
|
| 105 |
+
cd /path/to/edgeai-tidlrunner
|
| 106 |
+
tidlrunner-cli infer --target_device J784S4 \
|
| 107 |
+
--config_path /path/to/rfdetr_nano_config.yaml
|
| 108 |
+
```
|
| 109 |
+
|
| 110 |
+
### Compile and Infer using edgeai-tidl-tools (Advanced):
|
| 111 |
+
|
| 112 |
+
Follow the instructions at https://github.com/TexasInstruments/edgeai-tidl-tools
|
| 113 |
+
|
| 114 |
+
### Deploy using edgeai-tidl-tools:
|
| 115 |
+
|
| 116 |
+
Deplyment can be done using **[edgeai-tidl-tools](https://github.com/TexasInstruments/edgeai-tidl-tools)**. For ONNX models, onnxruntime-tidl with TIDL acceleration can be used. Consult the documentation of edgeai-tidl-tools for more details.
|
| 117 |
+
|
| 118 |
+
---
|
| 119 |
+
|
| 120 |
+
## Citation
|
| 121 |
+
|
| 122 |
+
If you use RF-DETR in your research, please cite:
|
| 123 |
+
|
| 124 |
+
```bibtex
|
| 125 |
+
@software{rfdetr2025,
|
| 126 |
+
title = {RF-DETR},
|
| 127 |
+
author = {Robinson, Isaac and Robicheaux, Peter and Popov, Matvei},
|
| 128 |
+
year = {2025},
|
| 129 |
+
publisher = {Roboflow},
|
| 130 |
+
url = {https://github.com/roboflow/rf-detr},
|
| 131 |
+
note = {International Conference on Learning Representations (ICLR) 2026}
|
| 132 |
+
}
|
| 133 |
+
```
|
| 134 |
+
|
| 135 |
+
---
|
| 136 |
+
|
| 137 |
+
## 🔗 Resources
|
| 138 |
+
|
| 139 |
+
| Resource | Link |
|
| 140 |
+
|----------|------|
|
| 141 |
+
| **RF-DETR Source Code** | [roboflow/rf-detr](https://github.com/roboflow/rf-detr) |
|
| 142 |
+
| **RF-DETR Documentation** | [rfdetr.roboflow.com](https://rfdetr.roboflow.com) |
|
| 143 |
+
| **RF-DETR on HuggingFace** | [huggingface.co/roboflow](https://huggingface.co/roboflow) |
|
| 144 |
+
| **edgeai-tidl-tools** | [GitHub](https://github.com/TexasInstruments/edgeai-tidl-tools) |
|
| 145 |
+
| **edgeai-tidlrunner** | [GitHub](https://github.com/TexasInstruments/edgeai-tidlrunner) |
|
| 146 |
+
| **EdgeAI SDK** | [Documentation](https://github.com/TexasInstruments/edgeai/blob/main/edgeai-mpu/readme_sdk.md) |
|
| 147 |
+
|
| 148 |
+
---
|
| 149 |
+
|
| 150 |
+
## Related Models
|
| 151 |
+
|
| 152 |
+
<table>
|
| 153 |
+
<tr>
|
| 154 |
+
<td align="center">
|
| 155 |
+
|
| 156 |
+
**RT-DETRv2**
|
| 157 |
+
Real-time DETR variant
|
| 158 |
+
Anchor-free, NMS-free
|
| 159 |
+
|
| 160 |
+
</td>
|
| 161 |
+
<td align="center">
|
| 162 |
+
|
| 163 |
+
**DEIMv2**
|
| 164 |
+
DETR-family detector
|
| 165 |
+
Improved matching/training
|
| 166 |
+
|
| 167 |
+
</td>
|
| 168 |
+
<td align="center">
|
| 169 |
+
|
| 170 |
+
**Deformable-DETR**
|
| 171 |
+
Sparse attention DETR
|
| 172 |
+
Faster convergence
|
| 173 |
+
|
| 174 |
+
</td>
|
| 175 |
+
<td align="center">
|
| 176 |
+
|
| 177 |
+
**DETR**
|
| 178 |
+
Original transformer detector
|
| 179 |
+
End-to-end set prediction
|
| 180 |
+
|
| 181 |
+
</td>
|
| 182 |
+
</tr>
|
| 183 |
+
</table>
|
| 184 |
+
|
| 185 |
+
---
|
| 186 |
+
|
| 187 |
+
<div align="center">
|
| 188 |
+
|
| 189 |
+
**Maintained by:** Texas Instruments EdgeAI Team
|
| 190 |
+
**Last Updated:** August 2026
|
| 191 |
+
|
| 192 |
+
</div>
|
prepare_model.py
ADDED
|
@@ -0,0 +1,653 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Script to export RF-DETR pretrained ONNX model(s).
|
| 2 |
+
|
| 3 |
+
The rfdetr package auto-downloads pretrained COCO weights from HuggingFace on
|
| 4 |
+
first use, then this script calls model.export() to produce the ONNX file.
|
| 5 |
+
|
| 6 |
+
Detection variants (Apache 2.0, COCO pretrained):
|
| 7 |
+
rfdetr_nano – 384×384, 30.5 M params, AP50:95 48.4
|
| 8 |
+
rfdetr_small – 512×512, 32.1 M params, AP50:95 53.0
|
| 9 |
+
rfdetr_medium – 576×576, 33.7 M params, AP50:95 54.7
|
| 10 |
+
rfdetr_large – 704×704, 33.9 M params, AP50:95 56.5
|
| 11 |
+
rfdetr_xlarge – 700×700, 126.4 M params, AP50:95 58.6 [requires --plus]
|
| 12 |
+
rfdetr_2xlarge – 880×880, 126.9 M params, AP50:95 60.1 [requires --plus]
|
| 13 |
+
|
| 14 |
+
Segmentation variants (COCO pretrained):
|
| 15 |
+
rfdetr_seg_nano – 312×312, 33.6 M params, AP50:95 40.3
|
| 16 |
+
rfdetr_seg_small – 384×384, 33.7 M params, AP50:95 43.1
|
| 17 |
+
rfdetr_seg_medium – 432×432, 35.7 M params, AP50:95 45.3
|
| 18 |
+
rfdetr_seg_large – 504×504, 36.2 M params, AP50:95 47.1
|
| 19 |
+
rfdetr_seg_xlarge – 624×624, 38.1 M params, AP50:95 48.8 [requires --plus]
|
| 20 |
+
rfdetr_seg_2xlarge – 768×768, 38.6 M params, AP50:95 49.9 [requires --plus]
|
| 21 |
+
|
| 22 |
+
Input shape constraints:
|
| 23 |
+
Each model's spatial dimensions must be divisible by its block_size
|
| 24 |
+
(= patch_size × num_windows). The rfdetr API enforces this; using a
|
| 25 |
+
custom --shape that violates the constraint will raise a clear error.
|
| 26 |
+
|
| 27 |
+
Usage:
|
| 28 |
+
python prepare_model.py
|
| 29 |
+
python prepare_model.py --model rfdetr_nano
|
| 30 |
+
python prepare_model.py --model rfdetr_nano rfdetr_small rfdetr_medium
|
| 31 |
+
python prepare_model.py --model rfdetr_large --shape 640 640
|
| 32 |
+
python prepare_model.py --model rfdetr_nano --backbone-only
|
| 33 |
+
python prepare_model.py --model rfdetr_nano --opset 18 --output-dir ./exports
|
| 34 |
+
python prepare_model.py --model rfdetr_xlarge rfdetr_2xlarge --plus
|
| 35 |
+
python prepare_model.py --model rfdetr_seg_nano rfdetr_seg_small
|
| 36 |
+
python prepare_model.py --list-models
|
| 37 |
+
"""
|
| 38 |
+
|
| 39 |
+
from __future__ import annotations
|
| 40 |
+
|
| 41 |
+
import argparse
|
| 42 |
+
import importlib
|
| 43 |
+
import os
|
| 44 |
+
import shutil
|
| 45 |
+
import subprocess
|
| 46 |
+
import sys
|
| 47 |
+
import tempfile
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
# ─────────────────────────────────────────────
|
| 51 |
+
# Model catalogue
|
| 52 |
+
# ─────────────────────────────────────────────
|
| 53 |
+
|
| 54 |
+
# Each entry: variant_key → (class_name, default_shape, params_m, coco_ap5095, license, requires_plus, task)
|
| 55 |
+
MODEL_CATALOG: dict[str, dict] = {
|
| 56 |
+
# ── Detection ────────────────────────────────────────────────────────────
|
| 57 |
+
"rfdetr_nano": {
|
| 58 |
+
"class": "RFDETRNano",
|
| 59 |
+
"shape": (384, 384),
|
| 60 |
+
"params_m": 30.5,
|
| 61 |
+
"ap50_95": 48.4,
|
| 62 |
+
"ap50": 67.6,
|
| 63 |
+
"latency_ms": 2.3,
|
| 64 |
+
"license": "Apache 2.0",
|
| 65 |
+
"requires_plus": False,
|
| 66 |
+
"task": "detection",
|
| 67 |
+
},
|
| 68 |
+
"rfdetr_small": {
|
| 69 |
+
"class": "RFDETRSmall",
|
| 70 |
+
"shape": (512, 512),
|
| 71 |
+
"params_m": 32.1,
|
| 72 |
+
"ap50_95": 53.0,
|
| 73 |
+
"ap50": 72.1,
|
| 74 |
+
"latency_ms": 3.5,
|
| 75 |
+
"license": "Apache 2.0",
|
| 76 |
+
"requires_plus": False,
|
| 77 |
+
"task": "detection",
|
| 78 |
+
},
|
| 79 |
+
"rfdetr_medium": {
|
| 80 |
+
"class": "RFDETRMedium",
|
| 81 |
+
"shape": (576, 576),
|
| 82 |
+
"params_m": 33.7,
|
| 83 |
+
"ap50_95": 54.7,
|
| 84 |
+
"ap50": 73.6,
|
| 85 |
+
"latency_ms": 4.4,
|
| 86 |
+
"license": "Apache 2.0",
|
| 87 |
+
"requires_plus": False,
|
| 88 |
+
"task": "detection",
|
| 89 |
+
},
|
| 90 |
+
"rfdetr_large": {
|
| 91 |
+
"class": "RFDETRLarge",
|
| 92 |
+
"shape": (704, 704),
|
| 93 |
+
"params_m": 33.9,
|
| 94 |
+
"ap50_95": 56.5,
|
| 95 |
+
"ap50": 75.1,
|
| 96 |
+
"latency_ms": 6.8,
|
| 97 |
+
"license": "Apache 2.0",
|
| 98 |
+
"requires_plus": False,
|
| 99 |
+
"task": "detection",
|
| 100 |
+
},
|
| 101 |
+
"rfdetr_xlarge": {
|
| 102 |
+
"class": "RFDETRXLarge",
|
| 103 |
+
"shape": (700, 700),
|
| 104 |
+
"params_m": 126.4,
|
| 105 |
+
"ap50_95": 58.6,
|
| 106 |
+
"ap50": 77.4,
|
| 107 |
+
"latency_ms": 11.5,
|
| 108 |
+
"license": "PML 1.0",
|
| 109 |
+
"requires_plus": True,
|
| 110 |
+
"task": "detection",
|
| 111 |
+
},
|
| 112 |
+
"rfdetr_2xlarge": {
|
| 113 |
+
"class": "RFDETR2XLarge",
|
| 114 |
+
"shape": (880, 880),
|
| 115 |
+
"params_m": 126.9,
|
| 116 |
+
"ap50_95": 60.1,
|
| 117 |
+
"ap50": 78.5,
|
| 118 |
+
"latency_ms": 17.2,
|
| 119 |
+
"license": "PML 1.0",
|
| 120 |
+
"requires_plus": True,
|
| 121 |
+
"task": "detection",
|
| 122 |
+
},
|
| 123 |
+
# ── Segmentation ─────────────────────────────────────────────────────────
|
| 124 |
+
"rfdetr_seg_nano": {
|
| 125 |
+
"class": "RFDETRSegNano",
|
| 126 |
+
"shape": (312, 312),
|
| 127 |
+
"params_m": 33.6,
|
| 128 |
+
"ap50_95": 40.3,
|
| 129 |
+
"ap50": 63.0,
|
| 130 |
+
"latency_ms": 3.4,
|
| 131 |
+
"license": "Apache 2.0",
|
| 132 |
+
"requires_plus": False,
|
| 133 |
+
"task": "segmentation",
|
| 134 |
+
},
|
| 135 |
+
"rfdetr_seg_small": {
|
| 136 |
+
"class": "RFDETRSegSmall",
|
| 137 |
+
"shape": (384, 384),
|
| 138 |
+
"params_m": 33.7,
|
| 139 |
+
"ap50_95": 43.1,
|
| 140 |
+
"ap50": 66.2,
|
| 141 |
+
"latency_ms": 4.4,
|
| 142 |
+
"license": "Apache 2.0",
|
| 143 |
+
"requires_plus": False,
|
| 144 |
+
"task": "segmentation",
|
| 145 |
+
},
|
| 146 |
+
"rfdetr_seg_medium": {
|
| 147 |
+
"class": "RFDETRSegMedium",
|
| 148 |
+
"shape": (432, 432),
|
| 149 |
+
"params_m": 35.7,
|
| 150 |
+
"ap50_95": 45.3,
|
| 151 |
+
"ap50": 68.4,
|
| 152 |
+
"latency_ms": 5.9,
|
| 153 |
+
"license": "Apache 2.0",
|
| 154 |
+
"requires_plus": False,
|
| 155 |
+
"task": "segmentation",
|
| 156 |
+
},
|
| 157 |
+
"rfdetr_seg_large": {
|
| 158 |
+
"class": "RFDETRSegLarge",
|
| 159 |
+
"shape": (504, 504),
|
| 160 |
+
"params_m": 36.2,
|
| 161 |
+
"ap50_95": 47.1,
|
| 162 |
+
"ap50": 70.5,
|
| 163 |
+
"latency_ms": 8.8,
|
| 164 |
+
"license": "Apache 2.0",
|
| 165 |
+
"requires_plus": False,
|
| 166 |
+
"task": "segmentation",
|
| 167 |
+
},
|
| 168 |
+
"rfdetr_seg_xlarge": {
|
| 169 |
+
"class": "RFDETRSegXLarge",
|
| 170 |
+
"shape": (624, 624),
|
| 171 |
+
"params_m": 38.1,
|
| 172 |
+
"ap50_95": 48.8,
|
| 173 |
+
"ap50": 72.2,
|
| 174 |
+
"latency_ms": 13.5,
|
| 175 |
+
"license": "PML 1.0",
|
| 176 |
+
"requires_plus": True,
|
| 177 |
+
"task": "segmentation",
|
| 178 |
+
},
|
| 179 |
+
"rfdetr_seg_2xlarge": {
|
| 180 |
+
"class": "RFDETRSeg2XLarge",
|
| 181 |
+
"shape": (768, 768),
|
| 182 |
+
"params_m": 38.6,
|
| 183 |
+
"ap50_95": 49.9,
|
| 184 |
+
"ap50": 73.1,
|
| 185 |
+
"latency_ms": 21.8,
|
| 186 |
+
"license": "PML 1.0",
|
| 187 |
+
"requires_plus": True,
|
| 188 |
+
"task": "segmentation",
|
| 189 |
+
},
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
# Default model exported when --model is not supplied
|
| 193 |
+
DEFAULT_MODEL = "rfdetr_nano"
|
| 194 |
+
|
| 195 |
+
|
| 196 |
+
# ─────────────────────────────────────────────
|
| 197 |
+
# Dependency installer
|
| 198 |
+
# ─────────────────────────────────────────────
|
| 199 |
+
|
| 200 |
+
def _pip_install(*packages: str) -> None:
|
| 201 |
+
"""Install *packages* via pip, suppressing verbose output."""
|
| 202 |
+
print(f"[DEP] Installing: {', '.join(packages)} …")
|
| 203 |
+
result = subprocess.run(
|
| 204 |
+
[sys.executable, "-m", "pip", "install", *packages],
|
| 205 |
+
stdout=subprocess.DEVNULL,
|
| 206 |
+
stderr=subprocess.PIPE,
|
| 207 |
+
text=True,
|
| 208 |
+
)
|
| 209 |
+
if result.returncode != 0:
|
| 210 |
+
print(f"[DEP] ERROR: pip install failed (exit code {result.returncode}).")
|
| 211 |
+
if result.stderr:
|
| 212 |
+
print(result.stderr.strip())
|
| 213 |
+
print("[DEP] Please install manually and re-run:")
|
| 214 |
+
print(f" pip install {' '.join(packages)}")
|
| 215 |
+
sys.exit(1)
|
| 216 |
+
print("[DEP] Installation complete.\n")
|
| 217 |
+
|
| 218 |
+
|
| 219 |
+
def ensure_rfdetr(need_plus: bool = False) -> None:
|
| 220 |
+
"""
|
| 221 |
+
Ensure the rfdetr package (with ONNX export support) is importable.
|
| 222 |
+
Installs automatically if missing.
|
| 223 |
+
|
| 224 |
+
Args:
|
| 225 |
+
need_plus: Also install the rfdetr[plus] extra required by XLarge /
|
| 226 |
+
2XLarge models (PML 1.0 licence).
|
| 227 |
+
"""
|
| 228 |
+
extras = "rfdetr[onnx,plus]" if need_plus else "rfdetr[onnx]"
|
| 229 |
+
|
| 230 |
+
try:
|
| 231 |
+
importlib.import_module("rfdetr")
|
| 232 |
+
print(f"[DEP] ✔ rfdetr is already installed.")
|
| 233 |
+
except ImportError:
|
| 234 |
+
print(f"[DEP] ✘ rfdetr not found – installing '{extras}' …")
|
| 235 |
+
_pip_install(extras)
|
| 236 |
+
return
|
| 237 |
+
|
| 238 |
+
# rfdetr is present; check the onnx export extra (rfdetr.export module)
|
| 239 |
+
try:
|
| 240 |
+
importlib.import_module("rfdetr.export")
|
| 241 |
+
print("[DEP] ✔ rfdetr export module is available.")
|
| 242 |
+
except (ImportError, ModuleNotFoundError):
|
| 243 |
+
print(f"[DEP] ✘ rfdetr export support missing – upgrading to '{extras}' …")
|
| 244 |
+
_pip_install(extras)
|
| 245 |
+
# Invalidate cached module so export_model picks up the upgraded version
|
| 246 |
+
sys.modules.pop("rfdetr", None)
|
| 247 |
+
sys.modules.pop("rfdetr.export", None)
|
| 248 |
+
|
| 249 |
+
|
| 250 |
+
# ─────────────────────────────────────────────
|
| 251 |
+
# Model catalogue helpers
|
| 252 |
+
# ─────────────────────────────────────────────
|
| 253 |
+
|
| 254 |
+
def print_model_table() -> None:
|
| 255 |
+
"""Print a formatted table of all available models."""
|
| 256 |
+
col = 22
|
| 257 |
+
header = (
|
| 258 |
+
f" {'Variant':<{col}} {'Task':<12} {'Shape':<10} "
|
| 259 |
+
f"{'Params(M)':<10} {'AP50:95':<8} {'AP50':<6} "
|
| 260 |
+
f"{'Lat(ms)':<8} {'License'}"
|
| 261 |
+
)
|
| 262 |
+
sep = " " + "-" * (len(header) - 2)
|
| 263 |
+
print("\n" + "=" * len(header))
|
| 264 |
+
print(" Available RF-DETR model variants")
|
| 265 |
+
print("=" * len(header))
|
| 266 |
+
print(header)
|
| 267 |
+
print(sep)
|
| 268 |
+
|
| 269 |
+
for key, info in MODEL_CATALOG.items():
|
| 270 |
+
h, w = info["shape"]
|
| 271 |
+
plus = " [--plus]" if info["requires_plus"] else ""
|
| 272 |
+
print(
|
| 273 |
+
f" {key:<{col}} {info['task']:<12} {h}×{w:<5} "
|
| 274 |
+
f"{info['params_m']:<10.1f} {info['ap50_95']:<8.1f} "
|
| 275 |
+
f"{info['ap50']:<6.1f} {info['latency_ms']:<8.1f} "
|
| 276 |
+
f"{info['license']}{plus}"
|
| 277 |
+
)
|
| 278 |
+
print("=" * len(header) + "\n")
|
| 279 |
+
print(" Latency measured on NVIDIA T4 GPU (TensorRT FP16).")
|
| 280 |
+
print(" [--plus] models require: pip install rfdetr[onnx,plus]\n")
|
| 281 |
+
|
| 282 |
+
|
| 283 |
+
# ─────────────────────────────────────────────
|
| 284 |
+
# Core export
|
| 285 |
+
# ─────────────────────────────────────────────
|
| 286 |
+
|
| 287 |
+
def export_model(
|
| 288 |
+
model_key: str,
|
| 289 |
+
output_dir: str,
|
| 290 |
+
shape: tuple[int, int] | None,
|
| 291 |
+
opset: int,
|
| 292 |
+
backbone_only: bool,
|
| 293 |
+
batch_size: int,
|
| 294 |
+
verbose: bool,
|
| 295 |
+
custom_weights: str | None,
|
| 296 |
+
force: bool,
|
| 297 |
+
) -> str:
|
| 298 |
+
"""
|
| 299 |
+
Instantiate an RF-DETR model and export it to ONNX.
|
| 300 |
+
|
| 301 |
+
Pretrained COCO weights are downloaded automatically from HuggingFace
|
| 302 |
+
on first use unless *custom_weights* is provided.
|
| 303 |
+
|
| 304 |
+
The rfdetr API always writes the ONNX to:
|
| 305 |
+
<tmp_dir>/inference_model.onnx (or backbone_model.onnx)
|
| 306 |
+
|
| 307 |
+
This function moves it to:
|
| 308 |
+
<output_dir>/<model_key>.onnx (or <model_key>_backbone.onnx)
|
| 309 |
+
|
| 310 |
+
Any .pth weight files produced by rfdetr in the temp directory are also
|
| 311 |
+
kept and moved to output_dir alongside the ONNX.
|
| 312 |
+
|
| 313 |
+
Args:
|
| 314 |
+
model_key : Key from MODEL_CATALOG (e.g. "rfdetr_nano").
|
| 315 |
+
output_dir : Final destination directory for the .onnx file.
|
| 316 |
+
shape : Custom (height, width) or None to use model default.
|
| 317 |
+
opset : ONNX opset version.
|
| 318 |
+
backbone_only : Export backbone feature extractor only.
|
| 319 |
+
batch_size : Batch size embedded in the exported graph.
|
| 320 |
+
verbose : Print rfdetr's internal export messages.
|
| 321 |
+
custom_weights : Path to a local .pth checkpoint; None = COCO pretrained.
|
| 322 |
+
force : Re-export even if the destination .onnx already exists.
|
| 323 |
+
|
| 324 |
+
Returns:
|
| 325 |
+
Absolute path of the saved .onnx file.
|
| 326 |
+
"""
|
| 327 |
+
import rfdetr # noqa: PLC0415
|
| 328 |
+
|
| 329 |
+
info = MODEL_CATALOG[model_key]
|
| 330 |
+
class_name = info["class"]
|
| 331 |
+
task = info["task"]
|
| 332 |
+
|
| 333 |
+
# ── Resolve the model class ───────────────────────────────────────────────
|
| 334 |
+
model_cls = getattr(rfdetr, class_name, None)
|
| 335 |
+
if model_cls is None:
|
| 336 |
+
print(
|
| 337 |
+
f"[ERROR] Class '{class_name}' not found in the rfdetr package.\n"
|
| 338 |
+
f" Make sure rfdetr is up-to-date: pip install -U rfdetr[onnx]"
|
| 339 |
+
)
|
| 340 |
+
sys.exit(1)
|
| 341 |
+
|
| 342 |
+
# ── Determine export shape ────────────────────────────────────────────────
|
| 343 |
+
export_shape = shape if shape is not None else info["shape"]
|
| 344 |
+
h, w = export_shape
|
| 345 |
+
|
| 346 |
+
# ── Build destination path early so we can check for an existing file ─────
|
| 347 |
+
os.makedirs(output_dir, exist_ok=True)
|
| 348 |
+
suffix = "_backbone" if backbone_only else ""
|
| 349 |
+
shape_tag = f"_{h}x{w}" if shape is not None else ""
|
| 350 |
+
dst_name = f"{model_key}{shape_tag}{suffix}.onnx"
|
| 351 |
+
dst_path = os.path.join(output_dir, dst_name)
|
| 352 |
+
|
| 353 |
+
if not force and os.path.exists(dst_path):
|
| 354 |
+
print(f"[SKIP] {dst_name} already exists. Use --force to re-export.\n")
|
| 355 |
+
return dst_path
|
| 356 |
+
|
| 357 |
+
print(f"[INFO] Model class : {class_name}")
|
| 358 |
+
print(f"[INFO] Task : {task}")
|
| 359 |
+
print(f"[INFO] Input shape : {h}×{w}")
|
| 360 |
+
print(f"[INFO] Opset : {opset}")
|
| 361 |
+
print(f"[INFO] Batch size : {batch_size}")
|
| 362 |
+
if backbone_only:
|
| 363 |
+
print("[INFO] Mode : backbone only")
|
| 364 |
+
if custom_weights:
|
| 365 |
+
print(f"[INFO] Weights : {custom_weights}")
|
| 366 |
+
else:
|
| 367 |
+
print("[INFO] Weights : COCO pretrained (auto-downloaded)")
|
| 368 |
+
print()
|
| 369 |
+
|
| 370 |
+
# ── Instantiate model ─────────────────────────────────────────────────────
|
| 371 |
+
print("[INFO] Loading model …")
|
| 372 |
+
init_kwargs: dict = {}
|
| 373 |
+
if custom_weights:
|
| 374 |
+
init_kwargs["pretrain_weights"] = custom_weights
|
| 375 |
+
model = model_cls(**init_kwargs)
|
| 376 |
+
print("[INFO] Model ready.\n")
|
| 377 |
+
|
| 378 |
+
# ── Export to a temporary directory, then move to final destination ───────
|
| 379 |
+
with tempfile.TemporaryDirectory(prefix="rfdetr_export_") as tmp_dir:
|
| 380 |
+
print("[INFO] Exporting to ONNX …")
|
| 381 |
+
model.export(
|
| 382 |
+
output_dir = tmp_dir,
|
| 383 |
+
format = "onnx",
|
| 384 |
+
shape = (h, w),
|
| 385 |
+
opset_version = opset,
|
| 386 |
+
backbone_only = backbone_only,
|
| 387 |
+
batch_size = batch_size,
|
| 388 |
+
verbose = verbose,
|
| 389 |
+
)
|
| 390 |
+
|
| 391 |
+
# Locate the exported .onnx file.
|
| 392 |
+
# rfdetr has used different output filenames across versions:
|
| 393 |
+
# ≤1.x → inference_model.onnx / backbone_model.onnx
|
| 394 |
+
# ≥1.8 → rfdetr-<size>.onnx (e.g. rfdetr-nano.onnx)
|
| 395 |
+
# Try known names first, then fall back to any .onnx in the directory.
|
| 396 |
+
size_tag = model_key.replace("rfdetr_seg_", "").replace("rfdetr_", "")
|
| 397 |
+
candidates_ordered = (
|
| 398 |
+
[f"rfdetr-{size_tag}.onnx", "backbone_model.onnx"]
|
| 399 |
+
if backbone_only else
|
| 400 |
+
[f"rfdetr-{size_tag}.onnx", "inference_model.onnx"]
|
| 401 |
+
)
|
| 402 |
+
|
| 403 |
+
src_path = None
|
| 404 |
+
for name in candidates_ordered:
|
| 405 |
+
p = os.path.join(tmp_dir, name)
|
| 406 |
+
if os.path.exists(p):
|
| 407 |
+
src_path = p
|
| 408 |
+
break
|
| 409 |
+
|
| 410 |
+
if src_path is None:
|
| 411 |
+
all_onnx = [f for f in os.listdir(tmp_dir) if f.endswith(".onnx")]
|
| 412 |
+
if not all_onnx:
|
| 413 |
+
print(f"[ERROR] No .onnx file found in temp dir: {tmp_dir}")
|
| 414 |
+
sys.exit(1)
|
| 415 |
+
src_path = os.path.join(tmp_dir, all_onnx[0])
|
| 416 |
+
print(f"[INFO] Located exported model: {all_onnx[0]}")
|
| 417 |
+
|
| 418 |
+
shutil.move(src_path, dst_path)
|
| 419 |
+
|
| 420 |
+
# Keep any .pth weight files produced alongside the ONNX
|
| 421 |
+
for fname in os.listdir(tmp_dir):
|
| 422 |
+
if fname.endswith(".pth"):
|
| 423 |
+
pth_dst = os.path.join(output_dir, fname)
|
| 424 |
+
shutil.move(os.path.join(tmp_dir, fname), pth_dst)
|
| 425 |
+
print(f"[INFO] PTH weights saved to : {pth_dst}")
|
| 426 |
+
|
| 427 |
+
print(f"\n[SUCCESS] ONNX model saved to: {dst_path}\n")
|
| 428 |
+
return dst_path
|
| 429 |
+
|
| 430 |
+
|
| 431 |
+
# ─────────────────────────────────────────────
|
| 432 |
+
# CLI
|
| 433 |
+
# ─────────────────────────────────────────────
|
| 434 |
+
|
| 435 |
+
def build_parser() -> argparse.ArgumentParser:
|
| 436 |
+
default_output = os.path.dirname(os.path.abspath(__file__))
|
| 437 |
+
|
| 438 |
+
parser = argparse.ArgumentParser(
|
| 439 |
+
description=(
|
| 440 |
+
"Export RF-DETR pretrained ONNX models.\n\n"
|
| 441 |
+
"Pretrained COCO weights are downloaded automatically from\n"
|
| 442 |
+
"HuggingFace on first use. Run --list-models to see all variants."
|
| 443 |
+
),
|
| 444 |
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
| 445 |
+
epilog=(
|
| 446 |
+
"Examples:\n"
|
| 447 |
+
" %(prog)s\n"
|
| 448 |
+
" %(prog)s --model rfdetr_nano\n"
|
| 449 |
+
" %(prog)s --model rfdetr_nano rfdetr_small rfdetr_large\n"
|
| 450 |
+
" %(prog)s --model rfdetr_medium --shape 608 608\n"
|
| 451 |
+
" %(prog)s --model rfdetr_nano --backbone-only\n"
|
| 452 |
+
" %(prog)s --model rfdetr_xlarge rfdetr_2xlarge --plus\n"
|
| 453 |
+
" %(prog)s --model rfdetr_seg_nano rfdetr_seg_medium\n"
|
| 454 |
+
" %(prog)s --model rfdetr_large --weights /path/to/custom.pth\n"
|
| 455 |
+
" %(prog)s --model rfdetr_nano --opset 18 --output-dir ./exports\n"
|
| 456 |
+
" %(prog)s --list-models"
|
| 457 |
+
),
|
| 458 |
+
)
|
| 459 |
+
|
| 460 |
+
# ── Model selection ───────────────────────────────────────────────────────
|
| 461 |
+
parser.add_argument(
|
| 462 |
+
"--model",
|
| 463 |
+
nargs="+",
|
| 464 |
+
default=[DEFAULT_MODEL],
|
| 465 |
+
choices=list(MODEL_CATALOG.keys()),
|
| 466 |
+
metavar="VARIANT",
|
| 467 |
+
help=(
|
| 468 |
+
f"Model variant(s) to export. Default: {DEFAULT_MODEL}. "
|
| 469 |
+
"Run --list-models to see all options."
|
| 470 |
+
),
|
| 471 |
+
)
|
| 472 |
+
|
| 473 |
+
# ── Export parameters ─────────────────────────────────────────────────────
|
| 474 |
+
parser.add_argument(
|
| 475 |
+
"--shape",
|
| 476 |
+
nargs=2,
|
| 477 |
+
type=int,
|
| 478 |
+
default=None,
|
| 479 |
+
metavar=("H", "W"),
|
| 480 |
+
help=(
|
| 481 |
+
"Custom input resolution (height width). Must be divisible by the "
|
| 482 |
+
"model's block_size (patch_size × num_windows). "
|
| 483 |
+
"Default: each model's native resolution."
|
| 484 |
+
),
|
| 485 |
+
)
|
| 486 |
+
parser.add_argument(
|
| 487 |
+
"--opset",
|
| 488 |
+
type=int,
|
| 489 |
+
default=17,
|
| 490 |
+
metavar="N",
|
| 491 |
+
help="ONNX opset version. Default: 17.",
|
| 492 |
+
)
|
| 493 |
+
parser.add_argument(
|
| 494 |
+
"--batch-size",
|
| 495 |
+
type=int,
|
| 496 |
+
default=1,
|
| 497 |
+
metavar="N",
|
| 498 |
+
help="Batch size embedded in the exported ONNX graph. Default: 1.",
|
| 499 |
+
)
|
| 500 |
+
parser.add_argument(
|
| 501 |
+
"--backbone-only",
|
| 502 |
+
action="store_true",
|
| 503 |
+
default=False,
|
| 504 |
+
help=(
|
| 505 |
+
"Export only the DINOv2 backbone (feature extractor). "
|
| 506 |
+
"Output is named <variant>_backbone.onnx."
|
| 507 |
+
),
|
| 508 |
+
)
|
| 509 |
+
|
| 510 |
+
# ── Weight source ─────────────────────────────────────────────────────────
|
| 511 |
+
parser.add_argument(
|
| 512 |
+
"--weights",
|
| 513 |
+
default=None,
|
| 514 |
+
metavar="PATH",
|
| 515 |
+
help=(
|
| 516 |
+
"Path to a local .pth checkpoint. "
|
| 517 |
+
"When omitted the official COCO pretrained weights are downloaded "
|
| 518 |
+
"automatically from HuggingFace."
|
| 519 |
+
),
|
| 520 |
+
)
|
| 521 |
+
|
| 522 |
+
# ── Output ────────────────────────────────────────────────────────────────
|
| 523 |
+
parser.add_argument(
|
| 524 |
+
"--output-dir",
|
| 525 |
+
default=default_output,
|
| 526 |
+
metavar="DIR",
|
| 527 |
+
help=f"Directory where .onnx files will be saved. Default: {default_output}",
|
| 528 |
+
)
|
| 529 |
+
parser.add_argument(
|
| 530 |
+
"--force",
|
| 531 |
+
action="store_true",
|
| 532 |
+
default=False,
|
| 533 |
+
help="Re-export even if the destination .onnx file already exists.",
|
| 534 |
+
)
|
| 535 |
+
|
| 536 |
+
# ── Plus models ───────────────────────────────────────────────────────────
|
| 537 |
+
parser.add_argument(
|
| 538 |
+
"--plus",
|
| 539 |
+
action="store_true",
|
| 540 |
+
default=False,
|
| 541 |
+
help=(
|
| 542 |
+
"Install rfdetr[onnx,plus] to enable XLarge / 2XLarge models "
|
| 543 |
+
"(PML 1.0 license). Required when exporting rfdetr_xlarge, "
|
| 544 |
+
"rfdetr_2xlarge, rfdetr_seg_xlarge, or rfdetr_seg_2xlarge."
|
| 545 |
+
),
|
| 546 |
+
)
|
| 547 |
+
|
| 548 |
+
# ── Verbosity ─────────────────────────────────────────────────────────────
|
| 549 |
+
parser.add_argument(
|
| 550 |
+
"--quiet",
|
| 551 |
+
action="store_true",
|
| 552 |
+
default=False,
|
| 553 |
+
help="Suppress rfdetr's internal verbose output.",
|
| 554 |
+
)
|
| 555 |
+
|
| 556 |
+
# ── Utility ───────────────────────────────────────────────────────────────
|
| 557 |
+
parser.add_argument(
|
| 558 |
+
"--list-models",
|
| 559 |
+
action="store_true",
|
| 560 |
+
default=False,
|
| 561 |
+
help="Print the model catalogue table and exit.",
|
| 562 |
+
)
|
| 563 |
+
|
| 564 |
+
return parser
|
| 565 |
+
|
| 566 |
+
|
| 567 |
+
# ─────────────────────────────────────────────
|
| 568 |
+
# Entry point
|
| 569 |
+
# ─────────────────────────────────────────────
|
| 570 |
+
|
| 571 |
+
def main() -> None:
|
| 572 |
+
parser = build_parser()
|
| 573 |
+
args = parser.parse_args()
|
| 574 |
+
|
| 575 |
+
if args.list_models:
|
| 576 |
+
print_model_table()
|
| 577 |
+
return
|
| 578 |
+
|
| 579 |
+
# ── Validate requested models ─────────────────────────────────────────────
|
| 580 |
+
need_plus = args.plus or any(
|
| 581 |
+
MODEL_CATALOG[m]["requires_plus"] for m in args.model
|
| 582 |
+
)
|
| 583 |
+
|
| 584 |
+
plus_models = [m for m in args.model if MODEL_CATALOG[m]["requires_plus"]]
|
| 585 |
+
if plus_models and not args.plus:
|
| 586 |
+
print(
|
| 587 |
+
f"[WARN] {', '.join(plus_models)} require the rfdetr[plus] extra "
|
| 588 |
+
"(PML 1.0 license).\n"
|
| 589 |
+
" Re-run with --plus to confirm and install it."
|
| 590 |
+
)
|
| 591 |
+
sys.exit(1)
|
| 592 |
+
|
| 593 |
+
# ── Warn when --weights is used with multiple models ─────────────────────
|
| 594 |
+
if args.weights and len(args.model) > 1:
|
| 595 |
+
print(
|
| 596 |
+
"[WARN] --weights applies the same checkpoint to every model in "
|
| 597 |
+
"--model.\n This is unusual; pass a single --model variant "
|
| 598 |
+
"when using custom weights."
|
| 599 |
+
)
|
| 600 |
+
|
| 601 |
+
# ── Install rfdetr ────────────────────────────────────────────────────────
|
| 602 |
+
ensure_rfdetr(need_plus=need_plus)
|
| 603 |
+
|
| 604 |
+
# ── Export each model ─────────────────────────────────────────────────────
|
| 605 |
+
shape = (args.shape[0], args.shape[1]) if args.shape else None
|
| 606 |
+
output_dir = os.path.abspath(args.output_dir)
|
| 607 |
+
|
| 608 |
+
exported: list[str] = []
|
| 609 |
+
failed: list[str] = []
|
| 610 |
+
|
| 611 |
+
for model_key in args.model:
|
| 612 |
+
print(f"\n{'='*60}")
|
| 613 |
+
print(f" Exporting: {model_key}")
|
| 614 |
+
print(f"{'='*60}\n")
|
| 615 |
+
|
| 616 |
+
try:
|
| 617 |
+
out_path = export_model(
|
| 618 |
+
model_key = model_key,
|
| 619 |
+
output_dir = output_dir,
|
| 620 |
+
shape = shape,
|
| 621 |
+
opset = args.opset,
|
| 622 |
+
backbone_only = args.backbone_only,
|
| 623 |
+
batch_size = args.batch_size,
|
| 624 |
+
verbose = not args.quiet,
|
| 625 |
+
custom_weights = args.weights,
|
| 626 |
+
force = args.force,
|
| 627 |
+
)
|
| 628 |
+
exported.append(out_path)
|
| 629 |
+
except SystemExit:
|
| 630 |
+
raise
|
| 631 |
+
except Exception as exc:
|
| 632 |
+
print(f"[ERROR] Export failed for '{model_key}': {exc}")
|
| 633 |
+
failed.append(model_key)
|
| 634 |
+
|
| 635 |
+
# ── Summary ───────────────────────────────────────────────────────────────
|
| 636 |
+
print("\n" + "=" * 60)
|
| 637 |
+
print(" Export Summary")
|
| 638 |
+
print("=" * 60)
|
| 639 |
+
for path in exported:
|
| 640 |
+
size_mb = os.path.getsize(path) / (1024 * 1024)
|
| 641 |
+
print(f" ✔ {os.path.basename(path)} ({size_mb:.1f} MB)")
|
| 642 |
+
print(f" {path}")
|
| 643 |
+
if failed:
|
| 644 |
+
for key in failed:
|
| 645 |
+
print(f" ✘ {key} (FAILED)")
|
| 646 |
+
print("=" * 60 + "\n")
|
| 647 |
+
|
| 648 |
+
if failed:
|
| 649 |
+
sys.exit(1)
|
| 650 |
+
|
| 651 |
+
|
| 652 |
+
if __name__ == "__main__":
|
| 653 |
+
main()
|
rfdetr_large_config.yaml
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
task_type: detection
|
| 2 |
+
dataloader:
|
| 3 |
+
name: coco_detection_dataloader
|
| 4 |
+
path: ./data/datasets/coco
|
| 5 |
+
preprocess:
|
| 6 |
+
resize: 704
|
| 7 |
+
crop: 704
|
| 8 |
+
data_layout: NCHW
|
| 9 |
+
reverse_channels: true
|
| 10 |
+
backend: cv2
|
| 11 |
+
interpolation: null
|
| 12 |
+
resize_with_pad: false
|
| 13 |
+
pad_color:
|
| 14 |
+
- 0
|
| 15 |
+
- 0
|
| 16 |
+
- 0
|
| 17 |
+
name: image_preprocess
|
| 18 |
+
session:
|
| 19 |
+
input_optimization: false
|
| 20 |
+
input_data_layout: NCHW
|
| 21 |
+
input_mean:
|
| 22 |
+
- 123.675
|
| 23 |
+
- 116.28
|
| 24 |
+
- 103.53
|
| 25 |
+
input_scale:
|
| 26 |
+
- 0.017125
|
| 27 |
+
- 0.017507
|
| 28 |
+
- 0.017429
|
| 29 |
+
runtime_options: {}
|
| 30 |
+
model_path: rfdetr_large.onnx
|
| 31 |
+
model_id: od-mh8043
|
| 32 |
+
input_details: null
|
| 33 |
+
output_details: null
|
| 34 |
+
num_inputs: 1
|
| 35 |
+
postprocess:
|
| 36 |
+
reshape_list: null
|
| 37 |
+
formatter:
|
| 38 |
+
name: DetectionXYWH2XYXYCenterXY
|
| 39 |
+
resize_with_pad: false
|
| 40 |
+
normalized_detections: true
|
| 41 |
+
shuffle_indices: null
|
| 42 |
+
squeeze_axis: null
|
| 43 |
+
ignore_index: null
|
| 44 |
+
model_output_type: split
|
| 45 |
+
logits_bbox_to_bbox_ls:
|
| 46 |
+
score_fn: sigmoid
|
| 47 |
+
bbox_index: 0
|
| 48 |
+
scores_index: 1
|
| 49 |
+
keypoint: false
|
| 50 |
+
object6dpose: false
|
| 51 |
+
name: detection_postprocess
|
| 52 |
+
metric:
|
| 53 |
+
label_offset_pred:
|
| 54 |
+
1: 1
|
| 55 |
+
2: 2
|
| 56 |
+
3: 3
|
| 57 |
+
4: 4
|
| 58 |
+
5: 5
|
| 59 |
+
6: 6
|
| 60 |
+
7: 7
|
| 61 |
+
8: 8
|
| 62 |
+
9: 9
|
| 63 |
+
10: 10
|
| 64 |
+
11: 11
|
| 65 |
+
12: 12
|
| 66 |
+
13: 13
|
| 67 |
+
14: 14
|
| 68 |
+
15: 15
|
| 69 |
+
16: 16
|
| 70 |
+
17: 17
|
| 71 |
+
18: 18
|
| 72 |
+
19: 19
|
| 73 |
+
20: 20
|
| 74 |
+
21: 21
|
| 75 |
+
22: 22
|
| 76 |
+
23: 23
|
| 77 |
+
24: 24
|
| 78 |
+
25: 25
|
| 79 |
+
26: 26
|
| 80 |
+
27: 27
|
| 81 |
+
28: 28
|
| 82 |
+
29: 29
|
| 83 |
+
30: 30
|
| 84 |
+
31: 31
|
| 85 |
+
32: 32
|
| 86 |
+
33: 33
|
| 87 |
+
34: 34
|
| 88 |
+
35: 35
|
| 89 |
+
36: 36
|
| 90 |
+
37: 37
|
| 91 |
+
38: 38
|
| 92 |
+
39: 39
|
| 93 |
+
40: 40
|
| 94 |
+
41: 41
|
| 95 |
+
42: 42
|
| 96 |
+
43: 43
|
| 97 |
+
44: 44
|
| 98 |
+
45: 45
|
| 99 |
+
46: 46
|
| 100 |
+
47: 47
|
| 101 |
+
48: 48
|
| 102 |
+
49: 49
|
| 103 |
+
50: 50
|
| 104 |
+
51: 51
|
| 105 |
+
52: 52
|
| 106 |
+
53: 53
|
| 107 |
+
54: 54
|
| 108 |
+
55: 55
|
| 109 |
+
56: 56
|
| 110 |
+
57: 57
|
| 111 |
+
58: 58
|
| 112 |
+
59: 59
|
| 113 |
+
60: 60
|
| 114 |
+
61: 61
|
| 115 |
+
62: 62
|
| 116 |
+
63: 63
|
| 117 |
+
64: 64
|
| 118 |
+
65: 65
|
| 119 |
+
66: 66
|
| 120 |
+
67: 67
|
| 121 |
+
68: 68
|
| 122 |
+
69: 69
|
| 123 |
+
70: 70
|
| 124 |
+
71: 71
|
| 125 |
+
72: 72
|
| 126 |
+
73: 73
|
| 127 |
+
74: 74
|
| 128 |
+
75: 75
|
| 129 |
+
76: 76
|
| 130 |
+
77: 77
|
| 131 |
+
78: 78
|
| 132 |
+
79: 79
|
| 133 |
+
80: 80
|
| 134 |
+
81: 81
|
| 135 |
+
82: 82
|
| 136 |
+
83: 83
|
| 137 |
+
84: 84
|
| 138 |
+
85: 85
|
| 139 |
+
86: 86
|
| 140 |
+
87: 87
|
| 141 |
+
88: 88
|
| 142 |
+
89: 89
|
| 143 |
+
90: 90
|
| 144 |
+
91: 91
|
| 145 |
+
0: 0
|
| 146 |
+
model_info:
|
| 147 |
+
metric_reference:
|
| 148 |
+
accuracy_ap[.5:.95]%: 56.5
|
| 149 |
+
model_shortlist: 10
|
| 150 |
+
compact_name: rfdetr-large-704x704
|
| 151 |
+
shortlisted: true
|
| 152 |
+
recommended: false
|
rfdetr_medium_config.yaml
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
task_type: detection
|
| 2 |
+
dataloader:
|
| 3 |
+
name: coco_detection_dataloader
|
| 4 |
+
path: ./data/datasets/coco
|
| 5 |
+
preprocess:
|
| 6 |
+
resize: 576
|
| 7 |
+
crop: 576
|
| 8 |
+
data_layout: NCHW
|
| 9 |
+
reverse_channels: true
|
| 10 |
+
backend: cv2
|
| 11 |
+
interpolation: null
|
| 12 |
+
resize_with_pad: false
|
| 13 |
+
pad_color:
|
| 14 |
+
- 0
|
| 15 |
+
- 0
|
| 16 |
+
- 0
|
| 17 |
+
name: image_preprocess
|
| 18 |
+
session:
|
| 19 |
+
input_optimization: false
|
| 20 |
+
input_data_layout: NCHW
|
| 21 |
+
input_mean:
|
| 22 |
+
- 123.675
|
| 23 |
+
- 116.28
|
| 24 |
+
- 103.53
|
| 25 |
+
input_scale:
|
| 26 |
+
- 0.017125
|
| 27 |
+
- 0.017507
|
| 28 |
+
- 0.017429
|
| 29 |
+
runtime_options: {}
|
| 30 |
+
model_path: rfdetr_medium.onnx
|
| 31 |
+
model_id: od-mh8042
|
| 32 |
+
input_details: null
|
| 33 |
+
output_details: null
|
| 34 |
+
num_inputs: 1
|
| 35 |
+
postprocess:
|
| 36 |
+
reshape_list: null
|
| 37 |
+
formatter:
|
| 38 |
+
name: DetectionXYWH2XYXYCenterXY
|
| 39 |
+
resize_with_pad: false
|
| 40 |
+
normalized_detections: true
|
| 41 |
+
shuffle_indices: null
|
| 42 |
+
squeeze_axis: null
|
| 43 |
+
ignore_index: null
|
| 44 |
+
model_output_type: split
|
| 45 |
+
logits_bbox_to_bbox_ls:
|
| 46 |
+
score_fn: sigmoid
|
| 47 |
+
bbox_index: 0
|
| 48 |
+
scores_index: 1
|
| 49 |
+
keypoint: false
|
| 50 |
+
object6dpose: false
|
| 51 |
+
name: detection_postprocess
|
| 52 |
+
metric:
|
| 53 |
+
label_offset_pred:
|
| 54 |
+
1: 1
|
| 55 |
+
2: 2
|
| 56 |
+
3: 3
|
| 57 |
+
4: 4
|
| 58 |
+
5: 5
|
| 59 |
+
6: 6
|
| 60 |
+
7: 7
|
| 61 |
+
8: 8
|
| 62 |
+
9: 9
|
| 63 |
+
10: 10
|
| 64 |
+
11: 11
|
| 65 |
+
12: 12
|
| 66 |
+
13: 13
|
| 67 |
+
14: 14
|
| 68 |
+
15: 15
|
| 69 |
+
16: 16
|
| 70 |
+
17: 17
|
| 71 |
+
18: 18
|
| 72 |
+
19: 19
|
| 73 |
+
20: 20
|
| 74 |
+
21: 21
|
| 75 |
+
22: 22
|
| 76 |
+
23: 23
|
| 77 |
+
24: 24
|
| 78 |
+
25: 25
|
| 79 |
+
26: 26
|
| 80 |
+
27: 27
|
| 81 |
+
28: 28
|
| 82 |
+
29: 29
|
| 83 |
+
30: 30
|
| 84 |
+
31: 31
|
| 85 |
+
32: 32
|
| 86 |
+
33: 33
|
| 87 |
+
34: 34
|
| 88 |
+
35: 35
|
| 89 |
+
36: 36
|
| 90 |
+
37: 37
|
| 91 |
+
38: 38
|
| 92 |
+
39: 39
|
| 93 |
+
40: 40
|
| 94 |
+
41: 41
|
| 95 |
+
42: 42
|
| 96 |
+
43: 43
|
| 97 |
+
44: 44
|
| 98 |
+
45: 45
|
| 99 |
+
46: 46
|
| 100 |
+
47: 47
|
| 101 |
+
48: 48
|
| 102 |
+
49: 49
|
| 103 |
+
50: 50
|
| 104 |
+
51: 51
|
| 105 |
+
52: 52
|
| 106 |
+
53: 53
|
| 107 |
+
54: 54
|
| 108 |
+
55: 55
|
| 109 |
+
56: 56
|
| 110 |
+
57: 57
|
| 111 |
+
58: 58
|
| 112 |
+
59: 59
|
| 113 |
+
60: 60
|
| 114 |
+
61: 61
|
| 115 |
+
62: 62
|
| 116 |
+
63: 63
|
| 117 |
+
64: 64
|
| 118 |
+
65: 65
|
| 119 |
+
66: 66
|
| 120 |
+
67: 67
|
| 121 |
+
68: 68
|
| 122 |
+
69: 69
|
| 123 |
+
70: 70
|
| 124 |
+
71: 71
|
| 125 |
+
72: 72
|
| 126 |
+
73: 73
|
| 127 |
+
74: 74
|
| 128 |
+
75: 75
|
| 129 |
+
76: 76
|
| 130 |
+
77: 77
|
| 131 |
+
78: 78
|
| 132 |
+
79: 79
|
| 133 |
+
80: 80
|
| 134 |
+
81: 81
|
| 135 |
+
82: 82
|
| 136 |
+
83: 83
|
| 137 |
+
84: 84
|
| 138 |
+
85: 85
|
| 139 |
+
86: 86
|
| 140 |
+
87: 87
|
| 141 |
+
88: 88
|
| 142 |
+
89: 89
|
| 143 |
+
90: 90
|
| 144 |
+
91: 91
|
| 145 |
+
0: 0
|
| 146 |
+
model_info:
|
| 147 |
+
metric_reference:
|
| 148 |
+
accuracy_ap[.5:.95]%: 54.7
|
| 149 |
+
model_shortlist: 10
|
| 150 |
+
compact_name: rfdetr-medium-576x576
|
| 151 |
+
shortlisted: true
|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dataloader
|
| 4 |
+
path: ./data/datasets/coco
|
| 5 |
+
preprocess:
|
| 6 |
+
resize: 384
|
| 7 |
+
crop: 384
|
| 8 |
+
data_layout: NCHW
|
| 9 |
+
reverse_channels: true
|
| 10 |
+
backend: cv2
|
| 11 |
+
interpolation: null
|
| 12 |
+
resize_with_pad: false
|
| 13 |
+
pad_color:
|
| 14 |
+
- 0
|
| 15 |
+
- 0
|
| 16 |
+
- 0
|
| 17 |
+
name: image_preprocess
|
| 18 |
+
session:
|
| 19 |
+
input_optimization: false
|
| 20 |
+
input_data_layout: NCHW
|
| 21 |
+
input_mean:
|
| 22 |
+
- 123.675
|
| 23 |
+
- 116.28
|
| 24 |
+
- 103.53
|
| 25 |
+
input_scale:
|
| 26 |
+
- 0.017125
|
| 27 |
+
- 0.017507
|
| 28 |
+
- 0.017429
|
| 29 |
+
runtime_options: {}
|
| 30 |
+
model_path: rfdetr_nano.onnx
|
| 31 |
+
model_id: od-mh8040
|
| 32 |
+
input_details: null
|
| 33 |
+
output_details: null
|
| 34 |
+
num_inputs: 1
|
| 35 |
+
postprocess:
|
| 36 |
+
reshape_list: null
|
| 37 |
+
formatter:
|
| 38 |
+
name: DetectionXYWH2XYXYCenterXY
|
| 39 |
+
resize_with_pad: false
|
| 40 |
+
normalized_detections: true
|
| 41 |
+
shuffle_indices: null
|
| 42 |
+
squeeze_axis: null
|
| 43 |
+
ignore_index: null
|
| 44 |
+
model_output_type: split
|
| 45 |
+
logits_bbox_to_bbox_ls:
|
| 46 |
+
score_fn: sigmoid
|
| 47 |
+
bbox_index: 0
|
| 48 |
+
scores_index: 1
|
| 49 |
+
keypoint: false
|
| 50 |
+
object6dpose: false
|
| 51 |
+
name: detection_postprocess
|
| 52 |
+
metric:
|
| 53 |
+
label_offset_pred:
|
| 54 |
+
1: 1
|
| 55 |
+
2: 2
|
| 56 |
+
3: 3
|
| 57 |
+
4: 4
|
| 58 |
+
5: 5
|
| 59 |
+
6: 6
|
| 60 |
+
7: 7
|
| 61 |
+
8: 8
|
| 62 |
+
9: 9
|
| 63 |
+
10: 10
|
| 64 |
+
11: 11
|
| 65 |
+
12: 12
|
| 66 |
+
13: 13
|
| 67 |
+
14: 14
|
| 68 |
+
15: 15
|
| 69 |
+
16: 16
|
| 70 |
+
17: 17
|
| 71 |
+
18: 18
|
| 72 |
+
19: 19
|
| 73 |
+
20: 20
|
| 74 |
+
21: 21
|
| 75 |
+
22: 22
|
| 76 |
+
23: 23
|
| 77 |
+
24: 24
|
| 78 |
+
25: 25
|
| 79 |
+
26: 26
|
| 80 |
+
27: 27
|
| 81 |
+
28: 28
|
| 82 |
+
29: 29
|
| 83 |
+
30: 30
|
| 84 |
+
31: 31
|
| 85 |
+
32: 32
|
| 86 |
+
33: 33
|
| 87 |
+
34: 34
|
| 88 |
+
35: 35
|
| 89 |
+
36: 36
|
| 90 |
+
37: 37
|
| 91 |
+
38: 38
|
| 92 |
+
39: 39
|
| 93 |
+
40: 40
|
| 94 |
+
41: 41
|
| 95 |
+
42: 42
|
| 96 |
+
43: 43
|
| 97 |
+
44: 44
|
| 98 |
+
45: 45
|
| 99 |
+
46: 46
|
| 100 |
+
47: 47
|
| 101 |
+
48: 48
|
| 102 |
+
49: 49
|
| 103 |
+
50: 50
|
| 104 |
+
51: 51
|
| 105 |
+
52: 52
|
| 106 |
+
53: 53
|
| 107 |
+
54: 54
|
| 108 |
+
55: 55
|
| 109 |
+
56: 56
|
| 110 |
+
57: 57
|
| 111 |
+
58: 58
|
| 112 |
+
59: 59
|
| 113 |
+
60: 60
|
| 114 |
+
61: 61
|
| 115 |
+
62: 62
|
| 116 |
+
63: 63
|
| 117 |
+
64: 64
|
| 118 |
+
65: 65
|
| 119 |
+
66: 66
|
| 120 |
+
67: 67
|
| 121 |
+
68: 68
|
| 122 |
+
69: 69
|
| 123 |
+
70: 70
|
| 124 |
+
71: 71
|
| 125 |
+
72: 72
|
| 126 |
+
73: 73
|
| 127 |
+
74: 74
|
| 128 |
+
75: 75
|
| 129 |
+
76: 76
|
| 130 |
+
77: 77
|
| 131 |
+
78: 78
|
| 132 |
+
79: 79
|
| 133 |
+
80: 80
|
| 134 |
+
81: 81
|
| 135 |
+
82: 82
|
| 136 |
+
83: 83
|
| 137 |
+
84: 84
|
| 138 |
+
85: 85
|
| 139 |
+
86: 86
|
| 140 |
+
87: 87
|
| 141 |
+
88: 88
|
| 142 |
+
89: 89
|
| 143 |
+
90: 90
|
| 144 |
+
91: 91
|
| 145 |
+
0: 0
|
| 146 |
+
model_info:
|
| 147 |
+
metric_reference:
|
| 148 |
+
accuracy_ap[.5:.95]%: 48.4
|
| 149 |
+
model_shortlist: 10
|
| 150 |
+
compact_name: rfdetr-nano-384x384
|
| 151 |
+
shortlisted: true
|
| 152 |
+
recommended: true
|
rfdetr_small_config.yaml
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
task_type: detection
|
| 2 |
+
dataloader:
|
| 3 |
+
name: coco_detection_dataloader
|
| 4 |
+
path: ./data/datasets/coco
|
| 5 |
+
preprocess:
|
| 6 |
+
resize: 512
|
| 7 |
+
crop: 512
|
| 8 |
+
data_layout: NCHW
|
| 9 |
+
reverse_channels: true
|
| 10 |
+
backend: cv2
|
| 11 |
+
interpolation: null
|
| 12 |
+
resize_with_pad: false
|
| 13 |
+
pad_color:
|
| 14 |
+
- 0
|
| 15 |
+
- 0
|
| 16 |
+
- 0
|
| 17 |
+
name: image_preprocess
|
| 18 |
+
session:
|
| 19 |
+
input_optimization: false
|
| 20 |
+
input_data_layout: NCHW
|
| 21 |
+
input_mean:
|
| 22 |
+
- 123.675
|
| 23 |
+
- 116.28
|
| 24 |
+
- 103.53
|
| 25 |
+
input_scale:
|
| 26 |
+
- 0.017125
|
| 27 |
+
- 0.017507
|
| 28 |
+
- 0.017429
|
| 29 |
+
runtime_options: {}
|
| 30 |
+
model_path: rfdetr_small.onnx
|
| 31 |
+
model_id: od-mh8041
|
| 32 |
+
input_details: null
|
| 33 |
+
output_details: null
|
| 34 |
+
num_inputs: 1
|
| 35 |
+
postprocess:
|
| 36 |
+
reshape_list: null
|
| 37 |
+
formatter:
|
| 38 |
+
name: DetectionXYWH2XYXYCenterXY
|
| 39 |
+
resize_with_pad: false
|
| 40 |
+
normalized_detections: true
|
| 41 |
+
shuffle_indices: null
|
| 42 |
+
squeeze_axis: null
|
| 43 |
+
ignore_index: null
|
| 44 |
+
model_output_type: split
|
| 45 |
+
logits_bbox_to_bbox_ls:
|
| 46 |
+
score_fn: sigmoid
|
| 47 |
+
bbox_index: 0
|
| 48 |
+
scores_index: 1
|
| 49 |
+
keypoint: false
|
| 50 |
+
object6dpose: false
|
| 51 |
+
name: detection_postprocess
|
| 52 |
+
metric:
|
| 53 |
+
label_offset_pred:
|
| 54 |
+
1: 1
|
| 55 |
+
2: 2
|
| 56 |
+
3: 3
|
| 57 |
+
4: 4
|
| 58 |
+
5: 5
|
| 59 |
+
6: 6
|
| 60 |
+
7: 7
|
| 61 |
+
8: 8
|
| 62 |
+
9: 9
|
| 63 |
+
10: 10
|
| 64 |
+
11: 11
|
| 65 |
+
12: 12
|
| 66 |
+
13: 13
|
| 67 |
+
14: 14
|
| 68 |
+
15: 15
|
| 69 |
+
16: 16
|
| 70 |
+
17: 17
|
| 71 |
+
18: 18
|
| 72 |
+
19: 19
|
| 73 |
+
20: 20
|
| 74 |
+
21: 21
|
| 75 |
+
22: 22
|
| 76 |
+
23: 23
|
| 77 |
+
24: 24
|
| 78 |
+
25: 25
|
| 79 |
+
26: 26
|
| 80 |
+
27: 27
|
| 81 |
+
28: 28
|
| 82 |
+
29: 29
|
| 83 |
+
30: 30
|
| 84 |
+
31: 31
|
| 85 |
+
32: 32
|
| 86 |
+
33: 33
|
| 87 |
+
34: 34
|
| 88 |
+
35: 35
|
| 89 |
+
36: 36
|
| 90 |
+
37: 37
|
| 91 |
+
38: 38
|
| 92 |
+
39: 39
|
| 93 |
+
40: 40
|
| 94 |
+
41: 41
|
| 95 |
+
42: 42
|
| 96 |
+
43: 43
|
| 97 |
+
44: 44
|
| 98 |
+
45: 45
|
| 99 |
+
46: 46
|
| 100 |
+
47: 47
|
| 101 |
+
48: 48
|
| 102 |
+
49: 49
|
| 103 |
+
50: 50
|
| 104 |
+
51: 51
|
| 105 |
+
52: 52
|
| 106 |
+
53: 53
|
| 107 |
+
54: 54
|
| 108 |
+
55: 55
|
| 109 |
+
56: 56
|
| 110 |
+
57: 57
|
| 111 |
+
58: 58
|
| 112 |
+
59: 59
|
| 113 |
+
60: 60
|
| 114 |
+
61: 61
|
| 115 |
+
62: 62
|
| 116 |
+
63: 63
|
| 117 |
+
64: 64
|
| 118 |
+
65: 65
|
| 119 |
+
66: 66
|
| 120 |
+
67: 67
|
| 121 |
+
68: 68
|
| 122 |
+
69: 69
|
| 123 |
+
70: 70
|
| 124 |
+
71: 71
|
| 125 |
+
72: 72
|
| 126 |
+
73: 73
|
| 127 |
+
74: 74
|
| 128 |
+
75: 75
|
| 129 |
+
76: 76
|
| 130 |
+
77: 77
|
| 131 |
+
78: 78
|
| 132 |
+
79: 79
|
| 133 |
+
80: 80
|
| 134 |
+
81: 81
|
| 135 |
+
82: 82
|
| 136 |
+
83: 83
|
| 137 |
+
84: 84
|
| 138 |
+
85: 85
|
| 139 |
+
86: 86
|
| 140 |
+
87: 87
|
| 141 |
+
88: 88
|
| 142 |
+
89: 89
|
| 143 |
+
90: 90
|
| 144 |
+
91: 91
|
| 145 |
+
0: 0
|
| 146 |
+
model_info:
|
| 147 |
+
metric_reference:
|
| 148 |
+
accuracy_ap[.5:.95]%: 53.0
|
| 149 |
+
model_shortlist: 10
|
| 150 |
+
compact_name: rfdetr-small-512x512
|
| 151 |
+
shortlisted: true
|
| 152 |
+
recommended: false
|