SPPAS 4.22

https://sppas.org/

Module sppas.src.imgdata

Class NeuralNetONNXDetector

Description

Detect objects in an image with an Artificial Neural Network.

* * * * * Not tested (no free model found) * * * * *

Constructor

View Source
def __init__(self):
    super(NeuralNetONNXDetector, self).__init__()
    self._extension = '.onnx'

Private functions

_set_detector

Initialize the model with the given file.

Parameters
  • model: (str) Filename of the Caffe model file
Raises

IOError, Exception

View Source
def _set_detector(self, model):
    """Initialize the model with the given file.

        :param model: (str) Filename of the Caffe model file
        :raise: IOError, Exception

        """
    try:
        self._detector = cv2.dnn.readNetFromONNX(model)
    except cv2.error as e:
        logging.error('Artificial Neural Network model (ONNX) failed to be read.')
        raise sppasError(str(e))

_net_detections

Initialize net and blob for the processing.

Returns
  • detections.
Parameters
  • image
View Source
def _net_detections(self, image):
    """Initialize net and blob for the processing.

        :returns: detections.

        """
    blob = cv2.dnn.blobFromImage(image, 1.0, (320, 240), (127, 127, 127), False, False)
    self._detector.setInput(blob)
    return self._detector.forward()