Skip to content

augmentation

feature's utils.

Classes:

Name Description
ImageFeatureAugmentation

Feature augmentation class for images.

ImageFeatureAugmentation #

Feature augmentation class for images.

Parameters:

Name Type Description Default

augment_raw #

Compose | None

A feature augmentation function used to augment raw data. This is done before data preprocessing.

None

augment_preprocessed #

Compose | None

A feature augmentation function used to augment data after it has been preprocessed.

None

Methods:

Name Description
__attrs_post_init__

Post init method, triggered after calling init method to check instance's validity.

from_exposed

ImageFeatureAugmentation from ExposedImageFeatureAugmentation.

as_exposed

ImageFeatureAugmentation as ExposedImageFeatureAugmentation.

Attributes:

Name Type Description
augment_raw Compose | None
augment_preprocessed Compose | None

augment_raw: transforms.Compose | None = field(default=None) #

augment_preprocessed: transforms.Compose | None = field(default=None) #

__attrs_post_init__() -> None #

Post init method, triggered after calling init method to check instance's validity.

Source code in src/xpdeep/dataset/schema/feature/augmentation.py
def __attrs_post_init__(self) -> None:
    """Post init method, triggered after calling __init__ method to check instance's validity."""
    if self.augment_raw is None and self.augment_preprocessed is None:
        message = "`augment_raw` and `augment_preprocessed` are both None, no augmentation will be applied."
        raise Warning(message)

from_exposed(exposed_image_feature_augmentation: ExposedImageFeatureAugmentation) -> ImageFeatureAugmentation #

ImageFeatureAugmentation from ExposedImageFeatureAugmentation.

Source code in src/xpdeep/dataset/schema/feature/augmentation.py
@classmethod
def from_exposed(
    cls, exposed_image_feature_augmentation: ExposedImageFeatureAugmentation
) -> "ImageFeatureAugmentation":
    """ImageFeatureAugmentation from ExposedImageFeatureAugmentation."""
    augment_raw = (
        exposed_image_feature_augmentation.augment_raw.unparse(None, None)
        if exposed_image_feature_augmentation.augment_raw is not None
        else None
    )
    augment_preprocessed = (
        exposed_image_feature_augmentation.augment_preprocessed.unparse(None, None)
        if exposed_image_feature_augmentation.augment_preprocessed is not None
        else None
    )

    return ImageFeatureAugmentation(augment_raw=augment_raw, augment_preprocessed=augment_preprocessed)

as_exposed() -> ExposedImageFeatureAugmentation #

ImageFeatureAugmentation as ExposedImageFeatureAugmentation.

Source code in src/xpdeep/dataset/schema/feature/augmentation.py
def as_exposed(self) -> ExposedImageFeatureAugmentation:
    """ImageFeatureAugmentation as ExposedImageFeatureAugmentation."""
    return ExposedImageFeatureAugmentation(
        augment_raw=ExposedTrustedObject.parse(self.augment_raw) if self.augment_raw is not None else None,
        augment_preprocessed=ExposedTrustedObject.parse(self.augment_preprocessed)
        if self.augment_preprocessed is not None
        else None,
    )