Skip to main content

ONNX

ONNX (Open Neural Network Exchange) is an open-source format that lets you create, train, and save a machine learning model. The Classification module lets you import such a model into an ONNX classifier context (M_CLASSIFIER_ONNX) and incorporate it into your Aurora Imaging Library application for the inference (MclassPredict). The imported ONNX model is already trained (no further training is required).

The classification task that you can perform with an ONNX classifier depends on the machine learning model you designed and trained prior to importing it. Possible tasks include those inherently available with the Classification module (for example, image classification, segmentation, object detection, and anomaly detection), as well as any other task available with ONNX.

The following steps provide a basic methodology for using an ONNX classifier:

  1. Allocate an ONNX classifier context, using MclassAlloc with M_CLASSIFIER_ONNX.
  2. Import a trained ONNX machine learning model into an ONNX classifier context, using MclassImport with M_ONNX_FILE.
  3. Optionally, modify ONNX classifier settings, using MclassControl.
  4. Preprocess the ONNX classifier context, using MclassPreprocess.
  5. Allocate an ONNX result buffer to hold the prediction results, using MclassAllocResult with M_PREDICT_ONNX_RESULT.
  6. Perform the inference using the imported ONNX classifier on the specified target image, using MclassPredict.
  7. Retrieve the required results from the classification result buffer, using MclassGetResult.
  8. Free all your allocated objects, using MclassFree, unless M_UNIQUE_ID was specified during allocation.

ONNX requirements

To ensure the ONNX machine learning model that you import with M_ONNX_FILE works as expected, all per-established requirements must be met. For example, you must ensure:

  • You are using a supported ONNX file format version (ir_version).
  • The network's inputs and outputs are properly configured. This includes the network having at least 1 input and 1 output, and that the type of the inputs and outputs are dense tensor (the tensors must have a shape).
  • The graph of the machine learning model is free from cycles.

For a complete description of all requirements, refer to M_ONNX_FILE in the Aurora Imaging Library Reference.

Copyright © 2026 Zebra Technologies.