html5 opencv .net,OpenCV: Deep Neural Network module

Classes

Derivatives of this class encapsulates functions of certain backends. More...

Derivatives of this class wraps cv::Mat for different backends and targets. More...

This class represents high-level API for classification models. More...

This class represents high-level API for object detection networks. More...

This class implements name-value dictionary, values are instances of DictValue. More...

This struct stores the scalar value (or array) of one of the following type: double, cv::String or int64. More...

This class represents high-level API for keypoints models. More...

This interface class allows to build new Layers - are building blocks of networks. More...

This class provides all data needed to initialize layer. More...

This class is presented high-level API for neural networks. More...

This class allows to create and manipulate comprehensive artificial neural networks. More...

This class represents high-level API for segmentation models. More...

Base class for text detection networks. More...

This class represents high-level API for text detection DL networks compatible with DB model. More...

This class represents high-level API for text detection DL networks compatible with EAST model. More...

This class represents high-level API for text recognition networks. More...Typedefs

Register layer types of DNN model. More...

typedef std::vector< int >Functions

cv::dnn::blobFromImage (InputArray image, double scalefactor=1.0, const Size &size=Size(), const Scalar &mean=Scalar(), bool swapRB=false, bool crop=false, int ddepth=CV_32F)

Creates 4-dimensional blob from image. Optionally resizes and crops image from center, subtract mean values, scales values by scalefactor, swap Blue and Red channels. More...

voidcv::dnn::blobFromImage (InputArray image, OutputArray blob, double scalefactor=1.0, const Size &size=Size(), const Scalar &mean=Scalar(), bool swapRB=false, bool crop=false, int ddepth=CV_32F)

Creates 4-dimensional blob from image. More...

cv::dnn::blobFromImages (InputArrayOfArrays images, double scalefactor=1.0, Size size=Size(), const Scalar &mean=Scalar(), bool swapRB=false, bool crop=false, int ddepth=CV_32F)

Creates 4-dimensional blob from series of images. Optionally resizes and crops images from center, subtract mean values, scales values by scalefactor, swap Blue and Red channels. More...

voidcv::dnn::blobFromImages (InputArrayOfArrays images, OutputArray blob, double scalefactor=1.0, Size size=Size(), const Scalar &mean=Scalar(), bool swapRB=false, bool crop=false, int ddepth=CV_32F)

Creates 4-dimensional blob from series of images. More...

Enables detailed logging of the DNN model loading with CV DNN API. More...

Parse a 4D blob and output the images it contains as 2D arrays through a simpler data structure (std::vector<:mat>). More...

voidcv::dnn::NMSBoxes (const std::vector< Rect > &bboxes, const std::vector< float > &scores, const float score_threshold, const float nms_threshold, std::vector< int > &indices, const float eta=1.f, const int top_k=0)

Performs non maximum suppression given boxes and corresponding scores. More...

voidcv::dnn::NMSBoxes (const std::vector< Rect2d > &bboxes, const std::vector< float > &scores, const float score_threshold, const float nms_threshold, std::vector< int > &indices, const float eta=1.f, const int top_k=0)

voidcv::dnn::NMSBoxes (const std::vector< RotatedRect > &bboxes, const std::vector< float > &scores, const float score_threshold, const float nms_threshold, std::vector< int > &indices, const float eta=1.f, const int top_k=0)

cv::dnn::readNet (const String &model, const String &config="", const String &framework="")

Read deep learning network represented in one of the supported formats. More...

cv::dnn::readNet (const String &framework, const std::vector< uchar > &bufferModel, const std::vector< uchar > &bufferConfig=std::vector< uchar >())

Read deep learning network represented in one of the supported formats. More...

Reads a network model stored in Caffe framework's format. More...

cv::dnn::readNetFromCaffe (const std::vector< uchar > &bufferProto, const std::vector< uchar > &bufferModel=std::vector< uchar >())

Reads a network model stored in Caffe model in memory. More...

cv::dnn::readNetFromCaffe (const char *bufferProto, size_t lenProto, const char *bufferModel=NULL, size_t lenModel=0)

Reads a network model stored in Caffe model in memory. More...

