yolov8n unable to compile in .hef, hailo_sdk_common.states.states.InvalidStateException

I have installed hailort-4.21.0-cp310-cp310-linux_x86_64.whl, .deb + hailo-model-zoo-2.15.0 from cloned git repo.
I’m using Python 3.10.12.

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.03)
[info] Extracted ONNXRuntime meta-data for Hailo model (completion time: 00:00:00.15)
[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': 'yolov8n/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 yolov8n (completion time: 00:00:00.40)
[info] Appending model script commands to yolov8n from string
[info] Added nms postprocess command to model script.
Traceback (most recent call last):
  File "/home/user1/Lalit/ek/export_hailo/hailo_model_zoo/exp_hailo/bin/hailomz", line 33, in <module>
    sys.exit(load_entry_point('hailo-model-zoo', 'console_scripts', 'hailomz')())
  File "/home/user1/Lalit/ek/export_hailo/hailo_model_zoo/hailo_model_zoo/main.py", line 122, in main
    run(args)
  File "/home/user1/Lalit/ek/export_hailo/hailo_model_zoo/hailo_model_zoo/main.py", line 111, in run
    return handlers[args.command](args)
  File "/home/user1/Lalit/ek/export_hailo/hailo_model_zoo/hailo_model_zoo/main_driver.py", line 248, in compile
    _ensure_optimized(runner, logger, args, network_info)
  File "/home/user1/Lalit/ek/export_hailo/hailo_model_zoo/hailo_model_zoo/main_driver.py", line 73, in _ensure_optimized
    _ensure_parsed(runner, logger, network_info, args)
  File "/home/user1/Lalit/ek/export_hailo/hailo_model_zoo/hailo_model_zoo/main_driver.py", line 108, in _ensure_parsed
    parse_model(runner, network_info, ckpt_path=args.ckpt_path, results_dir=args.results_dir, logger=logger)
  File "/home/user1/Lalit/ek/export_hailo/hailo_model_zoo/hailo_model_zoo/core/main_utils.py", line 148, in parse_model
    runner.save_har(results_dir / f"{network_info.network.network_name}.har")
  File "/home/user1/Lalit/ek/export_hailo/hailo_model_zoo/exp_hailo/lib/python3.10/site-packages/hailo_sdk_common/states/states.py", line 13, in wrapped_func
    raise InvalidStateException(
hailo_sdk_common.states.states.InvalidStateException: The execution of save_har is not available under the state: uninitialized

command used :

hailomz compile yolov8n \
    --ckpt best.onnx \
    --calib-path "/media/user1/Local storage 10/data/ek/v0_lp_dataset/images/train/" \
    --hw-arch hailo8l \
    --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

another run:

(exp_hailo) user1@dell-X670E-AORUS-MASTER:~/Lalit/ek/export_hailo/hailo_model_zoo$ hailomz compile yolov8n --ckpt best.onnx --calib-path "/media/user1/Local storage 10/data/ek/v0_lp_dataset/images/train/" --hw-arch hailo8l
<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.03)
[info] Extracted ONNXRuntime meta-data for Hailo model (completion time: 00:00:00.12)
[info] Simplified ONNX model for a parsing retry attempt (completion time: 00:00:00.34)
[info] According to recommendations, retrying parsing with end node names: ['/model.22/Concat_3'].
[info] Translation started on ONNX model yolov8n
[info] Restored ONNX model yolov8n (completion time: 00:00:00.02)
[info] Extracted ONNXRuntime meta-data for Hailo model (completion time: 00:00:00.09)
[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': 'yolov8n/input_layer1'.
[info] End nodes mapped from original model: '/model.22/Concat_3'.
[info] Translation completed on ONNX model yolov8n (completion time: 00:00:00.38)
[info] Translation started on ONNX model yolov8n
[info] Restored ONNX model yolov8n (completion time: 00:00:00.02)
[info] Extracted ONNXRuntime meta-data for Hailo model (completion time: 00:00:00.11)
[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': 'yolov8n/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 yolov8n (completion time: 00:00:00.38)
[info] Appending model script commands to yolov8n from string
[info] Added nms postprocess command to model script.
Traceback (most recent call last):
  File "/home/user1/Lalit/ek/export_hailo/hailo_model_zoo/exp_hailo/bin/hailomz", line 33, in <module>
    sys.exit(load_entry_point('hailo-model-zoo', 'console_scripts', 'hailomz')())
  File "/home/user1/Lalit/ek/export_hailo/hailo_model_zoo/hailo_model_zoo/main.py", line 122, in main
    run(args)
  File "/home/user1/Lalit/ek/export_hailo/hailo_model_zoo/hailo_model_zoo/main.py", line 111, in run
    return handlers[args.command](args)
  File "/home/user1/Lalit/ek/export_hailo/hailo_model_zoo/hailo_model_zoo/main_driver.py", line 248, in compile
    _ensure_optimized(runner, logger, args, network_info)
  File "/home/user1/Lalit/ek/export_hailo/hailo_model_zoo/hailo_model_zoo/main_driver.py", line 73, in _ensure_optimized
    _ensure_parsed(runner, logger, network_info, args)
  File "/home/user1/Lalit/ek/export_hailo/hailo_model_zoo/hailo_model_zoo/main_driver.py", line 108, in _ensure_parsed
    parse_model(runner, network_info, ckpt_path=args.ckpt_path, results_dir=args.results_dir, logger=logger)
  File "/home/user1/Lalit/ek/export_hailo/hailo_model_zoo/hailo_model_zoo/core/main_utils.py", line 148, in parse_model
    runner.save_har(results_dir / f"{network_info.network.network_name}.har")
  File "/home/user1/Lalit/ek/export_hailo/hailo_model_zoo/exp_hailo/lib/python3.10/site-packages/hailo_sdk_common/states/states.py", line 13, in wrapped_func
    raise InvalidStateException(
hailo_sdk_common.states.states.InvalidStateException: The execution of save_har is not available under the state: uninitialized

I have the same problem; I followed the tutorial “Raspberry Pi AI Kit: ONNX to HEF Conversion” exactly.

Environment creation process(on ubuntu 20.04 PC):
conda create --name hailo python=3.10
conda activate hailo
sudo pip install pygraphviz
pip3 install hailo_dataflow_compiler-3.30.0-py3-none-linux_x86_64.whl
git clone GitHub - hailo-ai/hailo_model_zoo: The Hailo Model Zoo includes pre-trained models and a full building and evaluation environment
cd hailo_model_zoo
pip install -e .
sudo dpkg -i hailort_4.21.0_amd64.deb
pip install hailort-4.21.0-cp310-cp310-linux_x86_64.whl



(hailo) user@ubuntu01:~/hailo_model_zoo$ hailomz compile yolov8s --ckpt=best.onnx --hw-arch hailo8l --calib-path train/images  --classes 3 --performance
<Hailo Model Zoo INFO> Start run for network yolov8s ...
<Hailo Model Zoo INFO> Initializing the hailo8l runner...
[info] Translation started on ONNX model yolov8s
[info] Restored ONNX model yolov8s (completion time: 00:00:00.11)
[info] Extracted ONNXRuntime meta-data for Hailo model (completion time: 00:00:00.36)
[info] Simplified ONNX model for a parsing retry attempt (completion time: 00:00:00.71)
[info] According to recommendations, retrying parsing with end node names: ['/model.22/Concat_3'].
[info] Translation started on ONNX model yolov8s
[info] Restored ONNX model yolov8s (completion time: 00:00:00.08)
[info] Extracted ONNXRuntime meta-data for Hailo model (completion time: 00:00:00.35)
[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/Concat_3'.
[info] Translation completed on ONNX model yolov8s (completion time: 00:00:00.62)
[info] Translation started on ONNX model yolov8s
[info] Restored ONNX model yolov8s (completion time: 00:00:00.08)
[info] Extracted ONNXRuntime meta-data for Hailo model (completion time: 00:00:00.35)
[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:00.62)
[info] Appending model script commands to yolov8s from string
[info] Added nms postprocess command to model script.
Traceback (most recent call last):
  File "/home/user/anaconda3/envs/hailo/bin/hailomz", line 33, in <module>
    sys.exit(load_entry_point('hailo-model-zoo', 'console_scripts', 'hailomz')())
  File "/home/user/hailo_model_zoo/hailo_model_zoo/main.py", line 122, in main
    run(args)
  File "/home/user/hailo_model_zoo/hailo_model_zoo/main.py", line 111, in run
    return handlers[args.command](args)
  File "/home/user/hailo_model_zoo/hailo_model_zoo/main_driver.py", line 248, in compile
    _ensure_optimized(runner, logger, args, network_info)
  File "/home/user/hailo_model_zoo/hailo_model_zoo/main_driver.py", line 73, in _ensure_optimized
    _ensure_parsed(runner, logger, network_info, args)
  File "/home/user/hailo_model_zoo/hailo_model_zoo/main_driver.py", line 108, in _ensure_parsed
    parse_model(runner, network_info, ckpt_path=args.ckpt_path, results_dir=args.results_dir, logger=logger)
  File "/home/user/hailo_model_zoo/hailo_model_zoo/core/main_utils.py", line 148, in parse_model
    runner.save_har(results_dir / f"{network_info.network.network_name}.har")
  File "/home/user/anaconda3/envs/hailo/lib/python3.10/site-packages/hailo_sdk_common/states/states.py", line 13, in wrapped_func
    raise InvalidStateException(
hailo_sdk_common.states.states.InvalidStateException: The execution of save_har is not available under the state: uninitialized

@user167

solved this issue by installing these:

used this command:


hailomz compile yolov8n --ckpt best.onnx --calib-path "/media/user1/Local storage 10/data/ek/v0_lp_dataset/images/train/" --classes 7 --hw-arch hailo8l
1 Like

Sorry it was 3.31.0 pip install -U hailo_dataflow_compiler-3.31.0-py3-none-linux_x86_64.whl instead of Hailo Dataflow Compiler – Python package (whl) 3.30.0

this and --classes 7 resolved this

1 Like

Thanks for your helping.