in data/datasets/dataset_base.py [0:0]
def additional_transforms(opts):
aug_list = []
if getattr(opts, "image_augmentation.random_gamma_correction.enable", False):
aug_list.append(cv_transforms.RandomGammaCorrection(opts=opts))
if getattr(opts, "image_augmentation.random_rotate.enable", False):
aug_list.append(cv_transforms.RandomRotate(opts=opts))
if getattr(opts, "image_augmentation.random_blur.enable", False):
aug_list.append(cv_transforms.RandomBlur(opts=opts))
if getattr(opts, "image_augmentation.random_translate.enable", False):
aug_list.append(cv_transforms.RandomTranslate(opts=opts))
if getattr(opts, "image_augmentation.random_jpeg_compress.enable", False):
aug_list.append(cv_transforms.RandomJPEGCompress(opts=opts))
if getattr(opts, "image_augmentation.random_gauss_noise.enable", False):
aug_list.append(cv_transforms.RandomGaussianNoise(opts=opts))
if getattr(opts, "image_augmentation.random_resize.enable", False):
aug_list.append(cv_transforms.RandomResize(opts=opts))
if getattr(opts, "image_augmentation.random_scale.enable", False):
aug_list.append(cv_transforms.RandomScale(opts=opts))
if getattr(opts, "image_augmentation.photo_metric_distort.enable", False):
aug_list.append(cv_transforms.PhotometricDistort(opts=opts))
# Flipping
random_flip = getattr(opts, "image_augmentation.random_flip.enable", False)
if random_flip:
aug_list.append(cv_transforms.RandomFlip(opts=opts))
else:
random_h_flip = getattr(opts, "image_augmentation.random_horizontal_flip.enable", False)
random_v_flip = getattr(opts, "image_augmentation.random_vertical_flip.enable", False)
if random_h_flip and random_v_flip:
aug_list.append(cv_transforms.RandomFlip(opts=opts))
elif random_v_flip:
aug_list.append(cv_transforms.RandomVerticalFlip(opts=opts))
elif random_h_flip:
aug_list.append(cv_transforms.RandomHorizontalFlip(opts=opts))
if getattr(opts, "image_augmentation.random_order.enable", False):
assert len(aug_list) > 1
aug_list = [cv_transforms.RandomOrder(opts=opts, img_transforms=aug_list)]
return aug_list