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.
- Locate output layer names
- At Our Model Zoo open the relevant
YAMLfile and search the original model’s output layer names , those will be our parsing end_nodes.
- At Our Model Zoo open the relevant
- Compare with ModelZoo model
- In the case of
yolov5n_seg, download our pre-trained model from model explorer .
Open the downloadedonnxusing Netron and search (usingctrl + F) the layer names you found earlier.
- In the case of
- Map to your own ONNX
-
Open your own
onnxusing Netron -
Find the equivalent layers and their names — these will be your
end_node_names.
-
- Parse with DFC
DFC CLI Tool:
hailo parser onnx <own_model.onnx> --end-node-names [list] - Optimize & Compile
Optimize the network with your model script and compile it using DFC or ModelZoo.
For more information on this process:
