Skip to content

Mapper

app.infrastructure.detection.model.torch.mapper

View source code

Mapper for converting TorchVision model output to DetectionPayload.

See Also

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

TorchDetectionMapper

Maps raw TorchVision detection results to DetectionPayload format.

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

map(raw_results: dict, labels: list[str], chosen_labels: list[str] | None = None) -> list[DetectionResult] staticmethod

Map TorchVision raw inference output to DetectionResult list.

PARAMETER DESCRIPTION
raw_results

Raw model output (dict with "boxes", "scores", "labels" keys).

TYPE: dict

labels

Label names extracted from model weights metadata.

TYPE: list[str]

chosen_labels

Optional filter to include only these labels.

TYPE: list[str] | None DEFAULT: None

RETURNS DESCRIPTION
list[DetectionResult]

List of DetectionResult instances filtered by confidence and label.