Inception v4 is a member of the Inception family of image classification models. Compared to previous versions, it has a more uniform, simplified architecture and uses more Inception modules. Given an RGB image, the model classifies it into one of the 1000 ImageNet classes, returning a vector of 1001 output probabilities (index 0 is an unused background class).
This repository contains the Inception v4 model, quantized to int8 and compiled for NXP i.MX 8M Plus, i.MX 93,
i.MX 95, and i.MX 952 processors, together with the recipe used to regenerate the assets (recipe.sh) and an
inference example (example.py).
This is a quantized and compiled version of Inception v4, 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/models/tree/master/research/slim.
| Information | Value |
|---|---|
| Input shape | Color image (1, 299, 299, 3), uint8 |
| Input example | (Public domain picture) |
| Output shape | Vector of probabilities (1, 1001), uint8 quantized; dequantize with the tensor's scale / zero point |
| Output example | [[0, ..., 0, 252, 1, ..., 0]] -> Top class: boxer |
| FLOPS | 24.6 G OPS |
| Number of parameters | 43 M |
| File size (int8) | 40.9 MB (assets/quantized_tflite_model/inceptionv4_quant_int8.tflite) |
| Source framework | TensorFlow |
Output labels: 1000 ImageNet classes (offset by 1 for the unused background class); see labels.py.
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 i.MX 8M Plus asset (assets/imx8mplus/inceptionv4_quant_int8.tflite) is identical to the
hardware-independent int8 model, also provided for host (x86) inference at
assets/quantized_tflite_model/inceptionv4_quant_int8.tflite.
This model inherits all limitations from the original Inception v4 model. Additional limitations:
The original Inception v4 model was trained by its authors on the ImageNet dataset. No additional retraining was performed by NXP; the int8 quantized checkpoint used in this repository is downloaded as-is from the pre-quantized version published by the TensorFlow authors on Kaggle.
An example of how to run inference on a host PC is in example.py. Install the dependencies from
requirements.txt first.
# Run on PC:
python example.py -m assets/quantized_tflite_model/inceptionv4_quant_int8.tflite -i example_input.jpg
example.py accepts the following arguments:
-m, --model (default: assets/quantized_tflite_model/inceptionv4_quant_int8.tflite): path to the
TFLite model file.-i, --input (default: example_input.jpg): path to the input image.-o, --output (default: none): optional path to write the top predictions as text.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 script takes two optional positional arguments:
bash recipe.sh [IMX_ETHOS_U_VELA_TAG] [EIQ_NEUTRON_SDK_VERSION]
defaulting to lf-6.18.20_2.0.0 and 3.2.3 respectively. For example:
bash recipe.sh lf-6.18.37_2.1.0 3.2.3
recipe.sh downloads the pre-quantized int8 model from Kaggle, then generates:
assets/quantized_tflite_model/inceptionv4_quant_int8.tflite - hardware-independent int8 model (also used
for i.MX 8M Plus, at assets/imx8mplus/inceptionv4_quant_int8.tflite).assets/imx93/<IMX_ETHOS_U_VELA_TAG>/inceptionv4_quant_int8_vela.tflite - Vela-compiled for i.MX 93.assets/imx95/<EIQ_NEUTRON_SDK_VERSION>/inceptionv4_quant_int8_converted.tflite - Neutron-converted for
i.MX 95.assets/imx952/<EIQ_NEUTRON_SDK_VERSION>/inceptionv4_quant_int8_converted.tflite - Neutron-converted for
i.MX 952.This model is released under the Apache License 2.0 (see LICENSE), the same license as the original TensorFlow models - Inception v4 model.
If you use this model, please cite both this work and the original model:
@inproceedings{szegedy2017inception,
title={Inception-v4, inception-resnet and the impact of residual connections on learning},
author={Szegedy, Christian and Ioffe, Sergey and Vanhoucke, Vincent and Alemi, Alexander},
booktitle={Proceedings of the AAAI conference on artificial intelligence},
volume={31},
number={1},
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}
}