View Source Evision.DNN (Evision v0.2.9)

Summary

Types

t()

Type that represents an DNN struct.

Functions

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

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

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

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

blobFromImagesWithParams

blobFromImagesWithParams

blobFromImageWithParams

blobFromImageWithParams

getAvailableTargets

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

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

Performs non maximum suppression given boxes and corresponding scores.

Performs non maximum suppression given boxes and corresponding scores.

Performs batched non maximum suppression on given boxes and corresponding scores across different classes.

Performs batched non maximum suppression on given boxes and corresponding scores across different classes.

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

Variant 1:

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

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

Reads a network model stored in <a href="http://caffe.berkeleyvision.org">Caffe</a> framework's format.

Reads a network model stored in <a href="http://caffe.berkeleyvision.org">Caffe</a> framework's format.

Reads a network model stored in Caffe model in memory.

Reads a network model stored in Caffe model in memory.

Reads a network model stored in <a href="https://pjreddie.com/darknet/">Darknet</a> model files.

Reads a network model stored in <a href="https://pjreddie.com/darknet/">Darknet</a> model files.

Reads a network model stored in <a href="https://pjreddie.com/darknet/">Darknet</a> model files.

Reads a network model stored in <a href="https://pjreddie.com/darknet/">Darknet</a> model files.

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

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

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

Reads a network model <a href="https://onnx.ai/">ONNX</a>.

Reads a network model from <a href="https://onnx.ai/">ONNX</a> in-memory buffer.

Reads a network model stored in <a href="https://www.tensorflow.org/">TensorFlow</a> framework's format.

Reads a network model stored in <a href="https://www.tensorflow.org/">TensorFlow</a> framework's format.

Reads a network model stored in <a href="https://www.tensorflow.org/">TensorFlow</a> framework's format.

Reads a network model stored in <a href="https://www.tensorflow.org/">TensorFlow</a> framework's format.

Reads a network model stored in <a href="https://www.tensorflow.org/lite">TFLite</a> framework's format.

Reads a network model stored in <a href="https://www.tensorflow.org/lite">TFLite</a> framework's format.

Reads a network model stored in <a href="http://torch.ch">Torch7</a> framework's format.

Reads a network model stored in <a href="http://torch.ch">Torch7</a> framework's format.

Creates blob from .pb file.

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

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

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

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

Performs soft non maximum suppression given boxes and corresponding scores. Reference: https://arxiv.org/abs/1704.04503

Performs soft non maximum suppression given boxes and corresponding scores. Reference: https://arxiv.org/abs/1704.04503

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

Types

@type t() :: %Evision.DNN{ref: reference()}

Type that represents an DNN struct.

  • ref. reference()

    The underlying erlang resource variable.

Functions

Link to this function

blobFromImage(named_args)

View Source
@spec blobFromImage(Keyword.t()) :: any() | {:error, String.t()}
@spec blobFromImage(Evision.Mat.maybe_mat_in()) ::
  Evision.Mat.t() | {:error, String.t()}

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

Positional Arguments
  • image: Evision.Mat.

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

Keyword Arguments
  • scalefactor: double.

    multiplier for @p images values.

  • size: Size.

    spatial size for output image

  • mean: Evision.scalar().

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

  • swapRB: bool.

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

  • crop: bool.

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

  • ddepth: integer().

    Depth of output blob. Choose CV_32F or CV_8U.

Return
  • retval: Evision.Mat.t()

@details if @p crop is true, input image is resized so one side after resize is equal to corresponding dimension in @p size and another one is equal or larger. Then, crop from the center is performed. If @p crop is false, direct resize without cropping and preserving aspect ratio is performed. @returns 4-dimensional Mat with NCHW dimensions order. Note: The order and usage of scalefactor and mean are (input - mean) * scalefactor.

Python prototype (for reference only):

blobFromImage(image[, scalefactor[, size[, mean[, swapRB[, crop[, ddepth]]]]]]) -> retval
Link to this function

blobFromImage(image, opts)

View Source
@spec blobFromImage(
  Evision.Mat.maybe_mat_in(),
  [
    crop: term(),
    ddepth: term(),
    mean: term(),
    scalefactor: term(),
    size: term(),
    swapRB: term()
  ]
  | nil
) :: Evision.Mat.t() | {:error, String.t()}

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

Positional Arguments
  • image: Evision.Mat.

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

Keyword Arguments
  • scalefactor: double.

    multiplier for @p images values.

  • size: Size.

    spatial size for output image

  • mean: Evision.scalar().

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

  • swapRB: bool.

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

  • crop: bool.

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

  • ddepth: integer().

    Depth of output blob. Choose CV_32F or CV_8U.

Return
  • retval: Evision.Mat.t()

@details if @p crop is true, input image is resized so one side after resize is equal to corresponding dimension in @p size and another one is equal or larger. Then, crop from the center is performed. If @p crop is false, direct resize without cropping and preserving aspect ratio is performed. @returns 4-dimensional Mat with NCHW dimensions order. Note: The order and usage of scalefactor and mean are (input - mean) * scalefactor.

