is there a google colab notebook to convert a yolov8 model to a .hef file

hi, I have a raspberry pi 5 with a hailo 8L. Is there a google colab notebook script to convert a yolov8 object detection model to a .hef file to run on the raspberry pi. Thanks mike

Hi @user921,

Please see here:

Thanks,

hi Michael, Thanks for your reply. I created a google colab notebook script following the example notebook that you referenced. I got a error when I tried to run !hailomz compile \. The error indicated that “The zoo’s internal metadata check is hardcoded and rejects hailo8l for yolov8n". I have a raspberry pi 5 with a hailo 8L hat. Could you please advise how I can correct this issue. Many Thanks mike

Hi @user921,

The line that finds the uploaded DFC wheel is commented out (for example). Change:

dfc_whl = 'dfc'  # [f for f in uploaded.keys() if "hailo_dataflow_compiler" in f]

to:

dfc_whl = [f for f in uploaded.keys() if "hailo_dataflow_compiler" in f]

In the last cell change the target to Hailo8L:

!hailomz compile \
    --ckpt /content/barcode-detection.onnx \
    --calib-path /content/barcode-detect/valid/ \
    --yaml /content/hailo_model_zoo/hailo_model_zoo/cfg/networks/yolov8s.yaml \
    --classes 2 \
    --hw-arch hailo8l \
    --performance

Thanks,

thanks for the hint. I now have another problem. If I use hailo_dataflow_compiler-3.33.1-py3-none-linux_x86_64.whl, what hailo_model_zoo version do I use. I tried to use hailo_model_zoo-2.18.0-py3-none-any.whl, but that did not work. Claude AI said to use hailo_model_zoo-2.14.0-py3-none-any.whl, but that is not working. Could you please advise a hailo_model_zoo version that will work with hailo_dataflow_compiler-3.33.1-py3-none-linux_x86_64.whl. Many thanks mike

Hi @user921,

The correct Model Zoo version for DFC 3.33.1 is hailo_model_zoo-2.18.0.
If v2.18.0 still isn’t working, could you share the error message?
FYI: In developer zone we have the “Ask AI” which might be helpful in dedicated questions about our SDK and versions (and many more).
image

Thanks,
Michael.

hi, the complete colab notebook is at Google Colab . The notebook script executes ok until it hits the last cell with the command

 !hailomz compile \
--ckpt /content/best.onnx \\

--calib-path /content/dataset/valid/ \\

--yaml /content/hailo_model_zoo/cfg/networks/yolov8n.yaml \\

--classes 1 \\

--hw-arch hailo8l \\

--performance 

the error is as follows:

WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
E0000 00:00:1774655676.152034   47515 cuda_dnn.cc:8310] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
E0000 00:00:1774655676.162300   47515 cuda_blas.cc:1418] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
/usr/local/lib/python3.12/dist-packages/jaxlib/plugin_support.py:71: RuntimeWarning: JAX plugin jax_cuda12_plugin version 0.7.2 is installed, but it is not compatible with the installed jaxlib version 0.5.3, so it will not be used.
  warnings.warn(
<Hailo Model Zoo INFO> Start run for network yolov8n ...
<Hailo Model Zoo INFO> Initializing the hailo8l runner...
[info] Translation started on ONNX model yolov8n
[info] Restored ONNX model yolov8n (completion time: 00:00:00.57)
[info] Extracted ONNXRuntime meta-data for Hailo model (completion time: 00:00:01.32)
[info] Simplified ONNX model for a parsing retry attempt (completion time: 00:00:02.89)
[info] According to recommendations, retrying parsing with end node names: ['/model.22/Sigmoid', '/model.22/Concat'].
[info] Translation started on ONNX model yolov8n
[info] Restored ONNX model yolov8n (completion time: 00:00:00.07)
[info] Extracted ONNXRuntime meta-data for Hailo model (completion time: 00:00:00.60)
[info] Start nodes mapped from original model: 'images': 'yolov8n/input_layer1'.
[info] End nodes mapped from original model: '/model.22/Sigmoid', '/model.22/Concat'.
[info] Translation completed on ONNX model yolov8n (completion time: 00:00:01.46)
[info] Saved HAR to: /content/yolov8n.har
<Hailo Model Zoo INFO> Using generic alls script found in /usr/local/lib/python3.12/dist-packages/hailo_model_zoo/cfg/alls/generic/yolov8n.alls because there is no specific hardware alls
<Hailo Model Zoo INFO> Preparing calibration data...
[info] Loading model script commands to yolov8n from /usr/local/lib/python3.12/dist-packages/hailo_model_zoo/cfg/alls/generic/yolov8n.alls
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/dist-packages/hailo_sdk_client/sdk_backend/script_parser/model_script_parser.py", line 381, in parse_script
    script_grammar.parseString(input_script, parseAll=True)
  File "/usr/local/lib/python3.12/dist-packages/pyparsing/util.py", line 256, in _inner
    return fn(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/pyparsing/core.py", line 1197, in parse_string
    raise exc.with_traceback(None)
pyparsing.exceptions.ParseException: Expected end of text, found 'change'  (at char 64), (line:2, col:1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/hailomz", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/hailo_model_zoo/main.py", line 122, in main
    run(args)
  File "/usr/local/lib/python3.12/dist-packages/hailo_model_zoo/main.py", line 111, in run
    return handlers[args.command](args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/hailo_model_zoo/main_driver.py", line 255, in compile
    _ensure_optimized(runner, logger, args, network_info)
  File "/usr/local/lib/python3.12/dist-packages/hailo_model_zoo/main_driver.py", line 91, in _ensure_optimized
    optimize_model(
  File "/usr/local/lib/python3.12/dist-packages/hailo_model_zoo/core/main_utils.py", line 351, in optimize_model
    optimize_full_precision_model(runner, calib_feed_callback, logger, model_script, resize, input_conversion, classes)
  File "/usr/local/lib/python3.12/dist-packages/hailo_model_zoo/core/main_utils.py", line 315, in optimize_full_precision_model
    runner.load_model_script(model_script)
  File "/usr/local/lib/python3.12/dist-packages/hailo_sdk_common/states/states.py", line 16, in wrapped_func
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/hailo_sdk_client/runner/client_runner.py", line 502, in load_model_script
    self._sdk_backend.load_model_script_from_file(model_script, append)
  File "/usr/local/lib/python3.12/dist-packages/hailo_sdk_client/sdk_backend/sdk_backend.py", line 492, in load_model_script_from_file
    self._script_parser.parse_script_from_file(model_script_path, nms_config, append)
  File "/usr/local/lib/python3.12/dist-packages/hailo_sdk_client/sdk_backend/script_parser/model_script_parser.py", line 312, in parse_script_from_file
    return self.parse_script(f.read(), append, nms_config_file)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/hailo_sdk_client/sdk_backend/script_parser/model_script_parser.py", line 389, in parse_script
    raise BackendScriptParserException(f"Parsing failed at:\n{e.markInputline()}")
hailo_sdk_client.sdk_backend.sdk_backend_exceptions.BackendScriptParserException: Parsing failed at:
>!<change_output_activation(conv42,sigmoid)

Hi @user921.

Try following the guide below, they already solved a lot the issues you are seeing:

hi, Thanks for your reply. The guide at Guide to using the DFC to convert a modified YoloV11 on Google Colab is for object detection. Do you know a guide that will show me how to convert a segmentation yolov8 .pt file to a segmentation .hef file. Many thanks mike