AdrianLlopart commited on
Commit
28d517a
Β·
verified Β·
1 Parent(s): 038e613

Copy rskill from AdrianLlopart/rskill-rtdetr-coco-r18

Browse files
Files changed (5) hide show
  1. .gitattributes +1 -0
  2. README.md +154 -0
  3. model.onnx +3 -0
  4. model.onnx.data +3 -0
  5. rskill.yaml +187 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ model.onnx.data filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - OpenRAL
4
+ - rskill
5
+ - detector
6
+ - object-detection
7
+ - rt-detr
8
+ - onnx
9
+ - coco
10
+ license: apache-2.0
11
+ language:
12
+ - en
13
+ base_model:
14
+ - PekingU/rtdetr_r18vd_coco_o365
15
+ ---
16
+
17
+ # rskill-rtdetr-coco-r18
18
+
19
+ > **OpenRAL rSkill** β€” RT-DETR (Real-Time DEtection TRansformer) with a
20
+ > ResNet-18vd backbone (r18vd), trained on COCO and exported to ONNX. Runs
21
+ > as a perception producer on the camera tee and publishes `ObjectsMetadata`
22
+ > to `/openral/perception/objects`. **No actuators.** This skill uses
23
+ > `kind: detector` (ADR-0034); it emits no `Action` chunks and drives no
24
+ > `ros2_control` joints.
25
+
26
+ ## What it does
27
+
28
+ RT-DETR r18vd detects 80 COCO-category objects in each camera frame and
29
+ publishes per-frame `ObjectsMetadata` events containing bounding boxes,
30
+ class labels, and confidence scores. The runtime `ObjectsDetector`
31
+ (in `openral_perception`) reads the `detector` manifest block at configure
32
+ time to initialise the ONNX inference session and bind the class-id β†’
33
+ label mapping.
34
+
35
+ ## Latency
36
+
37
+ | Host | Latency (ms) |
38
+ |----------------|-------------|
39
+ | NVIDIA GPU | ~15–30 |
40
+ | x86 CPU | ~35–50 |
41
+
42
+ Budget declared in manifest: `per_chunk_ms: 50.0`.
43
+
44
+ ## Weights
45
+
46
+ The `model.onnx` file is not committed to the repository (binary artefact; see
47
+ `.gitignore`). Reproduce it with an **ephemeral** overlay environment (does not
48
+ mutate the project venv):
49
+
50
+ ```bash
51
+ uv run --isolated --no-project \
52
+ --with "transformers>=4.45,<5" --with "torch>=2.2" --with torchvision \
53
+ --with onnx --with onnxscript \
54
+ python tools/export_rtdetr_onnx.py \
55
+ --out rskills/rtdetr-coco-r18/model.onnx \
56
+ --model-id PekingU/rtdetr_r18vd_coco_o365
57
+ ```
58
+
59
+ > **Do NOT** run this via `uv sync --group onnx-export` β€” `uv sync` reconciles
60
+ > the project venv to the synced group set and prunes `pydantic`/`structlog`
61
+ > (and other deps) the source-on-PYTHONPATH dev/test setup relies on, breaking
62
+ > the unit tests.
63
+ >
64
+ > `--isolated --no-project` is required: a plain `uv run --with` overlays on the
65
+ > project venv, whose `torchvision` is built against a different `torch` than the
66
+ > overlay's β€” importing `RTDetrForObjectDetection` then dies with
67
+ > `operator torchvision::nms does not exist`. The isolated form builds a clean
68
+ > ephemeral env (project venv untouched). `transformers<5` keeps the stable
69
+ > RTDetr `forward` (logits + pred_boxes) signature; `onnx`+`onnxscript` are
70
+ > required by the torch β‰₯2.7 ONNX exporter. GPU footprint: ~0.2 GB at 640Β² fp32 β€”
71
+ > runs on an 8 GB card, no quantization needed.
72
+
73
+ The torch 2.9 new exporter splits the model into two files that must be kept
74
+ together in the same directory:
75
+
76
+ | File | Description | sha256 (first 16 hex) | Size |
77
+ |--------------------|----------------------------------------------|----------------------------|-------|
78
+ | `model.onnx` | ONNX graph (references `model.onnx.data`) | `bda4dbeceff130ce...` | 2.3 MB |
79
+ | `model.onnx.data` | External weight data (loaded by ORT) | `8dff132e55df1bef...` | 78 MB |
80
+
81
+ Full sha256 values (reproduced with `transformers 4.x` + `torch 2.9` + `onnxscript`;
82
+ the new torch exporter is not bit-reproducible across toolchain versions, so treat
83
+ these as a same-host integrity check, not a cross-version guarantee):
84
+ - `model.onnx`: `bda4dbeceff130cec050e9757c9d95e217526a00730fb5f1558f960a6b316c63`
85
+ - `model.onnx.data`: `8dff132e55df1befdf394a672a29906e38df7653be66705c47bd2a41634567b2`
86
+
87
+ The published copies on the HF Hub repo are the canonical artefacts; the local
88
+ export above must match them on the same toolchain.
89
+
90
+ | Field | Value |
91
+ |--------------|----------------------------------------------------------------------|
92
+ | `model_id` | `PekingU/rtdetr_r18vd_coco_o365` |
93
+ | `opset` | 18 (torch 2.9 new exporter; opset 17 target auto-bumped by exporter) |
94
+ | `input` | `pixel_values` β€” shape `(batch, 3, 640, 640)`, float32, range [0,1] |
95
+ | `outputs` | `logits (1, 300, 80)` pre-sigmoid; `pred_boxes (1, 300, 4)` cxcywh |
96
+
97
+ ## Upstream model / training
98
+
99
+ This rSkill packages an RT-DETR (Real-Time DEtection TRansformer) object
100
+ detector with a **ResNet-18vd backbone (`r18vd`)**, exported to ONNX. It
101
+ copies no PyTorch policy weights β€” the ONNX graph is produced from the
102
+ upstream Transformers checkpoint by `tools/export_rtdetr_onnx.py` (see the
103
+ **Weights** section above for the exact command and sha256 digests).
104
+
105
+ | Field | Value |
106
+ | --- | --- |
107
+ | Architecture | RT-DETR, `r18vd` backbone |
108
+ | Source repo | [`PekingU/rtdetr_r18vd_coco_o365`](https://huggingface.co/PekingU/rtdetr_r18vd_coco_o365) |
109
+ | Training data | COCO (80 categories), pretrained on Objects365 (`o365`) |
110
+ | Export tool | `tools/export_rtdetr_onnx.py` β†’ `model.onnx` + `model.onnx.data` |
111
+ | Paper | [arxiv:2304.08069](https://arxiv.org/abs/2304.08069) β€” *DETRs Beat YOLOs on Real-time Object Detection* |
112
+ | License | apache-2.0 |
113
+
114
+ ## Supported robots / embodiments
115
+
116
+ This detector is **embodiment-agnostic**: it consumes any RGB camera stream
117
+ and emits `ObjectsMetadata`. All known embodiment tags are declared in the
118
+ manifest; the `sensors_required` entry has no `vla_feature_key`, so the
119
+ loader accepts any camera key β€” not just `camera1`.
120
+
121
+ ## Sensors / observation contract
122
+
123
+ | Direction | Key | Modality | Shape / format | Notes |
124
+ | --- | --- | --- | --- | --- |
125
+ | in | any RGB camera | RGB `sensor_msgs/Image` | min 640 Γ— 480 | `vla_feature_key` unset β€” any camera name accepted |
126
+ | (preprocessing) | β€” | β€” | resized to 640 Γ— 640, `/255` β†’ float32 `[0,1]`, NCHW | `pixel_values` `(batch, 3, 640, 640)` |
127
+ | out | COCO-80 detections | `ObjectsMetadata` | per object: `label`, `confidence`, `bbox` | published to `/openral/perception/objects` |
128
+
129
+ The detector emits **no** `Action` chunks and has no proprioception
130
+ (`observation.state`) contract.
131
+
132
+ ## Manifest summary
133
+
134
+ | Field | Value |
135
+ | --- | --- |
136
+ | `name` | `AdrianLlopart/rskill-rtdetr-coco-r18` |
137
+ | `version` | `0.1.0` |
138
+ | `license` | `apache-2.0` |
139
+ | `role` | `s1` |
140
+ | `kind` | `detector` (ADR-0034 perception producer) |
141
+ | `embodiment_tags` | all 17 canonical embodiment tags (any robot with RGB camera) |
142
+ | `runtime` / `quantization.dtype` | `onnx` / `fp32` |
143
+ | `weights_uri` | `rskill://rskills/rtdetr-coco-r18` |
144
+ | `latency_budget.per_chunk_ms` | `50.0` |
145
+ | `detector.labels` | 80 COCO categories |
146
+ | `detector.input_size` | `[640, 640]` |
147
+ | `detector.score_threshold` | `0.5` |
148
+
149
+ Full schema: [`openral_core.schemas.RSkillManifest`](../../python/core/src/openral_core/schemas.py).
150
+
151
+ ## License
152
+
153
+ Weights: Apache-2.0 (PaddlePaddle RT-DETR public release).
154
+ See [arxiv:2304.08069](https://arxiv.org/abs/2304.08069) for the paper.
model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bda4dbeceff130cec050e9757c9d95e217526a00730fb5f1558f960a6b316c63
3
+ size 2313746
model.onnx.data ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8dff132e55df1befdf394a672a29906e38df7653be66705c47bd2a41634567b2
3
+ size 81199104
rskill.yaml ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # rSkill manifest β€” RT-DETR COCO detector (kind: detector, ADR-0034)
2
+ #
3
+ # Packages a PaddlePaddle RT-DETR-L model exported to ONNX for use as
4
+ # an OpenRAL perception producer. The skill runs on the camera tee and
5
+ # publishes ObjectsMetadata to /openral/perception/objects.
6
+ #
7
+ # This is a pure perception producer: it emits no Action chunks, drives
8
+ # no actuators, and has no proprioception contract. The runtime
9
+ # ObjectsDetector (openral_perception) reads the detector block at
10
+ # configure time to initialise the ONNX session and label map.
11
+ #
12
+ # LICENSE: weights are Apache-2.0 (PaddlePaddle RT-DETR public release).
13
+
14
+ schema_version: "0.1"
15
+ name: "AdrianLlopart/rskill-rtdetr-coco-r18"
16
+ version: "0.1.0"
17
+ license: "apache-2.0"
18
+ role: "s1"
19
+ kind: "detector" # ADR-0034: perception producer; emits ObjectsMetadata, no Action
20
+
21
+ # ── Compatibility contract ──────────────────────────────────────────────────
22
+ # A detector is camera-based, not manipulator-specific. All embodiments are
23
+ # declared because the only requirement is an RGB camera stream.
24
+ embodiment_tags:
25
+ - "aloha"
26
+ - "franka_panda"
27
+ - "g1"
28
+ - "google_robot"
29
+ - "gr1"
30
+ - "h1"
31
+ - "mobile_base"
32
+ - "openarm"
33
+ - "panda_mobile"
34
+ - "pusht"
35
+ - "rizon4"
36
+ - "sawyer"
37
+ - "so100_follower"
38
+ - "so101_follower"
39
+ - "ur10e"
40
+ - "ur5e"
41
+ - "widowx"
42
+
43
+ # The detector reads any RGB camera stream. vla_feature_key is omitted so
44
+ # the loader accepts any camera key, not just "camera1".
45
+ sensors_required:
46
+ - modality: "rgb"
47
+ min_width: 640
48
+ min_height: 480
49
+
50
+ # Detectors command no actuators.
51
+ actuators_required: []
52
+
53
+ # ── Runtime / weights ───────────────────────────────────────────────────────
54
+ runtime: "onnx"
55
+ quantization:
56
+ dtype: "fp32"
57
+ backend: "onnx"
58
+
59
+ # RT-DETR-L exported to ONNX. References the in-tree rSkill package.
60
+ # The loader resolves rskill:// to the local rskills/<id>/ directory.
61
+ weights_uri: "rskill://rskills/rtdetr-coco-r18"
62
+
63
+ # ── Execution semantics ─────────────────────────────────────────────────────
64
+ # chunk_size is 1: the detector runs per-frame. The safety supervisor never
65
+ # sees detector output (no Action chunks), but chunk_size=1 keeps the
66
+ # execution tick consistent with the camera frame rate.
67
+ chunk_size: 1
68
+ latency_budget:
69
+ # RT-DETR-L on an NVIDIA GPU is typically 15-30 ms; allow 50 ms budget
70
+ # to cover CPU fallback on smaller hosts.
71
+ per_chunk_ms: 50.0
72
+
73
+ # ── Detector contract (ADR-0034) ────────────────────────────────────────────
74
+ # 80 COCO labels (subset shown for readability β€” full list matches the
75
+ # 0-indexed COCO category order used by the exported model).
76
+ detector:
77
+ labels:
78
+ - "person"
79
+ - "bicycle"
80
+ - "car"
81
+ - "motorcycle"
82
+ - "airplane"
83
+ - "bus"
84
+ - "train"
85
+ - "truck"
86
+ - "boat"
87
+ - "traffic light"
88
+ - "fire hydrant"
89
+ - "stop sign"
90
+ - "parking meter"
91
+ - "bench"
92
+ - "bird"
93
+ - "cat"
94
+ - "dog"
95
+ - "horse"
96
+ - "sheep"
97
+ - "cow"
98
+ - "elephant"
99
+ - "bear"
100
+ - "zebra"
101
+ - "giraffe"
102
+ - "backpack"
103
+ - "umbrella"
104
+ - "handbag"
105
+ - "tie"
106
+ - "suitcase"
107
+ - "frisbee"
108
+ - "skis"
109
+ - "snowboard"
110
+ - "sports ball"
111
+ - "kite"
112
+ - "baseball bat"
113
+ - "baseball glove"
114
+ - "skateboard"
115
+ - "surfboard"
116
+ - "tennis racket"
117
+ - "bottle"
118
+ - "wine glass"
119
+ - "cup"
120
+ - "fork"
121
+ - "knife"
122
+ - "spoon"
123
+ - "bowl"
124
+ - "banana"
125
+ - "apple"
126
+ - "sandwich"
127
+ - "orange"
128
+ - "broccoli"
129
+ - "carrot"
130
+ - "hot dog"
131
+ - "pizza"
132
+ - "donut"
133
+ - "cake"
134
+ - "chair"
135
+ - "couch"
136
+ - "potted plant"
137
+ - "bed"
138
+ - "dining table"
139
+ - "toilet"
140
+ - "tv"
141
+ - "laptop"
142
+ - "mouse"
143
+ - "remote"
144
+ - "keyboard"
145
+ - "cell phone"
146
+ - "microwave"
147
+ - "oven"
148
+ - "toaster"
149
+ - "sink"
150
+ - "refrigerator"
151
+ - "book"
152
+ - "clock"
153
+ - "vase"
154
+ - "scissors"
155
+ - "teddy bear"
156
+ - "hair drier"
157
+ - "toothbrush"
158
+ input_size: [640, 640]
159
+ score_threshold: 0.5
160
+
161
+ # ── Provenance ──────────────────────────────────────────────────────────────
162
+ paper_url: "https://arxiv.org/abs/2304.08069"
163
+ source_repo: "hf://PekingU/rtdetr_r18vd_coco_o365"
164
+
165
+ description: >
166
+ RT-DETR-L (Real-Time DEtection TRansformer, large variant) trained on
167
+ COCO and exported to ONNX. Runs on the camera tee and publishes
168
+ ObjectsMetadata to /openral/perception/objects. 80 COCO categories.
169
+ Apache-2.0 weights. Reference latency ~20 ms on GPU, ~45 ms on CPU.
170
+ See ADR-0034 for the detector rSkill kind contract.
171
+
172
+ # ADR-0022 β€” action vocabulary for the reasoner LLM tool palette.
173
+ # DETECT signals that this skill is a perception producer.
174
+ actions:
175
+ - "detect"
176
+
177
+ objects:
178
+ - "person"
179
+ - "cup"
180
+ - "bottle"
181
+ - "bowl"
182
+ - "chair"
183
+ - "table"
184
+ scenes:
185
+ - "tabletop"
186
+ - "kitchen"
187
+ - "indoor"