Class YoloUtils
- java.lang.Object
-
- org.deeplearning4j.nn.layers.objdetect.YoloUtils
-
public class YoloUtils extends Object
-
-
Constructor Summary
Constructors Constructor Description YoloUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static INDArray
activate(@NonNull INDArray boundingBoxPriors, @NonNull INDArray input, boolean nchw, LayerWorkspaceMgr layerWorkspaceMgr)
static INDArray
activate(@NonNull INDArray boundingBoxPriors, @NonNull INDArray input, LayerWorkspaceMgr layerWorkspaceMgr)
static INDArray
activate(INDArray boundingBoxPriors, INDArray input)
Essentially: just apply activation functions...static INDArray
activate(INDArray boundingBoxPriors, INDArray input, boolean nchw)
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 returnedDetectedObject
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).static double
iou(DetectedObject o1, DetectedObject o2)
Returns intersection over union (IOU) between o1 and o2.static void
nms(List<DetectedObject> objects, double iouThreshold)
Performs non-maximum suppression (NMS) on objects, using their IOU with threshold to match pairs.static double
overlap(double x1, double x2, double x3, double x4)
Returns overlap between lines [x1, x2] and [x3.
-
-
-
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
-
activate
public static INDArray activate(@NonNull @NonNull INDArray boundingBoxPriors, @NonNull @NonNull INDArray input, LayerWorkspaceMgr layerWorkspaceMgr)
-
activate
public static INDArray activate(@NonNull @NonNull INDArray boundingBoxPriors, @NonNull @NonNull INDArray input, boolean nchw, LayerWorkspaceMgr layerWorkspaceMgr)
-
overlap
public static double overlap(double x1, double x2, double x3, double x4)
Returns overlap between lines [x1, x2] and [x3. x4].
-
iou
public static double iou(DetectedObject o1, DetectedObject o2)
Returns intersection over union (IOU) between o1 and o2.
-
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 returnedDetectedObject
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 Yolo2OutputLayernetworkOutput
- 4d activations out of the networkconfThreshold
- Detection threshold, in range 0.0 (least strict) to 1.0 (most strict). Objects are returned where predicted confidence is >= confThresholdnmsThreshold
- passed tonms(List, double)
(0 == disabled) as the threshold for intersection over union (IOU)- Returns:
- List of detected objects
-
-