Hi
I am trying to run inference on the Yolov5 network. I should start by saying that everything runs great with Yolov8s, so I expected it would be straigthforward with Yolov5, but I have an error message.
Here is the python code:
# -*- coding: utf-8 -*-
from hailo_sdk_client import ClientRunner
from hailo_sdk_client import InferenceContext
import numpy as np
# Yolo v5n
model_name = 'yolov5nu'
model_type = 'yolov5'
end_node_names = ['/model.24/cv2.0/cv2.0.2/Conv', '/model.24/cv3.0/cv3.0.2/Conv', '/model.24/cv2.1/cv2.1.2/Conv', '/model.24/cv3.1/cv3.1.2/Conv', '/model.24/cv2.2/cv2.2.2/Conv', '/model.24/cv3.2/cv3.2.2/Conv']
onnx_path = f'./{model_name}.onnx'
# Image parameters
HEIGHT = 640
WIDTH = 640
nCalib = 1024
nSave = 5
nms_scores_th = 0.1
nms_iou_th = 0.7
# Load calibration dataset
calib_dataset = np.load("calib_set_640_640.npy")
# Initialize a new client runner
runner = ClientRunner(hw_arch='hailo8')
# Translate YOLO model from ONNX
runner.translate_onnx_model(onnx_path, end_node_names=end_node_names)
# Add model script with NMS layer at the network's output.
model_script_commands = [
'normalization1 = normalization([0.0, 0.0, 0.0], [255.0, 255.0, 255.0])\n',
f'resize_input1= resize(resize_shapes=[{HEIGHT},{WIDTH}])\n',
f'nms_postprocess(meta_arch={model_type}, engine=cpu, nms_scores_th={nms_scores_th}, nms_iou_th={nms_iou_th})\n',]
runner.load_model_script(''.join(model_script_commands))
print('\nFP optimized')
runner.optimize_full_precision()
# Infer with the Hailo Emulator
with runner.infer_context(InferenceContext.SDK_FP_OPTIMIZED) as ctx:
nms_output = runner.infer(ctx, calib_dataset)
The onnx file is generated using Ultralytics framwork:
from ultralytics import YOLO
model = YOLO("yolov5n.pt") # Load a COCO-pretrained YOLO model
model.info() # Display model information (optional)
model.export(format="onnx", opset=11) # Export to onnx format
I open if with Netron to find the end nodes names.
When I execute this script, I get a cryptic error:
File “/local/workspace/hailo_virtualenv/lib/python3.10/site-packages/hailo_sdk_client/sdk_backend/script_parser/nms_postprocess_command.py”, line 667, in _set_yolo_config_layers
raise AllocatorScriptParserException(msg)
hailo_sdk_client.sdk_backend.sdk_backend_exceptions.AllocatorScriptParserException: Cannot infer bbox conv layers automatically. Please specify the bbox layer in the json configuration file
Where is the yaml file ? Where can I find it and where should I put it? How to use it in my script ?
I followed an example from the DFC user guide, but it doesn’t mention this yaml file.
Thanks for your help