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

PipelineWrapper

This example runs an exported object-detection .denkflow through PipelineWrapper and draws annotated images. Results are returned in absolute pixel coordinates, ready to use without subscribe/receive or tensor decoding.

For the classic subscribe/receive flow, see Basic object detection.

import denkflow

pat = "YOUR-PAT"
denkflow_path = "path/to/model/file.denkflow"
image_path = "path/to/an/image.jpg"
confidence_threshold = 0.5

pipeline = denkflow.Pipeline.from_denkflow(denkflow_path, pat=pat)
wrapper = denkflow.PipelineWrapper(pipeline)

image_tensor = denkflow.ImageTensor.from_file(image_path)
results = wrapper.run(image_tensor, confidence_threshold=confidence_threshold)

for image_result in results:
for r in image_result.results:
if r.bounding_box:
bb = r.bounding_box
print(f"[{r.index}] {bb.class_label.name}: {bb.confidence:.2f}")

annotated = image_tensor.to_images_with_annotations(
results,
annotation_label_font_size=16.0,
)
# annotated: uint8 NumPy array with shape [batch, height, width, 3]