Add output layer after applying nms postprocess command

Hi,

I’m currently working on a custom model based on a yolov8 architecture. I use the command nms_postprocess(meta_arch=yolov8, engine=cpu) to add the postprocessing layer. This command replace the conv outputs layers with a NMS postprocessing layer followed by a new output layer.

I would like to keep the conv tensors as outputs of my model too. So my model output would be the conv tensors with also the nms postprocess tensors. Is it possible ? How should I proceed ?

I tried to add an output_layer command inside the .alls file, the command parsing seems to be fine, but that doesn’t seem to add anything in the .hn model, probably because it’s not a model modifications command.

Thank you.

Hey @Julien,

You’re correct that the .alls model-script language doesn’t include a built-in output_layer command. When you run:

nms_postprocess(meta_arch=yolov8, engine=cpu)

The compiler automatically replaces your original conv outputs with the NMS layer and its single output. To preserve both the original conv outputs and add NMS post-processing, you’ll need to use the Python API approach.

Here’s the recommended workflow:

1. Translate your ONNX model with explicit output declarations

from hailo_sdk_client import HailoSdkClient
runner = HailoSdkClient()
runner.translate_onnx_model(
    onnx_path="yolov8.onnx",
    end_node_names=["Conv_298", "Conv_248", "Conv_198"]  # specify your conv node names
)

The end_node_names parameter ensures these conv tensors are marked as permanent outputs in the Hailo-NN graph.

2. Apply your model script with NMS post-processing

runner.load_model_script("my_model.alls")
runner.optimize_full_precision()

Since the conv nodes were declared as outputs during translation, they won’t be removed when the NMS layer is added.

Your final model will have multiple outputs: the three conv layers plus the NMS-filtered detections.

Note: The .alls model-script is designed for layer transformations and post-processing operations, but output node selection must be specified at translation time through the Python API.

Hope this helps!

1 Like

It works well for almost all convs in the model, except for the last layers because the nms postprocess is designed to remove them (even if I double them in the end_node_names). That’s why I was looking at the .alls file.

In the picture below, I can’t get for example conv41 as an output, and ofc I added it to the end_node_names section because it’s required by the nms.

I think I will find another way using the convs in green or I will directly modify the onnx model to get the output in another layer so it will not be impacted by the nms layer modification.
Thank you for your answer.