Running inference
Input types
run accepts several image sources and converts each into the tensor type the
pipeline's image input requires (ImageTensor for standard ONNX networks,
ImageTensorU8 for barcode readers and Ambarella exports):
- an image file path
- an
ImageTensororImageTensorU8 - a NumPy array
Barcode and Ambarella pipelines use raw RGB ImageTensorU8 input. Standard
ONNX networks use ImageTensor. When you pass a file path or NumPy array,
SimplifiedPipeline selects the required type automatically.
- Python
- C / C++
# From a file path
results = simplified.run("path/to/image.jpg", confidence_threshold=0.5)
# From an existing tensor
tensor = denkflow.ImageTensor.from_file("path/to/image.jpg")
results = simplified.run(tensor, confidence_threshold=0.5)
# Barcode and Ambarella exports require ImageTensorU8 instead
tensor_u8 = denkflow.ImageTensorU8.from_file("path/to/image.jpg")
results = simplified.run(tensor_u8, confidence_threshold=0.5)
# From a NumPy array (e.g. cv2.imread output)
import cv2
results = simplified.run(cv2.imread("path/to/image.jpg"), confidence_threshold=0.5)
See Creating ImageTensors for the array layout and constructor details.
// From a file path
denkflow_simplified_pipeline_run_from_file(&results, simplified, "path/to/image.jpg", 0.5f);
// From an existing tensor (consumed by the call)
denkflow_simplified_pipeline_run_from_tensor(&results, simplified, (void**)&image_tensor, 0.5f);
// From a raw buffer
denkflow_simplified_pipeline_run_from_buffer(
&results, simplified, buffer, DenkflowArrayDataType_UInt8,
batch_size, width, height, channels,
"BHWC", "RGB", 0.5f);
confidence_threshold filters detections below the given score. A value of 0.0 returns every result. When the graph exposes a score_threshold constant (for example on a bounding-box filter / NMS node), run also applies confidence_threshold there for that call. If the constant is absent, only the post-filter runs — no error.
Batches
A batched image tensor produces one ImageInferenceResult per batch element, in input order.
batch = denkflow.ImageTensor.from_files(["a.jpg", "b.jpg", "c.jpg"])
results = simplified.run(batch, confidence_threshold=0.5)
assert len(results) == 3
Overriding graph constants
When the exported graph exposes them as constant inputs, image size and IoU threshold can be overridden before run. Prefer run(..., confidence_threshold=...) for the score gate; it already drives graph score_threshold when present.
- Python
- C / C++
simplified.set_image_size(1088, 1280)
simplified.set_iou_threshold(0.7)
denkflow_simplified_pipeline_set_image_size(simplified, 1088, 1280);
denkflow_simplified_pipeline_set_iou_threshold(simplified, 0.7f);
Each override applies only when the corresponding constant exists in the graph; otherwise an error is returned. For the equivalent mechanism on the classic Pipeline, see Runtime parameters on exported pipelines.