model package

Subpackages

Submodules

model.base module

Base Armory model wrapper.

class model.base.ArmoryModel(name: str, model, preadapter: Callable[[...], Tuple[Tuple[Any, ...], Dict[str, Any]]] | None = None, postadapter: Callable[[Any], Any] | None = None)

Bases: Trackable, Module

Wrapper around a model to apply an adapter to inputs and outputs of the model.

Example:

from armory.model import ArmoryModel

def preadapter(images, *args, **kwargs):

# Apply some transform to images return (images,) + args, kwargs

def postadapter(output):

# Apply some transform to output return output

# assuming model has been defined elsewhere wrapper = ArmoryModel(

“MyModel”, model, preadapter=preadapter, postadapter=postadapter,

)

forward(*args, **kwargs)

Applies pre- or postadapters, as appropriate and invokes the wrapped model

training: bool
model.base.ModelInputAdapter

An adapter for model inputs. The output must be a tuple of args and kwargs for the model’s forward method.

alias of Callable[[…], Tuple[Tuple[Any, …], Dict[str, Any]]]

Module contents

This package contains Armory model adaption APIs.