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.

The LumiScan Training splash screen showing the HD Vision Systems logo, the text Loading LumiScan Training, and a progress bar
Figure 1. Fig. 11: LumiScan Training: Splash Screen

After loading, the main window opens (Fig. 12). Model conversion is started using the Model Conversion button.

The LumiScan Training Framework main window with the Select Config File and Process Status areas and the buttons Start Training, Start Testing, Start Inference, and Model Conversion
Figure 2. Fig. 12: LumiScan Training Framework: Main Window with 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.

The Model Conversion dialog with the fields ONNX model file, Calibration folder, and Output folder, each with a Browse button, as well as the Start Conversion button and the status Ready
Figure 3. Fig. 13: LumiScan Training: Model Conversion Dialog
Table 1. Table 3: LumiScan Training Model Conversion Parameters
Field Description

ONNX model file

The trained network in ONNX format. It is normally located in the folder specified by exportDirectory in the JSON Settings.

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 Model Conversion dialog during conversion, showing the Stop Conversion button, the status Converting, and the log console with container output
Figure 4. Fig. 14: LumiScan Training: Model Conversion in Progress
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.