Breadcrumbs

Import of ONNX model

ONNX models created outside Breeze can be used to make classification and quantification predictions during runtime. To import an existing model complete a model wizard for Machine Learning and select Import at the last step.

image-20260107-095623.png

The model must follow the standard format specified below for both name and datatype. Inputs and outputs are bound by name so the names must match exactly according to the specification below.

Classification model

The model INPUTS and OUTPUTS of the model should be as below, the names and data types must match. The dimensions for the INPUTS.Features must be the same as the number of wavelengths in the Breeze model. In the example below 29 wavelengths are included in the Breeze model and also then in the ONNX model.

image-20220524-094457.png

The INPUTS must have the name Features.

image-20220524-094604.png

For the classification model, the above OUTPUTS should in the listed format. The dimension for the Score.output (or Score_output) variable must be the same as the number of classes available in Breeze. PredictedLabel.output (or PredictedLabel_output) is the prediction result in a single dimension variable, the shape of this node is not required to be known - it is assumed to be [-1,1].

If the PredictedLabel.output is missing the argument of the maxima index + 1 will be used as the class assigned.

image-20220524-095308.png

If only one output node exist the naming convention is not required as the node is assumed to be the Score.output node.

Quantification model

The INPUTS are the same as for Classification (wavelengths in model).

image-20220524-094650.png

For OUTPUTS only Score.output (or Score_output) is applicable for quantification. The dimensions are the number of variables used in the Breeze model.

image-20220524-094706.png

Troubleshooting

Got invalid dimensions for input

This error is due to a mismatch between the models input or output dimensions. The training/test data selected in Breeze for the import.

The example below is based on the Powder quantification which has 67 wavelengths and the model expects 288.

[ErrorCode:InvalidArgument] Got invalid dimensions for input: Features for the following indices
 index: 1 Got: 67 Expected: 288
 Please fix either the inputs/outputs or the model.
image-20260107-093831.png

The model must be aligned to accept 67 wavelengths (Features) to be able to be imported into Breeze.

Additional resources

Inspect your model properties using https://netron.app/