openvino.inference_engine.IENetwork

class openvino.inference_engine.IENetwork

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.

__init__()

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__()

Initialize self.

add_outputs(self, outputs)

Marks any intermediate layer as output layer to retrieve the inference results from the specified layers.

get_ov_name_for_tensor(self, unicode orig_name)

reshape(self, dict input_shapes)

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

serialize(self, path_to_xml, unicode path_to_bin)

Serializes the network and stores it in files.

Attributes

batch_size

Batch size of the network.

input_info

A dictionary that maps input layer names to InputInfoPtr objects.

inputs

A dictionary that maps input layer names to DataPtr objects

name

Name of the loaded network

outputs

A dictionary that maps output layer names to DataPtr objects

add_outputs(self, outputs)

Marks any intermediate layer as output layer to retrieve the inference results from the specified layers.

Parameters

outputs – List of layers to be set as model outputs. The list can contain strings with layer names to be set as outputs or tuples with layer name as first element and output port id as second element. In case of setting one layer as output, string or tuple with one layer can be provided.

Returns

None

Usage example:

ie = IECore()
net = ie.read_network(model=path_to_xml_file, weights=path_to_bin_file)
net.add_outputs(["conv5_1', conv2_1', (split_2, 1)])]
batch_size

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

ie = IECore()
net = ie.read_network(model=path_to_xml_file, weights=path_to_bin_file)
print(net.batch_size)
net.batch_size = 4
print(net.batch_size)
print(net.input_info['data'].input_data.shape)
get_ov_name_for_tensor(self, unicode orig_name: str)
input_info

A dictionary that maps input layer names to InputInfoPtr objects.

inputs

A dictionary that maps input layer names to DataPtr objects

Note

The property is deprecated. Please use the input_info property to get the map of inputs

name

Name of the loaded network

outputs

A dictionary that maps output layer names to DataPtr objects

reshape(self, dict input_shapes: dict)

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

Parameters

input_shapes – A dictionary that maps input layer names to tuples with the target shape

Returns

None

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.

Usage example:

ie = IECore()
net = ie.read_network(model=path_to_xml_file, weights=path_to_bin_file)
input_layer = next(iter(net.input_info))
n, c, h, w = net.input_info[input_layer].input_data.shape
net.reshape({input_layer: (n, c, h*2, w*2)})
serialize(self, path_to_xml, unicode path_to_bin: str = u'')

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:

ie = IECore()
net = ie.read_network(model=path_to_xml, weights=path_to_bin)
net.serialize(path_to_xml, path_to_bin)