Reads a network model stored in Darknet model files. More...

cv::dnn::readNetFromDarknet (const std::vector< uchar > &bufferCfg, const std::vector< uchar > &bufferModel=std::vector< uchar >())

Reads a network model stored in Darknet model files. More...

cv::dnn::readNetFromDarknet (const char *bufferCfg, size_t lenCfg, const char *bufferModel=NULL, size_t lenModel=0)

Reads a network model stored in Darknet model files. More...

Load a network from Intel's Model Optimizer intermediate representation. More...

cv::dnn::readNetFromModelOptimizer (const std::vector< uchar > &bufferModelConfig, const std::vector< uchar > &bufferWeights)

Load a network from Intel's Model Optimizer intermediate representation. More...

cv::dnn::readNetFromModelOptimizer (const uchar *bufferModelConfigPtr, size_t bufferModelConfigSize, const uchar *bufferWeightsPtr, size_t bufferWeightsSize)

Load a network from Intel's Model Optimizer intermediate representation. More...

Reads a network model ONNX. More...

cv::dnn::readNetFromONNX (const char *buffer, size_t sizeBuffer)

Reads a network model from ONNX in-memory buffer. More...

Reads a network model from ONNX in-memory buffer. More...

Reads a network model stored in TensorFlow framework's format. More...

cv::dnn::readNetFromTensorflow (const std::vector< uchar > &bufferModel, const std::vector< uchar > &bufferConfig=std::vector< uchar >())

Reads a network model stored in TensorFlow framework's format. More...

cv::dnn::readNetFromTensorflow (const char *bufferModel, size_t lenModel, const char *bufferConfig=NULL, size_t lenConfig=0)

Reads a network model stored in TensorFlow framework's format. More...

cv::dnn::readNetFromTorch (const String &model, bool isBinary=true, bool evaluate=true)

Reads a network model stored in Torch7 framework's format. More...

Creates blob from .pb file. More...

cv::dnn::readTorchBlob (const String &filename, bool isBinary=true)

Loads blob which was serialized as torch.Tensor object of Torch7 framework. More...

voidcv::dnn::shrinkCaffeModel (const String &src, const String &dst, const std::vector< String > &layersTypes=std::vector< String >())

Convert all weights of Caffe network to half precision floating point. More...

Create a text representation for a binary network stored in protocol buffer format. More...

Detailed Description

This module contains:API for new layers creation, layers are building bricks of neural networks;

set of built-in most-useful Layers;

API to construct and modify comprehensive neural networks from layers;

functionality for loading serialized networks models from different frameworks.

Functionality of this module is designed only for forward pass computations (i.e. network testing). A network training is in principle not supported.

Typedef Documentation

Register layer types of DNN model.

Enumeration Type Documentation

Enum of computation backends supported by layers.

Enumerator

DNN_BACKEND_DEFAULT

Python: cv.dnn.DNN_BACKEND_DEFAULTDNN_BACKEND_DEFAULT equals to DNN_BACKEND_INFERENCE_ENGINE if OpenCV is built with Intel's Inference Engine library or DNN_BACKEND_OPENCV otherwise.

DNN_BACKEND_HALIDE

Python: cv.dnn.DNN_BACKEND_HALIDE

DNN_BACKEND_INFERENCE_ENGINE

Python: cv.dnn.DNN_BACKEND_INFERENCE_ENGINEIntel's Inference Engine computational backend

DNN_BACKEND_OPENCV

Python: cv.dnn.DNN_BACKEND_OPENCV

DNN_BACKEND_VKCOM

Python: cv.dnn.DNN_BACKEND_VKCOM

DNN_BACKEND_CUDA

Python: cv.dnn.DNN_BACKEND_CUDA

Enum of target devices for computations.

Enumerator

DNN_TARGET_CPU

Python: cv.dnn.DNN_TARGET_CPU

DNN_TARGET_OPENCL

Python: cv.dnn.DNN_TARGET_OPENCL

DNN_TARGET_OPENCL_FP16

Python: cv.dnn.DNN_TARGET_OPENCL_FP16

DNN_TARGET_MYRIAD

