Spaces:
Sleeping
Sleeping
File size: 2,489 Bytes
b2c5353 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | # This code was originally written by Jose Javier Gonzalez Ortiz
# for use in UniverSeg (https://github.com/JJGO/UniverSeg).
# It is included here with their permission, without modifications.
from typing import Union
from kornia.augmentation import AugmentationBase2D
def is_task_aug(aug: Union[str, AugmentationBase2D]) -> bool:
if isinstance(aug, AugmentationBase2D):
aug = aug.__class__.__name__
_is_task_aug = {
"ChannelwiseColorJitter": False,
"ChannelwiseRandomAffine": False,
"ChannelwiseRandomBoxBlur": False,
"ChannelwiseRandomBrightnessContrast": False,
"ChannelwiseRandomCrop": False,
"ChannelwiseRandomElasticTransform": False,
"ChannelwiseRandomErasing": False,
"ChannelwiseRandomFisheye": False,
"ChannelwiseRandomGaussianBlur": False,
"ChannelwiseRandomGaussianNoise": False,
"ChannelwiseRandomHorizontalFlip": False,
"ChannelwiseRandomInvert": False,
"ChannelwiseRandomMotionBlur": False,
"ChannelwiseRandomPerspective": False,
"ChannelwiseRandomPosterize": False,
"ChannelwiseRandomResizedCrop": False,
"ChannelwiseRandomRotation": False,
"ChannelwiseRandomSharpness": False,
"ChannelwiseRandomSolarize": False,
"ChannelwiseRandomThinPlateSpline": False,
"ChannelwiseRandomVariableBoxBlur": False,
"ChannelwiseRandomVariableElasticTransform": False,
"TorchvisionChannelwiseRandomVariableElasticTransform": False,
"ChannelwiseRandomVariableGaussianBlur": False,
"ChannelwiseRandomVariableGaussianNoise": False,
"ChannelwiseRandomVerticalFlip": False,
# Task Augs
"RandomAffine": True,
"RandomBrightnessContrast": True,
"RandomDilation": True,
"RandomErosion": True,
"RandomFlipIntensities": True,
"RandomFlipLabel": True,
"RandomHorizontalFlip": True,
"RandomMorphGradient": True,
"RandomScale": True,
"RandomSharpness": True,
"RandomShear": True,
"RandomSobelEdgesLabel": True,
"RandomTranslate": True,
"RandomVariableBoxBlur": True,
"RandomVariableDilation": True,
"RandomVariableElasticTransform": True,
"RandomVariableErosion": True,
"RandomVariableGaussianBlur": True,
"RandomVariableGaussianNoise": True,
"RandomVerticalFlip": True,
}
return _is_task_aug[aug]
|