Compiling YOLOv5-Seg with NMS Post-Processing into HEF

This guide walks you through the process of taking a YOLOv5-Seg model, adding an NMS post-processing layer, and compiling it into an HEF file.

Create model script
Post-processing must be added to the network using a model script.
This means adding the nms_postprocess command to the script, which will later be used with the DFC or ModelZoo tools.

Example Model script for YOLOv5-Seg models:
normalization1 = normalization([0.0, 0.0, 0.0], [255.0, 255.0, 255.0]) nms_postprocess(meta_arch=yolov5_seg, engine=cpu) model_optimization_flavor(compression_level=0, optimization_level=4) post_quantization_optimization(adaround, policy=enabled, epochs=6, cache_compression=enabled, batch_size=8)

  • Our ModelZoo’s YOLOvn5-Seg model script uses 16bit outputs, but Hailo NMS is only compatible with 8bit outputs. To minimize accuracy loss, use the adaround algorithm during post-quantization optimization.

Path 1 – Model Zoo

Use the pre-trained Model Zoo models - compile a HEF directly with:
hailomz compile yolov5n_seg -–model-script yolov5n_seg.alls

Path 2 – DFC
If you wish to use an onnx with layer names different from the pre-trained version,
you need to correctly choose the model output layers that will connect to the NMS layers.

  1. Locate output layer names
  2. Compare with ModelZoo model
    • In the case of yolov5n_seg, download our pre-trained model from model explorer .
      Open the downloaded onnx using Netron and search (using ctrl + F) the layer names you found earlier.
  3. Map to your own ONNX
    • Open your own onnx using Netron

    • Find the equivalent layers and their names — these will be your end_node_names.

  4. Parse with DFC
    DFC CLI Tool:
    hailo parser onnx <own_model.onnx> --end-node-names [list]
  5. Optimize & Compile
    Optimize the network with your model script and compile it using DFC or ModelZoo.
    For more information on this process:
1 Like