Python prototype (for reference only):

blobFromImage(image[, scalefactor[, size[, mean[, swapRB[, crop[, ddepth]]]]]]) -> retval
Link to this function

blobFromImages(named_args)

View Source
@spec blobFromImages(Keyword.t()) :: any() | {:error, String.t()}
@spec blobFromImages([Evision.Mat.maybe_mat_in()]) ::
  Evision.Mat.t() | {:error, String.t()}

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

Positional Arguments
  • images: [Evision.Mat].

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

Keyword Arguments
  • scalefactor: double.

    multiplier for @p images values.

  • size: Size.

    spatial size for output image

  • mean: Evision.scalar().

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

  • swapRB: bool.

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

  • crop: bool.

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

  • ddepth: integer().

    Depth of output blob. Choose CV_32F or CV_8U.

Return
  • retval: Evision.Mat.t()

@details if @p crop is true, input image is resized so one side after resize is equal to corresponding dimension in @p size and another one is equal or larger. Then, crop from the center is performed. If @p crop is false, direct resize without cropping and preserving aspect ratio is performed. @returns 4-dimensional Mat with NCHW dimensions order. Note: The order and usage of scalefactor and mean are (input - mean) * scalefactor.

Python prototype (for reference only):

blobFromImages(images[, scalefactor[, size[, mean[, swapRB[, crop[, ddepth]]]]]]) -> retval
Link to this function

blobFromImages(images, opts)

View Source
@spec blobFromImages(
  [Evision.Mat.maybe_mat_in()],
  [
    crop: term(),
    ddepth: term(),
    mean: term(),
    scalefactor: term(),
    size: term(),
    swapRB: term()
  ]
  | nil
) :: Evision.Mat.t() | {:error, String.t()}

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

Positional Arguments
  • images: [Evision.Mat].

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

Keyword Arguments
  • scalefactor: double.

    multiplier for @p images values.

  • size: Size.

    spatial size for output image

  • mean: Evision.scalar().

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

  • swapRB: bool.

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

  • crop: bool.

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

  • ddepth: integer().

    Depth of output blob. Choose CV_32F or CV_8U.

Return
  • retval: Evision.Mat.t()

@details if @p crop is true, input image is resized so one side after resize is equal to corresponding dimension in @p size and another one is equal or larger. Then, crop from the center is performed. If @p crop is false, direct resize without cropping and preserving aspect ratio is performed. @returns 4-dimensional Mat with NCHW dimensions order. Note: The order and usage of scalefactor and mean are (input - mean) * scalefactor.

Python prototype (for reference only):

blobFromImages(images[, scalefactor[, size[, mean[, swapRB[, crop[, ddepth]]]]]]) -> retval
Link to this function

blobFromImagesWithParams(named_args)

View Source
@spec blobFromImagesWithParams(Keyword.t()) :: any() | {:error, String.t()}
@spec blobFromImagesWithParams([Evision.Mat.maybe_mat_in()]) ::
  Evision.Mat.t() | {:error, String.t()}

blobFromImagesWithParams

Positional Arguments
  • images: [Evision.Mat]
Keyword Arguments
  • param: Image2BlobParams.
Return
  • blob: Evision.Mat.t().

Has overloading in C++

Python prototype (for reference only):

blobFromImagesWithParams(images[, blob[, param]]) -> blob
Link to this function

blobFromImagesWithParams(images, opts)

View Source
@spec blobFromImagesWithParams([Evision.Mat.maybe_mat_in()], [{:param, term()}] | nil) ::
  Evision.Mat.t() | {:error, String.t()}

blobFromImagesWithParams

Positional Arguments
  • images: [Evision.Mat]
Keyword Arguments
  • param: Image2BlobParams.
Return
  • blob: Evision.Mat.t().

Has overloading in C++

Python prototype (for reference only):

blobFromImagesWithParams(images[, blob[, param]]) -> blob
Link to this function

blobFromImageWithParams(named_args)

View Source
@spec blobFromImageWithParams(Keyword.t()) :: any() | {:error, String.t()}
@spec blobFromImageWithParams(Evision.Mat.maybe_mat_in()) ::
  Evision.Mat.t() | {:error, String.t()}

blobFromImageWithParams

Positional Arguments
Keyword Arguments
  • param: Image2BlobParams.
Return
  • blob: Evision.Mat.t().

Has overloading in C++

Python prototype (for reference only):

blobFromImageWithParams(image[, blob[, param]]) -> blob
Link to this function

blobFromImageWithParams(image, opts)

View Source
@spec blobFromImageWithParams(Evision.Mat.maybe_mat_in(), [{:param, term()}] | nil) ::
  Evision.Mat.t() | {:error, String.t()}

blobFromImageWithParams

Positional Arguments
Keyword Arguments
  • param: Image2BlobParams.
Return
  • blob: Evision.Mat.t().

Has overloading in C++

