Skip to main content
Version: 0.7.x [Latest Alpha]

Evaluating a Sequence of Images

This is a modification of the classification example to highlight how to evaluate a sequence of images.

import denkflow

pat = "YOUR-PAT"

denkflow_path = "path/to/model/file.denkflow"
image_paths = ["path/to/image_1.JPG", "path/to/image_2.JPG", "path/to/image_3.JPG"]

input_topic = "camera/image"
output_topic = "classification_node/output"

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

pipeline.initialize()

results_receiver = pipeline.subscribe(output_topic)

for path in image_paths:
image_tensor = denkflow.ImageTensor.from_file(path)

pipeline.publish_image_tensor(input_topic, image_tensor)

pipeline.run()

tensor = results_receiver.receive_scalar_tensor()

results_per_batch = tensor.to_objects()

print(f"Classification Results for {path}:")
for results_per_class_label in results_per_batch:
for result_for_class_label in results_per_class_label:
print(f"{result_for_class_label.class_label}: {result_for_class_label.value:.2f}")