Error Hailort in object detection with custom model

Hello, I have an error, I hope someone can help me. My task is to run object detection with my custom model on Rpi-5 with Ubuntu 22.04. I have successfully converted my onnx model to hef format. Now I need to run object detection of this model on my video. I am using the code from the gitHub GitHub - hailo-ai/hailo-rpi5-examples. I have modified the code for my model:
import gi
gi.require_version(‘Gst’, ‘1.0’)
from gi.repository import Gst, GLib
import os
import argparse
import multiprocessing
import numpy as np
import setproctitle
import cv2
import time
import hailo
from hailo_rpi_common import (
get_default_parser,
QUEUE,
SOURCE_PIPELINE,
DETECTION_PIPELINE,
INFERENCE_PIPELINE_WRAPPER,
USER_CALLBACK_PIPELINE,
DISPLAY_PIPELINE,
get_caps_from_pad,
get_numpy_from_buffer,
GStreamerApp,
app_callback_class,
dummy_callback,
)

-----------------------------------------------------------------------------------------------

User Gstreamer Application

-----------------------------------------------------------------------------------------------

This class inherits from the hailo_rpi_common.GStreamerApp class

class GStreamerDetectionApp(GStreamerApp):
def init(self, app_callback, user_data):
parser = get_default_parser()
# Add additional arguments here
parser.add_argument(
“–network”,
default=“yolov8n”,
choices=[‘yolov6n’, ‘yolov8n’, ‘yolov8s’],
help=“Which Network to use, default is yolov6n”,
)
parser.add_argument(
“–hef-path”,
default=None,
help=“Path to HEF file”,
)
parser.add_argument(
“–labels-json”,
default=None,
help=“Path to costume labels JSON file”,
)
args = parser.parse_args()
# Call the parent class constructor
super().init(args, user_data)
# Additional initialization code can be added here
# Set Hailo parameters these parameters should be set based on the model used
self.batch_size = 2
self.network_width = 640
self.network_height = 640
self.network_format = “RGB”
nms_score_threshold = 0.3
nms_iou_threshold = 0.45
if args.hef_path is not None:
self.hef_path = args.hef_path
# Set the HEF file path based on the network
elif args.network == “yolov6n”:
self.hef_path = os.path.join(self.current_path, ‘…/resources/yolov6n.hef’)
elif args.network == “yolov8s”:
self.hef_path = os.path.join(self.current_path, ‘…/resources/yolov8s_h8l.hef’)
elif args.network == “yolov8n”:
self.hef_path = os.path.join(self.current_path, ‘…/resources/best_hailo_model.hef’)
else:
assert False, “Invalid network type”
# User-defined label JSON file
self.labels_json = args.labels_json
self.app_callback = app_callback
self.thresholds_str = (
f"nms-score-threshold={nms_score_threshold} "
f"nms-iou-threshold={nms_iou_threshold} "
f"output-format-type=HAILO_FORMAT_TYPE_FLOAT32"
)
# Set the process title
setproctitle.setproctitle(“Hailo Detection App”)
self.create_pipeline()
def get_pipeline_string(self):
source_pipeline = SOURCE_PIPELINE(self.video_source)
detection_pipeline = DETECTION_PIPELINE(hef_path=self.hef_path, batch_size=self.batch_size, labels_json=self.labels_json, additional_params=self.thresholds_str)
user_callback_pipeline = USER_CALLBACK_PIPELINE()
display_pipeline = DISPLAY_PIPELINE(video_sink=self.video_sink, sync=self.sync, show_fps=self.show_fps)
pipeline_string = (
f’{source_pipeline} ’
f’{detection_pipeline} ! ’
f’{user_callback_pipeline} ! ’
f’{display_pipeline}’
)
print(pipeline_string)
return pipeline_string
if name == “main”:
# Create an instance of the user app callback class
user_data = app_callback_class()
app_callback = dummy_callback
app = GStreamerDetectionApp(app_callback, user_data)
app.run()

