xnn.common.models.hub.formats.ModelFormat#

class xnn.common.models.hub.formats.ModelFormat(name, suffixes, convert, find_cached=None, requires='', detect=None)[source]#

Bases: object

A foreign model format the hub converts into xnn’s own.

Variables:
  • name (str) – Format key used in model cards (e.g. "mace-torch").

  • suffixes (tuple of str) – File suffixes recognized as this format.

  • convert (callable) – convert(path, head) -> (model, config): the bare xnn potential and the ModelConfig that build_model() rebuilds it from (the weights then load strictly), or a full Config when the model comes with more than its architecture (a subtracted_dispersion record).

  • find_cached (callable, optional) – find_cached(card) -> path or None: a copy of the card’s file that some other cache already holds, so it is not downloaded again.

  • requires (str) – What has to be installed to convert (shown in error messages).

  • detect (callable, optional) – detect(path) -> bool: recognizes a file or directory of this format when its suffix does not tell (a .pt artifact, a directory of weights and metadata); a path that does not exist is never one.

Parameters: