Analysis
Infery allows users to analyze deep learning model's basic properties. This data is stored as
the models' metadata
, inputs
and outputs
. Start by loading your model:
import infery
model = infery.Model('/path/to/model.onnx')
High-Level Metadata
The easiest way to see all input/output metadata of your model is through the metadata
property. There are also a couple
of batch-size-related properties you may access.
# Get all inputs/outputs metadata
model.metadata
# A model is considered dynamic if it supports inference with varying batch sizes.
model.is_dynamic
# A dynamic model has a "None" batch size. A static model will return an int specifying the static batch size here.
model.batch_size
Inputs, Outputs, and Metadata
You may view shapes, names and dtypes of models' inputs and outputs by utilizing the inputs
and outputs
properties:
# List of model input names (simply switch "inputs" to "outputs" to access outputs' metadata)
model.inputs.names
# Dictionary of model's dynamic axes ({input_name : {axis_index: label}})
model.inputs.dynamic_axes
# List of TensorSpecs - the underlying objects that actually contain the metadata.
model.inputs.specs
None
will we returned for inputs
and outputs
.
TensorSpecs and Axes
- Inputs and outputs are composed of
TensorSpecs
. Specs hold a list ofAxis
objects. - Every
Axis
may have avalue
,range
, and/orlabel
. - If a model is dynamic at a certain axis, this axis will have a
range
and/orlabel
. - If a model is static at a certain axis, this axis will have a
value
and possibly alabel
. Alabel
has no real significance other than helping refer to an axis or marking it as fully dynamic in the case where there is notvalue
orrange
. - For example - if a model has a "batch_size" label for
Axis
0, novalue
and norange
, it may receive inputs with varying batch sizes. The same axis may belabel
ed "foo" as still have the same exact functionality.
# Get all axes of a model's first input:
model.inputs.specs[0].axes
# Get the name of a model's first input (identical to model.inputs.names[0])
model.inputs.specs[0].name
# Get the dtype of a model;s first input
model.inputs.specs[0].dtype
To check out the different properties of the first Axis
of your model's first TensorSpec
:
model.inputs.specs[0].axes[0].value
model.inputs.specs[0].axes[0].label
model.inputs.specs[0].axes[0].value_range