ONNXModel¶
- class mlfmu.types.onnx_model.ONNXModel(onnx_path: str | PathLike[str], *, time_input: bool = False)¶
Bases:
object
ONNX Metadata class.
Represents an ONNX model and provides methods to load inputs and outputs. Allows to import the ONNX file and figure out the input/output sizes.
- Raises:
ValueError – If the ml model has 3 inputs, but the usesTime flag is set to false in the json interface.
ValueError – If the number of inputs to the ml model is larger than 3.
ValueError – If the number of outputs from the ml model is not exactly 1.
- __init__(onnx_path: str | PathLike[str], *, time_input: bool = False) None ¶
Initialize the ONNXModel object by loading the ONNX file and assigning model parameters.
- Parameters:
onnx_path (Union[str, os.PathLike[str]]) – The path to the ONNX file.
time_input (bool, optional) – Flag indicating whether the model uses time input. Defaults to False.
Methods
__init__
(onnx_path, *[, time_input])Initialize the ONNXModel object by loading the ONNX file and assigning model parameters.
Load the inputs from the ONNX file and assign the input name and size.
Load the outputs from the ONNX file and assign the output name and size.
Attributes
The name of the ONNX file.
The name of the main input.
The size of the main input.
The name of the output.
The size of the output.
The size of the internal states input.
The name of the internal states input.
Flag indicating whether the model uses time input.
The name of the time input.
- load_inputs() None ¶
Load the inputs from the ONNX file and assign the input name and size.
- load_outputs() None ¶
Load the outputs from the ONNX file and assign the output name and size.
- filename: str = ''¶
The name of the ONNX file.
- input_name: str = ''¶
The name of the main input.
- input_size: int = 0¶
The size of the main input.
- output_name: str = ''¶
The name of the output.
- output_size: int = 0¶
The size of the output.
- state_size: int = 0¶
The size of the internal states input.
- states_name: str = ''¶
The name of the internal states input.
- time_input: bool = False¶
Flag indicating whether the model uses time input.
- time_input_name: str = ''¶
The name of the time input.