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