Instructions to use nxp/tiny-resnet-imx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use nxp/tiny-resnet-imx with LiteRT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Tiny ResNet (CIFAR-10)
Overview
Tiny ResNet is a small image-classification model from the MLPerf Tiny benchmark suite [2]. It is trained on the small 32x32 images of the CIFAR-10 dataset [1], distributed across 10 classes. Given an RGB image, the network returns a probability for each of the 10 CIFAR-10 classes. The model is designed for resource-constrained MCU/MPU deployment and is published as a pre-quantized int8 TFLite model by MLCommons.
This repository contains that int8 TFLite model, compiled for NXP i.MX 8M Plus, i.MX 93, i.MX 95, and
i.MX 952 processors, along with the script used to regenerate these assets (recipe.sh) and an inference
example (example.py).
Key Features
- Compact residual convolutional network for 32x32 RGB image classification
- 10-class CIFAR-10 classification
- ~78.7K parameters, ~25 MOPS
- int8 quantized (int8 input, int8 output) for accelerated NPU inference on NXP i.MX platforms
Model Description
This is a quantized and compiled version of the MLPerf Tiny ResNet image-classification model, optimized for NXP i.MX 8M Plus, i.MX 93, i.MX 95, and i.MX 952 processors.
- Base Model: MLPerf Tiny ResNet (image_classification)
- Original Model Authors: MLCommons
- Original License: Apache-2.0
- Modified by: NXP
Modifications
This model is a derivative work with the following changes from the original:
- Quantization: The int8 TFLite model (int8 input, int8 output) is provided directly by MLCommons; no local re-quantization or calibration dataset is used.
- Compilation (i.MX 93): compiled for the Ethos-U65 NPU using
Vela with 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 using the eIQ Neutron SDK
versions
3.1.3,3.2.1, and3.2.3.
Original model available at: https://github.com/mlcommons/tiny/tree/master/benchmark/training/image_classification.
Model Information
| Information | Value |
|---|---|
| Input shape | Color image (1, 32, 32, 3), dtype int8 |
| Input example | (Image from the CIFAR-10 dataset [1]) |
| Output shape | Vector of probabilities (1, 10), dtype int8 quantized; dequantize with the tensor's scale / zero point |
| Output example | [[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.996]] -> Top class: truck |
| FLOPS | 25 MOPS |
| Number of parameters | 78,666 |
| File size (int8) | 98,496 bytes (assets/quantized_tflite_model/pretrainedResnet_quant.tflite) |
| Source framework | TensorFlow / Keras |
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 at
assets/quantized_tflite_model/pretrainedResnet_quant.tflite. This file is byte-identical to
assets/imx8mplus/pretrainedResnet_quant.tflite (same sha256), since the i.MX 8M Plus VX delegate runs
the unmodified int8 graph.
Limitations and Biases
This model inherits all limitations from the original MLPerf Tiny ResNet model. Additional limitations:
- Task scope: 10-class CIFAR-10 image classification only; the model is not suited to other image classification tasks or different input resolutions without retraining.
- Dataset bias: The model is trained on CIFAR-10, a small, class-balanced dataset of generic object photos. Classification quality may vary for images that differ substantially from CIFAR-10 in style, lighting, or composition.
Training
The model was trained by MLCommons on the CIFAR-10 dataset [1]. Training scripts are available on the MLCommons Tiny GitHub page. NXP did not retrain the model; the int8 TFLite weights are used as published by MLCommons under the Apache-2.0 license.
Download and Run
Running the example
example.py runs classification on an image on a host PC and prints the predicted class. Install the
dependencies from requirements.txt first.
# Run on PC:
python example.py -m assets/quantized_tflite_model/pretrainedResnet_quant.tflite -i example_input.jpg
The output labels are listed in labels.py. An optional -o/--output flag writes the prediction to a
text file.
Please refer to the i.MX Machine Learning User Guide for details on how to run the models on each platform.
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 download the pre-quantized int8 model and compile the platform-specific variants, run:
bash recipe.sh
The Vela tag and eIQ Neutron SDK version can be passed as 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 generated files are:
assets/quantized_tflite_model/pretrainedResnet_quant.tflite- int8 model downloaded as-is from MLCommons, used for i.MX 8M Plus and host inference.assets/imx93/<VELA_TAG>/pretrainedResnet_quant_vela.tflite- Vela-compiled for i.MX 93.assets/imx95/<EIQ_NEUTRON_SDK_VERSION>/pretrainedResnet_quant_converted.tflite- Neutron-converted for i.MX 95.assets/imx952/<EIQ_NEUTRON_SDK_VERSION>/pretrainedResnet_quant_converted.tflite- Neutron-converted for i.MX 952.
License
This model, including the compiled assets and the scripts in this repository, is released under the Apache License 2.0 (see LICENSE), the same license as the original MLPerf Tiny ResNet model (see MODEL_LICENSE).
Citation
If you use this model, please cite both this work and the original model:
- Krizhevsky, Alex. "Learning Multiple Layers of Features from Tiny Images." 2009. https://www.cs.toronto.edu/~kriz/learning-features-2009-TR.pdf
- Banbury, Colby, et al. "MLPerf Tiny Benchmark." arXiv preprint arXiv:2106.07597 (2021). https://arxiv.org/abs/2106.07597
@article{krizhevsky2009learning,
title={Learning multiple layers of features from tiny images},
author={Krizhevsky, Alex and Hinton, Geoffrey and others},
year={2009},
publisher={Toronto, ON, Canada}
}
@article{banbury2021mlperf,
title={Mlperf tiny benchmark},
author={Banbury, Colby and Reddi, Vijay Janapa and Torelli, Peter and Holleman, Jeremy and Jeffries, Nat and Kiraly, Csaba and Montino, Pietro and Kanter, David and Ahmed, Sebastian and Pau, Danilo and others},
journal={arXiv preprint arXiv:2106.07597},
year={2021}
}
- Downloads last month
- 56
(Image from the CIFAR-10 dataset [1])