Compile YOLOv8 onnx to hef

I am trying to compile Yolov8n onnx to hef to infer on HAILO8. Model was trained using Hailo Model Zoo. After model`s export to hef it cannot find anything on images. Yolo config in attachments. Where is mistake?

Hi @anton.lukanov, which model script did you use?

Hi, @nina-vilela! I use hailomz. There is a command to compile:
hailomz compile --ckpt yolov8n_4classes_hailo.onnx --calib-path …/out_images --yaml yolov8.yaml
Hailo Model Zoo v2.10.0

I see in the yaml file that you passed a custom model script (.alls) path. Could you please confirm the commands that are in it?

Also, do you perform any pre-processing on your calibset?

@nina-vilela Commands in .alls file:
normalization1 = normalization([0.0, 0.0, 0.0], [255.0, 255.0, 255.0])
change_output_activation(conv42, sigmoid)
change_output_activation(conv53, sigmoid)
change_output_activation(conv63, sigmoid)
nms_postprocess(“/home/hailo/testing/yolov8/yolov8n_nms_config.json”, meta_arch=yolov8, engine=cpu)
yolov8n_nms_config.json in attachments.

Calibset was preprocessed (Images are 640 size with letterboxes)

@anton.lukanov thank you for sharing, the files seem correct.

I asked about the calibset pre-processing to confirm that the normalization is not performed twice.

It seems like there is some known accuracy issue with yolov8 re-trained with low number of classes, you can give this a try:

@nina-vilela I added model_optimization_flavor and post_quantization_optimization in .alls file. After that model works fine
Now .alls file looks like:
normalization1 = normalization([0.0, 0.0, 0.0], [255.0, 255.0, 255.0])
change_output_activation(conv42, sigmoid)
change_output_activation(conv53, sigmoid)
change_output_activation(conv63, sigmoid)
model_optimization_flavor(optimization_level=1, compression_level=0, batch_size=2)
post_quantization_optimization(finetune, policy=enabled, learning_rate=0.0001, epochs=20, batch_size=8, dataset_size=1112)
nms_postprocess(“/home/hailo/testing/yolov8/yolov8n_nms_config.json”, meta_arch=yolov8, engine=cpu)

1 Like