This article describes how to automatize machine learning model code generation and validation through X-CUBE-AI Command Line Interface (CLI). The example is provided for Windows thanks using batch script, however it can be easily adapted to other operating system or through Python. More information on CLI can be found in the embedded documentation.
1. Requirements & installations
- X-CUBE-AI latest version (latest tested v7.2)
- STM32CubeIDE latest version (latest tested v1.10.0)
- A STM32 evaluation board, for this example: NUCLEO-H723ZG
- A model (Keras .h5, tensorflow lite .tflite or ONNX). For this example we used a MobileNet v1 0.25 quantized with input of image input of 128x128x3.
You can download the model: mobilenet_v1_0.25_128_quantized.tflite.
Once X-CUBE-AI is X-CUBE-AI installed as well as STM32CubeIDE, please note the installation paths, usually by default on Windows (replacing username by your Windows user account name and adapting to your tool version):
- For X-CUBE-AI: C:\Users\username\STM32Cube\Repository\Packs\STMicroelectronics\X-CUBE-AI\7.2.0
- For STM32CubeIDE: C:\ST\STM32CubeIDE_1.10.0\STM32CubeIDE\
2. Validation application generation
In order to generate the initial validation project for the targeted board, we are using the STM32CubeMX with X-CUBE-AI plugin. Select