Everything else is the same. And now when I run the command: (venv_hailo_rpi5_examples) raspberry-pi-5@raspberrypi5-desktop :~/hailo-rpi5-examples $ python basic_pipelines/d
etection.py --input resources/DemoRender.mp4
I have error:
[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
Showing FPS
Error: gst-stream-error-quark: Internal data stream error. (1), …/libs/gst/base/gstbasesrc.c(3177): gst_base_
src_loop (): /GstPipeline:pipeline0/GstFileSrc:source:
streaming stopped, reason not-negotiated (-4)

Also checking hailort by command:
raspberry-pi-5@raspberrypi5-desktop :~/hailo-rpi5-examples $ hailortcli fw-control identify
Executing on device: 0000:01:00.0
Identifying board
Control Protocol Version: 2
Firmware Version: 4.17.0 (release,app,extended context switch buffer)
Logger Version: 0
Board Name: Hailo-8
Device Architecture: HAILO8L
Serial Number: HLDDLBB242601762
Part Number: HM21LB1C2LAE
Product Name: HAILO-8L AI ACC M.2 B+M KEY MODULE EXT TMP

I used dataflow compiler version 3.28 to compile the model into hef format. And I found a table that shows that for dataflow compiler version 3.28 I need hailort version 4.18


I have now installed hailort and hailort-pcie-driver for version 4.18, but now when I run the hailortcli command I get the following error
raspberry-pi-5@raspberrypi5-desktop:~$ dpkg -l | grep hailo
ii hailo-tappas-core-3.28.2 3.28.2 arm64 This package contains the core components of the Hailo Tappas platform.
ii hailort 4.18.0 arm64 HailoRT
iF hailort-pcie-driver 4.18.0 all Hailo PCIe driver and firmware
raspberry-pi-5@raspberrypi5-desktop:~$ hailortcli scan
[HailoRT] [error] Can’t find hailo pcie class, this may happen if the driver is not installed (this may happen if the kernel was updated), or if there is no connected Hailo board
[HailoRT] [error] CHECK_SUCCESS failed with status=HAILO_PCIE_DRIVER_NOT_INSTALLED(64) - Failed listing pcie devices
[HailoRT] [error] CHECK_SUCCESS failed with status=HAILO_PCIE_DRIVER_NOT_INSTALLED(64)
[HailoRT] [error] CHECK_SUCCESS failed with status=HAILO_PCIE_DRIVER_NOT_INSTALLED(64)
[HailoRT] [error] CHECK_SUCCESS failed with status=HAILO_PCIE_DRIVER_NOT_INSTALLED(64)
[HailoRT] [error] CHECK_SUCCESS failed with status=HAILO_PCIE_DRIVER_NOT_INSTALLED(64)
[HailoRT CLI] [error] CHECK_SUCCESS failed with status=HAILO_PCIE_DRIVER_NOT_INSTALLED(64)
As you can see in the main post, the hailortcli commands worked with version 4.17, but there was a problem with the model.
I understand that at this stage the best solution would be to downgrade to 3.27 and try to recompile the model again.
I hope you will help me to understand my mistakes with 4.18 version or tell me that my decision to downgrade dfc version is correct.

After I installed dataflow 3.27 and recompiled the model, I ran the hailo code on the rpi-5 again.It ran, but the video was black and I had a warning error.


I also tested the model using commands from hailort:
(venv_hailo_rpi5_examples) raspberry-pi-5@raspberrypi5-desktop:~/hailo-rpi5-examples$ hailortcli parse-hef resources/yolov8n2.hef
Architecture HEF was compiled for: HAILO8L
Network group name: best, Multi Context - Number of contexts: 2
Network name: best/best
VStream infos:
Input best/input_layer1 UINT8, NHWC(640x640x3)
Output best/conv38 UINT8, FCR(80x80x64)

(venv_hailo_rpi5_examples) raspberry-pi-5@raspberrypi5-desktop:~/hailo-rpi5-examples$ hailortcli run resources/yolov8n2.hef
Running streaming inference (resources/yolov8n2.hef):
Transform data: true
Type: auto
Quantized: true
Network best/best: 100% | 240 | FPS: 47.99 | ETA: 00:00:00

Inference result:
Network group: best
Frames count: 240
FPS: 47.99
Send Rate: 471.78 Mbit/s
Recv Rate: 157.26 Mbit/s

Hi @vlad.purhin,

As the output says, the application expects the HEF to contain NMS, but it doesn’t.

Here is how you can add it:

Hello, @nina-vilela
Yes, it helped me create a working model. I installed all the latest released versions and it worked.