Parsing custom ONNX - YoloV7

Hello Hailo,

I have an error when I try to parse my custom yolov7 model.

I know it exists in Hailo Zoo but I’d like to use my custom models because I plan to use other custom models not available in Hailo Zoo.

I run under Almalinux 8 (RHEL) under an Ubuntu 22 docker. I successfully installed the hailo dataflow compiler for my hailo8 card (hailo_dataflow_compiler-3.33.0-py3-none-linux_x86_64.whl) but when I try to parse, I receive this error :

root@693ec62ef232:/# hailo parser onnx /models/model_inferred.onnx
[info] No GPU chosen and no suitable GPU found, falling back to CPU.
[info] Current Time: 15:23:20, 10/17/25
[info] CPU: Architecture: x86_64, Model: Intel(R) Core™ i7-10875H CPU @ 2.30GHz, Number Of Cores: 16, Utilization: 5.1%
[info] Memory: Total: 15GB, Available: 8GB
[info] System info: OS: Linux, Kernel: 4.18.0-553.77.1.el8_10.x86_64
[info] Hailo DFC Version: 3.33.0
[info] HailoRT Version: Not Installed
[info] PCIe: No Hailo PCIe device was found
[info] Running hailo parser onnx /models/model_inferred.onnx
[info] Translation started on ONNX model model_inferred
[info] Restored ONNX model model_inferred (completion time: 00:00:00.37)
[info] Extracted ONNXRuntime meta-data for Hailo model (completion time: 00:00:01.23)
[info] Simplified ONNX model for a parsing retry attempt (completion time: 00:00:03.68)
Traceback (most recent call last):
File “/hailo_dataflow_compiler_venv/lib/python3.10/site-packages/hailo_sdk_client/sdk_backend/parser/parser.py”, line 235, in translate_onnx_model
parsing_results = self._parse_onnx_model_to_hn(
File “/hailo_dataflow_compiler_venv/lib/python3.10/site-packages/hailo_sdk_client/sdk_backend/parser/parser.py”, line 316, in _parse_onnx_model_to_hn
return self.parse_model_to_hn(
File “/hailo_dataflow_compiler_venv/lib/python3.10/site-packages/hailo_sdk_client/sdk_backend/parser/parser.py”, line 359, in parse_model_to_hn
fuser = HailoNNFuser(converter.convert_model(), net_name, converter.end_node_names)
File “/hailo_dataflow_compiler_venv/lib/python3.10/site-packages/hailo_sdk_client/model_translator/translator.py”, line 82, in convert_model
self._create_layers()
File “/hailo_dataflow_compiler_venv/lib/python3.10/site-packages/hailo_sdk_client/model_translator/edge_nn_translator.py”, line 39, in _create_layers
self._add_direct_layers()
File “/hailo_dataflow_compiler_venv/lib/python3.10/site-packages/hailo_sdk_client/model_translator/edge_nn_translator.py”, line 121, in _add_direct_layers
self._layer_callback_from_vertex(vertex)
File “/hailo_dataflow_compiler_venv/lib/python3.10/site-packages/hailo_sdk_client/model_translator/onnx_translator/onnx_translator.py”, line 434, in _layer_callback_from_vertex
self._create_ew_add_layer(vertex)
File “/hailo_dataflow_compiler_venv/lib/python3.10/site-packages/hailo_sdk_client/model_translator/onnx_translator/onnx_translator.py”, line 1156, in _create_ew_add_layer
self._create_ew_layer(vertex, EWAddLayer)
File “/hailo_dataflow_compiler_venv/lib/python3.10/site-packages/hailo_sdk_client/model_translator/onnx_translator/onnx_translator.py”, line 1179, in _create_ew_layer
const_layer, ew_op_input = self._create_ew_const_input_layer(vertex)
File “/hailo_dataflow_compiler_venv/lib/python3.10/site-packages/hailo_sdk_client/model_translator/onnx_translator/onnx_translator.py”, line 1316, in _create_ew_const_input_layer
const_layer = ConstInputLayer.create(f"{vertex.name}_input", [const_output_shape], input_values)
UnboundLocalError: local variable ‘const_output_shape’ referenced before assignment

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/hailo_dataflow_compiler_venv/bin/hailo”, line 8, in 
sys.exit(main())
File “/hailo_dataflow_compiler_venv/lib/python3.10/site-packages/hailo_sdk_client/tools/cmd_utils/main.py”, line 111, in main
ret_val = client_command_runner.run()
File “/hailo_dataflow_compiler_venv/lib/python3.10/site-packages/hailo_sdk_client/tools/cmd_utils/base_utils.py”, line 68, in run
return self._run(argv)
File “/hailo_dataflow_compiler_venv/lib/python3.10/site-packages/hailo_sdk_client/tools/cmd_utils/base_utils.py”, line 89, in _run
return args.func(args)
File “/hailo_dataflow_compiler_venv/lib/python3.10/site-packages/hailo_sdk_client/tools/parser_cli.py”, line 212, in run
self._parse(net_name, args, tensor_shapes)
File “/hailo_dataflow_compiler_venv/lib/python3.10/site-packages/hailo_sdk_client/tools/parser_cli.py”, line 298, in _parse
self.runner.translate_onnx_model(
File “/hailo_dataflow_compiler_venv/lib/python3.10/site-packages/hailo_sdk_common/states/states.py”, line 16, in wrapped_func
return func(self, *args, **kwargs)
File “/hailo_dataflow_compiler_venv/lib/python3.10/site-packages/hailo_sdk_client/runner/client_runner.py”, line 1192, in translate_onnx_model
parser.translate_onnx_model(
File “/hailo_dataflow_compiler_venv/lib/python3.10/site-packages/hailo_sdk_client/sdk_backend/parser/parser.py”, line 276, in translate_onnx_model
parsing_results = self._parse_onnx_model_to_hn(
File “/hailo_dataflow_compiler_venv/lib/python3.10/site-packages/hailo_sdk_client/sdk_backend/parser/parser.py”, line 316, in _parse_onnx_model_to_hn
return self.parse_model_to_hn(
File “/hailo_dataflow_compiler_venv/lib/python3.10/site-packages/hailo_sdk_client/sdk_backend/parser/parser.py”, line 359, in parse_model_to_hn
fuser = HailoNNFuser(converter.convert_model(), net_name, converter.end_node_names)
File “/hailo_dataflow_compiler_venv/lib/python3.10/site-packages/hailo_sdk_client/model_translator/translator.py”, line 82, in convert_model
self._create_layers()
File “/hailo_dataflow_compiler_venv/lib/python3.10/site-packages/hailo_sdk_client/model_translator/edge_nn_translator.py”, line 39, in _create_layers
self._add_direct_layers()
File “/hailo_dataflow_compiler_venv/lib/python3.10/site-packages/hailo_sdk_client/model_translator/edge_nn_translator.py”, line 121, in _add_direct_layers
self._layer_callback_from_vertex(vertex)
File “/hailo_dataflow_compiler_venv/lib/python3.10/site-packages/hailo_sdk_client/model_translator/onnx_translator/onnx_translator.py”, line 434, in _layer_callback_from_vertex
self._create_ew_add_layer(vertex)
File “/hailo_dataflow_compiler_venv/lib/python3.10/site-packages/hailo_sdk_client/model_translator/onnx_translator/onnx_translator.py”, line 1156, in _create_ew_add_layer
self._create_ew_layer(vertex, EWAddLayer)
File “/hailo_dataflow_compiler_venv/lib/python3.10/site-packages/hailo_sdk_client/model_translator/onnx_translator/onnx_translator.py”, line 1179, in _create_ew_layer
const_layer, ew_op_input = self._create_ew_const_input_layer(vertex)
File “/hailo_dataflow_compiler_venv/lib/python3.10/site-packages/hailo_sdk_client/model_translator/onnx_translator/onnx_translator.py”, line 1316, in _create_ew_const_input_layer
const_layer = ConstInputLayer.create(f"{vertex.name}_input", [const_output_shape], input_values)
UnboundLocalError: local variable ‘const_output_shape’ referenced before assignment

Following some of the directives found here Onnx to Har parsing error
I tried to remove any unknown shape using the following command, but it didn’t help. From what I could see, the models has no dynamic shape.

python -m onnxruntime.tools.symbolic_shape_infer --input /models/original_model.onnx --output /models/model_inferred.onnx --auto_merge

Am I missing something in the parsing process ?
Thank you !

Hi @K_E, The Dataflow Compiler is designed to be used only on X86 systems at the moment, it might be the issue, I;m not sure since it’s not tested.

Have you tried using the model-zoo recipe for converting the yolov7?

Thank you for your reply !

I am not sure to understand your remark : I am running on a x86 system, just a different operating system (Almalinux with is RHEL based VS Ubuntu).

I have tested the yolov7 from Hailo-Zoo to make sure the card is installed properly and it seems to be ok, but in the end, I need to transform my custom ONNX because we have some intern models that won’t be available in the Zoo.

you’re right, my bad, not sure what led me to belive this an ARM based machine.
In any case, if you use a model that is supported ni the model zoo, but your mocel is pruned, or have less classes, or different dimensions etc. The model-zoo can still be your friend! We have API to change the conversion to comply with these changes.

After adding some prints in the hailo code, it turns out that the onnx should have an input batch size of 1 to work properly.

I changed and it now works.

1 Like