xnn.common.models.hub.formats.ModelFormat#
- class xnn.common.models.hub.formats.ModelFormat(name, suffixes, convert, find_cached=None, requires='', detect=None)[source]#
Bases:
objectA 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 theModelConfigthatbuild_model()rebuilds it from (the weights then load strictly), or a fullConfigwhen the model comes with more than its architecture (asubtracted_dispersionrecord).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.ptartifact, a directory of weights and metadata); a path that does not exist is never one.
- Parameters: