Error: converting yolov3-12-int8.onnx to HEF format

I’m getting error when converting yolov3-12-int8.onnx to HEF format. I’m working on Rpi5 and I need to a model which support “hailo8l”

runner = ClientRunner(hw_arch=chosen_hw_arch)
hn, npz = runner.translate_onnx_model(
onnx_path,
onnx_model_name,
start_node_names=[‘input_1’, ‘image_shape’],
end_node_names=[‘yolonms_layer_1/ExpandDims_1:0’, ‘yolonms_layer_1/ExpandDims_3:0’, ‘yolonms_layer_1/concat_2:0’],
net_input_shapes={‘input_1’: [1, 3, 416, 416], ‘image_shape’: [1, 2]},
)

Error:

/Hailo/.venv/lib/python3.10/site-packages/hailo_sdk_client/sdk_backend/parser/parser.py:367, in Parser.parse_model_to_hn(self, model, values, net_name, start_node_names, end_node_names, nn_framework, output_shapes, net_input_format, rename_layers_by_blocks)
365 raise BackendRuntimeException(f"Unsupported NN framework {nn_framework}")
–> 367 fuser = HailoNNFuser(converter.convert_model(), net_name, converter.end_node_names)
368 hailo_nn = fuser.convert_model()

Does DFC supports only static input shapes models:

(.venv) taruna@taruna-desktop:~/Hailo

$ hailo parser onnx ~/Hailo/models/yolov3-12-int8.onnx --net-name yolov3-12-int8 --har-path ~/Hailo/models/yolov3-12-int8.har --hw-arch hailo8l

[info] Current Time: 13:05:49, 11/15/24
[info] CPU: Architecture: x86_64, Model: 12th Gen Intel(R) Core™ i7-12700, Number Of Cores: 20, Utilization: 0.6%
[info] Memory: Total: 23GB, Available: 8GB
[info] System info: OS: Linux, Kernel: 6.8.0-40-generic
[info] Hailo DFC Version: 3.29.0
[info] HailoRT Version: Not Installed
[info] PCIe: No Hailo PCIe device was found
[info] Running hailo parser onnx /home/taruna/Hailo/models/yolov3-12-int8.onnx --net-name yolov3-12-int8 --har-path /home/taruna/Hailo/models/yolov3-12-int8.har --hw-arch hailo8l
[info] Translation started on ONNX model yolov3-12-int8
[info] Restored ONNX model yolov3-12-int8 (completion time: 00:00:00.17)
[info] Extracted ONNXRuntime meta-data for Hailo model (completion time: 00:00:00.17)
[warning] ONNX shape inference failed: Unsupported dynamic shape([0, 3, 0, 0]) found on input node input_1. Please use net_input_shapes, see documentation for additional info.
[info] Simplified ONNX model for a parsing retry attempt (completion time: 00:00:01.14)

[warning] ONNX shape inference failed: Unsupported dynamic shape([0, 3, 0, 0]) found on input node input_1. Please use net_input_shapes, see documentation for additional info.
Traceback (most recent call last):

File “/home/taruna/Hailo/.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 “/home/taruna/Hailo/.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 “/home/taruna/Hailo/.venv/lib/python3.10/site-packages/hailo_sdk_client/sdk_backend/parser/parser.py”, line 367, in parse_model_to_hn
fuser = HailoNNFuser(converter.convert_model(), net_name, converter.end_node_names)
File “/home/taruna/Hailo/.venv/lib/python3.10/site-packages/hailo_sdk_client/model_translator/translator.py”, line 83, in convert_model
self._create_layers()
File “/home/taruna/Hailo/.venv/lib/python3.10/site-packages/hailo_sdk_client/model_translator/edge_nn_translator.py”, line 38, in _create_layers
self._add_input_layers()
File “/home/taruna/Hailo/.venv/lib/python3.10/site-packages/hailo_sdk_client/model_translator/edge_nn_translator.py”, line 73, in _add_input_layers
input_shapes = vertex.get_input_layer_shapes()
File “/home/taruna/Hailo/.venv/lib/python3.10/site-packages/hailo_sdk_client/model_translator/onnx_translator/onnx_graph.py”, line 5994, in get_input_layer_shapes

