MobileNet V1
Introduction
MobileNet V1 [1] is a family of lightweight convolutional neural networks for image classification.
We use the weights from the implementation found on
Kaggle.
Key Features of MobileNetv1
- Depth wise separable convolutions: Normal convolutions are splitted along depth convolutions and 1x1 point convolutions. Effectively reducing both the total number of weights and the computation time.
- Global Hyper-parameters: Two global hyper-parameters, width multiplier $\alpha$ and Resolution multiplier $\rho$, were introduced to reduce the width of the layers as well as the dimension of the input image respectively.
- Latency-Accuracy: MobileNet is engineered to have have good performance without sacrificing accuracy, making it a good choice for Edge Device deployment.
Model Description
This repository contains pre-compiled model files optimized for NXP i.MX 93 and 95 processors..
- Base Model: TensorFlow/mobilenet_v1_1.0_224
- Original Model Authors: Google
- Original License: Apache-2.0
- Modified by: NXP
Modifications
This model is a derivative work with the following changes from the original:
- Compilation: Compiled for i.MX 93 with Ethos-U65 NPU using Vela tool
- Compilation: Compiled for i.MX 95 with eIQ Neutron NPU using eIQ Neutron SDK
Model Information
| Information | Value |
|---|
| Input shape | Color image (H, W, 3) (e.g., 224x224x3, or 128x128x3) |
| Input example | (Public domain image) |
| Output shape | Vector of probabilities shape (1, 1001). Labels can be found in labels.py. |
| Output example | Output tensor: [[0., 0., 0., 58, ... 0., 0., 0. ]] |
Version and changelog
Initial release of quantized and converted int8 models.
Tested configurations
Tested configurations
The int8 model has been tested on i.MX 8M Plus, i.MX 93, i.MX 95 and i.MX 952 using benchmark-model
(see
i.MX Machine Learning User Guide).
Training and evaluation
The model has been trained and evaluated on the ImageNet dataset [2].
The original training procedure is detailed
here.
Accuracy on ImageNet validation set
Evaluation was performed on all 50 000 ImageNet ILSVRC 2012 validation images using
the evaluate.py script included in this repository. 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.
| Model variant | Input size | Top-1 accuracy | Top-5 accuracy |
|---|
| mobilenet_v1_0.25_128_quant | 128x128 | 40.31% | 65.16% |
| mobilenet_v1_1.0_224_quant | 224x224 | 68.85% | 87.91% |
Conversion/Quantization
The model is downloaded in an archive which contains the quantized model TensorFlow model. See
the source of the model for information on the quantization procedure that was used. Then, the model is compiled for the target hardware using the appropriate compiler toolchain by the included
recipe.sh script.
Download and run
To re-create the TFLite model fully quantized in int8 with int8 input and float32 output, run bash recipe.sh.
The TFLite model file for i.MX 8M Plus is original_model/mobilenet_v1_0.25_128_quant.tflite. The files for i.MX 93 are in the imx93 directory. The files for i.MX 95 are in the imx95 directory.
An example of how to use the model is in
example.py. The output labels are listed in
labels.py. Please refer to
i.MX Machine Learning User Guide for details on how to run the models on each platform.
Full on-device examples leveraging GStreamer/NNStreamer and this model can be found in
nxp-nnstreamer-examples on GitHub
Origin
[1] Howard, Andrew G., et al. "Mobilenets: Efficient convolutional neural networks for mobile vision applications." arXiv preprint arXiv:1704.04861 (2017).
[2] Deng, Jia, et al. "Imagenet: A large-scale hierarchical image database." 2009 IEEE conference on computer vision and pattern recognition. Ieee, 2009.