Skip to content

Models

Source

Models package.

ModelConstraints

Bases: Protocol

Protocol for model constraints on input and output tensors.

validate_input_channels(n_channels)

Whether the given channel size is compatible with the model constraints.

Parameters:

  • n_channels (int) –

    The number of channels in the input tensor to validate.

Raises:

  • ValueError

    If the number of channels is not compatible with the model constraints.

validate_spatial_shape(shape)

Whether the given spatial shape is compatible with the model constraints.

Shape must be of length 2 (YX) or 3 (ZYX). To validate channel dimension, use validate_input_channels or validate_target_channels instead.

Parameters:

  • shape (Sequence[int]) –

    The spatial shape of the input tensor to validate (length 2 or 3).

Raises:

  • ValueError

    If the spatial shape is not compatible with the model constraints.

validate_target_channels(n_channels)

Whether the given channel size is compatible with the model constraints.

Parameters:

  • n_channels (int) –

    The number of channels in the target tensor to validate.

Raises:

  • ValueError

    If the number of channels is not compatible with the model constraints.

get_model_constraints(model_config)

Get the model constraints for the given model configuration.

Parameters:

  • model_config (UNetConfig) –

    The model configuration.

Returns:

Raises:

  • ValueError

    If the model type is not supported.