Model Conversion: ONNX to Hailo
A network that has been trained and exported as an ONNX file can be converted into a Hailo model for execution on a Hailo TPU.
The conversion runs inside the Hailo conversion container. It is therefore only available if the Hailo PlugIn (Installer-LumiScanTraining-HailoPlugIn) is installed in addition to LumiScan Training. If the plugin is missing, the application reports that the podman command or the required conversion image could not be found.
Starting the Program
Start LumiScan Training as described in LumiScan Training Installation. The splash screen (Fig. 11) is displayed while the application is loading.
After loading, the main window opens (Fig. 12). Model conversion is started using the Model Conversion button.
Preparing the Calibration Images
During conversion, the network is quantized. A set of calibration images is required to determine the value ranges that occur within the network.
| The calibration images must have the same resolution as the training images. Images with a different resolution can result in an unusable model. |
The quality and representativeness of the calibration images influence the accuracy of the converted model. Therefore:
-
Record the images under real production conditions, using the same camera, optics, working distance, and objects as in later operation.
-
Include representative lighting conditions. For example, use different exposure times if the exposure time also varies during operation, or record image sets under different ambient lighting conditions.
Store the images in a single folder, referred to below as the calibration folder. Supported image formats include .png, .jpg, .jpeg, .bmp, and .tiff.
Performing the Conversion
Click Model Conversion to open the Model Conversion (ONNX → Hailo) dialog (Fig. 13). Use the corresponding Browse buttons to select the three paths described in Table 3.
| Field | Description |
|---|---|
ONNX model file |
The trained network in ONNX format. It is normally located in the folder specified by |
Calibration folder |
The folder containing the calibration images described in the previous section. |
Output folder |
The folder in which the converted model and associated files are stored. By default, the folder containing the ONNX file is selected. |
Click Start Conversion to begin the conversion (Fig. 14).
While the conversion is running:
-
The status changes to Converting….
-
The Start Conversion button changes to Stop Conversion, which can be used to cancel the running conversion.
-
The input fields are disabled.
-
The progress of the conversion is displayed in the log console at the bottom of the window.
| The first conversion can take longer because the Podman machine is started first if it is not already running. |
The conversion container can access the C: drive directly. If the ONNX file, calibration folder, or output folder is located on another drive, for example E:, or on a network share, the required files are automatically transferred to the container before conversion. The results are transferred back after conversion is complete. No additional configuration is required. The log console displays the additional transfer steps, and the overall conversion time may increase depending on the size of the calibration data.
|
When the conversion is complete, the message Conversion finished successfully. is displayed.
The following files are created in the output folder, where <name> is the name of the ONNX file:
-
<name>.hef- Model for the Hailo TPU. -
<name>.har- Intermediate archive created during conversion. -
<name>_hailo.onnx- ONNX model adapted for Hailo. -
convert_parameters.json- Parameters used for the conversion.
If the conversion fails, the exit code is displayed in the status line and additional information is shown in the log console.
If exit code 137 occurs, the Podman machine has run out of memory during quantization. The log console also provides information on how to assign additional memory to the virtual machine.
If you encounter problems during model conversion, contact HD Vision Systems.