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:
- Allocate an ONNX classifier context, using
MclassAllocwithM_CLASSIFIER_ONNX. - Import a trained ONNX machine learning model into an ONNX classifier context, using
MclassImportwithM_ONNX_FILE. - Optionally, modify ONNX classifier settings, using
MclassControl. - Preprocess the ONNX classifier context, using
MclassPreprocess. - Allocate an ONNX result buffer to hold the prediction results, using
MclassAllocResultwithM_PREDICT_ONNX_RESULT. - Perform the inference using the imported ONNX classifier on the specified target image, using
MclassPredict. - Retrieve the required results from the classification result buffer, using
MclassGetResult. - Free all your allocated objects, using
MclassFree, unlessM_UNIQUE_IDwas 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.