Translating
First, the model needs to be parsed from a .pth format into onnx, run convert_pth_to_onnx.py with the pytorch model.
Parsing
Use the translated .onnx model file to parse it to a .har (Hailo archive) file. Go to /hailo
Run:
. parse_model.sh "path_to_.onnx_model"
Optimization
To optimize the model we first need to create the calibration set so the model will know what data types to expect as input and calibrates the weights correctly when optimizing.
Go to hailo/2.create_calibration_set_FinalRun:
# Create a directory with preprocessed faces resized to 224x224 as the model expects
python3 preprocess_images.py
# create the calibration set as a .npy array file
python3 prepare_calibration_set_FLOAT32.py
Go to hailo/3.optimization_Final
Run:
# Optimize the model
. optimize_model.sh --hw-arch 'hardware architecture' --calib-set-path 'calibration set' --output-har-path 'output file name' 'input file
# For help run
. optimize_model.sh
Compilation
Go to hailo/4.compilationRun:
# Compile the model
. compile_model.sh --hw-arch 'hardware architecture' --output-dir output 'input_file'
# For help run
. compile_model.sh