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

Runtime parameters on exported pipelines

Exported .denkflow files from the Vision AI Hub can embed constant topic values — for example bounding-box filter thresholds (/iou_threshold, /score_threshold) or resize dimensions (/image_size).

If you need different values on each pipeline run without re-exporting the graph, treat those constants as runtime parameters: discover them with get_constant_values() on an uninitialized pipeline, release the baked-in values with remove_constant_value() before initialization, then publish your own tensors before every run().

When to use this

  • Tune detection sensitivity per image, product line, or station
  • A/B test threshold combinations in production
  • Drive resize or filter settings from external configuration

This example builds on Basic object detection and assumes a typical object-detection export with a bounding-box filter node.

Workflow

  1. Discover — load the export and call get_constant_values() before initialize(). You get each topic name and its default value as a NumPy array (Python) or a raw buffer with DenkflowArrayDataType, DenkflowTensorType, and shape (C).
  2. Release constants — call remove_constant_value(topic) for each runtime parameter you intend to override.
  3. Initialize once — call initialize() and set up receivers.
  4. Publish per run — before every run(), publish your parameter values, then publish the image input.
get_topics() vs get_constant_values()

Use get_constant_values() to discover exported constant names and default values before initialization. Use get_topics() after initialization to wire external inputs and outputs — it is not the right API for runtime-parameter discovery.

Discover constant topics and defaults

from denkflow import Pipeline

pipeline = Pipeline.from_denkflow("model.denkflow", pat="YOUR-PAT")

defaults = pipeline.get_constant_values()
for topic, array in defaults.items():
print(topic, array.dtype, array.shape, array)

runtime_parameter_topics = list(defaults.keys())

Typical object-detection exports expose /iou_threshold and /score_threshold as runtime parameters. Topic names vary by export — always call get_constant_values() on your .denkflow file.

Override parameters on each run

Remove the constants you want to control, initialize once, then publish new values before every run().

import numpy as np
from denkflow import Pipeline, ImageTensor, BaseTensor

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

input_topic = "/image"
output_topic = "bounding_box_filter_node/filtered_bounding_boxes"

pipeline = Pipeline.from_denkflow(denkflow_path, pat=pat)

defaults = pipeline.get_constant_values()
for topic in defaults:
pipeline.remove_constant_value(topic)

pipeline.initialize()
receiver = pipeline.subscribe(output_topic)

for iou, score in [(0.7, 0.5), (0.5, 0.3)]:
pipeline.publish_tensor(
"/iou_threshold",
BaseTensor.from_numpy(np.array([iou], dtype=np.float32)),
)
pipeline.publish_tensor(
"/score_threshold",
BaseTensor.from_numpy(np.array([score], dtype=np.float32)),
)
pipeline.publish_image_tensor(input_topic, ImageTensor.from_file(image_path))
pipeline.run()

results = receiver.receive_bounding_box_tensor().to_objects(score)
print(f"IoU={iou}, score={score}: {len(results)} detections")
for box in results:
print(f" {box.class_label.name}: {box.confidence:.2f}")

Tips and pitfalls

  • get_constant_values() must be called before initialize() — same timing as set_constant_value and remove_constant_value.
  • remove_constant_value only works on topics that have a constant — use get_constant_values() to confirm which topics are set before removing.
  • C: cast data using data_type — each DenkflowConstantValue includes a DenkflowArrayDataType enum. Match the enum when casting data (for example DenkflowArrayDataType_Float32(const float*)c->data). Element count is the product of shape[]. Free the result with denkflow_constant_value_array_free(&constants).
  • Use publish_tensor for all runtime inputs in C — build a typed tensor (denkflow_base_tensor_from_buffer for numeric values, denkflow_image_tensor_from_file for images), then call denkflow_initialized_pipeline_publish_tensor with a (void**) cast. Python still has separate publish_image_tensor and publish_tensor methods.
  • Constants you do not remove keep their exported defaults — only remove topics you intend to supply yourself each run.
  • See alsoCore concepts: constant topic values for the underlying topic naming rules.