Skip to content

augmentation

feature's utils.

Classes:

Name Description
ImageFeatureAugmentation

Feature augmentation class for images.

ImageFeatureAugmentation #

Feature augmentation class for images.

The corresponding data uses the channel-last format, i.e. batch_size x H x W x num_channels. You may need to use Compose([Permute([0, 3, 1, 2]), YourTransformation(), Permute([0, 2, 3, 1])]) if your augmentation requires the channel first. You don't need to convert to torch tensor first, as it is automatically handled by xpdeep.

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.

to_model

Convert to AugmentationInsert.

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/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)

to_model() -> AugmentationInsert #

Convert to AugmentationInsert.

Source code in src/xpdeep/dataset/feature/augmentation.py
def to_model(self) -> AugmentationInsert:
    """Convert to AugmentationInsert."""
    trusted_augmentation = TrustedObjectConverter.to_model(
        "xpdeep_dataset.augmentation.image_feature_augmentation",
        "ImageFeatureAugmentation",
        reconstructor="_reconstructor",
        augment_raw=self.augment_raw,
        augment_preprocessed=self.augment_preprocessed,
        single_thread=False,
    )
    return AugmentationInsert(trusted_augmentation)