Add C++ inference recipes for LT-DETR object detection#909
Add C++ inference recipes for LT-DETR object detection#909gabrielfruet wants to merge 3 commits into
Conversation
Add ONNX Runtime CUDA EP and TensorRT EP recipes under examples/cpp/, mirroring the postprocessing contract of ObjectDetectionPostprocessor and the existing export notebook.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ec14cfff81
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Verification: compute-02-ubuntu-4x4090 (1 GPU, Docker — CUDA 12.4.1 devel, ONNX Runtime GPU 1.20.1 tarball, TensorRT 10.13.3.9 via apt), ONNX Runtime recipe vs TensorRT recipe: default No screenshots — verification ran headless on the cluster and the image was dropped afterward. |
|
Correction to my earlier comment — the TensorRT validation claim was overstated.
Only the ONNX Runtime recipe is verified against |
What has changed and why?
C++ inference recipes for LT-DETR object detection under
examples/cpp/, for ONNX Runtime (CUDA EP) and TensorRT (EP), both with zero-copy GPU input allocation. Postprocessing (top-k over query×class, cxcywh→xyxy, class remap) mirrorsObjectDetectionPostprocessor.decode()exactly. These are copy-paste-and-edit recipes (hardcoded constants, no CLI/JSON parsing), matching the style of the existing export notebooks. Linked fromobject_detection_export.ipynb.Known limitation, not fixed here:
model.export_tensorrt(precision="fp32")onltdetrv2-s-cococurrently produces a numerically degraded engine (max score drops from ~0.97 to ~0.32) — TensorRT's weakly-typed builder appears to pick FP16 tactics in the transformer decoder despitefp32being requested.strongly_typed=Truefixes it. Tracking that separately; the TensorRT recipe here is verified correct against astrongly_typedengine.How has it been tested?
Built and ran both recipes on a GPU node (Docker, ONNX Runtime 1.20.1 + TensorRT 10.13.3.9) against
ltdetrv2-s-cocoon the COCO000000039769.jpgsample. ONNX Runtime recipe matchesmodel.predict(threshold=0.6)almost exactly (scores within ~0.01, boxes within ~0.1px). TensorRT recipe matches Python's TensorRT backend byte-for-byte given the same engine.Did you update CHANGELOG.md?
Did you update the documentation?