Spaces:
Running on Zero
Running on Zero
File size: 800 Bytes
87608ea | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | """Public construction helpers for config-driven PXDepth components."""
from typing import Any, Dict
import torch.nn as nn
from .registry import MODELS
# Import built-in modules once so their registration decorators run. External
# components are imported by ``load_config`` before these builders are called.
from . import model as _model # noqa: F401,E402
def build_model(config: Dict[str, Any]) -> nn.Module:
"""Build a model from its JSON-compatible configuration.
Args:
config: Model dictionary. ``type`` defaults to ``PXDepth`` for old
public configs and checkpoints.
Returns:
Constructed ``torch.nn.Module`` registered in :data:`MODELS`.
"""
config = dict(config)
config.setdefault("type", "PXDepth")
return MODELS.build(config)
|