Python prototype (for reference only):

blobFromImageWithParams(image[, blob[, param]]) -> blob
Link to this function

getAvailableTargets(named_args)

View Source
@spec getAvailableTargets(Keyword.t()) :: any() | {:error, String.t()}
@spec getAvailableTargets(Evision.DNN.Backend.enum()) ::
  [Evision.DNN.Target.enum()] | {:error, String.t()}

getAvailableTargets

Positional Arguments
  • be: dnn_Backend
Return
  • retval: [Target]

Python prototype (for reference only):

getAvailableTargets(be) -> retval
Link to this function

imagesFromBlob(named_args)

View Source
@spec imagesFromBlob(Keyword.t()) :: any() | {:error, String.t()}
@spec imagesFromBlob(Evision.Mat.maybe_mat_in()) ::
  [Evision.Mat.t()] | {:error, String.t()}

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

Positional Arguments
  • blob_: Evision.Mat.

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

Return
  • images_: [Evision.Mat].

    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).

Python prototype (for reference only):

imagesFromBlob(blob_[, images_]) -> images_
Link to this function

imagesFromBlob(blob_, opts)

View Source
@spec imagesFromBlob(Evision.Mat.maybe_mat_in(), [{atom(), term()}, ...] | nil) ::
  [Evision.Mat.t()] | {:error, String.t()}

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

Positional Arguments
  • blob_: Evision.Mat.

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

Return
  • images_: [Evision.Mat].

    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).

Python prototype (for reference only):

imagesFromBlob(blob_[, images_]) -> images_
Link to this function

nmsBoxes(bboxes, scores, score_threshold, nms_threshold)

View Source
@spec nmsBoxes(
  [{number(), number(), number(), number()}] | Evision.Mat.t() | Nx.Tensor.t(),
  [number()],
  number(),
  number()
) :: [integer()] | {:error, String.t()}

Performs non maximum suppression given boxes and corresponding scores.

Positional Arguments
  • bboxes: [Rect2d], Nx.Tensor.t(), Evision.Mat.t()..

    a set of bounding boxes to apply NMS.

  • scores: [float].

    a set of corresponding confidences.

  • score_threshold: float.

    a threshold used to filter boxes by score.

  • nms_threshold: float.

    a threshold used in non maximum suppression.

Keyword Arguments
  • eta: float.

    a coefficient in adaptive threshold formula: $nmsthreshold{i+1}=etacdot nms_threshold_i $.

  • top_k: int.

    if >0, keep at most @p top_k picked indices.

Return
  • indices: [int].

    the kept indices of bboxes after NMS.

Python prototype (for reference only):

NMSBoxes(bboxes, scores, score_threshold, nms_threshold[, eta[, top_k]]) -> indices
Link to this function

nmsBoxes(bboxes, scores, score_threshold, nms_threshold, opts)

View Source
@spec nmsBoxes(
  [{number(), number(), number(), number()}] | Evision.Mat.t() | Nx.Tensor.t(),
  [number()],
  number(),
  number(),
  [eta: term(), top_k: term()] | nil
) :: [integer()] | {:error, String.t()}

Performs non maximum suppression given boxes and corresponding scores.

Positional Arguments
  • bboxes: [Rect2d], Nx.Tensor.t(), Evision.Mat.t().

    a set of bounding boxes to apply NMS.

  • scores: [float].

    a set of corresponding confidences.

  • score_threshold: float.

    a threshold used to filter boxes by score.

  • nms_threshold: float.

    a threshold used in non maximum suppression.

Keyword Arguments
  • eta: float.

    a coefficient in adaptive threshold formula: $nmsthreshold{i+1}=etacdot nms_threshold_i $.

  • top_k: int.

    if >0, keep at most @p top_k picked indices.

Return
  • indices: [int].

    the kept indices of bboxes after NMS.

Python prototype (for reference only):

NMSBoxes(bboxes, scores, score_threshold, nms_threshold[, eta[, top_k]]) -> indices
Link to this function

nmsBoxesBatched(bboxes, scores, class_ids, score_threshold, nms_threshold)

View Source
@spec nmsBoxesBatched(
  [{number(), number(), number(), number()}],
  [number()],
  [integer()],
  number(),
  number()
) :: [integer()] | {:error, String.t()}

Performs batched non maximum suppression on given boxes and corresponding scores across different classes.

Positional Arguments
  • bboxes: [Rect2d], Nx.Tensor.t(), Evision.Mat.t().

    a set of bounding boxes to apply NMS.

  • scores: [float].

    a set of corresponding confidences.

  • class_ids: [int].

    a set of corresponding class ids. Ids are integer and usually start from 0.

  • score_threshold: float.

    a threshold used to filter boxes by score.

  • nms_threshold: float.

    a threshold used in non maximum suppression.

Keyword Arguments
  • eta: float.

    a coefficient in adaptive threshold formula: $nmsthreshold{i+1}=etacdot nms_threshold_i $.

  • top_k: int.

    if >0, keep at most @p top_k picked indices.

