Skip to content

cyclux/HailoConverter

Repository files navigation

Hailo ONNX to HEF Converter

This docker image can be used to convert an ONNX exported yolov8s model to Hailo's HEF format. It utilizes the Hailo Dataflow Compiler.

Pre-requisites

  • Docker
  • ONNX exported model (only yolov8s tested so far)
  • Calibration images

Usage

1. Train Model and Export

Train your model with Ultralytics and export it to ONNX format.

yolo export model=/path/to/trained/best.pt imgsz=640 format=onnx opset=11

For reference see:

2. Clone the repository

Note

The cloning takes longer than usual because of a large whl file.

git clone https://github.com/cyclux/HailoConverter.git
cd HailoConverter

3. Build the docker image

docker build -t hailo_converter .

4. Prepare model and calibration images

Place the ONNX model and calibration images (calibration_imgs folder) in the root directory of the repository.

Note

The calibration set should be real images that are a subset of the training dataset. They should be diverse and representative of the dataset. Max 64 images are used.

cp /path/to/best.onnx best.onnx
cp -r /path/to/calibration_imgs calibration_imgs

5. Run the docker image

Ensure that the current directory is where the ONNX model and calibration images are placed.

Important

They need to be named best.onnx and calibration_imgs.

docker run -v $(pwd):/workspace --gpus all --ipc=host hailo_converter:latest

This will run the following command inside the docker container:

hailomz compile --ckpt best.onnx --hw-arch hailo8l --calib-path calibration_imgs/ --yaml yolov8s_custom.yaml --model-script yolov8s_custom.alls --classes 1

Note

The Using deprecated NumPy API warning at the beginning can be ignored it seems.

Note

The compilation can take a considerable amount of time.

Once successful, the HEF model will be saved in the same directory.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published