← Python API
vraven · function

load_pytorch_model

load_pytorch_model(path: 'str | Path', *, model_factory: 'Callable[[], torch.nn.Module] | None' = None, format: 'PyTorchModelFormat' = 'state_dict', state_dict_key: 'str | None' = None, strip_prefix: 'str | None' = None, map_location: 'str | torch.device' = 'cpu', strict: 'bool' = True, allow_unsafe_pickle: 'bool' = False) -> 'torch.nn.Module'

Load a trusted PyTorch model using an explicit format.

``state_dict`` is the default and uses ``torch.load(..., weights_only=True)``.
It requires a caller-supplied architecture factory. ``torchscript`` uses
``torch.jit.load``. Python-pickle model loading is disabled unless
``allow_unsafe_pickle=True`` because untrusted pickle content may execute code.

Usage

from vraven import load_pytorch_model

result = load_pytorch_model(... )
Source of truthThis page is generated from the checked-out public symbol, signature, and docstring. Pin the package version for reproducible work.