Python: cv.dnn.DNN_TARGET_MYRIAD

DNN_TARGET_VULKAN

Python: cv.dnn.DNN_TARGET_VULKAN

DNN_TARGET_FPGA

Python: cv.dnn.DNN_TARGET_FPGAFPGA device with CPU fallbacks using Inference Engine's Heterogeneous plugin.

DNN_TARGET_CUDA

Python: cv.dnn.DNN_TARGET_CUDA

DNN_TARGET_CUDA_FP16

Python: cv.dnn.DNN_TARGET_CUDA_FP16

DNN_TARGET_HDDL

Python: cv.dnn.DNN_TARGET_HDDL

Function Documentation

[1/2]

Mat cv::dnn::blobFromImage

(

image,

double

scalefactor = 1.0,

const Size &

size =

const Scalar &

mean =

bool

swapRB = false,

bool

crop = false,

int

ddepth =

)Python:

cv.dnn.blobFromImage(image[, scalefactor[, size[, mean[, swapRB[, crop[, ddepth]]]]]]) ->retval

Creates 4-dimensional blob from image. Optionally resizes and crops image from center, subtract mean values, scales values by scalefactor, swap Blue and Red channels.

Parametersimageinput image (with 1-, 3- or 4-channels).

sizespatial size for output image

meanscalar with mean values which are subtracted from channels. Values are intended to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true.

scalefactormultiplier for image values.

swapRBflag which indicates that swap first and last channels in 3-channel image is necessary.

cropflag which indicates whether image will be cropped after resize or not

ddepthDepth of output blob. Choose CV_32F or CV_8U.

if crop is true, input image is resized so one side after resize is equal to corresponding dimension in size and another one is equal or larger. Then, crop from the center is performed. If crop is false, direct resize without cropping and preserving aspect ratio is performed.Returns4-dimensional Mat with NCHW dimensions order.

[2/2]

void cv::dnn::blobFromImage

(

image,

double

scalefactor = 1.0,

const Size &

size =

const Scalar &

mean =

bool

swapRB = false,

bool

crop = false,

int

ddepth =

)Python:

cv.dnn.blobFromImage(image[, scalefactor[, size[, mean[, swapRB[, crop[, ddepth]]]]]]) ->retval

Creates 4-dimensional blob from image.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

[1/2]

Mat cv::dnn::blobFromImages

(

images,

double

scalefactor = 1.0,

size =

const Scalar &

mean =

bool

swapRB = false,

bool

crop = false,

int

ddepth =

)Python:

cv.dnn.blobFromImages(images[, scalefactor[, size[, mean[, swapRB[, crop[, ddepth]]]]]]) ->retval

Creates 4-dimensional blob from series of images. Optionally resizes and crops images from center, subtract mean values, scales values by scalefactor, swap Blue and Red channels.

Parametersimagesinput images (all with 1-, 3- or 4-channels).

sizespatial size for output image

meanscalar with mean values which are subtracted from channels. Values are intended to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true.

scalefactormultiplier for images values.

swapRBflag which indicates that swap first and last channels in 3-channel image is necessary.

cropflag which indicates whether image will be cropped after resize or not

ddepthDepth of output blob. Choose CV_32F or CV_8U.

if crop is true, input image is resized so one side after resize is equal to corresponding dimension in size and another one is equal or larger. Then, crop from the center is performed. If crop is false, direct resize without cropping and preserving aspect ratio is performed.Returns4-dimensional Mat with NCHW dimensions order.

[2/2]

void cv::dnn::blobFromImages

(

images,

double

scalefactor = 1.0,

size =

const Scalar &

mean =

bool

swapRB = false,

bool

crop = false,

int

ddepth =

)Python:

cv.dnn.blobFromImages(images[, scalefactor[, size[, mean[, swapRB[, crop[, ddepth]]]]]]) ->retval

Creates 4-dimensional blob from series of images.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void cv::dnn::enableModelDiagnostics

(

bool

isDiagnosticsMode)

Enables detailed logging of the DNN model loading with CV DNN API.

Parameters[in]isDiagnosticsModeIndicates whether diagnostic mode should be set.

