Class MultiBoxDetection
- java.lang.Object
-
- ai.djl.modality.cv.MultiBoxDetection
-
public class MultiBoxDetection extends java.lang.ObjectMultiBoxDetectionis the class that takes the output of a multi-box detection model, and converts it into an NDList that contains the object detections.The output from a Single Shot Detection(SSD) network would be class probabilities, box offset predictions, and the generated anchor boxes. Once out-of-boundary boxes are eliminated, and boxes with scores lower than the threshold are removed, we will ideally have a small number of candidates for each object in the image. Since anchor boxes are generated in multiple scales around each pixel by
MultiBoxPrior, there are bound to be multiple boxes around each object which have a score greater than the threshold. We use Non-Maximum Suppression(NMS) to choose one box that is most likely to fit the object in the image.MultiBoxDetectionhandles all of these tasks, and returns anNDListwith a singleNDArrayofShape(batch_size, Number of generated anchor boxes, 6). For each generated anchor box, there is anNDArrayofShape(6,). The values in each of those arrays represent the following:[class, score, x_min, y_min, x_max, y_max]. Theclassis set to -1 for boxes that are removed or classified as background. Thescoreis the confidence with which the model thinks the box contains an object of the specifiedclass, and the other four values represent the normalised co-ordinates of the box.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMultiBoxDetection.BuilderThe Builder to construct aMultiBoxDetectionobject.
-
Constructor Summary
Constructors Constructor Description MultiBoxDetection(MultiBoxDetection.Builder builder)Creates a new instance ofMultiBoxDetectionwith the arguments from the givenMultiBoxDetection.Builder.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MultiBoxDetection.Builderbuilder()Creates a builder to build aMultiBoxDetection.NDListdetection(NDList inputs)Converts multi-box detection predictions.
-
-
-
Constructor Detail
-
MultiBoxDetection
public MultiBoxDetection(MultiBoxDetection.Builder builder)
Creates a new instance ofMultiBoxDetectionwith the arguments from the givenMultiBoxDetection.Builder.- Parameters:
builder- theMultiBoxDetection.Builderwith the necessary arguments
-
-
Method Detail
-
detection
public NDList detection(NDList inputs)
Converts multi-box detection predictions.- Parameters:
inputs- a NDList of (class probabilities, box predictions, and anchors) in that order- Returns:
- an
NDListwith a singleNDArrayofShape(batch_size, Number of generated anchor boxes, 6). For each generated anchor box, there is anNDArrayofShape(6,). The values in each of those arrays represent the following:[class, score, x_min, y_min, x_max, y_max]
-
builder
public static MultiBoxDetection.Builder builder()
Creates a builder to build aMultiBoxDetection.- Returns:
- a new builder
-
-