Trait opencv::prelude::NetTraitConst
source · [−]pub trait NetTraitConst {
Show 30 methods
fn as_raw_Net(&self) -> *const c_void;
fn empty(&self) -> Result<bool> { ... }
fn get_layer_id(&self, layer: &str) -> Result<i32> { ... }
fn get_layer_names(&self) -> Result<Vector<String>> { ... }
fn get_layer(&self, layer_id: i32) -> Result<Ptr<Layer>> { ... }
fn get_layer_1(&self, layer_name: &str) -> Result<Ptr<Layer>> { ... }
fn get_layer_2(&self, layer_id: &Net_LayerId) -> Result<Ptr<Layer>> { ... }
fn get_layer_inputs(&self, layer_id: i32) -> Result<Vector<Ptr<Layer>>> { ... }
fn get_input_details(
&self,
scales: &mut Vector<f32>,
zeropoints: &mut Vector<i32>
) -> Result<()> { ... }
fn get_output_details(
&self,
scales: &mut Vector<f32>,
zeropoints: &mut Vector<i32>
) -> Result<()> { ... }
fn get_param(&self, layer: i32, num_param: i32) -> Result<Mat> { ... }
fn get_param_1(&self, layer_name: &str, num_param: i32) -> Result<Mat> { ... }
fn get_unconnected_out_layers(&self) -> Result<Vector<i32>> { ... }
fn get_unconnected_out_layers_names(&self) -> Result<Vector<String>> { ... }
fn get_layers_shapes(
&self,
net_input_shapes: &Vector<MatShape>,
layers_ids: &mut Vector<i32>,
in_layers_shapes: &mut Vector<Vector<MatShape>>,
out_layers_shapes: &mut Vector<Vector<MatShape>>
) -> Result<()> { ... }
fn get_layers_shapes_1(
&self,
net_input_shape: &MatShape,
layers_ids: &mut Vector<i32>,
in_layers_shapes: &mut Vector<Vector<MatShape>>,
out_layers_shapes: &mut Vector<Vector<MatShape>>
) -> Result<()> { ... }
fn get_layer_shapes(
&self,
net_input_shape: &MatShape,
layer_id: i32,
in_layer_shapes: &mut Vector<MatShape>,
out_layer_shapes: &mut Vector<MatShape>
) -> Result<()> { ... }
fn get_layer_shapes_1(
&self,
net_input_shapes: &Vector<MatShape>,
layer_id: i32,
in_layer_shapes: &mut Vector<MatShape>,
out_layer_shapes: &mut Vector<MatShape>
) -> Result<()> { ... }
fn get_flops(&self, net_input_shapes: &Vector<MatShape>) -> Result<i64> { ... }
fn get_flops_1(&self, net_input_shape: &MatShape) -> Result<i64> { ... }
fn get_flops_2(
&self,
layer_id: i32,
net_input_shapes: &Vector<MatShape>
) -> Result<i64> { ... }
fn get_flops_3(
&self,
layer_id: i32,
net_input_shape: &MatShape
) -> Result<i64> { ... }
fn get_layer_types(&self, layers_types: &mut Vector<String>) -> Result<()> { ... }
fn get_layers_count(&self, layer_type: &str) -> Result<i32> { ... }
fn get_memory_consumption(
&self,
net_input_shapes: &Vector<MatShape>,
weights: &mut size_t,
blobs: &mut size_t
) -> Result<()> { ... }
fn get_memory_consumption_1(
&self,
net_input_shape: &MatShape,
weights: &mut size_t,
blobs: &mut size_t
) -> Result<()> { ... }
fn get_memory_consumption_for_layer(
&self,
layer_id: i32,
net_input_shapes: &Vector<MatShape>,
weights: &mut size_t,
blobs: &mut size_t
) -> Result<()> { ... }
fn get_memory_consumption_2(
&self,
layer_id: i32,
net_input_shape: &MatShape,
weights: &mut size_t,
blobs: &mut size_t
) -> Result<()> { ... }
fn get_memory_consumption_for_layers(
&self,
net_input_shapes: &Vector<MatShape>,
layer_ids: &mut Vector<i32>,
weights: &mut Vector<size_t>,
blobs: &mut Vector<size_t>
) -> Result<()> { ... }
fn get_memory_consumption_3(
&self,
net_input_shape: &MatShape,
layer_ids: &mut Vector<i32>,
weights: &mut Vector<size_t>,
blobs: &mut Vector<size_t>
) -> Result<()> { ... }
}
Expand description
This class allows to create and manipulate comprehensive artificial neural networks.
Neural network is presented as directed acyclic graph (DAG), where vertices are Layer instances, and edges specify relationships between layers inputs and outputs.
Each network layer has unique integer id and unique string name inside its network. LayerId can store either layer name or layer id.
This class supports reference counting of its instances, i. e. copies point to the same instance.
Required Methods
fn as_raw_Net(&self) -> *const c_void
Provided Methods
sourcefn get_layer_id(&self, layer: &str) -> Result<i32>
fn get_layer_id(&self, layer: &str) -> Result<i32>
Converts string name of the layer to the integer identifier.
Returns
id of the layer, or -1 if the layer wasn’t found.
fn get_layer_names(&self) -> Result<Vector<String>>
sourcefn get_layer(&self, layer_id: i32) -> Result<Ptr<Layer>>
fn get_layer(&self, layer_id: i32) -> Result<Ptr<Layer>>
Returns pointer to layer with specified id or name which the network use.
sourcefn get_layer_1(&self, layer_name: &str) -> Result<Ptr<Layer>>
fn get_layer_1(&self, layer_name: &str) -> Result<Ptr<Layer>>
Returns pointer to layer with specified id or name which the network use.
Overloaded parameters
Deprecated: Use int getLayerId(const String &layer)
sourcefn get_layer_2(&self, layer_id: &Net_LayerId) -> Result<Ptr<Layer>>
fn get_layer_2(&self, layer_id: &Net_LayerId) -> Result<Ptr<Layer>>
Returns pointer to layer with specified id or name which the network use.
Overloaded parameters
Deprecated: to be removed
sourcefn get_layer_inputs(&self, layer_id: i32) -> Result<Vector<Ptr<Layer>>>
fn get_layer_inputs(&self, layer_id: i32) -> Result<Vector<Ptr<Layer>>>
Returns pointers to input layers of specific layer.
sourcefn get_input_details(
&self,
scales: &mut Vector<f32>,
zeropoints: &mut Vector<i32>
) -> Result<()>
fn get_input_details(
&self,
scales: &mut Vector<f32>,
zeropoints: &mut Vector<i32>
) -> Result<()>
Returns input scale and zeropoint for a quantized Net.
Parameters
- scales: output parameter for returning input scales.
- zeropoints: output parameter for returning input zeropoints.
sourcefn get_output_details(
&self,
scales: &mut Vector<f32>,
zeropoints: &mut Vector<i32>
) -> Result<()>
fn get_output_details(
&self,
scales: &mut Vector<f32>,
zeropoints: &mut Vector<i32>
) -> Result<()>
Returns output scale and zeropoint for a quantized Net.
Parameters
- scales: output parameter for returning output scales.
- zeropoints: output parameter for returning output zeropoints.
sourcefn get_param(&self, layer: i32, num_param: i32) -> Result<Mat>
fn get_param(&self, layer: i32, num_param: i32) -> Result<Mat>
Returns parameter blob of the layer.
Parameters
- layer: name or id of the layer.
- numParam: index of the layer parameter in the Layer::blobs array.
See also
Layer::blobs
C++ default parameters
- num_param: 0
sourcefn get_param_1(&self, layer_name: &str, num_param: i32) -> Result<Mat>
fn get_param_1(&self, layer_name: &str, num_param: i32) -> Result<Mat>
C++ default parameters
- num_param: 0
sourcefn get_unconnected_out_layers(&self) -> Result<Vector<i32>>
fn get_unconnected_out_layers(&self) -> Result<Vector<i32>>
Returns indexes of layers with unconnected outputs.
FIXIT: Rework API to registerOutput() approach, deprecate this call
sourcefn get_unconnected_out_layers_names(&self) -> Result<Vector<String>>
fn get_unconnected_out_layers_names(&self) -> Result<Vector<String>>
Returns names of layers with unconnected outputs.
FIXIT: Rework API to registerOutput() approach, deprecate this call
sourcefn get_layers_shapes(
&self,
net_input_shapes: &Vector<MatShape>,
layers_ids: &mut Vector<i32>,
in_layers_shapes: &mut Vector<Vector<MatShape>>,
out_layers_shapes: &mut Vector<Vector<MatShape>>
) -> Result<()>
fn get_layers_shapes(
&self,
net_input_shapes: &Vector<MatShape>,
layers_ids: &mut Vector<i32>,
in_layers_shapes: &mut Vector<Vector<MatShape>>,
out_layers_shapes: &mut Vector<Vector<MatShape>>
) -> Result<()>
Returns input and output shapes for all layers in loaded model; preliminary inferencing isn’t necessary.
Parameters
- netInputShapes: shapes for all input blobs in net input layer.
- layersIds: output parameter for layer IDs.
- inLayersShapes: output parameter for input layers shapes; order is the same as in layersIds
- outLayersShapes: output parameter for output layers shapes; order is the same as in layersIds
sourcefn get_layers_shapes_1(
&self,
net_input_shape: &MatShape,
layers_ids: &mut Vector<i32>,
in_layers_shapes: &mut Vector<Vector<MatShape>>,
out_layers_shapes: &mut Vector<Vector<MatShape>>
) -> Result<()>
fn get_layers_shapes_1(
&self,
net_input_shape: &MatShape,
layers_ids: &mut Vector<i32>,
in_layers_shapes: &mut Vector<Vector<MatShape>>,
out_layers_shapes: &mut Vector<Vector<MatShape>>
) -> Result<()>
Returns input and output shapes for all layers in loaded model; preliminary inferencing isn’t necessary.
Parameters
- netInputShapes: shapes for all input blobs in net input layer.
- layersIds: output parameter for layer IDs.
- inLayersShapes: output parameter for input layers shapes; order is the same as in layersIds
- outLayersShapes: output parameter for output layers shapes; order is the same as in layersIds
Overloaded parameters
sourcefn get_layer_shapes(
&self,
net_input_shape: &MatShape,
layer_id: i32,
in_layer_shapes: &mut Vector<MatShape>,
out_layer_shapes: &mut Vector<MatShape>
) -> Result<()>
fn get_layer_shapes(
&self,
net_input_shape: &MatShape,
layer_id: i32,
in_layer_shapes: &mut Vector<MatShape>,
out_layer_shapes: &mut Vector<MatShape>
) -> Result<()>
Returns input and output shapes for layer with specified id in loaded model; preliminary inferencing isn’t necessary.
Parameters
- netInputShape: shape input blob in net input layer.
- layerId: id for layer.
- inLayerShapes: output parameter for input layers shapes; order is the same as in layersIds
- outLayerShapes: output parameter for output layers shapes; order is the same as in layersIds
sourcefn get_layer_shapes_1(
&self,
net_input_shapes: &Vector<MatShape>,
layer_id: i32,
in_layer_shapes: &mut Vector<MatShape>,
out_layer_shapes: &mut Vector<MatShape>
) -> Result<()>
fn get_layer_shapes_1(
&self,
net_input_shapes: &Vector<MatShape>,
layer_id: i32,
in_layer_shapes: &mut Vector<MatShape>,
out_layer_shapes: &mut Vector<MatShape>
) -> Result<()>
Returns input and output shapes for layer with specified id in loaded model; preliminary inferencing isn’t necessary.
Parameters
- netInputShape: shape input blob in net input layer.
- layerId: id for layer.
- inLayerShapes: output parameter for input layers shapes; order is the same as in layersIds
- outLayerShapes: output parameter for output layers shapes; order is the same as in layersIds
Overloaded parameters
sourcefn get_flops(&self, net_input_shapes: &Vector<MatShape>) -> Result<i64>
fn get_flops(&self, net_input_shapes: &Vector<MatShape>) -> Result<i64>
Computes FLOP for whole loaded model with specified input shapes.
Parameters
- netInputShapes: vector of shapes for all net inputs.
Returns
computed FLOP.
sourcefn get_flops_1(&self, net_input_shape: &MatShape) -> Result<i64>
fn get_flops_1(&self, net_input_shape: &MatShape) -> Result<i64>
Computes FLOP for whole loaded model with specified input shapes.
Parameters
- netInputShapes: vector of shapes for all net inputs.
Returns
computed FLOP.
Overloaded parameters
sourcefn get_flops_2(
&self,
layer_id: i32,
net_input_shapes: &Vector<MatShape>
) -> Result<i64>
fn get_flops_2(
&self,
layer_id: i32,
net_input_shapes: &Vector<MatShape>
) -> Result<i64>
Computes FLOP for whole loaded model with specified input shapes.
Parameters
- netInputShapes: vector of shapes for all net inputs.
Returns
computed FLOP.
Overloaded parameters
sourcefn get_flops_3(&self, layer_id: i32, net_input_shape: &MatShape) -> Result<i64>
fn get_flops_3(&self, layer_id: i32, net_input_shape: &MatShape) -> Result<i64>
Computes FLOP for whole loaded model with specified input shapes.
Parameters
- netInputShapes: vector of shapes for all net inputs.
Returns
computed FLOP.
Overloaded parameters
sourcefn get_layer_types(&self, layers_types: &mut Vector<String>) -> Result<()>
fn get_layer_types(&self, layers_types: &mut Vector<String>) -> Result<()>
Returns list of types for layer used in model.
Parameters
- layersTypes: output parameter for returning types.
sourcefn get_layers_count(&self, layer_type: &str) -> Result<i32>
fn get_layers_count(&self, layer_type: &str) -> Result<i32>
sourcefn get_memory_consumption(
&self,
net_input_shapes: &Vector<MatShape>,
weights: &mut size_t,
blobs: &mut size_t
) -> Result<()>
fn get_memory_consumption(
&self,
net_input_shapes: &Vector<MatShape>,
weights: &mut size_t,
blobs: &mut size_t
) -> Result<()>
Computes bytes number which are required to store all weights and intermediate blobs for model.
Parameters
- netInputShapes: vector of shapes for all net inputs.
- weights: output parameter to store resulting bytes for weights.
- blobs: output parameter to store resulting bytes for intermediate blobs.
sourcefn get_memory_consumption_1(
&self,
net_input_shape: &MatShape,
weights: &mut size_t,
blobs: &mut size_t
) -> Result<()>
fn get_memory_consumption_1(
&self,
net_input_shape: &MatShape,
weights: &mut size_t,
blobs: &mut size_t
) -> Result<()>
Computes bytes number which are required to store all weights and intermediate blobs for model.
Parameters
- netInputShapes: vector of shapes for all net inputs.
- weights: output parameter to store resulting bytes for weights.
- blobs: output parameter to store resulting bytes for intermediate blobs.
Overloaded parameters
sourcefn get_memory_consumption_for_layer(
&self,
layer_id: i32,
net_input_shapes: &Vector<MatShape>,
weights: &mut size_t,
blobs: &mut size_t
) -> Result<()>
fn get_memory_consumption_for_layer(
&self,
layer_id: i32,
net_input_shapes: &Vector<MatShape>,
weights: &mut size_t,
blobs: &mut size_t
) -> Result<()>
Computes bytes number which are required to store all weights and intermediate blobs for model.
Parameters
- netInputShapes: vector of shapes for all net inputs.
- weights: output parameter to store resulting bytes for weights.
- blobs: output parameter to store resulting bytes for intermediate blobs.
Overloaded parameters
sourcefn get_memory_consumption_2(
&self,
layer_id: i32,
net_input_shape: &MatShape,
weights: &mut size_t,
blobs: &mut size_t
) -> Result<()>
fn get_memory_consumption_2(
&self,
layer_id: i32,
net_input_shape: &MatShape,
weights: &mut size_t,
blobs: &mut size_t
) -> Result<()>
Computes bytes number which are required to store all weights and intermediate blobs for model.
Parameters
- netInputShapes: vector of shapes for all net inputs.
- weights: output parameter to store resulting bytes for weights.
- blobs: output parameter to store resulting bytes for intermediate blobs.
Overloaded parameters
sourcefn get_memory_consumption_for_layers(
&self,
net_input_shapes: &Vector<MatShape>,
layer_ids: &mut Vector<i32>,
weights: &mut Vector<size_t>,
blobs: &mut Vector<size_t>
) -> Result<()>
fn get_memory_consumption_for_layers(
&self,
net_input_shapes: &Vector<MatShape>,
layer_ids: &mut Vector<i32>,
weights: &mut Vector<size_t>,
blobs: &mut Vector<size_t>
) -> Result<()>
Computes bytes number which are required to store all weights and intermediate blobs for each layer.
Parameters
- netInputShapes: vector of shapes for all net inputs.
- layerIds: output vector to save layer IDs.
- weights: output parameter to store resulting bytes for weights.
- blobs: output parameter to store resulting bytes for intermediate blobs.
sourcefn get_memory_consumption_3(
&self,
net_input_shape: &MatShape,
layer_ids: &mut Vector<i32>,
weights: &mut Vector<size_t>,
blobs: &mut Vector<size_t>
) -> Result<()>
fn get_memory_consumption_3(
&self,
net_input_shape: &MatShape,
layer_ids: &mut Vector<i32>,
weights: &mut Vector<size_t>,
blobs: &mut Vector<size_t>
) -> Result<()>
Computes bytes number which are required to store all weights and intermediate blobs for each layer.
Parameters
- netInputShapes: vector of shapes for all net inputs.
- layerIds: output vector to save layer IDs.
- weights: output parameter to store resulting bytes for weights.
- blobs: output parameter to store resulting bytes for intermediate blobs.