Supplier eBooks

STMicroelectronics - Intelligence at the Edge

Issue link: https://resources.mouser.com/i/1481902

Contents of this Issue

Navigation

Page 25 of 33

Intelligence at the Edge 26 What if a pre-trained model isn't available? ST also offers various function packs that include application-oriented code examples around important use cases, such as computer vision, sensing, and condition monitoring. For example, FP-AI-VISION1 is the function pack featuring examples of computer vision applications based on convolutional neural networks (CNN), which run on the STM32H747I-DISCO Discovery Kit connected to the B-CAMS-OMV camera module bundle. The application examples provided in this function pack include food recognition, person presence detection, and people counting. Using person presence detection as an example, there are two projects inside the "..\FP-AI-VISION1_ Vx.x.x\Projects\STM32H747I-DISCO\Applications\ PersonDetection\" folder; one is based on MobileNet v1, and the other is based on MobileNet v2. Each project can be opened with the user's favorite IDE, STM32CubeIDE, IAR EWARM, or Keil MDK to explore and modify the code, as well as to build and run the project on the target device. There are also several NN models included in this function pack, both 32-bit floating-point model and 8-bit quantized model, which are built on the open-source MobileNets. They can be found inside the "..\FP-AI- VISION1_Vx.x.x\Utilities\AI_resources\" folder. If a pre-trained model exists and an engineer wants to develop their own application, they can install STM32CubeMX from st.com and the X-CUBE-AI expansion package from STM32CubeMX's embedded software packages manager. They first select their target STM32 using the MCU selector tool that includes a filter for AI, which analyzes the NN model to identify the best candidate MCU choices. After selecting the target device, one creates the project and enables the X-CUBE-AI component for the project. The current version of X-CUBE-AI tool can generate three kinds of projects: System Performance projects that run on the STM32 MCU and accurately measure the NN inference CPU load and memory usage; Validation projects that validate incrementally the results returned by the NN, stimulated with random or user test data on the desktop PC and/or STM32 MCU embedded environment; and Application Template projects that support the building of AI-based applications. It is important to ensure there is no accuracy loss after the optimization and conversion. By choosing the validation project application, for example, all the AI-related settings will be automatically configured, including the USART peripheral that is used for the virtual COM port. Inside the X-CUBE-AI configuration interface, the network model can be added and analyzed. For the current version, Keras and TensorFlow Lite models are natively supported, and other frameworks are supported through ONNX format. Users can also choose between the STM32Cube.AI runtime or TensorFlow Lite Micro runtime. After performing the analysis, the tool lists the model's complexity with the number of MACC, and the usage of both internal and external Flash and RAM memory. It can also show the topology of the model and the graph of memory usage. If the memory footprint is too large, a built-in compression function is provided inside the tool, which can compress the weight and bias by a factor of 4 or 8 using a weight-sharing-based algorithm. The advantage of this approach is to have a quick compression process, but the result is not lossless, and the global accuracy can be impacted. The validation process helps quantify the loss. To do this, two execution modes are provided. The "validation on desktop" mode runs on the host PC and allows the comparison of the original NN model with its generated X86 C model (this mode is also available for other applications); while the "validation on target" mode runs on the target device and compares the NN model with the C model. It requires a validation STM32Cube function pack with AI application for Computer Vision

Articles in this issue

Links on this page

view archives of Supplier eBooks - STMicroelectronics - Intelligence at the Edge