Public Member Functions
ie_api.IENetwork Class Reference

This class contains the information about the network model read from IR and allows you to manipulate with some model parameters such as layers affinity and output layers. More...

Public Member Functions

def  __init__
  Class constructor. More...
 
 
 
 
 
 
 
def  from_ir
  NOTE: The function is deprecated. More...
 
def  serialize (self, path_to_xml, path_to_bin="")
  Serializes the network and stores it in files. More...
 
def  reshape (self, input_shapes)
  Reshapes the network to change spatial dimensions, batch size, or any dimension. More...
 

Class Attributes

name
Name of the loaded network.
inputs
outputs
batch_size

Batch size of the network.

Provides getter and setter interfaces to get and modify the network batch size. For example:

net = IENetwork(model=path_to_xml_file, weights=path_to_bin_file)
print(et.batch_size)
net.batch_size = 4
print(net.batch_size)
print(net.inputs['data'].shape)
precision
Precision of the network.
layers
Return dictionary that maps network layer names in topological order to IENetLayer objects containing layer properties.
stats

Returns LayersStatsMap object containing dictionary that maps network layer names to calibration statistics represented by LayerStats objects.

Usage example:

net = IENetwork(model=path_to_xml_file, weights=path_to_bin_file)
net.stats.update({"conv1_2d" : LayserStats(min=(-25, -1, 0), max=(63, 124, 70)),
"conv2_2d" : LayserStats(min=(-5, -1, 0, 1, -7, 2), max=(63, 124, 70, 174, 99, 106))
})

Detailed Description

This class contains the information about the network model read from IR and allows you to manipulate with some model parameters such as layers affinity and output layers.

Constructor & Destructor Documentation

§ __init__()

def ie_api.IENetwork.__init__ (   self,
  model 
)

Class constructor.

Parameters
model An .xml file of the IR. Depending on init_from_buffer value, can be a string path or bytes with file content.
weights A .bin file of the IR. Depending on init_from_buffer value, can be a string path or bytes with file content.
init_from_buffer Defines the way of how model and weights attributes are interpreted. If True, attributes are interpreted as strings with paths to .xml and .bin files of IR. If False, they are interpreted as Python bytes object with .xml and .bin files content.
Returns
Instance of IENetwork class

Usage example:
Initializing IENetwork object from IR files:

net = IENetwork(model=path_to_xml_file, weights=path_to_bin_file)

Initializing IENetwork object bytes with content of IR files:

with open(path_to_bin_file, 'rb') as f:
bin = f.read()
with open(path_to_xml_file, 'rb') as f:
xml = f.read()
net = IENetwork(model=xml, weights=bin, init_from_buffer=True)

Member Function Documentation

§ from_ir()

def ie_api.IENetwork.from_ir (   cls,
  model,
  weights 
)

NOTE: The function is deprecated.

Please use the IENetwork() class constructor to create valid instance of IENetwork.

Reads the model from the .xml and .bin files of the IR.

Parameters
model Path to .xml file of the IR
weights Path to .bin file of the IR
Returns
An instance of the IENetwork class

§ reshape()

def ie_api.IENetwork.reshape (   self,
  input_shapes 
)

Reshapes the network to change spatial dimensions, batch size, or any dimension.

NOTE: Before using this method, make sure that the target shape is applicable for the network. Changing the network shape to an arbitrary value may lead to unpredictable behaviour.

Parameters
input_shapes A dictionary that maps input layer names to tuples with the target shape
Returns
None

Usage example:

net = IENetwork(model=path_to_xml_file, weights=path_to_bin_file)
input_layer = next(iter(net.inputs))
n, c, h, w = net.inputs[input_layer]
net.reshape({input_layer: (n, c, h*2, w*2)}]

§ serialize()

def ie_api.IENetwork.serialize (   self,
  path_to_xml,
  path_to_bin = "" 
)

Serializes the network and stores it in files.

Parameters
path_to_xml Path to a file, where a serialized model will be stored
path_to_bin Path to a file, where serialized weights will be stored
Returns
None

Usage example:

net = IENetwork(model=path_to_model, weights=path_to_weights)
net.serialize(path_to_xml, path_to_bin)