torchoutil.hub.registry module¶
- class RegistryHub(
- infos: Mapping[T_Hashable, RegistryEntry],
- register_root: str | Path = '~/.cache/torch/hub/checkpoints',
Bases:
Generic[T_Hashable]- classmethod from_file( ) RegistryHub[source]¶
Load register info from JSON file.
- property infos: Dict[T_Hashable, RegistryEntry]¶
- is_valid_hash(
- name: T_Hashable,
Returns True if target file hash is valid. If no hash is provided in infos, this function also returns True.
- load_state_dict(name_or_path: ~torchoutil.hub.registry.T_Hashable | str | ~pathlib.Path, *, device: ~torch.device | None | ~typing.Literal['default', 'cuda_if_available'] | str | int = None, offline: bool = False, load_fn: ~typing.Callable[[~typing.Any], ~torchoutil.serialization.load_fn.T] | ~typing.Literal['csv', 'json', 'h5py', 'numpy', 'pickle', 'safetensors', 'torch', 'torchaudio', 'yaml'] = <function load_torch>, load_kwds: ~typing.Dict[str, ~typing.Any] | None = None, verbose: int = 0) Dict[str, Tensor][source]¶
Load state_dict weights.
- Args:
model_name_or_path: Model name (case sensitive) or path to checkpoint file. device: Device of checkpoint weights. (deprecated) offline: If False, the checkpoint from a model name will be automatically downloaded. load_fn: Load function backend. defaults to torch.load. load_kwds: Optional keywords arguments passed to load_fn. defaults to None. verbose: Verbose level. defaults to 0.
- Returns:
Loaded file content.