Hailo Model Zoo : hailomz API를 이용한 커스텀 U-Net 모델을 Hailo에서 동작가능한 바이너리파일(.hef)로 컴파일 및 테스트

(2025-07-17) 커스텀 모델 최적화 및 컴파일에 필요한 스크립트 내용은 공개 불가합니다.


실행환경

Build PC

  • CPU: Intel i7-1355U
  • RAM: 16G
  • OS: Ubuntu-22.04 LTS
  • Target Hailo System: Hailo8

Hailo Version

  • Hailo DFC: 3.27.0
  • Hailo Model Zoo: 2.11.0

사전설치

Hailo Dataflow Compiler

  • 헤일로에서 실행가능한 바이너리파일(.hef) 컴파일용 SDK
  • Parse - Optimize - Compile 단계로 구성
  • Log In • Hailo 다음 경로에서 개발자 로그인 후 Dataflow Compiler 설치
  • Dataflow Compiler v3.27.0 Install guid 를 따라 가상환경 생성 후 라이브러리 설치

Hailo Model Zoo

Hailo Ai Suite 를 설치하여 위 두 라이브러리 설치 가능


구조 및 컴파일

+full

준비물

커스텀 빌드를 위한 ONNX 파일 준비

커스텀 빌드를 위한 스크립트 파일 준비

  • custom_unet.yaml : 현재 디렉토리에 위치
  • custom_unet_carvana.yaml : {hailo_path}/hailo_model_zoo/cfg/base/ 에 위치
  • custom_unet_mobilenet_v2.alls : {hailo_path}/hailo_model_zoo/cfg/alls/generic/ 에 위치

커스텀 모델 학습에 사용된 데이터셋 준비

  • hailo model zoo 에서는 .tfrecord 파일을 지원하므로, 해당 포맷의 데이터셋 필요
  • carvana_dataset.tfrecord

Parse

  • 헤일로에서 이해하는 구문파일(.har)로 변환하는 과정
  • CKPTONNX 포맷을 지원하며 hailomz parse 명령어를 통해 실행함

hailomz parse

$ hailomz parse --help
 
positional arguments:
  model_name            Which network to run
  // Hailo Model Zoo에 사전 정의된 모델을 입력(자동 컴파일)
 
options:
  -h, --help            show this help message and exit
  --yaml YAML_PATH      Path to YAML for network configuration.By default
                        using the default configuration
  --ckpt CKPT_PATH      Path to onnx or ckpt to use for parsing. By
                        default using the model cache location
  --hw-arch             Which hw arch to run: hailo8 / hailo8l/ hailo15h/
                        hailo15m. By default using hailo8.
  --start-node-names START_NODE_NAMES [START_NODE_NAMES ...]
                        List of names of the first nodes to parse.
                        Example: --start-node-names <start_name1>
                        <start_name2> ...
  --end-node-names END_NODE_NAMES [END_NODE_NAMES ...]
                        List of nodes that indicate the parsing end. The
                        order determines the order of the outputs.
                        Example: --end-node-names <end_name1> <end_name2> ...

custom .onnx parsing

$ hailomz parse --ckpt ./unet_13_256.onnx --yaml custom_unet.yaml
  • hailomz parse 는 커스텀 모델의 아키텍처에서 start/end node를 자동으로 찾음
  • 찾지 못하는 경우에는 custom_unet.yaml 스크립트에 직접 작성해야함

Results

  • custom_unet_256.har 파일 생성됨


Optimize

  • Parse 과정을 통해 변환된 .har 파일을 파라미터 양자화 및 입출력 데이터처리 등의 최적화를 통해 헤일로 시스템에서 높은 성능을 보장하도록하는 과정
  • 최적화를 위해 기존 모델의 훈련 시 사용한 데이터셋이 필요
  • 양자화 학습 및 입출력 데이터처리를 위한 함수는 .alls 파일에 작성됨
  • GPU 환경을 권장함

hailomz optimize

$ hailomz optimize --help
 
positional arguments:
  model_name            Which network to run
  // Hailo Model Zoo에 사전 정의된 모델을 입력(자동 컴파일)
 
options:
  -h, --help            show this help message and exit
  --yaml YAML_PATH      Path to YAML for network configuration.
  --ckpt CKPT_PATH      Path to onnx or ckpt to use for parsing.
  --hw-arch             hailo8 / hailo8l/ hailo15h/ hailo15m. By default using hailo8.
  --start-node-names START_NODE_NAMES [START_NODE_NAMES ...]
                        List of names of the first nodes to parse. Example: 
                        --start-node-names <start_name1> <start_name2>...
  --end-node-names END_NODE_NAMES [END_NODE_NAMES ...]
                        List of nodes that indicate the parsing end. The order determines the order of the outputs.
                        Example: --end-node-names <end_name1> <end_name2> ...
  --har HAR_PATH        Use external har file
  --calib-path CALIB_PATH
                        Path to external tfrecord for calibration or a directory containing images in jpg or png format
  --model-script MODEL_SCRIPT_PATH
                        Path to model script to use. By default using the model script specified
                        in the network YAML configuration
  --performance         Enable flag for benchmark performance
  --resize RESIZE [RESIZE ...]
                        Add input resize from given [h,w]
  --input-conversion {nv12_to_rgb,yuy2_to_rgb,rgbx_to_rgb}
                        Add input conversion from given type
  --classes             Number of classes for NMS configuration

custom .har optimize

hailomz optimize --har custom_unet_256.har --yaml custom_unet.yaml

Results

  • 최적화 과정을 마친 .har 파일이 생성됨

+full


++Optional

모델 구조 확인하기

  • hailo profiler 를 이용해 optimize 과정을 마친 .har 파일의 모델 구조를 확인할 수 있음
hailo profiler custom_unet_256.har
  • 생성되는 html 파일을 열어 다음과 같이 확인 가능

+full


Compile

  • Optimize 완료된 .har 파일을 헤일로에서 실행가능한 바이너리파일인 .hef 파일로 컴파일하는 과정
  • ONNX 파일을 입력으로, 전 과정을 한꺼번에 실행도 가능

har file compile

hailomz compile --har custom_unet.har --yaml custom_unet.yaml

Results

+full


Execute


참고


EmbeddedAI HailoDeepLearningQuantization