Skip to content

Inference Config

Source

Pydantic model representing CAREamics prediction configuration.

InferenceConfig

Bases: BaseModel

Configuration class for the prediction model.

axes instance-attribute

Data axes (TSCZYX) in the order of the input data.

batch_size = Field(default=1, ge=1) class-attribute instance-attribute

Batch size for prediction.

data_type instance-attribute

Type of input data: numpy.ndarray (array) or path (tiff, czi, or custom).

image_means = Field(..., min_length=0, max_length=32) class-attribute instance-attribute

Mean values for each input channel.

image_stds = Field(..., min_length=0, max_length=32) class-attribute instance-attribute

Standard deviation values for each input channel.

tile_overlap = Field(default=None, min_length=2, max_length=3) class-attribute instance-attribute

Overlap between tiles, only effective if tile_size is specified.

tile_size = Field(default=None, min_length=2, max_length=3) class-attribute instance-attribute

Tile size of prediction, only effective if tile_overlap is specified.

tta_transforms = Field(default=True) class-attribute instance-attribute

Whether to apply test-time augmentation (all 90 degrees rotations and flips).

all_elements_non_zero_even(tile_overlap) classmethod

Validate tile overlap.

Overlaps must be non-zero, positive and even.

Parameters:

Name Type Description Default
tile_overlap list[int] or None

Patch size.

required

Returns:

Type Description
list[int] or None

Validated tile overlap.

Raises:

Type Description
ValueError

If the patch size is 0.

ValueError

If the patch size is not even.

axes_valid(axes) classmethod

Validate axes.

Axes must: - be a combination of 'STCZYX' - not contain duplicates - contain at least 2 contiguous axes: X and Y - contain at most 4 axes - not contain both S and T axes

Parameters:

Name Type Description Default
axes str

Axes to validate.

required

Returns:

Type Description
str

Validated axes.

Raises:

Type Description
ValueError

If axes are not valid.

set_3D(axes, tile_size, tile_overlap)

Set 3D parameters.

Parameters:

Name Type Description Default
axes str

Axes.

required
tile_size list of int

Tile size.

required
tile_overlap list of int

Tile overlap.

required

std_only_with_mean()

Check that mean and std are either both None, or both specified.

Returns:

Type Description
Self

Validated prediction model.

Raises:

Type Description
ValueError

If std is not None and mean is None.

tile_min_8_power_of_2(tile_list) classmethod

Validate that each entry is greater or equal than 8 and a power of 2.

Parameters:

Name Type Description Default
tile_list list of int

Patch size.

required

Returns:

Type Description
list of int

Validated patch size.

Raises:

Type Description
ValueError

If the patch size if smaller than 8.

ValueError

If the patch size is not a power of 2.

validate_dimensions()

Validate 2D/3D dimensions between axes and tile size.

Returns:

Type Description
Self

Validated prediction model.