Return
  • indices: [int].

    the kept indices of bboxes after NMS.

Python prototype (for reference only):

NMSBoxesBatched(bboxes, scores, class_ids, score_threshold, nms_threshold[, eta[, top_k]]) -> indices
Link to this function

nmsBoxesBatched(bboxes, scores, class_ids, score_threshold, nms_threshold, opts)

View Source
@spec nmsBoxesBatched(
  [{number(), number(), number(), number()}],
  [number()],
  [integer()],
  number(),
  number(),
  [eta: term(), top_k: term()] | nil
) :: [integer()] | {:error, String.t()}

Performs batched non maximum suppression on given boxes and corresponding scores across different classes.

Positional Arguments
  • bboxes: [Rect2d], Nx.Tensor.t(), Evision.Mat.t().

    a set of bounding boxes to apply NMS.

  • scores: [float].

    a set of corresponding confidences.

  • class_ids: [int].

    a set of corresponding class ids. Ids are integer and usually start from 0.

  • score_threshold: float.

    a threshold used to filter boxes by score.

  • nms_threshold: float.

    a threshold used in non maximum suppression.

Keyword Arguments
  • eta: float.

    a coefficient in adaptive threshold formula: $nmsthreshold{i+1}=etacdot nms_threshold_i $.

  • top_k: int.

    if >0, keep at most @p top_k picked indices.

Return
  • indices: [int].

    the kept indices of bboxes after NMS.

Python prototype (for reference only):

NMSBoxesBatched(bboxes, scores, class_ids, score_threshold, nms_threshold[, eta[, top_k]]) -> indices
Link to this function

nmsBoxesRotated(named_args)

View Source
@spec nmsBoxesRotated(Keyword.t()) :: any() | {:error, String.t()}
Link to this function

nmsBoxesRotated(bboxes, scores, score_threshold, nms_threshold)

View Source
@spec nmsBoxesRotated(
  [{{number(), number()}, {number(), number()}, number()}],
  [number()],
  number(),
  number()
) :: [integer()] | {:error, String.t()}

NMSBoxesRotated

Positional Arguments
  • bboxes: [{centre={x, y}, size={s1, s2}, angle}]
  • scores: [float]
  • score_threshold: float
  • nms_threshold: float
Keyword Arguments
  • eta: float.
  • top_k: integer().
Return
  • indices: [integer()]

Python prototype (for reference only):

NMSBoxesRotated(bboxes, scores, score_threshold, nms_threshold[, eta[, top_k]]) -> indices
Link to this function

nmsBoxesRotated(bboxes, scores, score_threshold, nms_threshold, opts)

View Source
@spec nmsBoxesRotated(
  [{{number(), number()}, {number(), number()}, number()}],
  [number()],
  number(),
  number(),
  [eta: term(), top_k: term()] | nil
) :: [integer()] | {:error, String.t()}

NMSBoxesRotated

Positional Arguments
  • bboxes: [{centre={x, y}, size={s1, s2}, angle}]
  • scores: [float]
  • score_threshold: float
  • nms_threshold: float
Keyword Arguments
  • eta: float.
  • top_k: integer().
Return
  • indices: [integer()]

Python prototype (for reference only):

NMSBoxesRotated(bboxes, scores, score_threshold, nms_threshold[, eta[, top_k]]) -> indices
@spec readNet(Keyword.t()) :: any() | {:error, String.t()}
@spec readNet(binary()) :: Evision.DNN.Net.t() | {:error, String.t()}

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

Positional Arguments
Keyword Arguments
Return
  • retval: Evision.DNN.Net.t()

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

Python prototype (for reference only):

readNet(model[, config[, framework]]) -> retval
@spec readNet(binary(), [config: term(), framework: term()] | nil) ::
  Evision.DNN.Net.t() | {:error, String.t()}
@spec readNet(binary(), binary()) :: Evision.DNN.Net.t() | {:error, String.t()}

Variant 1:

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

Positional Arguments
  • framework: String.

    Name of origin framework.

  • bufferModel: [uchar].

    A buffer with a content of binary file with weights

Keyword Arguments
  • bufferConfig: [uchar].

    A buffer with a content of text file contains network configuration.

Return
  • retval: Evision.DNN.Net.t()

@details This is an overloaded member function, provided for convenience.

      It differs from the above function only in what argument(s) it accepts.

@returns Net object.

Python prototype (for reference only):

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

Variant 2:

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

Positional Arguments
Keyword Arguments
Return
  • retval: Evision.DNN.Net.t()

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

Python prototype (for reference only):

readNet(model[, config[, framework]]) -> retval
Link to this function

readNet(framework, bufferModel, opts)

View Source
@spec readNet(binary(), binary(), [{:bufferConfig, term()}] | nil) ::
  Evision.DNN.Net.t() | {:error, String.t()}

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

Positional Arguments
  • framework: String.

    Name of origin framework.

  • bufferModel: [uchar].

    A buffer with a content of binary file with weights

