xnn.common.models.hub.checkpoint.load_checkpoint#

xnn.common.models.hub.checkpoint.load_checkpoint(path, *, format=None, head=None)[source]#

Read any supported checkpoint into a Checkpoint.

Parameters:
  • path (str or pathlib.Path) – A portable model directory, an xnn trainer checkpoint (or bare state dict), or a file in a registered foreign format.

  • format (str, optional) – Force the format instead of detecting it from the suffix ("xnn", "mace-torch").

  • head (str, optional) – Head to keep when converting a multi-head foreign checkpoint. For an xnn checkpoint the heads are kept and chosen at build time (build_potential()).

Returns:

Config, weights and card.

Return type:

Checkpoint

Raises:
  • FileNotFoundError – If path does not exist, or a directory lacks its config/weights.

  • ValueError – If the file is not a recognizable checkpoint.