Can not run custom model detection on Raspberry PI 5

Greetings to all,

I have been attempting to run a retrained model example using my custom YOLOv8n model. However, I consistently encounter the following error. I have attempted to train the model twice and generated .hef file successfully, but the issue persists. Could you please assist me in resolving the error shown below? Thanks in advance for your help!

python basic_pipelines/detection.py --hef ./yolov8n.hef --input /dev/video0
hailomuxer name=hmux v4l2src device=/dev/video0 name=src_0 ! video/x-raw, width=640, height=480, framerate=30/1 ! queue name=queue_scale max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! videoscale n-threads=2 ! queue name=queue_src_convert max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! videoconvert n-threads=3 name=src_convert qos=false ! video/x-raw, format=RGB, width=640, height=640, pixel-aspect-ratio=1/1 ! tee name=t ! queue name=bypass_queue max-size-buffers=20 max-size-bytes=0 max-size-time=0 ! hmux.sink_0 t. ! queue name=queue_hailonet max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! videoconvert n-threads=3 ! hailonet hef-path=./yolov8n.hef batch-size=2 nms-score-threshold=0.3 nms-iou-threshold=0.45 output-format-type=HAILO_FORMAT_TYPE_FLOAT32 force-writable=true ! queue name=queue_hailofilter max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! hailofilter so-path=/home/raspi/Projects/hailo-rpi5-examples/basic_pipelines/../resources/libyolo_hailortpp_post.so  qos=false ! queue name=queue_hmuc max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! hmux.sink_1 hmux. ! queue name=queue_hailo_python max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! queue name=queue_user_callback max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! identity name=identity_callback ! queue name=queue_hailooverlay max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! hailooverlay ! queue name=queue_videoconvert max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! videoconvert n-threads=3 qos=false ! queue name=queue_hailo_display max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! fpsdisplaysink video-sink=xvimagesink name=hailo_display sync=false text-overlay=False signal-fps-measurements=true 
[HailoRT] [error] CHECK failed - HEF file length does not match
[HailoRT] [error] CHECK_SUCCESS failed with status=HAILO_INVALID_HEF(26)
[HailoRT] [error] Failed parsing HEF file
[HailoRT] [error] Failed creating HEF
[HailoRT] [error] CHECK_SUCCESS failed with status=HAILO_INVALID_HEF(26)
[HailoRT] [error] CHECK_SUCCESS failed with status=HAILO_INVALID_HEF(26)
CHECK_EXPECTED_AS_STATUS failed with status=26
Segmentation faults

Welcome to the Hailo Community!

Please have a look at the following post, reply #4

Hailo Community - Check failed hef file length does not match status 26

1 Like

Hi @klausk, thanks for your prompt reply. Indeed, it resolved the issue. Another issue has appeared for the YOLOv8s model, whereas it works for the YOLOv8n model.

When i run

python hailo_model_zoo/main.py compile yolov8s --ckpt /home/admin2/Projects/training/runs/detect/train/weights/best.onnx --hw-arch hailo8l  --calib-path /home/admin2/Projects/training/data/images  --classes 3 --performance

It shows:

hailo_model_optimization.acceleras.utils.acceleras_exceptions.NegativeSlopeExponentNonFixable: Quantization failed in layer yolov8s/conv63 due to unsupported required slope. Desired shift is 19.0, but op has only 8 data bits. This error raises when the data or weight range are not balanced. Mostly happens when using random calibration-set/weights, the calibration-set is not normalized properly or batch-normalization was not used during training.

Hello @shahizat,

a few other users encountered the same problem. You can find the thread here:

There is a solution posted on how to get the Yolo models compiled. It might need some adjustments of the final layers based on your used model type.

As of now it is not confirmed if the compiled models run tough.

As @emasty posted there is a solution in the thread he posted reply #25. I had the same issue with a Yolov8s model.

I can confirm that the compiled model works. I have a Hailo-8 in my model build machine and modified the Tappas detection app to work with my model.

1 Like

Hi @klausk and @emasty, thanks for your reply.

@klausk just fyi, I changed below code:

 + QUEUE("queue_hailo_display")
 + f"fpsdisplaysink video-sink={self.video_sink} name=hailo_display sync={self.sync} text-overlay={self.options_menu.show_fps} signal-fps-measurements=true "

to

+ "x264enc bitrate=5000 speed-preset=medium ! mp4mux ! filesink location=detection_output.mp4  "

So people can save the result directly to mp4 video file. I have uploaded a demo video to my LinkedIn account: Shakhizat Nurgaliyev on LinkedIn: Raspberry Pi 5 on Steroids! 🔥🔥🔥🔥 The Raspberry Pi AI kit allows us to… | 17 comments

1 Like

Hi @klausk, hope you are doing well! here is my project blog: Safety Helmet Detection System using Raspberry Pi AI Kit - Hackster.io

1 Like