Augmentations
December 14, 2022 · View on GitHub
class Augmentation:
def _augment(self, sample: Sample) -> Sample:
raise NotImplementedError("Please Implement this method")
def _set_metadata(self, sample: Sample) -> Sample:
return sample
def __call__(self, sample: Sample) -> Sample:
sample = init_augmentation(sample)
sample = self._augment(sample)
sample = self._set_metadata(sample)
return sample
Base types of augmentations
| Interface | Description | Metadata Changes | Code |
|---|---|---|---|
| Augmentation | Base Augmentation class from which every Augmentation inherits | None | here |
| OODAugmentation | Augmentation that transforms ID images into OOD images e.g. artifacts | OOD Flag, Augmentation severity if provided | here |
| INAugmentation | Augmentation that does not change the OOD flag but keeps the data IN Distribution e.g. cropping or resizing of images | None | here |
| AugmentationComposite | An Augmentation composite is a combination of multiple augmentations e.g. pick N of a list | Dependent of parameters | here |
Special types of augmentations
| Interface | Description | Metadata Changes | Code |
|---|---|---|---|
| SampableAugmentation | Sample Augmentation have sampable parameters which makes it possible to run an experiment with augmentations with different parameter values e.g. different scales for artifacts | Keeps Changes of base augmentation | here |
| ArtifactAugmentation | An Artifact Augmentation is a realization of an OODAugmentation and therefore inherits from it. This interface comes with a method that overlays an artifact on the image | like OODAugmentation | here |
FrOoDos Augmentations

| Name | Short description | Interface | Code |
|---|---|---|---|
| DarkSpotsAugmentation | Creates a dark spot on the image | ArtifactAugmentation, SampableAugmentation, OODAugmentation | here |
| FatAugmentation | Creates a fat drop on the image | ArtifactAugmentation, SampableAugmentation, OODAugmentation | here |
| SquamousAugmentation | Creates a tissue piece on the image | ArtifactAugmentation, SampableAugmentation, OODAugmentation | here |
| ThreadAugmentation | Creates a thread on the image | ArtifactAugmentation, SampableAugmentation, OODAugmentation | here |
| GaussianBlurAugmentation | Blures the image | SampableAugmentation, OODAugmentation | here |
| ZoomInAugmentation | Crops the image and then resizes it back to original size | SampableAugmentation, OODAugmentation | here |
| BrightnessAugmentation | Changes brightness of image | SampableAugmentation, OODAugmentation | here |
| InCrop | Crops image | INAugmentation | here |
| InResize | Resizes image | INAugmentation | here |
References
[1] Schömig-Markiefka, B., Pryalukhin, A., Hulla, W., Bychkov, A., Fukuoka, J., Mad- abhushi, A., Achter, V., Nieroda, L., Büttner, R., Quaas, A., et al.: Quality control stress test for deep learning-based diagnostic model in digital pathology. Modern Pathology (2021)