CenterNet MobileNetV2 FPN
Overview
CenterNet is a one-stage, anchor-free object detector that represents each object by the center point of its bounding box. This repository ships the CenterNet MobileNetV2 FPN 512x512 variant from the TensorFlow Model Garden, quantized to int8 and compiled for NXP i.MX platforms (i.MX 8M Plus, i.MX 93, i.MX 95 and i.MX 952).
The model takes a 512x512 RGB image and produces raw heatmap, box-size and offset tensors; the
detection post-processing (heatmap top-K decoding and non-maximum suppression) is not part of
the graph. See example.py for a reference implementation of box decoding and NMS.
Key Features
- One-stage anchor-free object detector for 512x512 inputs.
- Detects the 80 COCO object classes.
- Fully quantized int8 model with int8 input and float32 output.
- Post-processing (top-K decoding + NMS) performed outside the graph.
- Compiled for i.MX 93 Ethos-U65 NPU and converted for i.MX 95 / i.MX 952 Neutron NPU.
Model Description
CenterNet detects each object as a keypoint (the center of the bounding box) and regresses the box size and center offset from a set of raw output tensors. The MobileNetV2 FPN backbone keeps the model lightweight and suitable for embedded MPUs. The backbone can be swapped for another one (e.g. ResNet) by picking a different checkpoint from the TF2 detection zoo.
- Base Model: CenterNet MobileNetV2 FPN 512x512
- Original Model Authors: The TensorFlow Authors / TensorFlow Model Garden contributors
- Original License: Apache-2.0
- Modified by: NXP
Modifications
This model is a derivative work with the following changes from the original:
- Graph surgery: A patch (
centernet.patch) strips the in-graph post-processing fromexport_tflite_graph_lib_tf2.pyso the exported graph returns the raw heatmap, box-size and offset tensors instead of decoded detections. The box decoding (top-K) and NMS are performed outside the graph inexample.py/evaluate.py. - Quantization: Full post-training int8 quantization (int8 weights/activations) with int8 input and float32 output. Calibration uses 100 random images sampled from the COCO 2017 validation set, resized to 512x512.
- Compilation: Compiled for i.MX 93 (Arm Ethos-U65 NPU) using the NXP Vela tool with
--accelerator-config ethos-u65-256 --optimise Performance, BSP tagslf-6.18.20_2.0.0andlf-6.18.37_2.1.0. - Compilation: Converted for i.MX 95 and i.MX 952 (eIQ Neutron NPU) using the eIQ Neutron SDK,
versions
3.1.3,3.2.1and3.2.3.
Original model available at: TensorFlow Model Garden TF2 Detection Zoo.
Model Information
| Information | Value |
|---|---|
| Input shape | RGB image (1, 512, 512, 3), int8 quantized |
| Input example | (Image source, Public domain) |
| Output shape | Five float32 tensors, including the raw heatmap, box-size and offset tensors used to decode detections (and other unused intermediate tensors left over from the removed post-processing graph). See example.py for the exact output indices and decoding logic. |
| Output example | |
| FLOPS | 4.72 G |
| Number of parameters | 2.36 M |
| File size (int8) | 2.8 MB |
| Source framework | TensorFlow (TensorFlow Model Garden) |
Supported Hardware and Software Configurations
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/centernet.tflite) is the same int8 model as the host
reference model assets/quantized_tflite_model/centernet.tflite; the latter is also the input to
the i.MX 93 / i.MX 95 / i.MX 952 compilation steps and is used for host (x86) testing with
example.py and evaluate.py.
Limitations and Biases
- Task scope: This model only detects the 80 COCO object classes; it has no notion of objects outside that taxonomy.
- Post-processing outside the graph: Box decoding (top-K) and non-maximum suppression are not
part of the exported graph and must be reproduced by the integrator, as shown in
example.py/evaluate.py. Differences in this external post-processing (score threshold, IoU threshold, max detections) can change the final detections even if the underlying graph output is identical. - Training data bias: The model is trained on the COCO dataset, which is biased towards common everyday objects and scenes photographed in a Western, internet-sourced context; performance on underrepresented object categories, scenes or demographics is not guaranteed.
Training
The original model was trained by the TensorFlow Model Garden contributors on the COCO dataset [3], which features 80 object classes, as described in the TF2 detection zoo. NXP did not retrain the model; only graph surgery, quantization and compilation were performed, as described in Modifications. Instructions to re-train the network can be found in the original repository.
Evaluation
The quantized int8 model (assets/quantized_tflite_model/centernet.tflite) can be evaluated on a
PC with evaluate.py, which runs inference on the COCO 2017 validation images, decodes the raw
heatmap/size/offset tensors and applies NMS outside the graph (score threshold 0.0, IoU threshold
0.5), and reports COCO bounding-box mAP using pycocotools.
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/
To regenerate the int8 TFLite model (int8 input, float32 output) and compile it for all supported platforms, run:
bash recipe.sh [VELA_TAG] [NEUTRON_VERSION]
# e.g. default: bash recipe.sh lf-6.18.20_2.0.0 3.2.3
To export another input resolution, change INPUT_SIZE in recipe.sh (and the resize call inside
its calibration-data generator).
This will produce:
assets/quantized_tflite_model/centernet.tflite- int8 model for i.MX 8M Plusassets/imx93/<vela-tag>/centernet_vela.tflite- Vela-compiled for i.MX 93assets/imx95/<neutron-version>/centernet_converted.tflite- Neutron-converted for i.MX 95assets/imx952/<neutron-version>/centernet_converted.tflite- Neutron-converted for i.MX 952
An example showing how to run detection on an image is in example.py (run on a PC):
python example.py -m assets/quantized_tflite_model/centernet.tflite -i example_input.jpg -o example_output.jpg
example.py accepts -m/--model (default assets/quantized_tflite_model/centernet.tflite),
-i/--input (default example_input.jpg), -o/--output (default example_output.jpg),
-l/--labels (default coco-labels-2014_2017.txt) and -t/--threshold (default 0.4).
To evaluate the model on the COCO 2017 validation set on a PC, download the validation images and annotations and run:
python evaluate.py -m assets/quantized_tflite_model/centernet.tflite \
-d PATH/TO/val2017 -a PATH/TO/annotations/instances_val2017.json
Please refer to the i.MX Machine Learning User Guide for details on running models on each target platform.
License
This model is released under the MIT License, see LICENSE. The original CenterNet
MobileNetV2 FPN model from the TensorFlow Model Garden is released under the Apache License
2.0, see MODEL_LICENSE.
Citation
If you use this model, please cite both this work and the original model:
- Xingyi Zhou, Dequan Wang, and Philipp Krahenbuhl. "Objects as Points." arXiv preprint arXiv:1904.07850, 2019.
- Sandler, Mark, et al. "MobileNetV2: Inverted Residuals and Linear Bottlenecks." Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition. 2018.
- Lin, Tsung-Yi, et al. "Microsoft COCO: Common Objects in Context." European Conference on Computer Vision. Springer, Cham, 2014.
@inproceedings{zhou2019objects,
title={Objects as Points},
author={Zhou, Xingyi and Wang, Dequan and Kr{\"a}henb{\"u}hl, Philipp},
booktitle={arXiv preprint arXiv:1904.07850},
year={2019}
}
@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={Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition},
year={2018}
}
@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 = {Computer Vision -- ECCV 2014},
pages = {740--755},
year = {2014},
publisher = {Springer International Publishing},
address = {Cham},
doi = {10.1007/978-3-319-10602-1_48}
}