Part 1: Introduction
The eIQ Neutron Neural Processing Unit (NPU) is a highly scalable accelerator core architecture that provides machine learning (ML) acceleration. Compared to traditional MCUs like the Kinetis series and LPC series, the MCX N series marks the first integration of NXP's eIQ® Neutron NPU for ML acceleration. The eIQ Neutron NPU offers up to 38 times faster machine learning inference performance compared to a standalone CPU core. Specifically, the MCX N94 can execute 4.8G (150MHz * 4 * 4 * 2) INT8 operations per second.
Hardware Environment:
Development Board: FRDM-MCXN947
Display: 3.5" TFT LCD (PAR-LCD-S035)
Camera: OV7670
Instructions for putting together demo
Software Environment:
eIQ Neutron SDK
MCUXpresso IDE
Label CIFAR10 Image Demo on NXP App Code Hub
Part 2: Basic Model Classification Training and Deployment
The main content is divided into three steps: model training, model converting, and model deployment.
1. Dataset Preparation
A fruit dataset is prepared for a simple demonstration of binary classification between apples and bananas. The training set and test set are split in an 8:2 ratio.
2. Use a model generation tool like eIQ Model Creator or TensorFlow to train a model based on the image dataset.
3. Convert to TensorFlow Lite for Neutron (.tflite)
Unzip the eIQ Neutron SDK and use the neutron-converter command line tool to convert the trained TensorFlow Lite model to an eIQ Neutron enabled TFLite model:
neutron-converter --target mcxn94x --input fruit_model.tflite --output fruit_model_npu.tflite
4. Deploy the Model to the Label CIFAR10 Image Project
This example is based on a machine learning algorithm supported by the MCXN947, which can label images captured from a camera and display the type of object at the bottom of the LCD. The model is trained on the CIFAR10 dataset, which supports 10 categories of images:
"Airplane", "Automobile", "Bird", "Cat", "Deer", "Dog", "Frog", "Horse", "Ship", "Truck".
a. Open MCUXpresso IDE and import the Label CIFAR10 Image project from the Application Code Hub, as follows:
b. Select the project, click on "GitHub link" -> "Next", as shown below:
c. Set the save path, click "Next" -> "Next" -> "Finish", as shown below:
d. After successful import, click on the "source" folder -> "model" folder, open "model_data.s", and copy the model file converted using eIQ Neutron SDK into the "model" folder. Modify the name of the imported model (the name of the converted model) in "model_data.s", as shown below:
e. Click on the "source" folder -> "model" folder -> open the "labels.h" file. Modify the "labels[]" array to match the order of labels model output as shown below:
f. The eIQ middleware in the project needs to be updated to be compatible with the version of the eIQ Neutron SDK used to convert the TFLite model. Update the eIQ middleware folder in the project, including the eIQ Neutron libraries, as described in this Community post or in this lab.
f. Compile the project and download it to the development board.
Part 3: Results
Part 4: Summary
By efficiently utilizing the powerful performance of the eIQ Neutron NPU and the eIQ enablement tools like eIQ Neutron SDK, developers can significantly streamline the entire process from model training to deployment. This not only accelerates the development cycle of machine learning applications but also enhances their performance and reliability. Therefore, for developers looking to implement efficient machine learning applications on MCX N-series edge devices, mastering these technologies and tools is crucial.
We can also refer to the video for detailed steps using the deprecated eIQ Toolkit to generate a model. https://www.bilibili.com/video/BV1SS411N7Hv?t=12.9 For more vision examples on MCX N see this Community Post.
View full article