Keyword Arguments
  • bufferConfig: [uchar].

    A buffer with a content of text file contains network configuration.

Return
  • retval: Evision.DNN.Net.t()

@details This is an overloaded member function, provided for convenience.

      It differs from the above function only in what argument(s) it accepts.

@returns Net object.

Python prototype (for reference only):

readNet(framework, bufferModel[, bufferConfig]) -> retval
Link to this function

readNetFromCaffe(prototxt)

View Source
@spec readNetFromCaffe(binary()) :: Evision.DNN.Net.t() | {:error, String.t()}

Reads a network model stored in <a href="http://caffe.berkeleyvision.org">Caffe</a> framework's format.

Positional Arguments
  • prototxt: String.

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

Keyword Arguments
  • caffeModel: String.

    path to the .caffemodel file with learned network.

Return
  • retval: Evision.DNN.Net.t()

@returns Net object.

Python prototype (for reference only):

readNetFromCaffe(prototxt[, caffeModel]) -> retval
Link to this function

readNetFromCaffe(prototxt, opts)

View Source
@spec readNetFromCaffe(binary(), [{:caffeModel, term()}] | nil) ::
  Evision.DNN.Net.t() | {:error, String.t()}

Reads a network model stored in <a href="http://caffe.berkeleyvision.org">Caffe</a> framework's format.

Positional Arguments
  • prototxt: String.

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

Keyword Arguments
  • caffeModel: String.

    path to the .caffemodel file with learned network.

Return
  • retval: Evision.DNN.Net.t()

@returns Net object.

Python prototype (for reference only):

readNetFromCaffe(prototxt[, caffeModel]) -> retval
Link to this function

readNetFromCaffeBuffer(named_args)

View Source
@spec readNetFromCaffeBuffer(Keyword.t()) :: any() | {:error, String.t()}
@spec readNetFromCaffeBuffer(binary()) :: Evision.DNN.Net.t() | {:error, String.t()}

Reads a network model stored in Caffe model in memory.

Positional Arguments
  • bufferProto: [uchar].

    buffer containing the content of the .prototxt file

Keyword Arguments
  • bufferModel: [uchar].

    buffer containing the content of the .caffemodel file

Return
  • retval: Evision.DNN.Net.t()

@returns Net object.

Python prototype (for reference only):

readNetFromCaffe(bufferProto[, bufferModel]) -> retval
Link to this function

readNetFromCaffeBuffer(bufferProto, opts)

View Source
@spec readNetFromCaffeBuffer(binary(), [{:bufferModel, term()}] | nil) ::
  Evision.DNN.Net.t() | {:error, String.t()}

Reads a network model stored in Caffe model in memory.

Positional Arguments
  • bufferProto: [uchar].

    buffer containing the content of the .prototxt file

Keyword Arguments
  • bufferModel: [uchar].

    buffer containing the content of the .caffemodel file

Return
  • retval: Evision.DNN.Net.t()

@returns Net object.

Python prototype (for reference only):

readNetFromCaffe(bufferProto[, bufferModel]) -> retval
Link to this function

readNetFromDarknet(cfgFile)

View Source
@spec readNetFromDarknet(binary()) :: Evision.DNN.Net.t() | {:error, String.t()}

Reads a network model stored in <a href="https://pjreddie.com/darknet/">Darknet</a> model files.

Positional Arguments
  • cfgFile: String.

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

Keyword Arguments
  • darknetModel: String.

    path to the .weights file with learned network.

Return
  • retval: Evision.DNN.Net.t()

@returns Network object that ready to do forward, throw an exception in failure cases.

Python prototype (for reference only):

readNetFromDarknet(cfgFile[, darknetModel]) -> retval
Link to this function

readNetFromDarknet(cfgFile, opts)

View Source
@spec readNetFromDarknet(binary(), [{:darknetModel, term()}] | nil) ::
  Evision.DNN.Net.t() | {:error, String.t()}

Reads a network model stored in <a href="https://pjreddie.com/darknet/">Darknet</a> model files.

Positional Arguments
  • cfgFile: String.

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

Keyword Arguments
  • darknetModel: String.

    path to the .weights file with learned network.

Return
  • retval: Evision.DNN.Net.t()

@returns Network object that ready to do forward, throw an exception in failure cases.

Python prototype (for reference only):

readNetFromDarknet(cfgFile[, darknetModel]) -> retval
Link to this function

readNetFromDarknetBuffer(named_args)

View Source
@spec readNetFromDarknetBuffer(Keyword.t()) :: any() | {:error, String.t()}
@spec readNetFromDarknetBuffer(binary()) :: Evision.DNN.Net.t() | {:error, String.t()}

Reads a network model stored in <a href="https://pjreddie.com/darknet/">Darknet</a> model files.

Positional Arguments
  • bufferCfg: [uchar].

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

Keyword Arguments
  • bufferModel: [uchar].

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

Return
  • retval: Evision.DNN.Net.t()

@returns Net object.

Python prototype (for reference only):

