I have tested the yolov10n and yolov10s hef models from hailo model zoo on hailo 8. Now, I try to compile the yolov10n ONNX model to hef model.
I use the following code:
import numpy as np
import os
from hailo_sdk_client import ClientRunner
#Define model information
model_name = 'yolov10n'
onnx_path = '../onnx_models/yolov10n.onnx'
start_node = 'images'
end_node = ['output0']
input_shape = {'images': [1, 3, 640, 640]}
chosen_hw_arch = 'hailo8'
input_height = 640
input_width = 640
input_ch = 3
alls_lines = [
'model_optimization_flavor(optimization_level=0, compression_level=1)',
'resources_param(max_control_utilization=0.8, max_compute_utilization=0.8,max_memory_utilization=0.8)',
'performance_param(fps=10)'
]
# Join lines with newline separator
# script_content = '\n'.join(alls_lines)
#Parsing
runner = ClientRunner(hw_arch=chosen_hw_arch)
hn, npz = runner.translate_onnx_model(onnx_path, model_name, start_node_names=[start_node], end_node_names=end_node, net_input_shapes=input_shape)
parsed_model_har_path = f'{model_name}_parsed_model.har'
runner.save_har(parsed_model_har_path)
#Optimize
calibData = np.random.randint(0, 255, (1024, input_height, input_width, input_ch))
runner.load_model_script('\n'.join(alls_lines))
runner.optimize(calibData)
quantized_model_har_path = f'{model_name}_quantized_model.har'
runner.save_har(quantized_model_har_path)
#Compile
hef = runner.compile()
file_name = f'{model_name}.hef'
with open(file_name, 'wb') as f:
f.write(hef)
compiled_model_har_path = f'{model_name}_compiled_model.har'
runner.save_har(compiled_model_har_path)
But it reports following error:
hailo_sdk_client.model_translator.exceptions.ParsingWithRecommendationException: Parsing failed. The errors found in the graph are:
UnsupportedShuffleLayerError in op /model.23/dfl/Reshape: Failed to determine type of layer to create in node /model.23/dfl/Reshape
UnsupportedOperationError in op /model.23/GatherElements: GatherElements operation is unsupported
UnsupportedOperationError in op /model.23/GatherElements_1: GatherElements operation is unsupported
UnsupportedReduceMaxLayerError in op /model.23/ReduceMax: Failed to create reduce max layer at vertex /model.23/ReduceMax. Reduce max is only supported on the features axis, and with keepdim=True
UnsupportedShuffleLayerError in op /model.23/Flatten: Failed to determine type of layer to create in node /model.23/Flatten
UnsupportedOperationError in op /model.23/TopK: TopK operation is unsupported
UnsupportedGatherLayerError in op /model.23/Gather_3: Can't find index
UnsupportedOperationError in op /model.23/TopK_1: TopK operation is unsupported
UnsupportedOperationError in op /model.23/Mod: Mod operation is unsupported
UnsupportedConcatLayerError in op /model.23/Tile: Unsupported concat over axis batch
UnsupportedConcatLayerError in op /model.23/Tile_1: Unsupported concat over axis batch
UnsupportedModelError in op /model.23/Sub: In vertex /model.23/Sub_input the constant value shape (1, 2, 8400) must be broadcastable to the output shape [2, 8400, 1]
UnsupportedModelError in op /model.23/Add_1: In vertex /model.23/Add_1_input the constant value shape (1, 2, 8400) must be broadcastable to the output shape [2, 8400, 1]
And my SDK version is :
(hailo_virtualenv) hailo@simws08:/local/shared_with_docker/compile_test$ hailo --version
[info] Current Time: 16:02:04, 10/14/24
[info] CPU: Architecture: x86_64, Model: Intel(R) Core(TM) i9-10900F CPU @ 2.80GHz, Number Of Cores: 20, Utilization: 1.0%
[info] Memory: Total: 31GB, Available: 28GB
[info] System info: OS: Linux, Kernel: 5.15.0-122-generic
[info] Hailo DFC Version: 3.29.0
[info] HailoRT Version: 4.19.0
[info] PCIe: No Hailo PCIe device was found
[info] Running `hailo --version`
HailoRT v4.19.0
Hailo Dataflow Compiler v3.29.0
- In case where you have provided compiled yolov10n model on hailo model zoo. I wonder how you deal with those unsupported operations.
- I tried to bypass the unsupported operations by changing the end node to /model.23/Concat_3, but it report:
[info] Model Optimization is done
[info] Saved HAR to: /local/shared_with_docker/compile_test/yolov10n_h_quantized_model.har
[info] To achieve optimal performance, set the compiler_optimization_level to "max" by adding performance_param(compiler_optimization_level=max) to the model script. Note that this may increase compilation time.
[info] Loading network parameters
[info] Starting Hailo allocation and compilation flow
[error] Failed to reach fps on following nodes:
concat18 max reached fps: 0 required_fps: 10
concat18 errors:
Agent infeasible by resources sanity.: Memory units capacity exceeded (available: 128, required: 150).
it should be a small model, but it reports that memory units capacity exceeded. Why and how to deal with it?