Export a trained OrientedDet checkpoint to a pre-NMS ONNX graph plus Python preprocess / rotated NMS. Consumers run ONNX Runtime only — no PyTorch and no oriented-det.
The producer CLI is odet export (ONNX only; same as python -m export). Folder README: export/README.md. The Tile Geo Process HTTP service stays on the Docker deploy path. Sliding-window tiling for images larger than window_size runs in detect_image.
Producer (checkpoint → ONNX):
uv pip install -e ".[export]"Consumer (infer / demo without this repo):
pip install -r export/requirements-runtime.txtGPU ORT: install onnxruntime-gpu[cuda,cudnn] instead of onnxruntime (do not install both).
Default is Rotated FCOS (rotated_fcos_pre_nms). Download Hub weights or point at a training run:
odet pretrained download rotated_fcos_dota_le90_1x
make export-onnxFrom a run directory:
make export-onnx EXPERIMENT=runs/rotated_fcos/<timestamp>
make export-onnx EXPERIMENT=runs/oriented_rcnn/<timestamp> EXPORT_MODE=oriented_rcnn_pre_nms
make export-onnx EXPERIMENT=runs/rotated_faster_rcnn/<timestamp> EXPORT_MODE=faster_rcnn_pre_nms
make export-onnx EXPERIMENT=runs/rotated_rtmdet/<timestamp> EXPORT_MODE=rotated_rtmdet_pre_nmsEquivalent CLI (placeholder paths):
odet export onnx \
--config /path/to/oriented-det/runs/rotated_fcos/<timestamp>/config.json \
--checkpoint /path/to/oriented-det/runs/rotated_fcos/<timestamp>/checkpoints/checkpoint_best.pth \
--output /path/to/oriented-det/onnx_export/model.onnxArtifacts (gitignored except the folder README) land in onnx_export/:
| File | Role |
|---|---|
model.onnx |
Backbone + head + box decode; padded pre-NMS tensors |
model.export_meta.json |
Mean/std, class names, score floor, NMS IoU |
preprocess.py, nms.py, postprocess.py, runtime.py, ort_runtime.py |
Copies of the consumer stack |
demo.py, infer_onnx.py |
Copies of the infer scripts |
ONNX input is NCHW RGB, already mean/std-normalized, typically [1, 3, 1024, 1024]. Do not feed raw JPEGs into the graph.
odet export infer --onnx ./onnx_export/model.onnx --smoke
odet export infer --onnx ./onnx_export/model.onnx --images /path/to/data/tiles --output ./onnx_export/predictions
make export-demoPython:
from PIL import Image
from export.runtime import detect_image
dets = detect_image(Image.open("tile.jpg"), "onnx_export/model.onnx")
# each det: cx, cy, w, h, angle_rad, score, label, class_name (original image pixels)From a copied onnx_export/ folder only:
cd onnx_export
pip install -r requirements-runtime.txt
python demo.pyfrom runtime import detect_image
dets = detect_image("tile.jpg", "model.onnx")The ONNX graph bakes pre_nms_score_threshold (0.05 on the current RTMDet export) and does not take a threshold input. Boxes below that floor never reach Python.
Class floors come from production.per_class_score_threshold in the sidecar and are applied in Python before rotated NMS. Names match case-insensitively. --score-threshold replaces only the global floor and leaves the per-class map in place, so a sidecar entry such as aircraft=1.1 still wins for that class.
--per-class-score-threshold CLASS=FLOAT (repeatable) merges into that map for this process. Omitted classes keep their sidecar floors. A name that matches an existing key case-insensitively replaces it and keeps the sidecar spelling (Drone updates drone). Infer prints the effective map next to the score on the thr line. The same override is the per_class_score_threshold argument of detect_image / detect_array. odet export preds is the training-eval protocol and does not accept this flag.
odet export infer --onnx ./onnx_export/model.onnx --images ./tiles \
--per-class-score-threshold drone=0.45 \
--per-class-score-threshold shahed=0.35 \
--per-class-score-threshold aircraft=1.1 \
--per-class-score-threshold helicopter=1.1dets = detect_image(
"tile.jpg",
"onnx_export/model.onnx",
per_class_score_threshold={"drone": 0.45},
)Val-split predictions in the same JSON shape as odet preds (then make export-metrics / odet preds --metrics-from-json):
odet export preds \
--config /path/to/oriented-det/runs/rotated_fcos/<timestamp>/config.json \
--onnx /path/to/oriented-det/onnx_export/model.onnxdetect_image tiles an image when resize_mode is fixed or crop and the image is larger than the slice. The slice is window_size in source pixels when set, and target_size otherwise (default canvas 1024×1024). Each window is bilinear-resized onto that canvas. Overlap defaults to 200 px (production.overlap_pixels). pad and keep_ratio stay one full-image resize, which matches HRSC / SSDD / HRSID training. Pre-tiled DOTA images that already fit the slice are still one forward.
--mode / EXPORT_MODE |
Detector |
|---|---|
rotated_fcos_pre_nms (default) |
Rotated FCOS |
rotated_rtmdet_pre_nms |
Rotated RTMDet |
oriented_rcnn_pre_nms |
Oriented R-CNN |
faster_rcnn_pre_nms |
Rotated Faster R-CNN |
Decode runs inside ONNX. Final rotated NMS is numpy (export.nms; optional --nms-backend shapely). See export/PARITY.md.