readNetFromDarknet(bufferCfg[, bufferModel]) -> retval
Link to this function

readNetFromDarknetBuffer(bufferCfg, opts)

View Source
@spec readNetFromDarknetBuffer(binary(), [{:bufferModel, term()}] | nil) ::
  Evision.DNN.Net.t() | {:error, String.t()}

Reads a network model stored in <a href="https://pjreddie.com/darknet/">Darknet</a> model files.

Positional Arguments
  • bufferCfg: [uchar].

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

Keyword Arguments
  • bufferModel: [uchar].

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

Return
  • retval: Evision.DNN.Net.t()

@returns Net object.

Python prototype (for reference only):

readNetFromDarknet(bufferCfg[, bufferModel]) -> retval
Link to this function

readNetFromModelOptimizer(xml)

View Source
@spec readNetFromModelOptimizer(binary()) ::
  Evision.DNN.Net.t() | {:error, String.t()}

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

Positional Arguments
  • xml: String.

    XML configuration file with network's topology.

Keyword Arguments
  • bin: String.

    Binary file with trained weights.

Return
  • retval: Evision.DNN.Net.t()

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

Python prototype (for reference only):

readNetFromModelOptimizer(xml[, bin]) -> retval
Link to this function

readNetFromModelOptimizer(xml, opts)

View Source
@spec readNetFromModelOptimizer(binary(), [{:bin, term()}] | nil) ::
  Evision.DNN.Net.t() | {:error, String.t()}

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

Positional Arguments
  • xml: String.

    XML configuration file with network's topology.

Keyword Arguments
  • bin: String.

    Binary file with trained weights.

Return
  • retval: Evision.DNN.Net.t()

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

Python prototype (for reference only):

readNetFromModelOptimizer(xml[, bin]) -> retval
Link to this function

readNetFromModelOptimizerBuffer(named_args)

View Source
@spec readNetFromModelOptimizerBuffer(Keyword.t()) :: any() | {:error, String.t()}
Link to this function

readNetFromModelOptimizerBuffer(bufferModelConfig, bufferWeights)

View Source
@spec readNetFromModelOptimizerBuffer(binary(), binary()) ::
  Evision.DNN.Net.t() | {:error, String.t()}

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

Positional Arguments
  • bufferModelConfig: [uchar].

    Buffer contains XML configuration with network's topology.

  • bufferWeights: [uchar].

    Buffer contains binary data with trained weights.

Return
  • retval: Evision.DNN.Net.t()

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

Python prototype (for reference only):

readNetFromModelOptimizer(bufferModelConfig, bufferWeights) -> retval
Link to this function

readNetFromONNX(onnxFile)

View Source
@spec readNetFromONNX(binary()) :: Evision.DNN.Net.t() | {:error, String.t()}

Reads a network model <a href="https://onnx.ai/">ONNX</a>.

Positional Arguments
  • onnxFile: String.

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

Return
  • retval: Evision.DNN.Net.t()

@returns Network object that ready to do forward, throw an exception in failure cases.

Python prototype (for reference only):

readNetFromONNX(onnxFile) -> retval
Link to this function

readNetFromONNXBuffer(named_args)

View Source
@spec readNetFromONNXBuffer(Keyword.t()) :: any() | {:error, String.t()}
@spec readNetFromONNXBuffer(binary()) :: Evision.DNN.Net.t() | {:error, String.t()}

Reads a network model from <a href="https://onnx.ai/">ONNX</a> in-memory buffer.

Positional Arguments
  • buffer: [uchar].

    in-memory buffer that stores the ONNX model bytes.

Return
  • retval: Evision.DNN.Net.t()

@returns Network object that ready to do forward, throw an exception

    in failure cases.

Python prototype (for reference only):

readNetFromONNX(buffer) -> retval
Link to this function

readNetFromTensorflow(model)

View Source
@spec readNetFromTensorflow(binary()) :: Evision.DNN.Net.t() | {:error, String.t()}

Reads a network model stored in <a href="https://www.tensorflow.org/">TensorFlow</a> framework's format.

Positional Arguments
  • model: String.

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

Keyword Arguments
  • config: String.

    path 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.

Return
  • retval: Evision.DNN.Net.t()

@returns Net object.

Python prototype (for reference only):

readNetFromTensorflow(model[, config]) -> retval
Link to this function

readNetFromTensorflow(model, opts)

View Source
@spec readNetFromTensorflow(binary(), [{:config, term()}] | nil) ::
  Evision.DNN.Net.t() | {:error, String.t()}

Reads a network model stored in <a href="https://www.tensorflow.org/">TensorFlow</a> framework's format.

Positional Arguments
  • model: String.

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

Keyword Arguments
  • config: String.

    path 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.

Return
  • retval: Evision.DNN.Net.t()

@returns Net object.

Python prototype (for reference only):

readNetFromTensorflow(model[, config]) -> retval
Link to this function

readNetFromTensorflowBuffer(named_args)

View Source
@spec readNetFromTensorflowBuffer(Keyword.t()) :: any() | {:error, String.t()}
@spec readNetFromTensorflowBuffer(binary()) ::
  Evision.DNN.Net.t() | {:error, String.t()}

Reads a network model stored in <a href="https://www.tensorflow.org/">TensorFlow</a> framework's format.

Positional Arguments
  • bufferModel: [uchar].

    buffer containing the content of the pb file

Keyword Arguments
  • bufferConfig: [uchar].

    buffer containing the content of the pbtxt file

Return
  • retval: Evision.DNN.Net.t()

@returns Net object.

Python prototype (for reference only):

readNetFromTensorflow(bufferModel[, bufferConfig]) -> retval
Link to this function

readNetFromTensorflowBuffer(bufferModel, opts)

View Source
@spec readNetFromTensorflowBuffer(binary(), [{:bufferConfig, term()}] | nil) ::
  Evision.DNN.Net.t() | {:error, String.t()}

Reads a network model stored in <a href="https://www.tensorflow.org/">TensorFlow</a> framework's format.

Positional Arguments
  • bufferModel: [uchar].

    buffer containing the content of the pb file

Keyword Arguments
  • bufferConfig: [uchar].

    buffer containing the content of the pbtxt file

Return
  • retval: Evision.DNN.Net.t()

@returns Net object.

Python prototype (for reference only):

readNetFromTensorflow(bufferModel[, bufferConfig]) -> retval
Link to this function

readNetFromTFLite(model)

View Source
@spec readNetFromTFLite(binary()) :: Evision.DNN.Net.t() | {:error, String.t()}

Reads a network model stored in <a href="https://www.tensorflow.org/lite">TFLite</a> framework's format.

Positional Arguments
  • model: String.

    path to the .tflite file with binary flatbuffers description of the network architecture

Return
  • retval: Evision.DNN.Net.t()

@returns Net object.

Python prototype (for reference only):

readNetFromTFLite(model) -> retval
Link to this function

readNetFromTFLiteBuffer(named_args)

View Source
@spec readNetFromTFLiteBuffer(Keyword.t()) :: any() | {:error, String.t()}
@spec readNetFromTFLiteBuffer(binary()) :: Evision.DNN.Net.t() | {:error, String.t()}

Reads a network model stored in <a href="https://www.tensorflow.org/lite">TFLite</a> framework's format.

Positional Arguments
  • bufferModel: [uchar].

    buffer containing the content of the tflite file

Return
  • retval: Evision.DNN.Net.t()

@returns Net object.

Python prototype (for reference only):

readNetFromTFLite(bufferModel) -> retval
Link to this function

readNetFromTorch(named_args)

View Source
@spec readNetFromTorch(Keyword.t()) :: any() | {:error, String.t()}
@spec readNetFromTorch(binary()) :: Evision.DNN.Net.t() | {:error, String.t()}

Reads a network model stored in <a href="http://torch.ch">Torch7</a> framework's format.

Positional Arguments
  • model: String.

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

Keyword Arguments
  • isBinary: bool.

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

  • evaluate: bool.

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

Return
  • retval: Evision.DNN.Net.t()

@returns Net object. Note: Ascii 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 <a href="https://github.com/torch/nn/blob/master/doc/module.md">nn.Module</a> 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.

Python prototype (for reference only):

readNetFromTorch(model[, isBinary[, evaluate]]) -> retval
Link to this function

readNetFromTorch(model, opts)

View Source
@spec readNetFromTorch(binary(), [evaluate: term(), isBinary: term()] | nil) ::
  Evision.DNN.Net.t() | {:error, String.t()}

Reads a network model stored in <a href="http://torch.ch">Torch7</a> framework's format.

Positional Arguments
  • model: String.

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

Keyword Arguments
  • isBinary: bool.

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

  • evaluate: bool.

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

Return
  • retval: Evision.DNN.Net.t()

@returns Net object. Note: Ascii 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 <a href="https://github.com/torch/nn/blob/master/doc/module.md">nn.Module</a> 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.

Python prototype (for reference only):

readNetFromTorch(model[, isBinary[, evaluate]]) -> retval
Link to this function

readTensorFromONNX(named_args)

View Source
@spec readTensorFromONNX(Keyword.t()) :: any() | {:error, String.t()}
@spec readTensorFromONNX(binary()) :: Evision.Mat.t() | {:error, String.t()}

Creates blob from .pb file.

Positional Arguments
  • path: String.

    to the .pb file with input tensor.

Return
  • retval: Evision.Mat.t()

@returns Mat.

Python prototype (for reference only):

readTensorFromONNX(path) -> retval
Link to this function

readTorchBlob(named_args)

View Source
@spec readTorchBlob(Keyword.t()) :: any() | {:error, String.t()}
@spec readTorchBlob(binary()) :: Evision.Mat.t() | {:error, String.t()}

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

Positional Arguments
Keyword Arguments
  • isBinary: bool.
Return
  • retval: Evision.Mat.t()

