Skip to content

Patching Strategies

Source

Patching strategies Pydantic models.

FixedRandomPatchingConfig

Bases: _PatchedConfig

Fixed random patching Pydantic model.

Attributes:

  • name (fixed_random) –

    The name of the patching strategy.

  • patch_size (sequence of int) –

    The size of the patch in each spatial dimension, each patch size must be a power of 2 and larger than 8.

name = 'fixed_random' class-attribute instance-attribute

The name of the patching strategy.

patch_size = Field(..., min_length=2, max_length=3) class-attribute instance-attribute

The size of the patch in each spatial dimensions. Must be squared in YX.

seed = Field(default=None, gt=0) class-attribute instance-attribute

The random seed to use for patch sampling.

RandomPatchingConfig

Bases: _PatchedConfig

Random patching Pydantic model.

Attributes:

  • name (random) –

    The name of the patching strategy.

  • patch_size (sequence of int) –

    The size of the patch in each spatial dimension, each patch size must be a power of 2 and larger than 8.

name = 'random' class-attribute instance-attribute

The name of the patching strategy.

patch_size = Field(..., min_length=2, max_length=3) class-attribute instance-attribute

The size of the patch in each spatial dimensions. Must be squared in YX.

seed = Field(default=None, gt=0) class-attribute instance-attribute

Random seed for patch sampling, set to None for random seeding.

SequentialPatchingConfig

Bases: _OverlappingPatchedConfig

Sequential patching Pydantic model.

Attributes:

  • name (sequential) –

    The name of the patching strategy.

  • patch_size (sequence of int) –

    The size of the patch in each spatial dimension, each patch size must be a power of 2 and larger than 8.

  • overlaps (list of int, optional) –

    The overlaps between patches in each spatial dimension. If None, no overlap is applied. The overlaps must be smaller than the patch size in each spatial dimension, and the number of dimensions be either 2 or 3.

name = 'sequential' class-attribute instance-attribute

The name of the patching strategy.

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

The overlaps between patches in each spatial dimension. If None, no overlap is applied. The overlaps must be smaller than the patch size in each spatial dimension, and the number of dimensions be either 2 or 3.

patch_size = Field(..., min_length=2, max_length=3) class-attribute instance-attribute

The size of the patch in each spatial dimensions. Must be squared in YX.

overlap_even(overlaps) classmethod

Validate overlaps.

Overlap must be even.

Parameters:

  • overlaps (Sequence of int) –

    Overlaps.

Returns:

  • Sequence of int

    Validated overlap.

overlap_smaller_than_patch_size(overlaps, values) classmethod

Validate overlap.

Overlaps must be smaller than the patch size in each spatial dimension.

Parameters:

  • overlaps (Sequence of int) –

    Overlap in each dimension.

  • values (ValidationInfo) –

    Dictionary of values.

Returns:

  • Sequence of int

    Validated overlap.

StratifiedPatchingConfig

Bases: _PatchedConfig

Stratified patching Pydantic model.

Attributes:

  • name (stratified) –

    The name of the patching strategy.

  • patch_size (sequence of int) –

    The size of the patch in each spatial dimension, each patch size must be a power of 2 and larger than 8.

name = 'stratified' class-attribute instance-attribute

The name of the patching strategy.

patch_size = Field(..., min_length=2, max_length=3) class-attribute instance-attribute

The size of the patch in each spatial dimensions. Must be squared in YX.

seed = Field(default=None, gt=0) class-attribute instance-attribute

Random seed for patch sampling, set to None for random seeding.

TiledPatchingConfig

Bases: _OverlappingPatchedConfig

Tiled patching Pydantic model.

Attributes:

  • name (tiled) –

    The name of the patching strategy.

  • patch_size (sequence of int) –

    The size of the patch in each spatial dimension, each patch size must be a power of 2 and larger than 8.

  • overlaps (sequence of int) –

    The overlaps between patches in each spatial dimension. The overlaps must be smaller than the patch size in each spatial dimension, and the number of dimensions be either 2 or 3.

name = 'tiled' class-attribute instance-attribute

The name of the patching strategy.

overlaps = Field(..., min_length=2, max_length=3) class-attribute instance-attribute

The overlaps between patches in each spatial dimension. The overlaps must be smaller than the patch size in each spatial dimension, and the number of dimensions be either 2 or 3.

patch_size = Field(..., min_length=2, max_length=3) class-attribute instance-attribute

The size of the patch in each spatial dimensions. Must be squared in YX.

overlap_even(overlaps) classmethod

Validate overlaps.

Overlap must be even.

Parameters:

  • overlaps (Sequence of int) –

    Overlaps.

Returns:

  • Sequence of int

    Validated overlap.

overlap_smaller_than_patch_size(overlaps, values) classmethod

Validate overlap.

Overlaps must be smaller than the patch size in each spatial dimension.

Parameters:

  • overlaps (Sequence of int) –

    Overlap in each dimension.

  • values (ValidationInfo) –

    Dictionary of values.

Returns:

  • Sequence of int

    Validated overlap.

WholePatchingConfig

Bases: BaseModel

Whole image patching Pydantic model.

name = 'whole' class-attribute instance-attribute

The name of the patching strategy.