YOLACT-Edge
Overview
YOLACT-Edge is a lightweight, real-time instance
segmentation model based on the YOLACT architecture. Given an RGB image, it predicts bounding boxes,
per-class scores, prototype masks and mask coefficients for every detected object; the final per-instance
masks are assembled from these outputs in a post-processing step (see example.py).
This repository ships the MobileNetV2 backbone variant of YOLACT-Edge, quantized to int8 and compiled for NXP i.MX MPUs:
- i.MX 8M Plus as a LiteRT (
.tflite) model. - i.MX 93 as Vela-compiled LiteRT models for the Ethos-U65 NPU.
- i.MX 95 / i.MX 952 as Neutron-converted LiteRT models for the eIQ Neutron NPU.
It also contains the scripts used to regenerate these assets (recipe.sh) and an inference example
(example.py). Other YOLACT-Edge backbones can be substituted; see Modifications below.
Key Features
- Real-time instance segmentation with a lightweight MobileNetV2 backbone
- Produces bounding boxes and per-instance segmentation masks for 80 COCO object classes
- Fully int8 quantized with int8 input and float32 outputs
- Compiled for the i.MX 93 Ethos-U65 NPU (Vela) and converted for the i.MX 95 / i.MX 952 eIQ Neutron NPU
Model Description
This is a quantized and compiled version of the YOLACT-Edge (MobileNetV2 backbone) instance segmentation model, optimized for NXP i.MX 8M Plus, i.MX 93, i.MX 95, and i.MX 952 processors.
- Base Model: haotian-liu/yolact_edge
- Original Model Authors: Haotian Liu and Rafael A. Rivera-Soto
- Original License: MIT
- Modified by: NXP
Modifications
This model is a derivative work with the following changes from the original:
- Format conversion: PyTorch -> ONNX (pre-exported by a third party, see below) -> TensorFlow (via onnx2tf) -> TensorFlow Lite.
- Quantization: Full int8 post-training quantization with int8 input and float32 output, calibrated on 100 random images from the COCO 2017 validation set.
- Compilation (i.MX 93): Compiled with Vela for the
Ethos-U65 NPU, tags
lf-6.18.20_2.0.0andlf-6.18.37_2.1.0. - Compilation (i.MX 95 / i.MX 952): Converted with the eIQ Neutron SDK versions
3.1.3,3.2.1and3.2.3for the eIQ Neutron NPU. - Post-processing: Non-maximum suppression and mask assembly from the prototype masks and mask
coefficients are performed outside the graph (see
example.py).
Original model available at: https://github.com/haotian-liu/yolact_edge.
Note: The pre-exported ONNX model used by
recipe.sh(MobileNetV2 backbone) comes from a third-party release that also contains other YOLACT-Edge backbones. To use a different backbone, download the matchingyolact_edge_<backbone>_54_800000.onnxfile and update the file name inrecipe.sh.
Model Information
| Information | Value |
|---|---|
| Input shape | RGB image (1, 550, 550, 3), int8 |
| Input example | (Image source, Public domain) |
| Output shape | Boxes (1, 19248, 4); scores (1, 80, 19248); protos (1, 138, 138, 32); mask coefficients (1, 19248, 32), all float32. The final instance masks are assembled in post-processing. See example.py to decode them. |
| Output example | |
| FLOPS | ~17 GOPS at the 550x550 inference resolution, as defined by the original authors |
| Number of parameters | Not published by the original authors |
| File size (int8) | 8.3 MB (assets/quantized_tflite_model/YOLACT-Edge.tflite) |
| Source framework | PyTorch |
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 hardware-independent int8 model is also provided for host (x86) inference and as the input to the
compilers above: assets/quantized_tflite_model/YOLACT-Edge.tflite. The assets/imx8mplus/YOLACT-Edge.tflite
file listed above is the same file (it is a symlink to assets/quantized_tflite_model/YOLACT-Edge.tflite).
Limitations and Biases
This model inherits all limitations from the original YOLACT-Edge model. Additional limitations:
- Task scope: Instance segmentation over the 80 COCO object classes only. The model does not perform classification or detection of classes outside this set.
- Dataset bias: The model is trained on the COCO dataset, so detection and segmentation quality may vary for object categories, scenes, or demographic groups that are under-represented in that dataset.
Training
The model was trained on the COCO dataset, which features 80 object classes, by the original authors of YOLACT-Edge. NXP did not retrain this model; it only quantized and compiled the pre-trained weights.
Evaluation
There is no evaluation script in this repository. The original authors' accuracy figures for this MobileNetV2-backbone variant, measured on the floating-point model, are published at haotian-liu/yolact_edge.
Download and Run
Running the example
An example of how to use the model on a PC is in example.py. Install the dependencies from
requirements.txt first.
python example.py -m assets/quantized_tflite_model/YOLACT-Edge.tflite -i example_input.jpg -o example_output.jpg
-m/--model, -i/--input and -o/--output all default to the values shown above, so
python example.py with no arguments also works from the repository root.
To run the models on an i.MX MPU target with the NPU delegates, see the i.MX Machine Learning User Guide.
Regenerating the assets with recipe.sh
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 every asset with the default toolchain versions, run:
bash recipe.sh
The Vela tag and eIQ Neutron SDK version can be passed as optional positional arguments (defaulting to
lf-6.18.20_2.0.0 and 3.2.3 respectively):
bash recipe.sh lf-6.18.37_2.1.0 3.2.3
The recipe downloads the pre-exported ONNX model and the COCO 2017 validation images used for
calibration. Set the COCO_VAL_DIR environment variable to an existing local copy of the val2017/
directory to skip the download.
The generated files are:
assets/quantized_tflite_model/YOLACT-Edge.tflite- hardware-independent int8 model (PyTorch -> ONNX -> TensorFlow Lite via onnx2tf)assets/imx93/<VELA_TAG>/YOLACT-Edge_vela.tflite- Vela-compiled model for i.MX 93assets/imx95/<NEUTRON_SDK_VERSION>/YOLACT-Edge_converted.tflite- Neutron-converted model for i.MX 95assets/imx952/<NEUTRON_SDK_VERSION>/YOLACT-Edge_converted.tflite- Neutron-converted model for i.MX 952
License
This repository, including the quantized and compiled assets and the scripts it contains, is released under the MIT License (see LICENSE). The original haotian-liu/yolact_edge model is also released under the MIT License (see MODEL_LICENSE).
Citation
If you use this model, please cite both this work and the original model:
- D. Bolya, C. Zhou, F. Xiao and Y. J. Lee, "YOLACT: Real-time Instance Segmentation," IEEE/CVF International Conference on Computer Vision (ICCV), 2019.
- M. Sandler, A. Howard, M. Zhu, A. Zhmoginov and L.-C. Chen, "MobileNetV2: Inverted Residuals and Linear Bottlenecks," IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2018.
- T.-Y. Lin et al., "Microsoft COCO: Common Objects in Context," European Conference on Computer Vision (ECCV), 2014.
@INPROCEEDINGS{9010373,
author={Bolya, Daniel and Zhou, Chong and Xiao, Fanyi and Lee, Yong Jae},
booktitle={2019 IEEE/CVF International Conference on Computer Vision (ICCV)},
title={YOLACT: Real-Time Instance Segmentation},
year={2019},
volume={},
number={},
pages={9156-9165},
keywords={Prototypes;Real-time systems;Image segmentation;Object detection;Detectors;Computational modeling;Task analysis},
doi={10.1109/ICCV.2019.00925}}
@INPROCEEDINGS {8578572,
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 (CVPR) },
title = {{ MobileNetV2: Inverted Residuals and Linear Bottlenecks }},
year = {2018},
volume = {},
ISSN = {},
pages = {4510-4520},
month =Jun}
@InProceedings{10.1007/978-3-319-10602-1_48,
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",
title="Microsoft COCO: Common Objects in Context",
booktitle="Computer Vision -- ECCV 2014",
year="2014",
}