Class YoloUtils


  • public class YoloUtils
    extends Object
    • Constructor Detail

      • YoloUtils

        public YoloUtils()
    • Method Detail

      • activate

        public static INDArray activate​(INDArray boundingBoxPriors,
                                        INDArray input)
        Essentially: just apply activation functions... For NCHW format. For NCHW format, use one of the other activate methods
      • overlap

        public static double overlap​(double x1,
                                     double x2,
                                     double x3,
                                     double x4)
        Returns overlap between lines [x1, x2] and [x3. x4].
      • nms

        public static void nms​(List<DetectedObject> objects,
                               double iouThreshold)
        Performs non-maximum suppression (NMS) on objects, using their IOU with threshold to match pairs.
      • getPredictedObjects

        public static List<DetectedObject> getPredictedObjects​(INDArray boundingBoxPriors,
                                                               INDArray networkOutput,
                                                               double confThreshold,
                                                               double nmsThreshold)
        Given the network output and a detection threshold (in range 0 to 1) determine the objects detected by the network.
        Supports minibatches - the returned DetectedObject instances have an example number index.
        Note that the dimensions are grid cell units - for example, with 416x416 input, 32x downsampling by the network (before getting to the Yolo2OutputLayer) we have 13x13 grid cells (each corresponding to 32 pixels in the input image). Thus, a centerX of 5.5 would be xPixels=5.5x32 = 176 pixels from left. Widths and heights are similar: in this example, a with of 13 would be the entire image (416 pixels), and a height of 6.5 would be 6.5/13 = 0.5 of the image (208 pixels).
        Parameters:
        boundingBoxPriors - as given to Yolo2OutputLayer
        networkOutput - 4d activations out of the network
        confThreshold - Detection threshold, in range 0.0 (least strict) to 1.0 (most strict). Objects are returned where predicted confidence is >= confThreshold
        nmsThreshold - passed to nms(List, double) (0 == disabled) as the threshold for intersection over union (IOU)
        Returns:
        List of detected objects