I’m trying to compile YOLOv8n for Hailo8L

I am trying to compile and optimize a custom YOLOv8n model for Hailo8L using hailomz. Here’s what I have attempted so far:

  1. Compile directly from ONNX

    • Command: hailomz compile --ckpt yolov8n.onnx --yaml yolov8n.yaml --hw-arch hailo8l

    • Error: Parsing failed at nms_postprocess_end_nodes in the .alls script.

  2. Optimize using HAR file

    • Command: hailomz optimize --har yolov8n_custom.har --hw-arch hailo8l yolov8n

    • Error: HailoNNException: The layer named yolov8n/conv41 doesn't exist.

  3. Using NMS config from Hailo examples

    • Tried using JSON from postprocess_config folder

    • Error during calibration: ValueError: None values not supported.

  4. Reduced calibration dataset / CPU-only optimization

    • Dataset: 64 images, optimization level reduced to 0

    • Error: Post-processing layer fails, optimization incomplete.

I’m trying “https://community.hailo.ai/t/convert-to-hef-for-hailo8l-unable-to-compile-yolov8-onnx-model-with-hailomz-model-script-not-found/17613”. There have been many attempts. The task was to detect birds. The yolo network was trained. 1. Python script for train : “import torch
from ultralytics import YOLO
import os

def main():

Проверка доступных GPU

if torch.cuda.is_available():
gpus = list(range(torch.cuda.device_count()))
device = “,”.join(map(str, gpus)) # “0,1,2,3,4,5,6,7”
else:
device = “cpu”
gpus =

print(f" Используем устройство: {device}, GPU: {len(gpus)}")

# Путь к директории с предыдущими результатами обучения
checkpoint_dir = "runs/detect/train"

# Определение последней сохранённой модели для продолжения обучения
last_checkpoint = None
if os.path.exists(checkpoint_dir):
    checkpoints = [f for f in os.listdir(checkpoint_dir) if f.endswith(".pt")]
    if checkpoints:
        last_checkpoint = os.path.join(checkpoint_dir, sorted(checkpoints)[-1])
        print(f" Продолжаем обучение с модели: {last_checkpoint}")
    else:
        print("⚠️ Нет сохранённых моделей для продолжения обучения.")
else:
    print("⚠️ Директория с результатами обучения не найдена.")

# Загрузка модели
model = YOLO("yolov8n.pt")  # или путь к собственной модели

# Если есть сохранённая модель, продолжаем с неё
if last_checkpoint:
    model.load(last_checkpoint)

# Обучение
model.train(
    data="dataset_bird.yaml",
    epochs=300,
    imgsz=640,
    batch=512,
    workers=8,
    device=device,
    optimizer="AdamW",
    lr0=0.0005,
    patience=50,
    cos_lr=True,
    augment=True,
    dropout=0.1
)

if name == “main”:
main()“.

2. dataset_bird.yaml: “path: .

train: train/
val: valid/
test: test/

names:
0: bird“.

  1. Result train: “Validating /mnt/ramdisk/Dataset_bird_2/Birds/runs/detect/train/weights/best.pt…
    Ultralytics 8.3.195  Python-3.10.12 torch-2.1.0+cu118 CUDA:0 (NVIDIA A2, 14891MiB)
    CUDA:1 (NVIDIA A2, 14891MiB)
    CUDA:2 (NVIDIA A2, 14891MiB)
    CUDA:3 (NVIDIA A2, 14891MiB)
    CUDA:4 (NVIDIA A2, 14891MiB)
    CUDA:5 (NVIDIA A2, 14891MiB)
    CUDA:6 (NVIDIA A2, 14891MiB)
    CUDA:7 (NVIDIA A2, 14891MiB)
    Model summary (fused): 72 layers, 3,005,843 parameters, 0 gradients, 8.1 GFLOPs
    Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 4/4 0.7it/s 6.0s
    all 469 486 0.892 0.934 0.964 0.666
    Speed: 0.2ms preprocess, 7.5ms inference, 0.0ms loss, 0.8ms postprocess per image
    Results saved to /mnt/ramdisk/Dataset_bird_2/Birds/runs/detect/train“.
  2. download GitHub - hailo-ai/hailo_model_zoo at v2.16 for hailo8l.

Question:
I have a custom YOLOv8n model in .pt format and I want to run it on a Raspberry Pi 5 with a Hailo8L accelerator for bird detection.

What is the correct workflow to convert a .pt PyTorch model to a Hailo-compatible format (HEF/HAR) for Hailo8L?

How can I deploy and run the compiled model efficiently on Raspberry Pi 5?

I am a beginner in this field and do not understand how to use this hailo8l device in practice for scientific purposes.

Hi @Anton_Pivovarov

At DeGirum (a SW partner of Hailo), we developed a cloud compiler to help users convert YOLO checkpoints to hef: Early Access to DeGirum Cloud Compiler. Please see if you find it helpful for your use case.

1 Like