raise UnsupportedInputShapesError(
hailo_sdk_client.model_translator.exceptions.UnsupportedInputShapesError: ('Unsupported dynamic shape found on input node input_1, consider using start_node_names + net_input_shapes arguments when calling translator, e.g. runner.translate_onnx_model(..., start_node_names=[input_1], net_input_shapes=[0, 3, 224, 224])', '[0, 3, 224, 224]')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/taruna/Hailo/.venv/lib/python3.10/site-packages/hailo_sdk_client/tools/parser_cli.py”, line 198, in run
runner = self._parse(net_name, args, tensor_shapes)
File “/home/taruna/Hailo/.venv/lib/python3.10/site-packages/hailo_sdk_client/tools/parser_cli.py”, line 282, in _parse
runner.translate_onnx_model(
File “/home/taruna/Hailo/.venv/lib/python3.10/site-packages/hailo_sdk_common/states/states.py”, line 16, in wrapped_func
return func(self, *args, **kwargs)
File “/home/taruna/Hailo/.venv/lib/python3.10/site-packages/hailo_sdk_client/runner/client_runner.py”, line 1158, in translate_onnx_model
parser.translate_onnx_model(
File “/home/taruna/Hailo/.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 “/home/taruna/Hailo/.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 “/home/taruna/Hailo/.venv/lib/python3.10/site-packages/hailo_sdk_client/sdk_backend/parser/parser.py”, line 367, in parse_model_to_hn
fuser = HailoNNFuser(converter.convert_model(), net_name, converter.end_node_names)
File “/home/taruna/Hailo/.venv/lib/python3.10/site-packages/hailo_sdk_client/model_translator/translator.py”, line 83, in convert_model
self._create_layers()
File “/home/taruna/Hailo/.venv/lib/python3.10/site-packages/hailo_sdk_client/model_translator/edge_nn_translator.py”, line 38, in _create_layers
self._add_input_layers()
File “/home/taruna/Hailo/.venv/lib/python3.10/site-packages/hailo_sdk_client/model_translator/edge_nn_translator.py”, line 73, in _add_input_layers
input_shapes = vertex.get_input_layer_shapes()
File “/home/taruna/Hailo/.venv/lib/python3.10/site-packages/hailo_sdk_client/model_translator/onnx_translator/onnx_graph.py”, line 5994, in get_input_layer_shapes
raise UnsupportedInputShapesError(
hailo_sdk_client.model_translator.exceptions.UnsupportedInputShapesError: (‘Unsupported dynamic shape found on input node input_1, consider using start_node_names + net_input_shapes arguments when calling translator, e.g. runner.translate_onnx_model(…, start_node_names=[input_1], net_input_shapes=[0, 3, 224, 224])’, ‘[0, 3, 224, 224]’)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/taruna/Hailo/.venv/bin/hailo”, line 8, in
sys.exit(main())
File “/home/taruna/Hailo/.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 “/home/taruna/Hailo/.venv/lib/python3.10/site-packages/hailo_sdk_client/tools/cmd_utils/base_utils.py”, line 68, in run
return self._run(argv)
File “/home/taruna/Hailo/.venv/lib/python3.10/site-packages/hailo_sdk_client/tools/cmd_utils/base_utils.py”, line 89, in _run
return args.func(args)
File “/home/taruna/Hailo/.venv/lib/python3.10/site-packages/hailo_sdk_client/tools/parser_cli.py”, line 213, in run
raise ParserCLIException(f"Could not parse the model due to dynamic shapes. {msg}")
hailo_sdk_client.tools.parser_cli.ParserCLIException: Could not parse the model due to dynamic shapes. Please try to parse the model again, using: --tensor-shapes,
e.g. hailo parser onnx /home/taruna/Hailo/models/yolov3-12-int8.onnx --net-name yolov3-12-int8 --har-path /home/taruna/Hailo/models/yolov3-12-int8.har --hw-arch hailo8l --tensor-shapes [0,3,224,224]

Hey @taruna.chaudhary

Welcome to the Hailo Community!

The Hailo DFC (Dataflow Compiler) has limited support for dynamic shapes in models, requiring static input shapes for successful compilation.

To resolve this errors Unsupported dynamic shape([0, 3, 0, 0]) . You can either use the --tensor-shapes argument when parsing the ONNX model to specify static dimensions (e.g., [1,3,224,224]), or modify the ONNX model directly using libraries like onnxruntime to set permanent static input shapes. It’s also recommended to verify the model’s input shapes using visualization tools like Netron before parsing with the Hailo SDK.

Best Regards,
Omri