Running the inference application: every run mode and every command-line flag.
Part of the RF-DETR C++ Inference documentation.
This page is the operational reference — what each mode and flag does. For why and when — tuning strategy, custom class layouts, the GPU pipeline, embedding the library in your own code — see advanced-usage.md.
Three things, in the order the binary takes them:
- A model —
.onnxfor ONNX Runtime,.onnx/.engine/.trtfor TensorRT,.ptefor ExecuTorch. Export one with export.md. - An input — an image (e.g.
image.jpg) or a video (e.g.video.mp4). - A labels file — one label per line;
data/coco-labels-91.txtships with the repo.
./build/inference_app <model> <input> <labels> [flags...]./build/inference_app /path/to/model.onnx /path/to/image.jpg /path/to/coco-labels-91.txt./build/inference_app /path/to/model.onnx /path/to/image.jpg /path/to/coco-labels-91.txt --segmentation./build/inference_app /path/to/model.onnx /path/to/image.jpg /path/to/coco-labels-91.txt --keypointNote
The official keypoint checkpoint is background-first and decodes with the default config. An
active-first ([17]) export needs --keypoint-counts 17 --background-class-id none. See the
keypoint note in export.md.
./build/inference_app /path/to/model.onnx /path/to/video.mp4 /path/to/coco-labels-91.txtWith a live preview window (ESC quits early):
./build/inference_app /path/to/model.onnx /path/to/video.mp4 /path/to/coco-labels-91.txt --displayVideo with segmentation:
./build/inference_app /path/to/model.onnx /path/to/video.mp4 /path/to/coco-labels-91.txt --segmentationSupported containers: .mp4, .avi, .mov, .mkv, .webm, .flv, .wmv. Video files are
recognised by extension and processed with the multi-threaded pipeline; output is written to
output_video.mp4.
On a TensorRT build, a .engine or .trt file is loaded directly, skipping ONNX-to-TensorRT
conversion:
./build/inference_app /path/to/model.engine /path/to/image.jpg /path/to/coco-labels-91.txt --segmentationThe complete list. The inference parameters below work with every mode; the mode and GPU flags
carry the restrictions noted against each one (--display applies to video, --gpu-postprocess
requires --segmentation and is rejected without it).
| Flag | Effect |
|---|---|
| (none) | Object detection — the default |
--segmentation |
Instance segmentation; requires a model exported with masks |
--keypoint |
Keypoint detection; requires a keypoint export |
--display |
Open a live preview window while processing a video |
Overridable without recompiling.
| Flag | Default | Effect |
|---|---|---|
--threshold <val> |
0.5 |
Confidence threshold for keeping a detection; must be in [0, 1] |
--resolution <px> |
auto-detect | Model input resolution; omit to detect it from the model |
--max-detections <n> |
300 |
Top-k cap on the number of query/class pairs ranked before thresholding (upstream's num_select) |
--mask-threshold <val> |
0.0 |
Mask logit cutoff for binary mask generation (segmentation only); may be negative |
--background-class-id <n|none> |
0 |
Exported logit slot holding background, excluded before ranking; negative counts from the end, none keeps every slot |
--keypoint-counts <n[,n...]> |
0,17 |
num_keypoints_per_class; use 17 for an active-first [17] keypoint export (pair with --background-class-id none) |
--output <path> |
output_image.jpg / output_video.mp4 |
Output path for the saved image or video |
./build/inference_app /path/to/model.onnx /path/to/image.jpg /path/to/coco-labels-91.txt \
--threshold 0.7 --max-detections 100
./build/inference_app /path/to/model.onnx /path/to/image.jpg /path/to/coco-labels-91.txt \
--segmentation --mask-threshold 0.5--resolution is only useful for a model that accepts an input size other than the one recorded
in the model file — the auto-detected value is correct for a normally exported model.
--background-class-id must match your export's logit layout; getting it wrong shifts every
reported label by one. The layouts and what to pass for each are in
Customizing Labels and Class Layouts.
Available only on a TensorRT build compiled with the GPU pipeline, and off by default even then.
| Flag | Requires | Effect |
|---|---|---|
--gpu-preprocess |
-DUSE_CUDA_PREPROCESS=ON or -DUSE_DALI=ON |
Decode/resize/normalize on the GPU with whichever preprocessor was compiled in (CUDA kernel + nvJPEG, or DALI) |
--gpu-postprocess |
-DUSE_CUDA_POSTPROCESS=ON |
Segmentation mask decode/resize/threshold in CUDA kernels; segmentation only |
--dali-pipeline-dir <dir> |
-DUSE_DALI=ON |
Where the serialized .dali pipeline files live (default data/dali) |
./build/inference_app /path/to/model.engine /path/to/image.jpg /path/to/coco-labels-91.txt \
--segmentation --gpu-preprocess --gpu-postprocessSee The GPU Pipeline at Runtime for what each half does, and architecture.md for the design.
- The annotated image is saved as
output_image.jpg, video asoutput_video.mp4— override either with--output <path>. - Detection and segmentation results (bounding boxes, labels, scores, and mask pixels) are printed to the console.
- Input resolution is detected automatically from the model (432x432, 560x560, and so on).
- Segmentation mode draws colored masks with transparency overlays; keypoint mode draws the COCO skeleton.
- Results come back in descending-score order, and ties break deterministically — the same model
and image always produce the same ordering. Why, and how the top-k selection interacts with
--threshold: How detections are selected.
- advanced-usage.md — tuning strategy, class layouts, the GPU pipeline,
the
Configreference, and embeddingRFDETRInferencein your own code - building.md — build a different backend
- export.md — produce a model to run