Diagnostic mode provides detailed logging of the model loading stage to explore potential problems (ex.: not implemented layer type).

NoteIn diagnostic mode series of assertions will be skipped, it can lead to the expected application crash.

std::vector< std::pair > cv::dnn::getAvailableBackends

(

)

std::vector cv::dnn::getAvailableTargets

(

be)Python:

cv.dnn.getAvailableTargets(be) ->retval

void cv::dnn::imagesFromBlob

(

blob_,

)Python:

cv.dnn.imagesFromBlob(blob_[, images_]) ->images_

Parse a 4D blob and output the images it contains as 2D arrays through a simpler data structure (std::vector<:mat>).

Parameters[in]blob_4 dimensional array (images, channels, height, width) in floating point precision (CV_32F) from which you would like to extract the images.

[out]images_array of 2D Mat containing the images extracted from the blob in floating point precision (CV_32F). They are non normalized neither mean added. The number of returned images equals the first dimension of the blob (batch size). Every image has a number of channels equals to the second dimension of the blob (depth).

[1/3]

void cv::dnn::NMSBoxes

(

const std::vector< Rect > &

bboxes,

const std::vector< float > &

scores,

const float

score_threshold,

const float

nms_threshold,

std::vector< int > &

indices,

const float

eta = 1.f,

const int

top_k = 0

)Python:

cv.dnn.NMSBoxes(bboxes, scores, score_threshold, nms_threshold[, eta[, top_k]]) ->indices

cv.dnn.NMSBoxesRotated(bboxes, scores, score_threshold, nms_threshold[, eta[, top_k]]) ->indices

Performs non maximum suppression given boxes and corresponding scores.

Parametersbboxesa set of bounding boxes to apply NMS.

scoresa set of corresponding confidences.

score_thresholda threshold used to filter boxes by score.

nms_thresholda threshold used in non maximum suppression.

indicesthe kept indices of bboxes after NMS.

etaa coefficient in adaptive threshold formula: \(nms\_threshold_{i+1}=eta\cdot nms\_threshold_i\).

top_kif >0, keep at most top_k picked indices.

[2/3]

void cv::dnn::NMSBoxes

(

const std::vector< Rect2d > &

bboxes,

const std::vector< float > &

scores,

const float

score_threshold,

const float

nms_threshold,

std::vector< int > &

indices,

const float

eta = 1.f,

const int

top_k = 0

)Python:

cv.dnn.NMSBoxes(bboxes, scores, score_threshold, nms_threshold[, eta[, top_k]]) ->indices

cv.dnn.NMSBoxesRotated(bboxes, scores, score_threshold, nms_threshold[, eta[, top_k]]) ->indices

[3/3]

void cv::dnn::NMSBoxes

(

const std::vector< RotatedRect > &

bboxes,

const std::vector< float > &

scores,

const float

score_threshold,

const float

nms_threshold,

std::vector< int > &

indices,

const float

eta = 1.f,

const int

top_k = 0

)Python:

cv.dnn.NMSBoxes(bboxes, scores, score_threshold, nms_threshold[, eta[, top_k]]) ->indices

cv.dnn.NMSBoxesRotated(bboxes, scores, score_threshold, nms_threshold[, eta[, top_k]]) ->indices

[1/2]

Net cv::dnn::readNet

(

const String &

model,

const String &

config = "",

const String &

framework = ""

)Python:

cv.dnn.readNet(model[, config[, framework]]) ->retval

cv.dnn.readNet(framework, bufferModel[, bufferConfig]) ->retval

Read deep learning network represented in one of the supported formats.

Parameters[in]modelBinary file contains trained weights. The following file extensions are expected for models from different frameworks:

[in]configText file contains network configuration. It could be a file with the following extensions:

[in]frameworkExplicit framework name tag to determine a format.

ReturnsNet object.

This function automatically detects an origin framework of trained model and calls an appropriate function such readNetFromCaffe, readNetFromTensorflow, readNetFromTorch or readNetFromDarknet. An order of model and config arguments does not matter.

[2/2]

Net cv::dnn::readNet

