Transform Configs

pydantic model SkiNet.ML.configs.transform_configs.transform_config.TransformConfig[source]

Bases: BaseTransformConfig

Main configuration for transformations applied to samples, including cropping and augmentations.

Fields:
field crop: CropConfig [Optional]

Cropping configuration for segmentation experiments, including crop size and method.

field normalization_mean: tuple[float, float, float] | None = None

Per-channel mean for ‘standard’ normalization (R, G, B), values in [0, 1]. Required when normalization_mode=’standard’. Compute with compute_dataset_stats.py.

field normalization_mode: Literal['standard', 'image_per_channel', 'image', 'min_max'] = 'image_per_channel'

Albumentations normalization mode. Use ‘standard’ with dataset-level mean/std (fastest — fixed constants, no per-image reductions). ‘image_per_channel’ computes mean/std per sample at runtime and is ~20x slower. ‘image’ and ‘min_max’ are intermediate options.

field normalization_std: tuple[float, float, float] | None = None

Per-channel std for ‘standard’ normalization (R, G, B), values in [0, 1]. Required when normalization_mode=’standard’. Compute with compute_dataset_stats.py.

field photometric_augmentation: PhotoAugmentConfig [Optional]

Photometric augmentation configuration for segmentation experiments, including random brightness/contrast adjustments, hue/saturation adjustments, and RGB shifts.

field spatial_augmentation: SpatialAugmentConfig [Optional]

Spatial augmentation configuration for segmentation experiments, including random flips, affine transformations, perspective transformations, and square symmetry.

pydantic model SkiNet.ML.configs.transform_configs.crop_config.CropConfig[source]

Bases: BaseModel

Default configuration for cropping in segmentation.

Fields:
field crop_apply: bool = True

Apply cropping.

field crop_type: Literal['center_crop', 'random_crop', 'random_resized_crop'] = 'random_resized_crop'

Type of cropping to apply. Required if crop_apply is True.

field scale: tuple[float, float] = (0.8, 1.0)

Scale range for random resized crop. Required if crop_type is ‘random_resized_crop’.

field size: tuple[int, int] = (512, 512)

Crop size (height, width).

pydantic model SkiNet.ML.configs.transform_configs.augment_config.SpatialAugmentConfig[source]

Bases: BaseModel

Default configuration for spatial image augmenation in segmentation experiments using Albumentations library. Note that spatial augmentations are geometric transformations that manipulate the spatial arrangement of pixels in an image.

References: Chlap, P., Min, H., Vandenberg, N., Dowling, J., Holloway, L., & Haworth, A. (2021). A review of medical image data augmentation techniques for deep learning applications. Journal of medical imaging and radiation oncology, 65(5), 545-563

Basic augmentation techniques:

  • geometric: geometric transformations (scaling, translation, rotation, flipping, shear, skew); cropping; occlusion

  • photometric: gamma contrast, linear contrast, histogram equalization; filtering; adding noise (Gaussian, salt and pepper, uniform)

Deformable augmentation techniques:

  • randomised displacement of pixels

  • spline interpolation (B-splines)

  • deformable image registration

  • statistical shape models

Fields:
field affine_apply: bool = False

Apply affine transformations.

field affine_rotate: Tuple[float, float] = (-45, 45)

Rotation angle in degrees.

field affine_scale: Tuple[float, float] = (0.8, 1.0)

Scaling (zoom) factor for affine transformation.

field affine_shear: dict[str, float | Tuple[float, float]] [Optional]

Shear angle in degrees.

field affine_translate_percent: dict[str, float | Tuple[float, float]] [Optional]

Translation as a fraction of the image size.

field elastic_alpha: float = 120.0

Scaling factor controlling displacement magnitude.

field elastic_apply: bool = False

Apply elastic deformation.

field elastic_p: float = 0.3

Probability of applying elastic deformation.

Constraints:
  • ge = 0.0

  • le = 1.0

field elastic_sigma: float = 10.0

Gaussian smoothing factor; larger values produce smoother deformation.

field perspective_apply: bool = False

Apply perspective transformations.

field perspective_p: float = 0.2

Probability of applying perspective transformation.

Constraints:
  • ge = 0.0

  • le = 1.0

field perspective_scale: Tuple[float, float] = (0.05, 0.1)

Scaling factor for perspective transformation.

field square_symmetry_apply: bool = False

Apply square symmetry transformations.

field square_symmetry_p: float = 0.5

Probability of square symmetry transformations.

Constraints:
  • ge = 0.0

  • le = 1.0

pydantic model SkiNet.ML.configs.transform_configs.augment_config.PhotoAugmentConfig[source]

Bases: BaseModel

Default configuration for photometric image augmenation in segmentation experiments using Albumentations library. Note that photometric augmentations are transformations that manipulate the intensity values of pixels in an image without changing their spatial arrangement.

References: Chlap, P., Min, H., Vandenberg, N., Dowling, J., Holloway, L., & Haworth, A. (2021). A review of medical image data augmentation techniques for deep learning applications. Journal of medical imaging and radiation oncology, 65(5), 545-563.

Photometric augmentation techniques: - gamma contrast, linear contrast, histogram equalization - filtering (convolution to sharpen, blur or smooth) - adding noise (Gaussian, salt and pepper, uniform)

Implemented transforms: - ColorJitter (albumentations.ColorJitter) - GaussianBlur (albumentations.GaussianBlur) - GaussNoise (albumentations.GaussNoise)

Fields:
field color_jitter_apply: bool = False

Apply color jitter.

field color_jitter_brightness: float = 0.2

Brightness adjustment factor.

field color_jitter_contrast: float = 0.2

Contrast adjustment factor.

field color_jitter_hue: float = 0.0

Hue adjustment factor.

field color_jitter_p: float = 0.5

Probability of applying color jitter.

Constraints:
  • ge = 0.0

  • le = 1.0

field color_jitter_saturation: float = 0.0

Saturation adjustment factor.

field gaussian_blur_apply: bool = False

Apply Gaussian blur.

field gaussian_blur_p: float = 0.2

Probability of applying Gaussian blur.

Constraints:
  • ge = 0.0

  • le = 1.0

field gaussian_blur_sigma_limit: Tuple[float, float] = (0.5, 2.0)

Sigma range for Gaussian blur kernel.

field gaussian_noise_apply: bool = False

Apply Gaussian noise.

field gaussian_noise_p: float = 0.2

Probability of applying Gaussian noise.

Constraints:
  • ge = 0.0

  • le = 1.0

field gaussian_noise_std_range: Tuple[float, float] = (0.05, 0.15)

Std range as a fraction of max pixel value.