Skip to main content
Version: 0.10.x [Latest Beta]

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 ImageTensor or ImageTensorU8
  • 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.

# 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.

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.

simplified.set_image_size(1088, 1280)
simplified.set_iou_threshold(0.7)

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.