Need help with post processing

I was able to come up with a custom code which initializes the Hailo device, runs inference on a frame and outputs raw data. The data provided is apparently containing only 5 elements, 4 for coordinates and 5th is the conf_score. My code and post processing works if single forced class ID is specified

But how do I get access to class IDs?

If it is relevant, here is the parse hef output:
Architecture HEF was compiled for: HAILO8L
Network group name: yolov11s, Multi Context - Number of contexts: 5
Network name: yolov11s/yolov11s
VStream infos:
Input yolov11s/input_layer1 UINT8, NHWC(640x640x3)
Output yolov11s/yolov8_nms_postprocess FLOAT32, HAILO NMS BY CLASS(number of classes: 80, maximum bounding boxes per class: 100, maximum frame size: 160320)
Operation:
Op YOLOV8
Name: YOLOV8-Post-Process
Score threshold: 0.200
IoU threshold: 0.70
Classes: 80
Cross classes: false
NMS results order: BY_CLASS
Max bboxes per class: 100
Image height: 640
Image width: 640

Hey @Muhted_Baig

The output is actually a list of numpy arrays where each array represents one class. Each detection has 5 values: [y_min, x_min, y_max, x_max, score]. The class ID isn’t stored in those 5 values though - it’s implicit based on which array you’re looking at.

So how do you get the class IDs?

The position in the outer list tells you the class. So results[0] = class 0, results[1] = class 1, and so on up to results[79] for class 79. Each detection inside results[class_id] is a bounding box for that specific class.

Here’s an example of how I handle it:

# infer_results['yolov8_nms_postprocess'] is a list of 80 arrays (one per class)
nms_results = infer_results['yolov8_nms_postprocess'][0]  # [batch_idx] if batched

for class_id, detections in enumerate(nms_results):
    for det in detections:
        y_min, x_min, y_max, x_max, score = det
        if score > threshold:
            # Now you have the box and the class_id
            print(f"Class: {class_id}, Box: {y_min, x_min, y_max, x_max}, Score: {score}")

Important things to remember:

  • The class ID is NOT a sixth element in the detection - you get it from the array index
  • This is just how HAILO_NMS_BY_CLASS works according to the HailoRT docs

If you want all detections in a single flat list with class IDs included, you can do something like:

all_detections = []
for class_id, detections in enumerate(nms_results):
    for det in detections:
        y_min, x_min, y_max, x_max, score = det
        all_detections.append((y_min, x_min, y_max, x_max, score, class_id))

Hope this clears things up!