(

const String &

framework,

const std::vector< uchar > &

bufferModel,

const std::vector< uchar > &

bufferConfig = std::vector()

)Python:

cv.dnn.readNet(model[, config[, framework]]) ->retval

cv.dnn.readNet(framework, bufferModel[, bufferConfig]) ->retval

Read deep learning network represented in one of the supported formats.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Parameters[in]frameworkName of origin framework.

[in]bufferModelA buffer with a content of binary file with weights

[in]bufferConfigA buffer with a content of text file contains network configuration.

ReturnsNet object.

[1/3]

Net cv::dnn::readNetFromCaffe

(

const String &

prototxt,

const String &

caffeModel =

)Python:

cv.dnn.readNetFromCaffe(prototxt[, caffeModel]) ->retval

cv.dnn.readNetFromCaffe(bufferProto[, bufferModel]) ->retval

Reads a network model stored in Caffe framework's format.

Parametersprototxtpath to the .prototxt file with text description of the network architecture.

caffeModelpath to the .caffemodel file with learned network.

ReturnsNet object.

[2/3]

Net cv::dnn::readNetFromCaffe

(

const std::vector< uchar > &

bufferProto,

const std::vector< uchar > &

bufferModel = std::vector()

)Python:

cv.dnn.readNetFromCaffe(prototxt[, caffeModel]) ->retval

cv.dnn.readNetFromCaffe(bufferProto[, bufferModel]) ->retval

Reads a network model stored in Caffe model in memory.

ParametersbufferProtobuffer containing the content of the .prototxt file

bufferModelbuffer containing the content of the .caffemodel file

ReturnsNet object.

[3/3]

Net cv::dnn::readNetFromCaffe

(

const char *

bufferProto,

size_t

lenProto,

const char *

bufferModel = NULL,

size_t

lenModel = 0

)Python:

cv.dnn.readNetFromCaffe(prototxt[, caffeModel]) ->retval

cv.dnn.readNetFromCaffe(bufferProto[, bufferModel]) ->retval

Reads a network model stored in Caffe model in memory.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.ParametersbufferProtobuffer containing the content of the .prototxt file

lenProtolength of bufferProto

bufferModelbuffer containing the content of the .caffemodel file

lenModellength of bufferModel

ReturnsNet object.

[1/3]

Net cv::dnn::readNetFromDarknet

(

const String &

cfgFile,

const String &

darknetModel =

)Python:

cv.dnn.readNetFromDarknet(cfgFile[, darknetModel]) ->retval

cv.dnn.readNetFromDarknet(bufferCfg[, bufferModel]) ->retval

Reads a network model stored in Darknet model files.

ParameterscfgFilepath to the .cfg file with text description of the network architecture.

darknetModelpath to the .weights file with learned network.

ReturnsNetwork object that ready to do forward, throw an exception in failure cases.

Net object.

[2/3]

Net cv::dnn::readNetFromDarknet

(

const std::vector< uchar > &

bufferCfg,

const std::vector< uchar > &

bufferModel = std::vector()

)Python:

cv.dnn.readNetFromDarknet(cfgFile[, darknetModel]) ->retval

cv.dnn.readNetFromDarknet(bufferCfg[, bufferModel]) ->retval

Reads a network model stored in Darknet model files.

ParametersbufferCfgA buffer contains a content of .cfg file with text description of the network architecture.

bufferModelA buffer contains a content of .weights file with learned network.

ReturnsNet object.

[3/3]

Net cv::dnn::readNetFromDarknet

(

const char *

bufferCfg,

size_t

lenCfg,

const char *

bufferModel = NULL,

size_t

lenModel = 0

)Python:

cv.dnn.readNetFromDarknet(cfgFile[, darknetModel]) ->retval

cv.dnn.readNetFromDarknet(bufferCfg[, bufferModel]) ->retval

Reads a network model stored in Darknet model files.

ParametersbufferCfgA buffer contains a content of .cfg file with text description of the network architecture.

lenCfgNumber of bytes to read from bufferCfg

bufferModelA buffer contains a content of .weights file with learned network.

lenModelNumber of bytes to read from bufferModel

ReturnsNet object.

