Hi,
The issue stems from the fact that your custom yolov8n model must have different end nodes (right before the NMS) than the original yolov8n model in the Hailo model zoo. You may have passed one of these to the parser whereas there should be 6 of them.
These end modes are supplied to the parser so it can cut the model right before the NMS processing. Later on, the optimizer will âattachâ the NMS post-processing to the parser model. The NMS post-processing doesnât necessarily run on the Hailo-8 and might run on the host processor, depending on the model. For yolov8, it will run on the host processor.
How do you find the name of the end nodes of any model ?
You can use the CLI command
hailo parser onnx -y
TIP: if you need help with what arguments the command accepts, try to run both âhailo parser --help
â and âhailo parser onnx --help
â
For example, if I apply this command to the yolov8n.onnx downloaded from the model zoo: https://hailo-model-zoo.s3.eu-west-2.amazonaws.com/ModelZoo/Compiled/v2.13.0/hailo8/yolov8n.hef
Youâll find these lines amongst the output text displayed:
[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.
Now that you have the names of the end nodes, how do you pass them to the âhailomz parse
â command ?
There are two options:
- Directly as arguments to the â
hailomz parse
â command. If you run âhailomz parse --help
â, youâll see that it accepts --start-node-names
and --end-node-names
as arguments.
So, if I apply the end node names found earlier to this command, it would look like this:
hailomz parse yolov8n --end-node-names /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
You may be wondering now, if you donât pass any end-node-names argument to âhailomz parseâ, what node names would it use ? In this case, it will use the end node names written in the default yaml file corresponding to yolo8n. This lead to the second option of how you can pass the end node names to the parser.
- When you invoke âhailomz parse yolov8nâ, it will use meta-information stored in the file yolov8n.yaml file: hailo_model_zoo/hailo_model_zoo/cfg/networks/yolov8n.yaml at master ¡ hailo-ai/hailo_model_zoo ¡ GitHub .
You will notice both the start and the end nodes listed there:
parser:
nodes:
- null
-
- /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
Therefore, one way to specify new end nodes is to make a copy of this yaml file, modify the end nodes field only and pass this new yaml file as argument to âhailomz parse yolov8nâ as follow:
hailomz parse yolov8n --yaml <PATH_TO_NEW_YAML_FILE>
Hopefully this resolves your issue. You should delete all the yolob8n HAR files that were created and run the correct sequence.
Note that running âhailomz optimize yolov8nâ didnât cause any errors because it used the default yolov8n model, not your custom trained model.
Last note, for conveniency, Hailo provides a yolov8 retraining docker as well: hailo_model_zoo/training/yolov8 at master ¡ hailo-ai/hailo_model_zoo ¡ GitHub
You donât have to use it but the README.rst can provide useful information as well.