Can't compile onnx to hef

I’m getting the following error:

Blockquote
[info] Extracted ONNXRuntime meta-data for Hailo model (completion time: 00:00:00.94)
[warning] ONNX shape inference failed: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Failed to load model with error: /onnxruntime_src/onnxruntime/core/graph/model.cc:147 onnxruntime::Model::Model(onnx::ModelProto&&, const PathString&, const IOnnxRuntimeOpSchemaRegistryList*, const onnxruntime::logging::Logger&, const onnxruntime::ModelOptions&) Unsupported model IR version: 9, max supported IR version: 8
Traceback (most recent call last):
File “/home/k8s/git/hailo_model_zoo/parsing.py”, line 8, in
hn, npz = runner.translate_onnx_model(
File “/home/k8s/git/hailo_model_zoo/.venv/lib/python3.10/site-packages/hailo_sdk_common/states/states.py”, line 16, in wrapped_func
return func(self, *args, **kwargs)
File “/home/k8s/git/hailo_model_zoo/.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/k8s/git/hailo_model_zoo/.venv/lib/python3.10/site-packages/hailo_sdk_client/sdk_backend/parser/parser.py”, line 248, in translate_onnx_model
raise e from None
File “/home/k8s/git/hailo_model_zoo/.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(

this is the code:

Blockquote
from hailo_sdk_client import ClientRunner
model_name = ‘model-v8’
onnx_path = f’…/train/model.onnx’
chosen_hw_arch = ‘hailo8l’
runner = ClientRunner(hw_arch=chosen_hw_arch)
hn, npz = runner.translate_onnx_model(
onnx_path,
model_name,
start_node_names=[‘images’],
end_node_names=[‘/model.24/m.0/Conv’, ‘/model.24/m.2/Conv’, ‘/model.24/m.1/Conv’],
net_input_shapes={‘images’: [1, 3, 640, 640]})
runner.save_har(f’{model_name}.har’)

Any ideas how to proceed?
I’m following this example:

I also tried to run the following command:

hailomz compile yolov8s --ckpt …/train/model.onnx
–hw-arch hailo8l
–calib-path …/train/datasets/images

and got the following error:
Start run for network yolov8s …
Initializing the hailo8l runner…
[info] Translation started on ONNX model yolov8s
[info] Restored ONNX model yolov8s (completion time: 00:00:00.21)
WARNING: failed to run “Add” op (name is “/model.22/Add”), skip…
WARNING: failed to run “Div” op (name is “/model.22/Div”), skip…
WARNING: failed to run “Mul” op (name is “/model.22/Mul_1”), skip…
WARNING: failed to run “Add” op (name is “/model.22/Add”), skip…
WARNING: failed to run “Div” op (name is “/model.22/Div”), skip…
WARNING: failed to run “Mul” op (name is “/model.22/Mul_1”), skip…
[info] Extracted ONNXRuntime meta-data for Hailo model (completion time: 00:00:00.98)
[info] NMS structure of yolov8 (or equivalent architecture) was detected.
[info] In order to use HailoRT post-processing capabilities, these end node names should be used: /model.22/cv2.0/cv2.0.2/Conv /model.22/cv3.0/cv3.0.2/Conv /model.22/cv2.1/cv2.1.2/Conv /model.22/cv3.1/cv3.1.2/Conv /model.22/cv2.2/cv2.2.2/Conv /model.22/cv3.2/cv3.2.2/Conv.
[info] Start nodes mapped from original model: ‘images’: ‘yolov8s/input_layer1’.
[info] End nodes mapped from original model: ‘/model.22/cv2.0/cv2.0.2/Conv’, ‘/model.22/cv3.0/cv3.0.2/Conv’, ‘/model.22/cv2.1/cv2.1.2/Conv’, ‘/model.22/cv3.1/cv3.1.2/Conv’, ‘/model.22/cv2.2/cv2.2.2/Conv’, ‘/model.22/cv3.2/cv3.2.2/Conv’.
[info] Translation completed on ONNX model yolov8s (completion time: 00:00:01.46)
[info] Saved HAR to: /home/k8s/git/hailo_model_zoo/yolov8s.har
Preparing calibration data…
[info] Loading model script commands to yolov8s from /home/k8s/git/hailo_model_zoo/hailo_model_zoo/cfg/alls/generic/yolov8s.alls
[info] Starting Model Optimization
[warning] Reducing optimization level to 0 (the accuracy won’t be optimized and compression won’t be used) because there’s less data than the recommended amount (1024), and there’s no available GPU
[warning] Running model optimization with zero level of optimization is not recommended for production use and might lead to suboptimal accuracy results
[info] Model received quantization params from the hn
Traceback (most recent call last):
File “/home/k8s/git/hailo_model_zoo/.venv/bin/hailomz”, line 33, in
sys.exit(load_entry_point(‘hailo-model-zoo’, ‘console_scripts’, ‘hailomz’)())
File “/home/k8s/git/hailo_model_zoo/hailo_model_zoo/main.py”, line 122, in main
run(args)
File “/home/k8s/git/hailo_model_zoo/hailo_model_zoo/main.py”, line 111, in run
return handlersargs.command
File “/home/k8s/git/hailo_model_zoo/hailo_model_zoo/main_driver.py”, line 250, in compile
ensure_optimized(runner, logger, args, network_info)
File “/home/k8s/git/hailo_model_zoo/hailo_model_zoo/main_driver.py”, line 91, in ensure_optimized
optimize_model(
File “/home/k8s/git/hailo_model_zoo/hailo_model_zoo/core/main_utils.py”, line 326, in optimize_model
runner.optimize(calib_feed_callback)
File “/home/k8s/git/hailo_model_zoo/.venv/lib/python3.10/site-packages/hailo_sdk_common/states/states.py”, line 16, in wrapped_func
return func(self, *args, **kwargs)
File “/home/k8s/git/hailo_model_zoo/.venv/lib/python3.10/site-packages/hailo_sdk_client/runner/client_runner.py”, line 2093, in optimize
self.optimize(calib_data, data_type=data_type, work_dir=work_dir)
File “/home/k8s/git/hailo_model_zoo/.venv/lib/python3.10/site-packages/hailo_sdk_common/states/states.py”, line 16, in wrapped_func
return func(self, *args, **kwargs)
File “/home/k8s/git/hailo_model_zoo/.venv/lib/python3.10/site-packages/hailo_sdk_client/runner/client_runner.py”, line 1935, in optimize
self.sdk_backend.full_quantization(calib_data, data_type=data_type, work_dir=work_dir)
File “/home/k8s/git/hailo_model_zoo/.venv/lib/python3.10/site-packages/hailo_sdk_client/sdk_backend/sdk_backend.py”, line 1045, in full_quantization
self.full_acceleras_run(self.calibration_data, data_type)
File “/home/k8s/git/hailo_model_zoo/.venv/lib/python3.10/site-packages/hailo_sdk_client/sdk_backend/sdk_backend.py”, line 1229, in full_acceleras_run
optimization_flow.run()
File “/home/k8s/git/hailo_model_zoo/.venv/lib/python3.10/site-packages/hailo_model_optimization/tools/orchestator.py”, line 306, in wrapper
return func(self, *args, **kwargs)
File “/home/k8s/git/hailo_model_zoo/.venv/lib/python3.10/site-packages/hailo_model_optimization/flows/optimization_flow.py”, line 326, in run
step_func()
File “/home/k8s/git/hailo_model_zoo/.venv/lib/python3.10/site-packages/hailo_model_optimization/tools/orchestator.py”, line 250, in wrapped
result = method(*args, **kwargs)
File “/home/k8s/git/hailo_model_zoo/.venv/lib/python3.10/site-packages/hailo_model_optimization/tools/subprocess_wrapper.py”, line 123, in parent_wrapper
self.build_model()
File “/home/k8s/git/hailo_model_zoo/.venv/lib/python3.10/site-packages/hailo_model_optimization/tools/orchestator.py”, line 250, in wrapped
result = method(*args, **kwargs)
File “/home/k8s/git/hailo_model_zoo/.venv/lib/python3.10/site-packages/hailo_model_optimization/flows/optimization_flow.py”, line 240, in build_model
model.compute_output_shape(shapes)
File “/home/k8s/git/hailo_model_zoo/.venv/lib/python3.10/site-packages/hailo_model_optimization/acceleras/model/hailo_model/hailo_model.py”, line 1039, in compute_output_shape
return self.compute_and_verify_output_shape(input_shape, verify_layer_inputs_shape=False)
File “/home/k8s/git/hailo_model_zoo/.venv/lib/python3.10/site-packages/hailo_model_optimization/acceleras/model/hailo_model/hailo_model.py”, line 1073, in compute_and_verify_output_shape
layer_output_shape = layer.compute_output_shape(layer_input_shapes)
File “/home/k8s/git/hailo_model_zoo/.venv/lib/python3.10/site-packages/keras/engine/base_layer.py”, line 917, in compute_output_shape
outputs = self(inputs, training=False)
File “/home/k8s/git/hailo_model_zoo/.venv/lib/python3.10/site-packages/keras/utils/traceback_utils.py”, line 70, in error_handler
raise e.with_traceback(filtered_tb) from None
File "/tmp/autograph_generated_filebyl8uwpj.py", line 41, in tf__call
outputs = ag
.converted_call(ag
.ld(self).call_core, (ag
.ld(inputs), ag
.ld(training)), dict(**ag
_.ld(kwargs)), fscope)
File "/tmp/autograph_generated_filefk3zztea.py", line 90, in tf__call_core
ag
.if_stmt(ag__.ld(self).postprocess_type in [ag__.ld(PostprocessType).NMS, ag__.ld(PostprocessType).BBOX_DECODER], if_body_3, else_body_3, get_state_3, set_state_3, (‘do_return’, ‘retval_’), 2)
File "/tmp/autograph_generated_filefk3zztea.py", line 22, in if_body_3
retval
= ag
_.converted_call(ag__.ld(self).bbox_decoding_and_nms_call, (ag__.ld(inputs),), dict(is_bbox_decoding_only=ag__.ld(self).postprocess_type == ag__.ld(PostprocessType).BBOX_DECODER), fscope)
File "/tmp/autograph_generated_filewlleovse.py", line 99, in tf__bbox_decoding_and_nms_call
ag
.if_stmt(ag__.ld(self).meta_arch in [ag__.ld(NMSOnCpuMetaArchitectures).YOLOV5, ag__.ld(NMSOnCpuMetaArchitectures).YOLOX], if_body_4, else_body_4, get_state_4, set_state_4, (‘decoded_bboxes’, ‘detection_score’, ‘do_return’, ‘retval_’, ‘inputs’), 4)
File "/tmp/autograph_generated_filewlleovse.py", line 96, in else_body_4
ag
.if_stmt(ag__.ld(self).meta_arch == ag__.ld(NMSOnCpuMetaArchitectures).YOLOV5_SEG, if_body_3, else_body_3, get_state_3, set_state_3, (‘decoded_bboxes’, ‘detection_score’, ‘do_return’, ‘retval_’), 4)
File "/tmp/autograph_generated_filewlleovse.py", line 93, in else_body_3
ag
.if_stmt(ag__.ld(self).meta_arch == ag__.ld(NMSOnCpuMetaArchitectures).YOLOV8, if_body_2, else_body_2, get_state_2, set_state_2, (‘decoded_bboxes’, ‘detection_score’), 2)
File "/tmp/autograph_generated_filewlleovse.py", line 69, in if_body_2
(decoded_bboxes, detection_score) = ag
.converted_call(ag__.ld(self).yolov8_decoding_call, (ag__.ld(inputs),), None, fscope)
File "/tmp/autograph_generated_filey5ktxuf8.py", line 82, in tf__yolov8_decoding_call
decoded_bboxes = ag
.converted_call(ag__.ld(tf).expand_dims, (ag__.ld(decoded_bboxes),), dict(axis=2), fscope)
ValueError: Exception encountered when calling layer “yolov8_nms_postprocess” (type HailoPostprocess).

in user code:

File "/home/k8s/git/hailo_model_zoo/.venv/lib/python3.10/site-packages/hailo_model_optimization/acceleras/hailo_layers/base_hailo_none_nn_core_layer.py", line 45, in call  *
    outputs = self.call_core(inputs, training, **kwargs)
File "/home/k8s/git/hailo_model_zoo/.venv/lib/python3.10/site-packages/hailo_model_optimization/acceleras/hailo_layers/hailo_postprocess.py", line 123, in call_core  *
    is_bbox_decoding_only=self.postprocess_type == PostprocessType.BBOX_DECODER,
File "/home/k8s/git/hailo_model_zoo/.venv/lib/python3.10/site-packages/hailo_model_optimization/acceleras/hailo_layers/hailo_postprocess.py", line 157, in bbox_decoding_and_nms_call  *
    decoded_bboxes, detection_score = self.yolov8_decoding_call(inputs)
File "/home/k8s/git/hailo_model_zoo/.venv/lib/python3.10/site-packages/hailo_model_optimization/acceleras/hailo_layers/hailo_postprocess.py", line 367, in yolov8_decoding_call  *
    decoded_bboxes = tf.expand_dims(decoded_bboxes, axis=2)

ValueError: Tried to convert 'input' to a tensor and failed. Error: None values not supported.

Call arguments received by layer “yolov8_nms_postprocess” (type HailoPostprocess):
• inputs=[‘tf.Tensor(shape=(None, 80, 80, 64), dtype=float32)’, ‘tf.Tensor(shape=(None, 80, 80, 3), dtype=float32)’, ‘tf.Tensor(shape=(None, 40, 40, 64), dtype=float32)’, ‘tf.Tensor(shape=(None, 40, 40, 3), dtype=float32)’, ‘tf.Tensor(shape=(None, 20, 20, 64), dtype=float32)’, ‘tf.Tensor(shape=(None, 20, 20, 3), dtype=float32)’]
• training=False
• kwargs=<class ‘inspect._empty’>

added the following argument --classes 3 and was able to continue, I will update about my progress

Update

I was able to complete the entire life cycle. no issue on Hailo side :slight_smile:

1 Like