11. Bring Your Own Model
This section explains how to use your own neural network with Tiny ML ModelZoo 1.5.0. There are two approaches.
Create a new architecture that plugs into the full pipeline (training, quantization, compilation). Either point
the config at your own .py file with custom_model_path (no source edits), or add a model class and a
model description to ModelZoo. Follow the step-by-step guide.
You already have a trained model from another framework. Skip the dataset and training steps and compile the ONNX file for a TI device.
11.1. Contents
- 11.1.1. Bring Your Own Model (BYOM)
- 11.1.1.1. Two Ways to Bring Your Own Model
- 11.1.1.2. Option A: Quick Start — Custom Model File
- 11.1.1.3. Option B: Permanent Addition to ModelZoo
- 11.1.1.4. Files You Will Change
- 11.1.1.5. Prerequisites
- 11.1.1.6. Step 1: Add the Model Class
- 11.1.1.7. Step 2: Add the Model Description
- 11.1.1.8. Step 3: Create a Config That Uses Your Model
- 11.1.1.9. Step 4: Train, Quantize and Compile
- 11.1.1.10. Step 5: Check the Results
- 11.1.1.11. Troubleshooting
- 11.1.1.12. Guidelines for Designing Your Model
- 11.1.2. Adding Models to ModelZoo
- 11.1.3. Compilation Only
11.2. Which approach do I need?
Use the ModelZoo approach when you want ModelMaker to train, quantize and test the model with your dataset. Start with a custom model file (
training.custom_model_path) to try an architecture quickly, then add it to the ModelZoo itself when you want it to show up with the other ModelZoo models and in the GUI.Use compilation only when the model is already trained (and, for NPU devices, already quantized) and you only need the compiled library for the device.
Important
A custom model file (custom_model_path) works with either install. Adding a model permanently to the
ModelZoo edits files in the tinyml-modelzoo source tree, so it needs the clone install
(pip install -e .). See Clone Installation. Compile-only needs just the normal
install (Wheel Installation).
11.3. Model requirements
NPU devices (for example F28P55): models have to follow the NPU rules to be accelerated, such as channel counts that are multiples of 4 and limits on kernel sizes. The full list is in NPU Configuration Guidelines for TI Neural Network Compiler. Layers that do not meet the rules fall back to the CPU.
Non-NPU devices: the architecture is more flexible, but keep the total parameter count within the device memory, and use layers the compiler supports. You can check the memory footprint before training with Memory Estimation.