[1/3]

Net cv::dnn::readNetFromModelOptimizer

(

const String &

xml,

const String &

bin

)Python:

cv.dnn.readNetFromModelOptimizer(xml, bin) ->retval

cv.dnn.readNetFromModelOptimizer(bufferModelConfig, bufferWeights) ->retval

Load a network from Intel's Model Optimizer intermediate representation.

Parameters[in]xmlXML configuration file with network's topology.

[in]binBinary file with trained weights.

ReturnsNet object. Networks imported from Intel's Model Optimizer are launched in Intel's Inference Engine backend.

[2/3]

Net cv::dnn::readNetFromModelOptimizer

(

const std::vector< uchar > &

bufferModelConfig,

const std::vector< uchar > &

bufferWeights

)Python:

cv.dnn.readNetFromModelOptimizer(xml, bin) ->retval

cv.dnn.readNetFromModelOptimizer(bufferModelConfig, bufferWeights) ->retval

Load a network from Intel's Model Optimizer intermediate representation.

Parameters[in]bufferModelConfigBuffer contains XML configuration with network's topology.

[in]bufferWeightsBuffer contains binary data with trained weights.

ReturnsNet object. Networks imported from Intel's Model Optimizer are launched in Intel's Inference Engine backend.

[3/3]

Net cv::dnn::readNetFromModelOptimizer

(

const uchar *

bufferModelConfigPtr,

size_t

bufferModelConfigSize,

const uchar *

bufferWeightsPtr,

size_t

bufferWeightsSize

)Python:

cv.dnn.readNetFromModelOptimizer(xml, bin) ->retval

cv.dnn.readNetFromModelOptimizer(bufferModelConfig, bufferWeights) ->retval

Load a network from Intel's Model Optimizer intermediate representation.

Parameters[in]bufferModelConfigPtrPointer to buffer which contains XML configuration with network's topology.

[in]bufferModelConfigSizeBinary size of XML configuration data.

[in]bufferWeightsPtrPointer to buffer which contains binary data with trained weights.

[in]bufferWeightsSizeBinary size of trained weights data.

ReturnsNet object. Networks imported from Intel's Model Optimizer are launched in Intel's Inference Engine backend.

[1/3]

Net cv::dnn::readNetFromONNX

(

const String &

onnxFile)Python:

cv.dnn.readNetFromONNX(onnxFile) ->retval

cv.dnn.readNetFromONNX(buffer) ->retval

Reads a network model ONNX.

ParametersonnxFilepath to the .onnx file with text description of the network architecture.

ReturnsNetwork object that ready to do forward, throw an exception in failure cases.

[2/3]

Net cv::dnn::readNetFromONNX

(

const char *

buffer,

size_t

sizeBuffer

)Python:

cv.dnn.readNetFromONNX(onnxFile) ->retval

cv.dnn.readNetFromONNX(buffer) ->retval

Reads a network model from ONNX in-memory buffer.

Parametersbuffermemory address of the first byte of the buffer.

sizeBuffersize of the buffer.

ReturnsNetwork object that ready to do forward, throw an exception in failure cases.

[3/3]

Net cv::dnn::readNetFromONNX

(

const std::vector< uchar > &

buffer)Python:

cv.dnn.readNetFromONNX(onnxFile) ->retval

cv.dnn.readNetFromONNX(buffer) ->retval

Reads a network model from ONNX in-memory buffer.

Parametersbufferin-memory buffer that stores the ONNX model bytes.

ReturnsNetwork object that ready to do forward, throw an exception in failure cases.

[1/3]

Net cv::dnn::readNetFromTensorflow

(

const String &

model,

const String &

config =

)Python:

cv.dnn.readNetFromTensorflow(model[, config]) ->retval

cv.dnn.readNetFromTensorflow(bufferModel[, bufferConfig]) ->retval

Reads a network model stored in TensorFlow framework's format.

Parametersmodelpath to the .pb file with binary protobuf description of the network architecture

configpath to the .pbtxt file that contains text graph definition in protobuf format. Resulting Net object is built by text graph using weights from a binary one that let us make it more flexible.

