Skip to content

Loader Factory

app.infrastructure.detection.model.torch.loader_factory

View source code

Factory for loading TorchVision detection model with pretrained weights.

See Also

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

LoadedTorchModel

Bases: NamedTuple

Result of successful TorchVision model loading.

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

labels: list[str] instance-attribute

model: Module instance-attribute

TorchModelLoaderFactory

Factory for loading TorchVision detection model.

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

create(model_name: str, weights_name: str) -> LoadedTorchModel staticmethod

Load TorchVision model by model_name and weights_name.

RETURNS DESCRIPTION
LoadedTorchModel

LoadedTorchModel with loaded model and labels extracted from weights metadata.

RAISES DESCRIPTION
DetectionModelError

If model loading fails.