Segmentation fault on running custom yolov5n_seg.hef

Hello, i trained a yolov5 segmentation model with my dataset on raspberry pi 5, but once i try to execute i get a segmentation fault. If i swap my yolov5n_seg.hef with deafult yolov5n_seg.hef (from hailo-rpi5-examples) it works correctly.

I compiled the model with the command

hailomz compile --ckpt /local/shared_with_docker/best.onnx --calib-path /local/shared_with_docker/dataset_lasax/train/images/ --yaml /local/workspace//hailo_model_zoo/hailo_model_zoo/cfg/networks/yolov5n_seg.yaml --classes 2 --end-node-names output0 output1

adding end-node-names because without it showed an error


Exception: Encountered error during parsing: Unable to find end node names: ['Conv_289', 'Conv_249', 'Conv_209'], please verify and try again.

There are 3 output layers, but my model seen on Netron have 2 with a different name (output0 and output1) could be this the problem?
How can i resolve?
Thanks to everyone!

Ok i resolved the issue on yolov5seg, now it works! There’s no guide about on how to change json file, in particular in the field outputs size and outputs name everything must go in order.

1) Run hailortcli parse-hef just to know how your net is
In my case:

hailortcli parse-hef /home/user/Desktop/custom_models/yolov5m_seg.hef
Architecture HEF was compiled for: HAILO8
Network group name: yolov5m_seg, Multi Context - Number of contexts: 3
    Network name: yolov5m_seg/yolov5m_seg
        VStream infos:
            Input  yolov5m_seg/input_layer1 UINT8, NHWC(640x640x3)
            Output yolov5m_seg/conv65 UINT16, FCR(80x80x117)
            Output yolov5m_seg/conv85 UINT8, FCR(160x160x32)
            Output yolov5m_seg/conv75 UINT16, FCR(40x40x117) 
            Output yolov5m_seg/conv83 UINT16, FCR(20x20x117)

2) Use the parse output to change the config.json!
In my case:

"outputs_size": [
        80,
        40,
        20
    ],
    "outputs_name": [
        "yolov5m_seg/conv85",
        "yolov5m_seg/conv65",
        "yolov5m_seg/conv75",
        "yolov5m_seg/conv83"
    ],

NOTE THAT A PRECISE ORDER MUST BE FOLLOW UNLESS SEGMENTATION FAULT HAPPENS!

Rules for the config.json for yolov5_seg (maybe works also with other segmentations custom models)

First line: the uint8 output conv85 in my case,
Second line and others lines: the uint16 output in order from the lesser (ending number) to the higher conv65, conv 75, conv83

outputs_size field MUST MATCH the uint8 output order given from hailortcli parse-hef in my case

Output yolov5m_seg/conv65 UINT16, FCR(**80**x80x117)
            Output yolov5m_seg/conv85 UINT8, FCR(160x160x32)
            Output yolov5m_seg/conv75 UINT16, FCR(**40**x40x117) 
            Output yolov5m_seg/conv83 UINT16, FCR(**20**x20x117)

FCR(80x80x117) FCR(40x40x117) (20x20x117) in my case 80, 40, 20


The config file modified in my case is QUITE different from hailo yolov5_seg from the examples!
Maybe this happen because i could have trained my custom model with a different version of the net.

If theese rules are not followed, a segmentation fault occour.

The process maybe could works also with yolov8_seg, but i didn’t tested because @shashi did a good wrapper to make it work DeGyrum.
If anyone could test other custom model trained with yolov and let us know below, would be great!

1 Like