def train_multi_augment12(image, bboxes=None, category_id=None): h, w = image.shape[0], image.shape[1] if bboxes is not None: aug = Compose( [ HorizontalFlip(p=0.5), ShiftScaleRotate( shift_limit=0.05, scale_limit=0.05, rotate_limit=5, border_mode=cv2.BORDER_REPLICATE, p=1, ), RandomSizedCrop(min_max_height=(int(h * 0.9), h), height=h, width=w, p=0.25), RandomBrightnessContrast( brightness_limit=0.0, contrast_limit=0.3, p=0.25), ], p=1, bbox_params=BboxParams(format="pascal_voc", label_fields=["category_id"]), ) augmented = aug(image=image, bboxes=bboxes, category_id=category_id) else: # Normal aug = Compose( [ HorizontalFlip(p=0.5), ShiftScaleRotate( shift_limit=0.05, scale_limit=0.05, rotate_limit=5, border_mode=cv2.BORDER_REPLICATE, p=1, ), RandomSizedCrop(min_max_height=(int(h * 0.9), h), height=h, width=w, p=0.25), RandomBrightnessContrast( brightness_limit=0.3, contrast_limit=0.3, p=0.25), ], p=1, ) augmented = aug(image=image) return augmented
def get_augmentations(p=1.0): return Compose([ RandomSizedCrop((250, 600), 224, 224), OneOf([ IAAAdditiveGaussianNoise(), GaussNoise(), ], p=1), OneOf([ MotionBlur(p=.6), MedianBlur(blur_limit=3, p=0.6), Blur(blur_limit=3, p=0.6), ], p=1), ShiftScaleRotate(shift_limit=0.0825, scale_limit=0.3, rotate_limit=30, p=1), OneOf([ OpticalDistortion(p=0.5), GridDistortion(p=.4), IAAPiecewiseAffine(p=0.5), ], p=0.8), OneOf([ CLAHE(clip_limit=2), IAASharpen(), IAAEmboss(), RandomBrightnessContrast(), ], p=0.9), HueSaturationValue(p=0.3), ], p=p)
def strong_aug(config, aug_prob): return Compose( [ # Resize(config.image_height, config.image_width, always_apply=True), RandomSizedCrop( p=config.random_sized_crop_prob, min_max_height=(int( config.image_height * config.min_max_height), config.image_height), height=config.image_height, width=config.image_width, w2h_ratio=config.image_width / config.image_height), HorizontalFlip(p=config.horizontal_flip_prob), RandomGamma(p=config.random_gamma_prob), RandomContrast(p=config.random_contrast_prob, limit=config.random_contrast_limit), RandomBrightness(p=config.random_brightness_prob, limit=config.random_brightness_limit), OneOf([ MotionBlur(p=config.motion_blur_prob), MedianBlur(blur_limit=config.median_blur_limit, p=config.median_blur_prob), Blur(blur_limit=config.blur_limit, p=config.blur_prob), ], p=config.one_of_blur_prob), CLAHE(clip_limit=config.clahe_limit, p=config.clahe_prob), IAAEmboss(p=config.iaaemboss_prob), HueSaturationValue(p=config.hue_saturation_value_prob, hue_shift_limit=config.hue_shift_limit, sat_shift_limit=config.sat_shift_limit, val_shift_limit=config.val_shift_limit) ], p=aug_prob)
def __init__(self, root_dir, annotation_lines, class_number, transform=None, loader=default_loader): self.annotation_lines = annotation_lines self.class_number = class_number self.transform = transform self.loader = loader self.root_dir = root_dir curr_size = 512 min_max_height = (curr_size - curr_size // 2, curr_size - 1) self.transform_strong = Compose([ RandomSizedCrop(min_max_height=min_max_height, height=curr_size, width=curr_size, p=1.0), OneOf([ Transpose(p=0.5), HorizontalFlip(p=0.5), VerticalFlip(p=0.5), Rotate(p=0.5), ], p=1.0), ElasticTransform(alpha=curr_size, sigma=curr_size * 0.05, alpha_affine=10, p=1.0) ])
def train_pipeline(cache, mask_db, path): image, mask = read_image_and_mask_cached(cache, mask_db, (101, 101), path) args = Compose([ LabelMaskBorder(), HorizontalFlip(p=0.5), OneOf([ ShiftScaleRotate(rotate_limit=15, border_mode=cv2.BORDER_REPLICATE), RandomSizedCrop(min_max_height=(70, 100), height=101, width=101) ], p=0.2), GaussNoise(p=0.2), OneOf([ RandomBrightness(limit=0.4), RandomGamma(), ], p=0.5), OneOf([Blur(), MedianBlur(), MotionBlur()], p=0.2), OneOf([ ElasticTransform(alpha=10, sigma=10, alpha_affine=10), GridDistortion() ], p=0.2), Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]), PadIfNeeded(128, 128, cv2.BORDER_REPLICATE), ChannelsFirst() ])(image=image, mask=mask) return args['image'], args.get('mask')
def hard_aug(original_height=128, original_width=128, k=4): aug = Compose([ OneOf([ RandomSizedCrop( min_max_height=(original_height // k, original_height), height=original_height, width=original_width, p=0.5), PadIfNeeded( min_height=original_height, min_width=original_width, p=0.5) ], p=1), VerticalFlip(p=0.5), HorizontalFlip(p=0.5), RandomRotate90(p=0.5), Transpose(p=0.5), OneOf([ ElasticTransform( p=0.5, alpha=120, sigma=120 * 0.05, alpha_affine=120 * 0.03), GridDistortion(p=0.5), OpticalDistortion(p=1, distort_limit=2, shift_limit=0.5) ], p=0.8), CLAHE(p=0.8), RandomBrightnessContrast(p=0.8), RandomGamma(p=0.8) ]) return aug
def test_random_sized_crop_size(): image = np.ones((100, 100, 3)) keypoints = [(0.2, 0.3, 0.6, 0.8), (0.3, 0.4, 0.7, 0.9, 99)] aug = RandomSizedCrop(min_max_height=(70, 90), height=50, width=50, p=1.0) transformed = aug(image=image, keypoints=keypoints) assert transformed["image"].shape == (50, 50, 3) assert len(keypoints) == len(transformed["keypoints"])
def augment_big(image, mask): original_height, original_width = image.shape[:2] aug = Compose([ RandomSizedCrop(p=0.5, min_max_height=(original_height // 2, original_height), height=original_height, width=original_width), OpticalDistortion(p=0.5, distort_limit=0.25, shift_limit=0.5), OneOf([ CLAHE(p=1., clip_limit=4.), RandomContrast(p=1., limit=0.25), RandomGamma(p=1., gamma_limit=(50, 200)) ], p=0.5), ], p=0.5) augmented = aug(image=image, mask=mask) image_heavy = augmented['image'] mask_heavy = augmented['mask'] return image_heavy, mask_heavy
def create_train_transforms(conf): height = conf['crop_height'] width = conf['crop_width'] return Compose([ SafeRotate(45, p=0.4, border_mode=cv2.BORDER_CONSTANT), OneOf([ RandomSizedCrop(min_max_height=(int(height * 0.7), int( height * 1.3)), w2h_ratio=1., height=height, width=width, p=0.8), RandomCrop(height=height, width=width, p=0.2) ], p=1), HorizontalFlip(), VerticalFlip(), RandomRotate90(), Transpose(), ImageCompression(p=0.1), Lighting(alphastd=0.3), RandomBrightnessContrast(p=0.4), RandomGamma(p=0.4), OneOf([RGBShift(), HueSaturationValue()], p=0.2) ], additional_targets={'image1': 'image'})
def __init__(self, root_path, file_list, is_test=False, is_val=False, augment=False): self.is_test = is_test self.augment = augment self.root_path = root_path self.file_list = file_list self.pad = Compose([ PadIfNeeded(p=1, min_height=PAD_SIZE, min_width=PAD_SIZE), ToTensor(), ]) original_height, original_width = 101, 101 self.augmentation = Compose([ RandomSizedCrop(min_max_height=(50, 101), height=original_height, width=original_width, p=0.9), HorizontalFlip(p=0.5), GridDistortion(p=0.8), RandomContrast(p=0.8), RandomBrightness(p=0.8), RandomGamma(p=0.8) ])
def get_transforms(phase): list_transforms = [] if phase == "train": list_transforms.extend( [ OneOf([ RandomSizedCrop(min_max_height=(50, 101), height=original_height, width=original_width, p=0.5), PadIfNeeded(min_height=original_height, min_width=original_width, p=0.5)], p=1), VerticalFlip(p=0.5), # RandomRotate90(p=0.5), OneOf([ ElasticTransform(p=0.5, alpha=120, sigma=120 * 0.05, alpha_affine=120 * 0.03), GridDistortion(p=0.5), OpticalDistortion(p=1, distort_limit=2, shift_limit=0.5) ], p=0.8), CLAHE(p=0.8), RandomBrightnessContrast(p=0.8), RandomGamma(p=0.8), ] ) list_transforms.extend( [ Resize(height=int(original_height/4), width=int(original_width/4), interpolation=cv2.INTER_NEAREST), Normalize(mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225), p=1), ToTensor(), ] ) list_trfms = Compose(list_transforms) return list_trfms
def get_light_augmentations(width, height): return [ HorizontalFlip(p=1), VerticalFlip(p=1), Transpose(p=1), RandomSizedCrop((height - 4, height - 2), height, width), ]
def train_transform(p=1): return Compose([ HorizontalFlip(p=0.5), OneOf([ RandomSizedCrop((92, 98), 101, 101, p=0.6), ShiftScaleRotate(shift_limit=(0, 0.1), scale_limit=(0, 0.05), rotate_limit=10, p=0.4), ], p=0.6), #OneOf([ # IAAAdditiveGaussianNoise(), #may by # GaussNoise(),#may by #], p=0.2), #OneOf([ # MotionBlur(p=0.2), # MedianBlur(blur_limit=3, p=0.3), # Blur(blur_limit=3, p=0.5), #], p=0.4), OneOf([ ElasticTransform(p=0.2, alpha=120, sigma=120 * 0.05, alpha_affine=120 * 0.03), IAAPiecewiseAffine(p=.4), GridDistortion(p=0.4), ], p=.4), OneOf([ #CLAHE(clip_limit=2), RandomGamma((90,110)), ShiftBrightness((5, 20)), IAAEmboss((0.1, 0.4), (0.1, 0.6)), RandomContrast(0.08), RandomBrightness(0.08), ], p=0.5), ], p=p)
def augment(self, image, mask): aug = Compose([ OneOf([ RandomSizedCrop(min_max_height=(50, 101), height=self.out_size, width=self.out_size, p=0.5), PadIfNeeded( min_height=self.out_size, min_width=self.out_size, p=0.5) ], p=1), VerticalFlip(p=0.5), RandomRotate90(p=0.5), OneOf([ ElasticTransform(p=0.5, alpha=120, sigma=120 * 0.05, alpha_affine=120 * 0.03), GridDistortion(p=0.5), OpticalDistortion(p=1, distort_limit=2, shift_limit=0.5) ], p=0.8), CLAHE(p=0.8), RandomBrightnessContrast(p=0.8), RandomGamma(p=0.8) ]) augmented = aug(image=image, mask=mask) image_heavy = augmented['image'] mask_heavy = augmented['mask'] return image_heavy, mask_heavy
def mask_aug(): aug = Compose([VerticalFlip(p=0.5), RandomRotate90(p=0.5), HorizontalFlip(p=0.5), RandomSizedCrop(min_max_height=(128, 512), height=384, width=384, p=0.5)]) return aug
def randomSizedCrop(image, mask, img_size, original_height, original_width): aug = RandomSizedCrop(p=1, min_max_height=img_size, height=original_height, width=original_width) augmented = aug(image=image, mask=mask) image_scaled = augmented['image'] mask_scaled = augmented['mask'] return image_scaled, mask_scaled
def get_input_pair(self, data_info_row): if len(self.channels) == 0: raise Exception('You have to specify at least one channel.') instance_name = '_'.join( [data_info_row['name'], str(data_info_row['position'])]) image_path = get_filepath(self.dataset_path, data_info_row['name'], self.images_folder, instance_name, file_type=self.image_type) mask_path = get_filepath(self.dataset_path, data_info_row['name'], self.masks_folder, instance_name, file_type=self.mask_type) images_array = filter_by_channels(read_tensor(image_path), self.channels, self.neighbours) if images_array.ndim == 2: images_array = np.expand_dims(images_array, -1) masks_array = read_tensor(mask_path) aug = Compose([ RandomRotate90(), Flip(), OneOf( [ RandomSizedCrop(min_max_height=(int( self.image_size * 0.7), self.image_size), height=self.image_size, width=self.image_size), RandomBrightnessContrast(brightness_limit=0.15, contrast_limit=0.15), #MedianBlur(blur_limit=3, p=0.2), MaskDropout(p=0.6), ElasticTransform(alpha=15, sigma=5, alpha_affine=5), GridDistortion(p=0.6) ], p=0.8), ToTensor() ]) augmented = aug(image=images_array, mask=masks_array) augmented_images = augmented['image'] augmented_masks = augmented['mask'] if self.classification_head: masks_class = ((augmented_masks.sum() > 0) * 1).unsqueeze(-1).float() #.type(torch.FloatTensor) return augmented_images, [augmented_masks, masks_class] else: return {'features': augmented_images, 'targets': augmented_masks}
def get_input_pair(self, data_info_row): if len(self.channels) == 0: raise Exception('You have to specify at least one channel.') instance_name = '_'.join( [data_info_row['name'], data_info_row['position']]) image_path = get_filepath(self.dataset_path, data_info_row['dataset_folder'], self.images_folder, instance_name, file_type=self.image_type) mask_path = get_filepath(self.dataset_path, data_info_row['dataset_folder'], self.masks_folder, instance_name, file_type=self.mask_type) images_array = filter_by_channels(read_tensor(image_path), self.channels) if images_array.ndim == 2: images_array = np.expand_dims(images_array, -1) masks_array = read_tensor(mask_path) if self.channels[0] == 'rgb': rgb_tensor = images_array[:, :, :3].astype(np.uint8) rgb_aug = Compose( [OneOf([RGBShift(), CLAHE(clip_limit=2)], p=0.4)], p=0.9) augmented_rgb = rgb_aug(image=rgb_tensor, mask=masks_array) images_array = np.concatenate( [augmented_rgb['image'], images_array[:, :, 3:]], axis=2) masks_array = augmented_rgb['mask'] aug = Compose([ RandomRotate90(), Flip(), OneOf([ RandomSizedCrop(min_max_height=(int( self.image_size * 0.7), self.image_size), height=self.image_size, width=self.image_size) ], p=0.4), ToTensor() ]) augmented = aug(image=images_array, mask=masks_array) augmented_images = augmented['image'] augmented_masks = augmented['mask'] return {'features': augmented_images, 'targets': augmented_masks}
def get_medium_augmentations(width, height): return [ HorizontalFlip(p=1), VerticalFlip(p=1), RandomSizedCrop((height - 4, height - 2), height, width, p=1), RandomContrast(p=1), RandomBrightness(p=1), RandomGamma(p=1), ShiftScaleRotate(p=1), Blur(blur_limit=3, p=1) ]
def _albumentations(mode, visualize, means, stds): aug_list = [] if 'resize' in self.augment: aug_list.append( Resize(RESIZE_IMAGE_SIZE, RESIZE_IMAGE_SIZE, interpolation=cv2.INTER_CUBIC, p=1.0)) if mode == "train": # use data augmentation only with train mode if 'verticalflip' in self.augment: aug_list.append(VerticalFlip(p=0.5)) if 'horizontalflip' in self.augment: aug_list.append(HorizontalFlip(p=0.5)) if 'randomrotate90' in self.augment: aug_list.append(RandomRotate90(p=1.)) if 'rotate' in self.augment: aug_list.append(Rotate(p=0.5)) if 'brightness' in self.augment: aug_list.append(RandomBrightnessContrast(p=0.5)) if 'randomsizedcrop' in self.augment: aug_list.append( RandomSizedCrop( min_max_height=(256, 512), height=512, width=512, p=0.5, )) if ('normalize' in self.augment or 'normalize_exp' in self.augment or 'normalize_plate_exp' in self.augment): aug_list.append(Normalize(p=1.0, mean=means, std=stds)) # # if not visualize: # if 'normalize' in self.augment: # experiment, plate, well = id_code.split('_') # norm_df = self.stats_df.query( # f'experiment == "{experiment}" and ' # f'plate == {int(plate)} and ' # f'well == "{well}" and ' # f'site == {int(site)}' # ).sort_values('channel') # aug_list.append( # Normalize( # p=1.0, # mean=norm_df['mean'].tolist(), # std=norm_df['std'].tolist(), # # mean=[0.485, 0.456, 0.406, 0.485, 0.456, 0.406], # # std=[0.229, 0.224, 0.225, 0.229, 0.224, 0.225] # ) # rgb -> 6 channels # ) # based on imagenet return Compose(aug_list, p=1.0)
def build_train(self): return Compose([ HorizontalFlip(p=0.5), VerticalFlip(p=0.5), Normalize(mean=self.MEAN, std=self.STD), RandomContrast(p=0.2), RandomBrightness(p=0.2), RandomSizedCrop((240, 256), self.H, self.W, w2h_ratio=1600 / 256), Cutout(max_h_size=32, max_w_size=32), ToTensor(), ])
def crop_aug(image, mask, h, w, min_max_height, w2h_ratio=2): aug = Compose([ HorizontalFlip(p=0.5), RandomBrightnessContrast(p=0.3), RandomSizedCrop(height=h, width=w, min_max_height=min_max_height, w2h_ratio=2), ]) augmented = aug(image=image, mask=mask) return augmented
def TTA(img, model, model_name, seed=88, niter=4): input_size = int(model.get_input_at(0).get_shape()[1]) AUGMENTATIONS = Compose([ HorizontalFlip(p=0.25), RandomSizedCrop(min_max_height=(int(input_size * 0.75), input_size), height=input_size, width=input_size, p=0.5), OneOf([ ShiftScaleRotate(rotate_limit=25), ElasticTransform( alpha=120, sigma=120 * 0.05, alpha_affine=120 * 0.03), GridDistortion(), OpticalDistortion(distort_limit=2, shift_limit=0.5), ], p=0.5), OneOf([RandomContrast(), RandomGamma(), RandomBrightness()], p=0.5), OneOf( [Blur(), MedianBlur(), GaussNoise(), GaussianBlur()], p=0.5) ], p=0.5) np.random.seed(seed) original_img = img.copy() inverted_img = np.invert(img.copy()) hflipped_img = np.fliplr(img.copy()) original_img_array = np.empty( (niter + 1, img.shape[0], img.shape[1], img.shape[2])) inverted_img_array = original_img_array.copy() hflipped_img_array = original_img_array.copy() original_img_array[0] = original_img inverted_img_array[0] = inverted_img hflipped_img_array[0] = hflipped_img for each_iter in range(niter): original_img_array[each_iter + 1] = AUGMENTATIONS(image=original_img)['image'] inverted_img_array[each_iter + 1] = AUGMENTATIONS(image=inverted_img)['image'] hflipped_img_array[each_iter + 1] = AUGMENTATIONS(image=hflipped_img)['image'] tmp_array = np.vstack( (original_img_array, inverted_img_array, hflipped_img_array)) tmp_array = preprocess_input(tmp_array, model_name) prediction = np.mean(model.predict(tmp_array), axis=0) return prediction
def augmentation_random(img, mask=None, img_size_target=128): aug = Compose([ RandomBrightness(limit=0.2, p=0.4), HorizontalFlip(p=0.5), Rotate(limit=10, p=0.4), ShiftScaleRotate(shift_limit=0.1, scale_limit=0, rotate_limit=0, p=0.5), RandomSizedCrop((img_size_target // 2, img_size_target), img_size_target, img_size_target, p=0.4) ], p=0.95) if mask is not None: res = aug(image=img, mask=mask) return res['image'], res['mask'] else: return aug(image=img)['image']
def make_basic_train_transform(mean=0, std=1): from interrater.config import SIZE, MAX_SIZE print("\nbasic transform\n") _train = Compose([ OneOf([ RandomSizedCrop((MAX_SIZE, MAX_SIZE), SIZE, SIZE, p=.8), Resize(SIZE, SIZE, p=.2), ], p=1), CLAHE(always_apply=True), Normalize(mean, std, always_apply=True), ToTensor(always_apply=True) ]) return _train
def weak_aug(p=1.0): return Compose( [ # 순서 고민한거임 # HorizontalFlip(p=0.5), Rotate(limit=360, border_mode=0, p=0.7), RandomSizedCrop(min_max_height=(int(512 * 0.8), 512), height=512, width=512, p=0.7), # RandomBrightnessContrast(brightness_limit=0.2, contrast_limit=0.2, p=0.7), ], p=p)
def test_transform(): rate = 0.9 size = 640 rot_deg = 3 transform = Compose([ #Rotate(rot_deg, p=1.), IAAPerspective(scale=(0.05, 0.1), p=1.0), RandomGamma(p=1.), HueSaturationValue(hue_shift_limit=10, sat_shift_limit=15, val_shift_limit=10, p=1.0), RandomBrightnessContrast(p=1.0), RandomSizedCrop((int(size * rate), int(size * rate)), size, size, p=1.), ]) dataset = datasets.SidewalkSegmentationDatasetFactory( IMAGE_DIRS, MASK_DIRS, SimpleCategory, transform, ) img, mask = dataset.get_raw_image(0) plt.figure(figsize=(12, 8)) plt.subplot(2, 1, 1) plt.title('Image') plt.imshow(img) plt.subplot(2, 1, 2) plt.title('Mask') plt.imshow(mask) plt.show() for i in range(5): data = dataset[0] img = np.array(to_pil_image(logging.normalize(data['X']))) mask = data['Y'].numpy() plt.figure(figsize=(12, 8)) plt.subplot(2, 1, 1) plt.imshow(img) plt.title('Cropped Image') plt.subplot(2, 1, 2) plt.title('Cropped Mask') plt.imshow(mask) plt.show()
def strong_aug(p=1.0): return Compose( [ RandomSizedCrop((100, HEIGHT), HEIGHT, WIDTH, w2h_ratio=1.0, p=1.0), Compose( [ Flip(), RandomRotate90(), Transpose(), OneOf([IAAAdditiveGaussianNoise(), GaussNoise()], p=0.2), OneOf( [MedianBlur(blur_limit=3), Blur(blur_limit=3), MotionBlur()] ), ShiftScaleRotate(args.shift, args.scale, args.rotate), # min_max_height: (height of crop before resizing) # crop_height = randint(min_height, max_height), endpoints included # crop_width = crop_height * w2h_ratio # height, width: height/width after crop and resize, for convenience, just use args for resize OneOf( [ GridDistortion(p=0.5), ElasticTransform(p=0.5), IAAPerspective(), IAAPiecewiseAffine(), ] ), OneOf( [ RGBShift(args.r_shift, args.g_shift, args.b_shift), HueSaturationValue( args.hue_shift, args.sat_shift, args.val_shift ), # ChannelShuffle(), CLAHE(args.clip), RandomBrightnessContrast( args.brightness, args.contrast ), RandomGamma(gamma_limit=(80, 120)), # ToGray(), ImageCompression(quality_lower=75, quality_upper=100), ] ), ], p=p, ), ToFloat(max_value=255), ] )
def get_augmentations(img_size): return Compose([ Resize(height=int(img_size * 1.5), width=int(img_size * 1.5), p=1), RandomSizedCrop(min_max_height=(int(img_size * 0.9), img_size), height=img_size, width=img_size, always_apply=True, p=1), RandomRotate90(), Flip(), Transpose(), OneOf([ IAAAdditiveGaussianNoise(), GaussNoise(), ], p=0.4), OneOf([ GlassBlur(p=1), GaussianBlur(p=1), MotionBlur(p=1), MedianBlur(blur_limit=3, p=1), Blur(blur_limit=3, p=1), ], p=0.4), ShiftScaleRotate(shift_limit=0.0625, scale_limit=0.2, rotate_limit=45, p=0.2), OneOf([ OpticalDistortion(p=1), ElasticTransform(), GridDistortion(p=1), IAAPiecewiseAffine(p=1), ], p=0.4), OneOf( [ CLAHE(clip_limit=2), # Histogram Equalization IAASharpen(), IAAEmboss(), RandomBrightnessContrast(), RGBShift() ], p=0.4), HueSaturationValue(p=0.3), ToSepia(p=0.2), Cutout(p=0.2), RandomScale(p=0.2) ])
def load_aug(img): original_height, original_width = img.shape[:2] aug = Compose([ OneOf([RandomSizedCrop(min_max_height=(50, 101), height=original_height, width=original_width, p=0.5), PadIfNeeded(min_height=original_height, min_width=original_width, p=0.5)], p=1), VerticalFlip(p=0.5), RandomRotate90(p=0.5), OneOf([ ElasticTransform(p=0.5, alpha=120, sigma=120 * 0.05, alpha_affine=120 * 0.03), GridDistortion(p=0.5), OpticalDistortion(p=1, distort_limit=2, shift_limit=0.5) ], p=0.8), CLAHE(p=0.8), RandomBrightnessContrast(p=0.8), RandomGamma(p=0.8)]) return aug