Compile your own model
This walkthrough compiles TI's pretrained YOLOX-tiny-lite 8210, a model not included in the tested image's demo inventory. It does not reuse the precompiled 8200/8220 artifacts. You download the original ONNX model, calibrate and compile it on x86, compare outputs and transfer your newly created bundle to Mo62A. Continue to YOLO: deployment and quantization for the full-video application and business events.
First complete Set up the toolchain. All commands below run from the extracted zone-demo directory unless marked as board commands. Keep the host compiler, runtime libraries and C7x firmware on the documented compatibility baseline.
Keep architecture and weights matched
The model is TI's already-trained Lite variant, not a renamed standard Ultralytics export. Its existing COCO person class needs no training for this demonstration. New business classes may require training; train the matched architecture and weights before ONNX export and TIDL compilation. Replacing an activation is not a lossless conversion or a substitute for training.
For a different network, record its source/license, training weights, exporter/version, ONNX opset, input/output contract and CPU reference. Do not reuse this example's detection metadata or selected mixed-precision tensor names. See Known issues for operator evidence and validation boundaries.
1. Download the exact model
On x86:
source ./activate_host.sh ./host
python -B fetch_model.py --bundle work/bundle
python -B verify_inputs.py
fetch_model.py downloads the model and its matching .prototxt from TI's download server, using the pinned model-zoo source entry. The filename is yolox_tiny_lite_416x416_20220217_model.onnx. The download path's model-zoo version 11_02_00 is not the compiler version: this specific source model is compiled here with tools 11_02_17_00.
| Item | Exact contract |
|---|---|
| Source model | TI model-zoo revision 99f1bd6e434bdde9d26c3b0678ce368e69050ea3, model ID 8210 |
| ONNX | IR 7, opset 11, original 418 nodes |
| Input | input, float32, NCHW [1,3,416,416] |
| Preprocessing | RGB values 0–255; aspect-preserving resize; top-left placement in a 416 × 416 canvas padded with 114; no division by 255 |
| Outputs | dets[N,5]: x1, y1, x2, y2, score; labels[N]: zero-based COCO class index |
| Detection metadata | Matching .prototxt, meta_arch_type=6; person index 0 |
The downloaded ONNX SHA256 is c9d2a3fdb21bed079a74029441d83235ddd910c82f1e7b9de5a2a5998bc3eeca; metadata SHA256 is bd8d5558af8c982da135579cd84851f9d95382aab6f089df7a49edacb846f142. The script checks both and refuses to replace an existing mismatched file. The source manifest preserves model and input provenance. Model/tool licenses are separate from the documentation license.
2. Prepare separate calibration and evaluation inputs
The archive contains two prepared warehouse clips by domdomegg under CC BY 4.0. Both depict the same site/date: they are separate inputs, not a broad independent accuracy dataset. Keep SOURCE.txt with them. No third-party endorsement or real restricted area is implied.
python -B prepare_inputs.py --video inputs/calibration.mp4 \
--count 32 --output work/calibration
python -B prepare_inputs.py --video inputs/evaluation.mp4 \
--count 8 --output work/evaluation
python -B run_images.py --bundle work/bundle --images work/evaluation \
--backend cpu --output work/cpu-images
The frame selector saves lossless PNGs and inputs.json with source hash, frame indices, timestamps and per-frame hashes. The CPU step runs the original floating-point graph through CPUExecutionProvider, saving raw NPZ tensors and decoded boxes in results.json.
Read the data contract before interpreting a result. The application restores coordinates using the actual resize scales; it does not apply a second sigmoid or a different NMS to these already postprocessed outputs. At score ≥0.4, the eight selected frames contain only two detected people in the CPU output, although more small/occluded people are visible. This is an important limitation, not evidence that the warehouse is empty.
3. Quantize and compile on x86
compile_model.py and model.py are maintained in mo-models; the application-side scripts are in mo-examples. The tutorial package downloaded on this page bundles the same files.
Use a new bundle for each changed graph, calibration set or compiler configuration. The script refuses to overwrite an artifact directory.
set -o pipefail
python -B -u compile_model.py --bundle work/bundle \
--calibration work/calibration --iterations 3 2>&1 | tee work/compile.log
python -B inspect_bundle.py --bundle work/bundle
Compilation takes several minutes on the tested host. Keep the full log. The recipe uses:
| Setting | Value and reason |
|---|---|
| Target | AM62A, tools 11_02_17_00 |
| Calibration | 32 actual frames, three iterations, quantization scale type 4 |
| Base precision | 8 bits |
| Selected 16-bit outputs | 1033,711,712,713,727,728,743,744,745; TI's exact model configuration with only its duplicate 728 removed |
| Detection | Matching meta-architecture 6 metadata; compiler score floor 0.3, top-k 200 |
| Graph optimization | ONNX Runtime optimization disabled consistently for compilation and execution |
This is mixed precision, not an all-8-bit network. The architecture/weights are unchanged. The selection comes from TI's exact source-model configuration, not a guessed workaround. Do not generalize these output names to another model. Its published reference accuracy is not a Mo62A measurement or an accuracy result for this footage.
The tested compile completed, but emitted two Requested output data convert layer is not added ... not optimal warnings. They are retained in the evidence; no optimization fix is claimed. The pinned TI wrapper also reports disabled runtime I/O validation. The application checks input shape/type, bundle hashes, output shape, finiteness, labels and scores itself. Do not remove those checks.
An artifact directory or success banner alone is not acceptance. Review errors and warnings, then compare host and board outputs. On a compiler failure, stop and retain the log; do not deploy partial artifacts.
4. Inspect the bundle and host outputs
The bundle contains model/, artifacts/ and bundle.json. The manifest records the compiler version, precision choices, complete calibration manifest and hashes of each deployable model/artifact file. Do not move only a .bin file or mix it with a different ONNX graph.
python -B inspect_bundle.py --bundle work/bundle
python -B run_images.py --bundle work/bundle --images work/evaluation \
--backend tidl --output work/host-images
python -B compare_detections.py --cpu work/cpu-images/results.json \
--quantized work/host-images/results.json --output work/agreement.json
Host TIDL is emulation, not Mo62A performance. It can be much slower than the board. The graph presented to the provider reports 326/326 nodes in one TIDL subgraph after its transformations; that count is not the original 418-node ONNX count.
For the eight fixed frames, CPU and quantized person counts matched; the two box matches had IoU approximately 0.943 and 0.967 at score ≥0.4. Six frames had no detections in either output. These are agreement checks, not ground truth, recall or mAP. They do not excuse visible misses or prove production accuracy.
5. Transfer and verify on Mo62A
First stop other inference applications and confirm a known-good model still works. Do not update board software for this tutorial. On the board, create a new user-owned directory:
mkdir "$HOME/mo62a-zone-demo"
If that directory already exists, stop and choose a new project name throughout the remaining commands; do not merge new artifacts into an older deployment. On the host, substitute your SSH username and reachable board address:
scp -r work/bundle work/evaluation work/host-images \
model.py logic.py run_images.py run_video.py inspect_bundle.py zone.json SOURCE.txt \
YOUR_USERNAME@BOARD_IP_ADDRESS:mo62a-zone-demo/
scp inputs/evaluation.mp4 YOUR_USERNAME@BOARD_IP_ADDRESS:mo62a-zone-demo/
In the board's shell:
cd "$HOME/mo62a-zone-demo"
python3 -B inspect_bundle.py --bundle bundle
python3 -c "import onnxruntime as o; print(o.__version__); print(o.get_available_providers())"
sudo python3 -B run_images.py --bundle bundle --images evaluation \
--backend tidl --compare host-images --output results-images
--compare requires both raw output tensors to match host TIDL exactly for every transferred frame. Input and bundle hashes are checked before inference. The target test must finish, not merely create a session.
If the first inference stalls or fails, stop the experiment, retain its log and verify the original baseline. Do not repeatedly reset remote processors, replace packages or reboot without a planned recovery procedure. Then continue to the complete video application for events, output media and repeated-run acceptance.
Adapt the recipe to your own project
For new classes, train/export first and verify the floating-point graph against its framework reference. For an existing class, camera placement, input resolution and representative calibration may matter more than changing a business threshold. Never assume a model compiled for another TI SoC is suitable for AM62A.
Before production, use independently labeled, representative data to measure task accuracy before/after quantization; test missing frames, occlusion, lighting, empty scenes and long runs. The example has no certified safety function, identity tracking or automated equipment control.
TI references: AM62A model guide, tag-specific compilation options, detection metadata, and E2E compilation-diagnostic example. Forum cases explain specific failures; they are not proof that our graph or an arbitrary custom export is valid.