MobileNet V1 [1] is a family of lightweight convolutional neural networks for image classification. Given an RGB image, the network outputs a vector of 1001 class probabilities (1000 ImageNet classes plus a background class).
This repository contains pre-compiled model files optimized for NXP i.MX application processors (MPUs) as
well as C header files for NXP MCUs running TensorFlow Lite Micro. Two width/resolution configurations of
the network are shipped: the full-size model (width multiplier 1.0, 224x224 input) and the smallest model
(width multiplier 0.25, 128x128 input), the latter being the one used for the MCU targets. It also contains
the scripts used to regenerate these assets (recipe.sh), an inference example (example.py) and an
evaluation script (evaluate.py).
This is a quantized and compiled version of the TensorFlow/mobilenet_v1 family of models, optimized for NXP i.MX MPUs and i.MX RT / MCX MCUs.
This model is a derivative work with the following changes from the original:
assets/quantized_tflite_model_mcu/mobilenet_v1_0.25_128_quant_int8_mcu.tflite).lf-6.18.20_2.0.0 and lf-6.18.37_2.1.0.3.1.3, 3.2.1 and
3.2.3 for the eIQ Neutron NPU.3.2.2 and 3.2.3.xxd -i) for direct inclusion
in a firmware image, since MCUs have no file system. The i.MX RT1170 target uses the plain int8 model
without NPU compilation.Original model available at: TensorFlow Model Garden - MobileNet V1.
| Information | Value |
|---|---|
| Input shape | RGB image (1, H, W, 3); uint8 for MPU targets (H,W = 128x128 or 224x224), int8 for the MCU target (128x128) |
| Input example | (Public domain image) |
| Output shape | Vector of 1001 class probabilities (1, 1001); uint8 quantized on MPU targets (dequantize with the tensor's scale / zero point), float32 on the MCU target. Labels are in labels.py / labels_mobilenet.txt. |
| Output example | Output tensor: [[0., 0., 0., 58, ... 0., 0., 0.]] |
| FLOPS | ~28 MFLOPs (width 0.25, 128x128 variant); ~1.14 GFLOPs (width 1.0, 224x224 variant) |
| Number of parameters | ~470K (width 0.25, 128x128 variant); ~4.24M (width 1.0, 224x224 variant) |
| File size (int8) | 486 KB (0.25/128 variant, assets/quantized_tflite_model/mobilenet_v1_0.25_128_quant.tflite); 4.08 MB (1.0/224 variant, assets/quantized_tflite_model/mobilenet_v1_1.0_224_quant.tflite) |
All MPU models run with the eIQ LiteRT (TensorFlow Lite) runtime and the corresponding NPU delegate (VX for i.MX 8M Plus, Ethos-U for i.MX 93, Neutron for i.MX 95 / i.MX 952). The MCU headers run with TensorFlow Lite Micro through the eIQ Media Processing Pipeline (MPP). Each MPU directory holds one asset per listed resolution. The same information is captured in release_manifest.json.
| Asset | Runtime | Precision | HW target | BSP & SDK versions | Resolutions | Link to asset |
|---|---|---|---|---|---|---|
| i.MX 8M Plus Quantized | LiteRT | INT8 | i.MX 8M Plus | - | 128x128, 224x224 | Download |
| i.MX 93 Precompiled | LiteRT | INT8 | i.MX 93 | BSP lf-6.18.20_2.0.0, VELA_TAG = lf-6.18.20_2.0.0 | 128x128, 224x224 | Download |
| i.MX 93 Precompiled | LiteRT | INT8 | i.MX 93 | BSP lf-6.18.37_2.1.0, VELA_TAG = lf-6.18.37_2.1.0 | 128x128, 224x224 | Download |
| i.MX 95 Precompiled | LiteRT | INT8 | i.MX 95 | BSP lf-6.18.20_2.0.0, Neutron SDK v3.1.3 | 128x128, 224x224 | Download |
| i.MX 95 Precompiled | LiteRT | INT8 | i.MX 95 | BSP lf-6.18.37_2.1.0, Neutron SDK v3.2.1 | 128x128, 224x224 | Download |
| i.MX 95 Precompiled | LiteRT | INT8 | i.MX 95 | BSP lf-6.18.37_2.1.0, Neutron SDK v3.2.3 | 128x128, 224x224 | Download |
| i.MX 952 Precompiled | LiteRT | INT8 | i.MX 952 | BSP lf-6.18.20_2.0.0, Neutron SDK v3.1.3 | 128x128, 224x224 | Download |
| i.MX 952 Precompiled | LiteRT | INT8 | i.MX 952 | BSP lf-6.18.37_2.1.0, Neutron SDK v3.2.1 | 128x128, 224x224 | Download |
| i.MX 952 Precompiled | LiteRT | INT8 | i.MX 952 | BSP lf-6.18.37_2.1.0, Neutron SDK v3.2.3 | 128x128, 224x224 | Download |
| i.MX RT1170 C header | TensorFlow Lite Micro | INT8 | i.MX RT1170 | MCUXpresso SDK 26.09.00 | 128x128 | Download |
| i.MX RT700 C header | TensorFlow Lite Micro | INT8 | i.MX RT700 | Neutron SDK v3.2.2, MCUXpresso SDK 26.09.00 | 128x128 | Download |
| i.MX RT700 C header | TensorFlow Lite Micro | INT8 | i.MX RT700 | Neutron SDK v3.2.3, MCUXpresso SDK 26.09.00 | 128x128 | Download |
| MCX-N947 C header | TensorFlow Lite Micro | INT8 | MCX-N947 | Neutron SDK v3.2.2, MCUXpresso SDK 26.09.00 | 128x128 | Download |
| MCX-N947 C header | TensorFlow Lite Micro | INT8 | MCX-N947 | Neutron SDK v3.2.3, MCUXpresso SDK 26.09.00 | 128x128 | Download |
The assets/imx8mplus/ files are symbolic links to the hardware-independent int8 models provided for host
(x86) inference and as inputs to the compilers: assets/quantized_tflite_model/ (MPU quantization) and
assets/quantized_tflite_model_mcu/ (MCU quantization).
This model inherits all limitations from the original MobileNet V1 model. Additional limitations:
assets/quantized_tflite_model/ for other targets.The model was trained and evaluated by the original authors on the ImageNet dataset [2]. The original training procedure is detailed here. No additional NXP retraining was performed; NXP only quantized and compiled the publicly released weights.
evaluate.py computes Top-1 and Top-5 accuracy of a quantized int8 TFLite model on the ImageNet validation
set (50,000 images), using the hardware-independent models under assets/quantized_tflite_model/. It runs
on a host PC (x86) with the LiteRT CPU runtime. Preprocessing follows the standard ImageNet pipeline: resize
the shorter side to 146 px (128 model) or 256 px (224 model), then center-crop to the model input size.
python evaluate.py \
--model_path assets/quantized_tflite_model/mobilenet_v1_1.0_224_quant.tflite \
--imagenet_dir /path/to/imagenet
example.py runs classification on an image on a host PC and prints the recognized class.
python example.py --model_path assets/quantized_tflite_model/mobilenet_v1_0.25_128_quant.tflite --image example_input.jpg
--model_path defaults to mobilenet_v1_0.25_128_quant.tflite and --image defaults to
example_input.jpg. The output labels are listed in labels.py / labels_mobilenet.txt.
Please refer to the i.MX Machine Learning User Guide for details on how to run the models on each i.MX platform. Full on-device examples leveraging GStreamer/NNStreamer and this model can be found in nxp-nnstreamer-examples on GitHub.
The recipe installs the eIQ Neutron SDK from the NXP eIQ PyPI Distribution Portal. Configure pip once to use it:
python -m pip config --user set global.index https://eiq.nxp.com/repository
python -m pip config --user set global.index-url https://eiq.nxp.com/repository
python -m pip config --user set global.trusted-host eiq.nxp.com
python -m pip config --user set global.extra-index-url https://pypi.org/simple
python -m pip config --user set global.find-links https://eiq.nxp.com/repository/
recipe.sh builds both the MPU (Part A) and the MCU (Part B) artifacts. To re-create all the model files,
run:
bash recipe.sh [IMX_ETHOS_U_VELA_TAG] [EIQ_NEUTRON_SDK_VERSION] [EIQ_NEUTRON_SDK_VERSION_MCU]
The defaults are lf-6.18.20_2.0.0, 3.2.3 and 3.2.3 respectively. Part A downloads the pre-quantized
MobileNet V1 TFLite model (width and resolution set by the MODEL_SCALE / MODEL_INPUT_RESOLUTION
variables inside the script) and compiles it with Vela for i.MX 93 and with the eIQ Neutron converter for
i.MX 95 / i.MX 952. Part B compiles the base int8 MCU model with the eIQ Neutron Compiler for mcxn94x and
imxrt700, then converts every .tflite into a C header (xxd -i) with the NXP banner and the
alignment / linker-placement macros expected by the eIQ MPP example projects.
The TFLite model file for i.MX 8M Plus is assets/quantized_tflite_model/mobilenet_v1_0.25_128_quant.tflite
(or the 1.0/224 variant). The files for i.MX 93 are in the assets/imx93 directory, and the files for
i.MX 95 / i.MX 952 are in the assets/imx95 / assets/imx952 directories.
Besides the i.MX MPU files, this repository also ships the 0.25/128x128 MobileNet V1 variant for NXP MCUs
running TensorFlow Lite Micro. The shippable artifacts there are C header files (model byte arrays) that get compiled
directly into the firmware image. The base int8 MCU model
(assets/quantized_tflite_model_mcu/mobilenet_v1_0.25_128_quant_int8_mcu.tflite, int8 input / float32
output) is a different quantization of the same network than the MPU models, provided for reference and for
re-running the conversion.
| MCU | Core / Accelerator | Neutron target | Directory |
|---|---|---|---|
| i.MX RT1170 | Cortex-M7, CPU only | - | assets/rt1170/ |
| MCX-N947 | Neutron-16 (small NPU) | mcxn94x |
assets/mcxn947/<neutron_ver>/ |
| i.MX RT700 | Neutron-64 (large NPU) | imxrt700 |
assets/rt700/<neutron_ver>/ |
The i.MX RT1170 header uses the plain int8 model (no NPU), found under assets/rt1170/. The Neutron (NPU)
headers are versioned by the eIQ Neutron SDK used to compile them, into a version-named subdirectory
(assets/mcxn947/3.2.2/, assets/mcxn947/3.2.3/, assets/rt700/3.2.2/, assets/rt700/3.2.3/).
Each *_tflite.h is accompanied by a matching *_tflite_info.h metadata header, which exposes the
pre/post-processing constants the application needs (MOBILENET_INPUT_MEAN 128, MOBILENET_INPUT_STD 127,
MOBILENET_WIDTH / MOBILENET_HEIGHT 128, MOBILENET_TENSOR_SIZE 1001, MOBILENET_TENSOR_TYPE
MPP_TENSOR_TYPE_FLOAT32).
Ready-to-run application examples that use these models are included in the eIQ Media Processing Pipeline (MPP):
camera_mobilenet_view example (uses these models):
https://mcuxpresso.nxp.com/mcuxsdk/latest/html/examples/eiq_examples/mpp/camera_mobilenet_view/readme.htmlThis model is released under the Apache License 2.0 (see LICENSE), the same license as the original TensorFlow/mobilenet_v1 model.
If you use this model, please cite both this work and the original model:
@article{howard2017mobilenets,
title={Mobilenets: Efficient convolutional neural networks for mobile vision applications},
author={Howard, Andrew G and Zhu, Menglong and Chen, Bo and Kalenichenko, Dmitry and Wang, Weijun and Weyand, Tobias and Andreetto, Marco and Adam, Hartwig},
journal={arXiv preprint arXiv:1704.04861},
year={2017}
}
@inproceedings{deng2009imagenet,
title={Imagenet: A large-scale hierarchical image database},
author={Deng, Jia and Dong, Wei and Socher, Richard and Li, Li-Jia and Li, Kai and Fei-Fei, Li},
booktitle={2009 IEEE conference on computer vision and pattern recognition},
pages={248--255},
year={2009},
organization={Ieee}
}