SSDLite MobileNetV2
Overview
SSDLite MobileNetV2
is a lightweight real-time object detection model designed to run efficiently on mobile and embedded
devices. It combines the SSD (Single Shot MultiBox Detector)
architecture with a MobileNetV2 backbone, replacing the standard SSD
convolutions with depthwise-separable convolutions (hence "SSDLite") to reduce computation. Given an
RGB image, the model regresses bounding box coordinates and a class-score distribution over 91 COCO
categories for each of 1917 prior boxes; box decoding and non-maximum suppression (NMS) are not part of
the model graph (see example.py for a full post-processing implementation).
This repository contains a quantized int8 model, pre-compiled for NXP i.MX 8M Plus, i.MX 93, i.MX 95 and
i.MX 952 processors, at a fixed 300x300 input resolution. It also contains the scripts used to
regenerate these assets (recipe.sh), an inference example (example.py) and an evaluation script
(evaluate.py).
Model Description
This repository contains pre-compiled model files optimized for NXP i.MX 8M Plus, i.MX 93, i.MX 95, and i.MX 952 processors.
- Base Model: SSDLite MobileNetV2 COCO (2018-05-09)
- Original Model Authors: Google / TensorFlow Object Detection API team
- Original License: Apache-2.0
- Modified by: NXP
Modifications
This model is a derivative work with the following changes from the original:
- Pruning: the pre- and post-processing subgraphs (image decoder, box decoding, NMS) are removed; only the backbone and SSD prediction heads are retained.
- Format conversion: converted from the original TensorFlow 1 SavedModel to TensorFlow Lite.
- Quantization: full int8 post-training quantization (weights and activations int8, input/output
tensors float32), performed with TensorFlow 2.13.0. Calibration data is 100 images randomly sampled
from COCO val2017, resized to 300x300 and normalized with
image / 127.5 - 1. - Compilation (i.MX 93): compiled for the Arm Ethos-U65 NPU with the
Vela tool, tags
lf-6.18.20_2.0.0andlf-6.18.37_2.1.0. - Compilation (i.MX 95 / i.MX 952): converted for the eIQ Neutron NPU with the eIQ Neutron SDK,
versions
3.1.3,3.2.1and3.2.3.
Original model available at: SSDLite MobileNetV2 COCO (2018-05-09).
Model Information
| Information | Value |
|---|---|
| Input shape | RGB image (1, 300, 300, 3), float32 |
| Input example | (Image source: Wikimedia Commons, Public domain) |
| Output shape | 2 tensors, both float32: (1, 1917, 1, 4) raw (not decoded) bounding box coordinates, and (1, 1917, 91) per-box class scores. See example.py to decode them. |
| Output example | |
| FLOPS | 1.5G |
| Number of parameters | 4.3M |
| File size (int8) | 5.3 MB (5,578,432 bytes) |
| Source framework | TensorFlow 1 |
Supported Hardware and Software Configurations
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 assets/imx8mplus/ssdlite_mobilenet_v2_quant.tflite file is a symlink to the hardware-independent
int8 model at assets/quantized_tflite_model/ssdlite_mobilenet_v2_quant.tflite (identical bytes, same
sha256); that same hardware-independent file is also used for host (x86) inference and as the input to
the i.MX 93 / i.MX 95 / i.MX 952 compilers.
Limitations and Biases
This model inherits all limitations from the original SSDLite MobileNetV2 COCO model. Additional limitations:
- Task scope: general-purpose object detection over the 80 non-background COCO categories only; it is not tuned for any specific domain (for example faces, license plates, or industrial defects).
- Dataset bias: the model is trained on COCO. Detection quality may vary for object categories, scenes, or demographic groups that are under-represented in that dataset.
Training
The original SSDLite MobileNetV2 model was trained and evaluated by its authors on the COCO dataset [1], which features 80 object classes, according to the source of the model. NXP did not retrain this model; only quantization and compilation were performed (see Modifications). Instructions for re-training the original model can be found in the TensorFlow Detection Model Zoo.
Evaluation
evaluate.py evaluates the int8 quantized, hardware-independent model
(assets/quantized_tflite_model/ssdlite_mobilenet_v2_quant.tflite) on the COCO val2017 dataset, using
the LiteRT CPU runtime on a host PC. It downloads the COCO val2017 images and annotations, runs
inference and the same post-processing as example.py, and reports standard COCO detection metrics via
pycocotools.
python3 evaluate.py -m assets/quantized_tflite_model/ssdlite_mobilenet_v2_quant.tflite
Download and Run
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/
Regenerating the assets with recipe.sh
To regenerate the quantized model and all precompiled assets, run:
bash recipe.sh
This downloads the original TF1 SavedModel and COCO val2017 calibration images, performs int8 post-training quantization, and compiles/converts the result for i.MX 93, i.MX 95 and i.MX 952. The generated files are:
assets/quantized_tflite_model/ssdlite_mobilenet_v2_quant.tflite- hardware-independent int8 model, also used for i.MX 8M Plus (assets/imx8mplus/)assets/imx93/<VELA_TAG>/ssdlite_mobilenet_v2_quant_vela.tflite- Vela-compiled for i.MX 93assets/imx95/<NEUTRON_SDK_VERSION>/ssdlite_mobilenet_v2_quant_converted.tflite- Neutron-converted for i.MX 95assets/imx952/<NEUTRON_SDK_VERSION>/ssdlite_mobilenet_v2_quant_converted.tflite- Neutron-converted for i.MX 952
Running the example
An example of how to use the model is in example.py (run on a PC):
python3 example.py -m assets/quantized_tflite_model/ssdlite_mobilenet_v2_quant.tflite \
-i example_input.jpg -o example_output.jpg
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.
License
This model is released under the Apache License 2.0, the same license as the original SSDLite MobileNetV2 COCO (2018-05-09) model.
Citation
If you use this model, please cite both this work and the original model:
- T.-Y. Lin et al., "Microsoft COCO: Common Objects in Context," European Conference on Computer Vision (ECCV), Springer, Cham, 2014.
- M. Sandler, A. Howard, M. Zhu, A. Zhmoginov and L.-C. Chen, "MobileNetV2: Inverted Residuals and Linear Bottlenecks," Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2018.
- W. Liu et al., "SSD: Single Shot MultiBox Detector," Computer Vision - ECCV 2016: 14th European Conference, Amsterdam, The Netherlands, October 11-14, 2016, Springer International Publishing, 2016.
@inproceedings{lin2014microsoft,
title={Microsoft coco: Common objects in context},
author={Lin, Tsung-Yi and Maire, Michael and Belongie, Serge and Hays, James and Perona, Pietro and Ramanan, Deva and Doll{\'a}r, Piotr and Zitnick, C Lawrence},
booktitle={European conference on computer vision},
pages={740--755},
year={2014},
organization={Springer}
}
@inproceedings{sandler2018mobilenetv2,
title={Mobilenetv2: Inverted residuals and linear bottlenecks},
author={Sandler, Mark and Howard, Andrew and Zhu, Menglong and Zhmoginov, Andrey and Chen, Liang-Chieh},
booktitle={2018 IEEE/CVF conference on computer vision and pattern recognition},
pages={4510--4520},
year={2018},
organization={Ieee}
}
@inproceedings{liu2016ssd,
title={Ssd: Single shot multibox detector},
author={Liu, Wei and Anguelov, Dragomir and Erhan, Dumitru and Szegedy, Christian and Reed, Scott and Fu, Cheng-Yang and Berg, Alexander C},
booktitle={European conference on computer vision},
pages={21--37},
year={2016},
organization={Springer}
}