Class MultiBoxDetection
- java.lang.Object
-
- ai.djl.modality.cv.MultiBoxDetection
-
public class MultiBoxDetection extends java.lang.Object
MultiBoxDetection
is 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.MultiBoxDetection
handles all of these tasks, and returns anNDList
with a singleNDArray
ofShape
(batch_size, Number of generated anchor boxes, 6). For each generated anchor box, there is anNDArray
ofShape
(6,). The values in each of those arrays represent the following:[class, score, x_min, y_min, x_max, y_max]
. Theclass
is set to -1 for boxes that are removed or classified as background. Thescore
is 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 class
MultiBoxDetection.Builder
The Builder to construct aMultiBoxDetection
object.
-
Constructor Summary
Constructors Constructor Description MultiBoxDetection(MultiBoxDetection.Builder builder)
Creates a new instance ofMultiBoxDetection
with the arguments from the givenMultiBoxDetection.Builder
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MultiBoxDetection.Builder
builder()
Creates a builder to build aMultiBoxDetection
.NDList
detection(NDList inputs)
Converts multi-box detection predictions.
-
-
-
Constructor Detail
-
MultiBoxDetection
public MultiBoxDetection(MultiBoxDetection.Builder builder)
Creates a new instance ofMultiBoxDetection
with the arguments from the givenMultiBoxDetection.Builder
.- Parameters:
builder
- theMultiBoxDetection.Builder
with 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
NDList
with a singleNDArray
ofShape
(batch_size, Number of generated anchor boxes, 6). For each generated anchor box, there is anNDArray
ofShape
(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
-
-