BB. Estimator. ObjectDetection. Codec behaviour
(bb_estimator_object_detection v0.1.0)
Copy Markdown
View Source
The :object_detection task: what a BB.Inference.ModelCodec for an
object detector takes and gives, and the one thing it must say beyond the
generic contract.
A detection codec implements both behaviours:
@behaviour BB.Inference.ModelCodec
@behaviour BB.Estimator.ObjectDetection.Codec
@impl BB.Inference.ModelCodec
def task, do: :object_detectionEncode
BB.Inference.ModelCodec.encode/2 receives a
BB.Estimator.ObjectDetection.Codec.Input: a {:raw, :I420} frame and the
minimum score. It prepares the frame with
BB.Estimator.ObjectDetection.Image.prepare/2 and carries the returned
transform, and the threshold, in its context.
Decode
BB.Inference.ModelCodec.decode/3 returns every candidate scoring at
least the threshold, as BB.Message.Vision.Detections.Detection structs
with boxes in frame pixels (BB.Estimator.ObjectDetection.Image.to_frame/2)
and label: nil. The estimator adds labels from the model.
Most of a detector's output is below the threshold, so a codec reading a
quantised output dequantises only the values it reads, with
BB.Inference.Quantisation.value/5, rather than the whole tensor.
Non-maximum suppression
nms?/1 says whether the candidates still overlap and need
non-maximum suppression, which the estimator then applies. A model that
ends in its own NMS says false.
Summary
Callbacks
Whether the decoded candidates still need non-maximum suppression.