@warning This function has the same limitations as readNetFromTorch().

Python prototype (for reference only):

readTorchBlob(filename[, isBinary]) -> retval
Link to this function

readTorchBlob(filename, opts)

View Source
@spec readTorchBlob(binary(), [{:isBinary, term()}] | nil) ::
  Evision.Mat.t() | {:error, String.t()}

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

Positional Arguments
Keyword Arguments
  • isBinary: bool.
Return
  • retval: Evision.Mat.t()

@warning This function has the same limitations as readNetFromTorch().

Python prototype (for reference only):

readTorchBlob(filename[, isBinary]) -> retval
Link to this function

shrinkCaffeModel(named_args)

View Source
@spec shrinkCaffeModel(Keyword.t()) :: any() | {:error, String.t()}
Link to this function

shrinkCaffeModel(src, dst)

View Source
@spec shrinkCaffeModel(binary(), binary()) :: :ok | {:error, String.t()}

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

Positional Arguments
  • src: String.

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

  • dst: String.

    Path to destination model with updated weights.

Keyword Arguments
  • layersTypes: [String].

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

Note: Shrinked 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.

Python prototype (for reference only):

shrinkCaffeModel(src, dst[, layersTypes]) -> None
Link to this function

shrinkCaffeModel(src, dst, opts)

View Source
@spec shrinkCaffeModel(binary(), binary(), [{:layersTypes, term()}] | nil) ::
  :ok | {:error, String.t()}

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

Positional Arguments
  • src: String.

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

  • dst: String.

    Path to destination model with updated weights.

Keyword Arguments
  • layersTypes: [String].

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

Note: Shrinked 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.

Python prototype (for reference only):

shrinkCaffeModel(src, dst[, layersTypes]) -> None
Link to this function

softNMSBoxes(bboxes, scores, score_threshold, nms_threshold)

View Source
@spec softNMSBoxes(
  [{number(), number(), number(), number()}],
  [number()],
  number(),
  number()
) ::
  {[number()], [integer()]} | {:error, String.t()}

Performs soft non maximum suppression given boxes and corresponding scores. Reference: https://arxiv.org/abs/1704.04503

Positional Arguments
  • bboxes: [Rect], Nx.Tensor.t(), Evision.Mat.t()..

    a set of bounding boxes to apply Soft NMS.

  • scores: [float].

    a set of corresponding confidences.

  • score_threshold: float.

    a threshold used to filter boxes by score.

  • nms_threshold: float.

    a threshold used in non maximum suppression.

Keyword Arguments
  • top_k: size_t.

    keep at most @p top_k picked indices.

  • sigma: float.

    parameter of Gaussian weighting.

  • method: SoftNMSMethod.

    Gaussian or linear.

Return
  • updated_scores: [float].

    a set of corresponding updated confidences.

  • indices: [int].

    the kept indices of bboxes after NMS.

@see SoftNMSMethod

Python prototype (for reference only):

softNMSBoxes(bboxes, scores, score_threshold, nms_threshold[, top_k[, sigma[, method]]]) -> updated_scores, indices
Link to this function

softNMSBoxes(bboxes, scores, score_threshold, nms_threshold, opts)

View Source
@spec softNMSBoxes(
  [{number(), number(), number(), number()}],
  [number()],
  number(),
  number(),
  [top_k: term(), sigma: term(), method: term()] | nil
) :: {[number()], [integer()]} | {:error, String.t()}

Performs soft non maximum suppression given boxes and corresponding scores. Reference: https://arxiv.org/abs/1704.04503

Positional Arguments
  • bboxes: [Rect], Nx.Tensor.t(), Evision.Mat.t()..

    a set of bounding boxes to apply Soft NMS.

  • scores: [float].

    a set of corresponding confidences.

  • score_threshold: float.

    a threshold used to filter boxes by score.

  • nms_threshold: float.

    a threshold used in non maximum suppression.

Keyword Arguments
  • top_k: size_t.

    keep at most @p top_k picked indices.

  • sigma: float.

    parameter of Gaussian weighting.

  • method: SoftNMSMethod.

    Gaussian or linear.

Return
  • updated_scores: [float].

    a set of corresponding updated confidences.

  • indices: [int].

    the kept indices of bboxes after NMS.

@see SoftNMSMethod

Python prototype (for reference only):

softNMSBoxes(bboxes, scores, score_threshold, nms_threshold[, top_k[, sigma[, method]]]) -> updated_scores, indices
Link to this function

writeTextGraph(named_args)

View Source
@spec writeTextGraph(Keyword.t()) :: any() | {:error, String.t()}
Link to this function

writeTextGraph(model, output)

View Source
@spec writeTextGraph(binary(), binary()) :: :ok | {:error, String.t()}

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

Positional Arguments
  • model: String.

    A path to binary network.

  • output: String.

    A path to output text file to be created.

Note: To reduce output file size, trained weights are not included.

Python prototype (for reference only):

writeTextGraph(model, output) -> None