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

Drawing results

The input ImageTensor (or ImageTensorU8) can render inference results directly onto the image: bounding boxes, segmentations, barcodes, and optional labels. The in-memory output is uint8 RGB in [batch, height, width, 3] (BHWC) layout.

Overlay behavior

  • Labels are multi-line chips placed above each box when possible (below the box if there is no room above), so the object stays visible.
  • Nested OD → classification: the label leads with the top classification score(s); the detector class line is omitted when classifications are present. OCR text children are shown as "…".
  • Color: for OD → classification, both the box outline and the label use the top nested classification class color (not the detector class, and not split colors). Otherwise the geometry's own class color is used.
  • Box outline is expanded slightly outward and supports a configurable line width so thick strokes do not cover the object.
import denkflow

pipeline = denkflow.Pipeline.from_denkflow("path/to/model.denkflow", pat="YOUR-PAT")
simplified = denkflow.SimplifiedPipeline(pipeline)

image_tensor = denkflow.ImageTensor.from_file("path/to/image.jpg")
results = simplified.run(image_tensor, confidence_threshold=0.5)

annotated = image_tensor.to_images_with_annotations(
results,
annotation_label_font_size=16.0,
top_classifications=1,
bounding_box_line_width=2,
save_path="annotated.png", # optional; batch > 1 is saved as a grid
)

Parameters:

  • segmentation_fill_alpha: None for outline-only segmentations; a value in (0, 1] fills at that opacity.
  • annotation_label_font_size: None to skip labels; otherwise a size relative to a 1080px-tall reference image.
  • top_classifications: how many nested classification scores (highest first) to show on each label (0 omits them; default 1).
  • bounding_box_line_width: outline thickness in pixels (default 1).
  • draw_orientation_lines: draws orientation lines on rotated boxes.
  • save_path: optional path to write the annotated image(s). Format is taken from the extension. With a batch larger than one, images are arranged into a near-square grid and saved as a single file.

ImageTensorU8 exposes the same to_images_with_annotations(...) method.