sleap.nn.model#
This module defines the main SLEAP model class for defining a trainable model.
This is a higher level wrapper around tf.keras.Model
that holds all the configuration
parameters required to construct the actual model. This allows for easy querying of the
model configuration without actually instantiating the model itself.
- class sleap.nn.model.Model(backbone: Architecture, heads: Any, keras_model: Optional[Model] = None)[source]#
SLEAP model that describes an architecture and output types.
- backbone#
An
Architecture
class that provides methods for building a tf.keras.Model given an input.- Type:
sleap.nn.model.Architecture
- keras_model#
The current
tf.keras.Model
instance if one has been created.- Type:
Optional[keras.engine.training.Model]
- classmethod from_config(config: ModelConfig, skeleton: Optional[Skeleton] = None, tracks: Optional[List[Track]] = None, update_config: bool = False) Model [source]#
Create a SLEAP model from configurations.
- Parameters:
config – The configurations as a
ModelConfig
instance.skeleton – A
sleap.Skeleton
to use if not provided in the config.update_config – If
True
, the input model configuration will be updated with values inferred from other fields.
- Returns:
An instance of
Model
built with the specified configurations.
- make_model(input_shape: Tuple[int, int, int]) Model [source]#
Create a trainable model by connecting the backbone with the heads.
- Parameters:
input_shape – Tuple of (height, width, channels) specifying the shape of the inputs before preprocessing.
- Returns:
An instantiated
tf.keras.Model
.
- property maximum_stride: int#
Return the maximum stride of the model backbone.