EfficientNet is a family of image classification models that scale network depth, width, and resolution together using a single compound coefficient [1]. EfficientNet-lite is a variant optimized for mobile and edge devices. Given an RGB image, the network returns a vector of 1001 class probabilities (1000 ImageNet classes plus a background class) [2].
This repository contains the EfficientNet-lite0 variant, quantized to int8 and compiled for NXP platforms:
i.MX 8M Plus, i.MX 93, i.MX 95, and i.MX 952. It also contains the script used to download and compile these
assets (recipe.sh) and an inference example (example.py).
This is a quantized and compiled version of EfficientNet-lite0 from the TensorFlow EfficientNet-lite repository, optimized for NXP i.MX 8M Plus, i.MX 93, i.MX 95, and i.MX 952 processors.
This model is a derivative work with the following changes from the original:
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.Original model available at: https://github.com/tensorflow/tpu/blob/master/models/official/efficientnet/lite/README.md.
| Information | Value |
|---|---|
| Input shape | RGB image (1, 224, 224, 3), uint8 |
| Input example | (Picture by Shizhao under CC BY-SA 3.0 license) |
| Output shape | Vector of class probabilities (1, 1001), uint8 quantized; dequantize with the tensor's scale / zero point. 1000 ImageNet classes offset by 1 background class, see labels.py. |
| Output example | [[0, 0, 255, 0, ..., 0]] -> Top class: giant panda |
| FLOPS | 814 MOPS |
| Number of parameters | 4.7 M |
| File size (int8) | 5.3 MB (assets/quantized_tflite_model/efficientnet-lite0-int8.tflite) |
| Source framework | TensorFlow |
All 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 same information is captured in release_manifest.json.
| Asset | Runtime | Precision | HW target | BSP & SDK versions | Link to asset |
|---|---|---|---|---|---|
| i.MX 8M Plus Quantized | LiteRT | INT8 | i.MX 8M Plus | - | 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 | 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 | Download |
| i.MX 95 Precompiled | LiteRT | INT8 | i.MX 95 | BSP lf-6.18.20_2.0.0, Neutron SDK v3.1.3 | Download |
| i.MX 95 Precompiled | LiteRT | INT8 | i.MX 95 | BSP lf-6.18.37_2.1.0, Neutron SDK v3.2.1 | Download |
| i.MX 95 Precompiled | LiteRT | INT8 | i.MX 95 | BSP lf-6.18.37_2.1.0, Neutron SDK v3.2.3 | Download |
| i.MX 952 Precompiled | LiteRT | INT8 | i.MX 952 | BSP lf-6.18.20_2.0.0, Neutron SDK v3.1.3 | Download |
| i.MX 952 Precompiled | LiteRT | INT8 | i.MX 952 | BSP lf-6.18.37_2.1.0, Neutron SDK v3.2.1 | Download |
| i.MX 952 Precompiled | LiteRT | INT8 | i.MX 952 | BSP lf-6.18.37_2.1.0, Neutron SDK v3.2.3 | Download |
The hardware-independent int8 model is also provided for host (x86) inference and as the input to the
compilers: assets/quantized_tflite_model/efficientnet-lite0-int8.tflite (identical to the i.MX 8M Plus asset).
This model inherits all limitations from the original EfficientNet-lite0 model. Additional limitations:
The model was trained by the original authors on the ImageNet dataset [2], according to the model source. No retraining is performed by NXP; the published int8 checkpoint is used as-is. The original training procedure is described in the EfficientNet TPU tutorial.
An example of how to use the model on a host PC is in example.py:
python example.py -m assets/quantized_tflite_model/efficientnet-lite0-int8.tflite -i example_input.jpg
To run the models on an i.MX MPU target with the NPU delegates, see the i.MX Machine Learning User Guide.
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/
To download the pre-quantized int8 model and compile it for all supported platforms, run:
bash recipe.sh
The Vela tag and eIQ Neutron SDK version can be passed as positional arguments (defaulting to
lf-6.18.20_2.0.0 and 3.2.3 respectively):
bash recipe.sh [IMX_ETHOS_U_VELA_TAG] [EIQ_NEUTRON_SDK_VERSION]
The generated files are:
assets/quantized_tflite_model/efficientnet-lite0-int8.tflite - hardware-independent int8 modelassets/imx8mplus/efficientnet-lite0-int8.tflite - int8 model for i.MX 8M Plus (identical to the
hardware-independent int8 model)assets/imx93/<IMX_ETHOS_U_VELA_TAG>/efficientnet-lite0-int8_vela.tflite - Vela-compiled for i.MX 93assets/imx95/<EIQ_NEUTRON_SDK_VERSION>/efficientnet-lite0-int8_converted.tflite - Neutron-converted for
i.MX 95assets/imx952/<EIQ_NEUTRON_SDK_VERSION>/efficientnet-lite0-int8_converted.tflite - Neutron-converted for
i.MX 952This model is released under the Apache License 2.0, the same license as the original EfficientNet-lite model.
If you use this model, please cite both this work and the original model:
@inproceedings{tan2019efficientnet,
title={Efficientnet: Rethinking model scaling for convolutional neural networks},
author={Tan, Mingxing and Le, Quoc},
booktitle={International conference on machine learning},
pages={6105--6114},
year={2019},
organization={PmLR}
}
@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}
}