ReturnsNet object.

[2/3]

Net cv::dnn::readNetFromTensorflow

(

const std::vector< uchar > &

bufferModel,

const std::vector< uchar > &

bufferConfig = std::vector()

)Python:

cv.dnn.readNetFromTensorflow(model[, config]) ->retval

cv.dnn.readNetFromTensorflow(bufferModel[, bufferConfig]) ->retval

Reads a network model stored in TensorFlow framework's format.

ParametersbufferModelbuffer containing the content of the pb file

bufferConfigbuffer containing the content of the pbtxt file

ReturnsNet object.

[3/3]

Net cv::dnn::readNetFromTensorflow

(

const char *

bufferModel,

size_t

lenModel,

const char *

bufferConfig = NULL,

size_t

lenConfig = 0

)Python:

cv.dnn.readNetFromTensorflow(model[, config]) ->retval

cv.dnn.readNetFromTensorflow(bufferModel[, bufferConfig]) ->retval

Reads a network model stored in TensorFlow framework's format.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.ParametersbufferModelbuffer containing the content of the pb file

lenModellength of bufferModel

bufferConfigbuffer containing the content of the pbtxt file

lenConfiglength of bufferConfig

Net cv::dnn::readNetFromTorch

(

const String &

model,

bool

isBinary = true,

bool

evaluate = true

)Python:

cv.dnn.readNetFromTorch(model[, isBinary[, evaluate]]) ->retval

Reads a network model stored in Torch7 framework's format.

Parametersmodelpath to the file, dumped from Torch by using torch.save() function.

isBinaryspecifies whether the network was serialized in ascii mode or binary.

evaluatespecifies testing phase of network. If true, it's similar to evaluate() method in Torch.

ReturnsNet object.

NoteAscii mode of Torch serializer is more preferable, because binary mode extensively use long type of C language, which has various bit-length on different systems.

The loading file must contain serialized nn.Module object with importing network. Try to eliminate a custom objects from serialazing data to avoid importing errors.

List of supported layers (i.e. object instances derived from Torch nn.Module class):nn.Sequential

nn.Parallel

nn.Concat

nn.Linear

nn.SpatialConvolution

nn.SpatialMaxPooling, nn.SpatialAveragePooling

nn.ReLU, nn.TanH, nn.Sigmoid

nn.Reshape

nn.SoftMax, nn.LogSoftMax

Also some equivalents of these classes from cunn, cudnn, and fbcunn may be successfully imported.

Mat cv::dnn::readTensorFromONNX

(

const String &

path)Python:

cv.dnn.readTensorFromONNX(path) ->retval

Creates blob from .pb file.

Parameterspathto the .pb file with input tensor.

Returns

Mat cv::dnn::readTorchBlob

(

const String &

filename,

bool

isBinary = true

)Python:

cv.dnn.readTorchBlob(filename[, isBinary]) ->retval

Loads blob which was serialized as torch.Tensor object of Torch7 framework.

WarningThis function has the same limitations as readNetFromTorch().

void cv::dnn::shrinkCaffeModel

(

const String &

src,

const String &

dst,

const std::vector< String > &

layersTypes = std::vector()

)Python:

cv.dnn.shrinkCaffeModel(src, dst[, layersTypes]) ->None

Convert all weights of Caffe network to half precision floating point.

ParameterssrcPath to origin model from Caffe framework contains single precision floating point weights (usually has .caffemodel extension).

dstPath to destination model with updated weights.

layersTypesSet of layers types which parameters will be converted. By default, converts only Convolutional and Fully-Connected layers' weights.

NoteShrinked model has no origin float32 weights so it can't be used in origin Caffe framework anymore. However the structure of data is taken from NVidia's Caffe fork: https://github.com/NVIDIA/caffe. So the resulting model may be used there.

void cv::dnn::writeTextGraph

(

const String &

model,

const String &

output

)Python:

cv.dnn.writeTextGraph(model, output) ->None

Create a text representation for a binary network stored in protocol buffer format.

Parameters[in]modelA path to binary network.

[in]outputA path to output text file to be created.

NoteTo reduce output file size, trained weights are not included.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值