I want to run yolov8n-pose on hailo8l, but I get error when I parse the onnx model.
Here is my code:
from hailo_sdk_client import ClientRunner
model_name = 'yolov8n-pose'
ckpt_path = '/home/jiahao/yolov8n_hailo/runs/pose/train/weights/best.onnx'
start_node = '/model.0/conv/Conv'
end_node = '/model.22/Concat_7'
chosen_hw_arch = 'hailo8l'
runner = ClientRunner(hw_arch=chosen_hw_arch)
hn, npz = runner.translate_onnx_model(ckpt_path, model_name, start_node_names=[start_node], end_node_names=[end_node])
And I get error like below:
{
"name": "KeyError",
"message": "'/model.2/Split_output_0'",
"stack": "---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
Cell In[16], line 2
1 runner = ClientRunner(hw_arch=chosen_hw_arch)
----> 2 hn, npz = runner.translate_onnx_model(ckpt_path, model_name, start_node_names=[start_node], end_node_names=[end_node])
File ~/hailo_env/lib/python3.8/site-packages/hailo_sdk_common/states/states.py:16, in allowed_states.<locals>.wrap.<locals>.wrapped_func(self, *args, **kwargs)
13 if self._state not in states:
14 raise InvalidStateException(\"The execution of {} is not available under the state: \"
15 \"{}\".format(func.__name__, self._state.value))
---> 16 return func(self, *args, **kwargs)
File ~/hailo_env/lib/python3.8/site-packages/hailo_sdk_client/runner/client_runner.py:876, in ClientRunner.translate_onnx_model(self, model, net_name, start_node_names, end_node_names, net_input_shapes, augmented_path, disable_shape_inference, disable_rt_metadata_extraction)
844 \"\"\"DFC API for parsing an ONNX model. This creates a runner with loaded HN (model) and
845 parameters.
846
(...)
873 tuple: The first item is the HN JSON as a string. The second item is the params dict.
874 \"\"\"
875 parser = Parser()
--> 876 parser.translate_onnx_model(model=model, net_name=net_name, start_node_names=start_node_names,
877 end_node_names=end_node_names, net_input_shapes=net_input_shapes,
878 augmented_path=augmented_path, disable_shape_inference=disable_shape_inference,
879 disable_rt_metadata_extraction=disable_rt_metadata_extraction)
881 return self._finalize_parsing(parser.return_data)
File ~/hailo_env/lib/python3.8/site-packages/hailo_sdk_client/sdk_backend/parser/parser.py:195, in Parser.translate_onnx_model(self, model, net_name, start_node_names, end_node_names, net_input_shapes, augmented_path, disable_shape_inference, disable_rt_metadata_extraction)
193 except Exception:
194 self._logger.info(f'Unable to simplify the model: {str(e)}')
--> 195 raise e from None
197 for node in simplified_model.graph.node:
198 if not node.name:
File ~/hailo_env/lib/python3.8/site-packages/hailo_sdk_client/sdk_backend/parser/parser.py:179, in Parser.translate_onnx_model(self, model, net_name, start_node_names, end_node_names, net_input_shapes, augmented_path, disable_shape_inference, disable_rt_metadata_extraction)
176 onnx.save_model(onnx_model, augmented_path)
178 try:
--> 179 parsing_results = self._parse_onnx_model_to_hn(onnx_model, valid_net_name, start_node_names,
180 end_node_names, net_input_shapes,
181 disable_shape_inference)
183 except Exception as e:
184 if large_model_detected or long_model_detected:
File ~/hailo_env/lib/python3.8/site-packages/hailo_sdk_client/sdk_backend/parser/parser.py:237, in Parser._parse_onnx_model_to_hn(self, onnx_model, net_name, start_node_names, end_node_names, net_input_shapes, disable_shape_inference)
234 except Exception as e:
235 self._logger.warning(f'ONNX shape inference failed: {str(e)}')
--> 237 return self.parse_model_to_hn(onnx_model, None, net_name, start_node_names, end_node_names,
238 nn_framework=NNFramework.ONNX, output_shapes=output_shapes)
File ~/hailo_env/lib/python3.8/site-packages/hailo_sdk_client/sdk_backend/parser/parser.py:263, in Parser.parse_model_to_hn(self, model, values, net_name, start_node_names, end_node_names, nn_framework, output_shapes)
260 else:
261 raise BackendRuntimeException(f'Unsupported NN framework {nn_framework}')
--> 263 fuser = HailoNNFuser(converter.convert_model(), net_name, converter.end_node_names)
264 hailo_nn = fuser.convert_model()
265 hailo_nn.validate_stage(HnStage.HN)
File ~/hailo_env/lib/python3.8/site-packages/hailo_sdk_client/model_translator/translator.py:76, in HailoNNConverter.convert_model(self)
74 self._validate_model_params()
75 self._validate_bn_ops_in_training()
---> 76 self._create_layers()
77 self._add_layers_connections()
78 self._layers_graph.set_names_and_indices()
File ~/hailo_env/lib/python3.8/site-packages/hailo_sdk_client/model_translator/edge_nn_translator.py:28, in EdgeNNConverter._create_layers(self)
26 self._add_input_layers()
27 self._update_vertices_info()
---> 28 self._add_direct_layers()
29 self._validate_processed_vertices()
File ~/hailo_env/lib/python3.8/site-packages/hailo_sdk_client/model_translator/edge_nn_translator.py:110, in EdgeNNConverter._add_direct_layers(self)
108 elif vertex not in self._visited_states:
109 self._logger.debug(f'Processing vertex {vertex.name}')
--> 110 self._layer_callback_from_vertex(vertex)
111 self._visited_states[vertex] = VertexState.PROCESSED
113 if (self._visited_states.get(vertex, VertexState.SKIPPED) != VertexState.SKIPPED and
114 len(list(self._graph.successors(vertex))) == 0 and not self._is_descendant_of_error(vertex)):
File ~/hailo_env/lib/python3.8/site-packages/hailo_sdk_client/model_translator/onnx_translator/onnx_translator.py:260, in ONNXConverter._layer_callback_from_vertex(self, vertex)
258 consumed_vertices = self._create_spatial_split_layer(vertex)
259 else:
--> 260 consumed_vertices = self._create_feature_split_layer(vertex)
261 elif vertex.is_grouped_reduce_max():
262 consumed_vertices = self._create_grouped_reduce_max_layer(vertex)
File ~/hailo_env/lib/python3.8/site-packages/hailo_sdk_client/model_translator/onnx_translator/onnx_translator.py:1098, in ONNXConverter._create_feature_split_layer(self, vertex)
1096 def _create_feature_split_layer(self, vertex):
1097 consumed_vertices = []
-> 1098 split_sizes, output_shapes = vertex.get_feature_split_info()
1099 layer = FeatureSplitterLayer.create(vertex.name, vertex.input, split_sizes,
1100 output_shapes=output_shapes)
1101 self._add_layer(layer)
File ~/hailo_env/lib/python3.8/site-packages/hailo_sdk_client/model_translator/onnx_translator/onnx_graph.py:2090, in ONNXGraphNode.get_feature_split_info(self)
2087 else:
2088 conversion_func = self.convert_nchw_to_nhwc
-> 2090 split_sizes = [conversion_func(self._graph.output_shapes[output][0])[-1] for output in self._info.output]
2092 return split_sizes, hailo_output_shapes
File ~/hailo_env/lib/python3.8/site-packages/hailo_sdk_client/model_translator/onnx_translator/onnx_graph.py:2090, in <listcomp>(.0)
2087 else:
2088 conversion_func = self.convert_nchw_to_nhwc
-> 2090 split_sizes = [conversion_func(self._graph.output_shapes[output][0])[-1] for output in self._info.output]
2092 return split_sizes, hailo_output_shapes
KeyError: '/model.2/Split_output_0'"
}