Skip to content

Mapper

app.infrastructure.detection.model.mtcnn_torch.mapper

View source code

Mapper for converting MTCNN (facenet-pytorch) output to DetectionResult.

See Also

Layer: Infrastructure. Context: Implements concrete processing and I/O behind application-facing contracts.

MTCNNTorchDetectionMapper

Maps raw MTCNN (facenet-pytorch) detection output to DetectionResult format.

facenet_pytorch.MTCNN.detect() returns a pair (boxes, probs) where:

  • boxes – numpy.ndarray of shape (N, 4) in xyxy order, or None when no face is found.
  • probs – numpy.ndarray of shape (N,) with confidence scores in [0, 1], or None when no face is found.

Layer: Infrastructure. Context: Implements concrete processing or I/O behind application-facing contracts.

map(boxes: 'np.ndarray | None', probs: 'np.ndarray | None', chosen_labels: list[str] | None = None) -> list[DetectionResult] staticmethod

Map MTCNN raw inference output to a list of DetectionResult.

PARAMETER DESCRIPTION
boxes

Array of bounding boxes in xyxy format, shape (N, 4), or None if no faces were detected.

TYPE: 'np.ndarray | None'

probs

Array of confidence scores, shape (N,), or None.

TYPE: 'np.ndarray | None'

chosen_labels

Optional filter; results whose label is not in this list are dropped. MTCNN always emits "person" labels.

TYPE: list[str] | None DEFAULT: None

RETURNS DESCRIPTION
list[DetectionResult]

List of DetectionResult instances filtered by confidence

list[DetectionResult]

threshold and optional label filter.