Пример #1
0
def alpha(image , xmin1 , ymin1 , xmax1 , ymax1 , classy , img_name):
	global xml_list
	ctt = 0 
	if classy == 'open':
		for i in range(10):
			rotate=iaa.Affine(rotate=(-12, 12))
			image_aug = rotate(image=image)
			
			for j in range(10):
				aug = iaa.AddToBrightness((-30, 30))
				image_color= aug(image=image_aug)

				aug = iaa.AddToHue((-15, 15))
				image_color= aug(image=image_color)


				ctt = ctt+1
				name_changed = str(ctt)+img_name


				cv2.imwrite(os.path.join(fin_folder, "training" , name_changed),image_color)
				# ia.imshow(draw_on_image(image_aug, size=2))

				value = (name_changed , 624 , 832 , 'open' , 0 , 0 , 0 , 0)
				xml_list.append(value)
	else:
		bbs = BoundingBoxesOnImage([
		BoundingBox(x1=xmin1, x2=xmax1, y1=ymin1, y2=ymax1)
		], shape=image.shape)
		for i in range(10):
			rotate=iaa.Affine(rotate=(-12, 12))
			image_aug, bbs_aug = rotate(image=image, bounding_boxes=bbs)
			
			for j in range(10):
				r="AddToHue"
				aug = iaa.AddToBrightness((-30, 30))
				image_color, bbs_aug = aug(image=image_aug, bounding_boxes=bbs_aug)


				aug = iaa.AddToHue((-15, 15))
				image_color, bbs_aug = aug(image=image_color, bounding_boxes=bbs_aug)



				ctt = ctt+1
				name_changed = str(ctt)+img_name


				cv2.imwrite(os.path.join(fin_folder, "training" , name_changed),image_color)
				# ia.imshow(bbs_aug.draw_on_image(image_color, size=2))

				value = (name_changed , 624 , 832 , 'closed' , bbs_aug[0].x1 , bbs_aug[0].y1 , bbs_aug[0].x2 , bbs_aug[0].y2)

				xml_list.append(value)
Пример #2
0
def check():
	image = imageio.imread("img1.jpg")
	bbs = BoundingBoxesOnImage([
	BoundingBox(x1=0, x2=0, y1=0, y2=0)
	], shape=image.shape)
	for i in range(1):
		rotate=iaa.Affine(rotate=(-12, 12))
		image_aug, bbs_aug = rotate(image=image, bounding_boxes=bbs)
		
		for j in range(1):
			r="AddToHue"
			aug = iaa.AddToBrightness((-30, 30))
			image_aug, bbs_aug = aug(image=image_aug, bounding_boxes=bbs_aug)


			aug = iaa.AddToHue((-15, 15))
			image_aug, bbs_aug = aug(image=image_aug, bounding_boxes=bbs_aug)





			# cv2.imwrite("a.jpg",image_aug)
			print(bbs_aug[0].x1)
			ia.imshow(bbs_aug.draw_on_image(image_aug, size=2))
def generate_add_to_brightness():
    ia.seed(1)

    image = ia.quokka((128, 128))
    images_aug = [image]
    for value in np.linspace(-100, 100, 7):
        images_aug.append(iaa.AddToBrightness(value)(image=image))
    _save("addtobrightness.jpg", ia.draw_grid(images_aug, cols=8, rows=1))
    def augmentate_image(self, image, bbs, augmentation_mode):
        """
        Augmentate image using a defined augmentation mode. 
        """

        # rotate
        if augmentation_mode == self.augmentation_modes["grayscale"]:
            gray = iaa.Grayscale(alpha=1.0)
            augmented_image, augmented_bbs = gray(image=image,
                                                  bounding_boxes=bbs)

        if augmentation_mode == self.augmentation_modes["rotate"]:
            rotate = iaa.Affine(rotate=(-30, 20))
            augmented_image, augmented_bbs = rotate(image=image,
                                                    bounding_boxes=bbs)
        # flip_horizontal
        if augmentation_mode == self.augmentation_modes["flip_horizontal"]:
            flip_hr = iaa.Fliplr(p=1.0)
            augmented_image, augmented_bbs = flip_hr(image=image,
                                                     bounding_boxes=bbs)
        # flip_vertical
        if augmentation_mode == self.augmentation_modes["flip_vertical"]:
            flip_vr = iaa.Flipud(p=1.0)
            augmented_image, augmented_bbs = flip_vr(image=image,
                                                     bounding_boxes=bbs)
        # gaussian_noise
        if augmentation_mode == self.augmentation_modes["gaussian_noise"]:
            gaussian_noise = iaa.AdditiveGaussianNoise(10, 20)
            augmented_image, augmented_bbs = gaussian_noise(image=image,
                                                            bounding_boxes=bbs)
        # brightness_darker
        if augmentation_mode == self.augmentation_modes["brightness_darker"]:
            bright_aug = iaa.AddToBrightness((-60, -20))
            augmented_image, augmented_bbs = bright_aug(image=image,
                                                        bounding_boxes=bbs)
        # brightness brighter
        if augmentation_mode == self.augmentation_modes["brightness_brighter"]:
            bright_aug = iaa.AddToBrightness((20, 40))
            augmented_image, augmented_bbs = bright_aug(image=image,
                                                        bounding_boxes=bbs)

        if self.with_visualisation:
            ia.imshow(augmented_bbs.draw_on_image(augmented_image, size=2))

        return augmented_image, augmented_bbs
Пример #5
0
 def __init__(self, ):
     self.augmentations = iaa.Sequential([
         iaa.Dropout([0.0, 0.01]),
         iaa.Sharpen((0.0, 0.1)),
         iaa.Affine(rotate=(-10, 10), translate_percent=(-0.1,0.1)),  # rotate by -45 to 45 degrees (affects segmaps)
         iaa.AddToBrightness((-10, 10)), 
         iaa.AddToHue((-5, 5)),
         iaa.Fliplr(0.5),
     ])
Пример #6
0
def chapter_augmenters_addtobrightness():
    fn_start = "color/addtobrightness"

    aug = iaa.AddToBrightness((-30, 30))

    run_and_save_augseq(fn_start + ".jpg",
                        aug, [ia.quokka(size=(128, 128)) for _ in range(8)],
                        cols=4,
                        rows=2)
Пример #7
0
def get_preview(images, augmentationList):
    """
    Accepts a list of images and augmentationList as input.
    Provides a list of augmented images in that order as ouptut.
    """
    augmented = []
    for image in images:
        for augmentation in augmentationList:
            aug_id = augmentation['id']
            params = augmentation['params']
            if (aug_id == 1):
                image = iaa.SaltAndPepper(p=params[0],
                                          per_channel=params[1])(image=image)
            elif (aug_id == 2):
                image = iaa.imgcorruptlike.GaussianNoise(
                    severity=(params[0], params[1]))(image=image)
            elif (aug_id == 3):
                image = iaa.Rain(speed=(params[0], params[1]),
                                 drop_size=(params[2], params[3]))(image=image)
            elif (aug_id == 4):
                image = iaa.imgcorruptlike.Fog(
                    severity=(params[0], params[1]))(image=image)
            elif (aug_id == 5):
                image = iaa.imgcorruptlike.Snow(
                    severity=(params[0], params[1]))(image=image)
            elif (aug_id == 6):
                image = iaa.imgcorruptlike.Spatter(
                    severity=(params[0], params[1]))(image=image)
            elif (aug_id == 7):
                image = iaa.BlendAlphaSimplexNoise(
                    iaa.EdgeDetect(1))(image=image)
            elif (aug_id == 8):
                image = iaa.Rotate(rotate=(params[0], params[1]))(image=image)
            elif (aug_id == 9):
                image = iaa.Affine()(image=image)  #to be implemented
            elif (aug_id == 10):
                image = iaa.MotionBlur(k=params[0],
                                       angle=(params[1],
                                              params[2]))(image=image)
            elif (aug_id == 11):
                image = iaa.imgcorruptlike.ZoomBlur(
                    severity=(params[0], params[1]))(image=image)
            elif (aug_id == 12):
                image = iaa.AddToBrightness()(image=image)  #to be implemented
            elif (aug_id == 13):
                image = iaa.ChangeColorTemperature(
                    kelvin=(params[0], params[1]))(image=image)
            elif (aug_id == 14):
                image = iaa.SigmoidContrast()(image=image)  #to be implemented
            elif (aug_id == 15):
                image = iaa.Cutout(nb_iterations=(params[0], params[1]),
                                   size=params[2],
                                   squared=params[3])(image=image)
            else:
                print("Not implemented")
        augmented.append(image)
    return augmented
Пример #8
0
 def __init__(self, ):
     self.augmentations = iaa.Sequential([
         iaa.Dropout([0.0, 0.01]),       # 随机去掉一些像素点, 即把这些像素点变成0。
         iaa.Sharpen((0.0, 0.2)),        # 锐化
         iaa.Affine(rotate=(-20, 20), translate_percent=(-0.2,0.2)),  # rotate by -45 to 45 degrees (affects segmaps)
         iaa.AddToBrightness((-30, 30)),     # change brightness of images
         iaa.AddToHue((-20, 20)),            # 为图像的色调添加随机值。
         iaa.Fliplr(0.5),    # 水平镜面翻转。
     ], random_order=True)
 def __init__(self, ):
     self.augmentations = iaa.Sequential([
         iaa.Sharpen((0.0, 0.1)),
         iaa.Affine(rotate=(-0, 0),
                    translate_percent=(-0.1, 0.1),
                    scale=(0.8, 1.5)),
         iaa.AddToBrightness((-60, 40)),
         iaa.AddToHue((-10, 10)),
         iaa.Fliplr(0.5),
     ])
Пример #10
0
 def __init__(self, ):
     self.augmentations = iaa.Sequential(
         [
             iaa.Dropout([0.0, 0.01]),
             iaa.Sharpen((0.0, 0.2)),
             iaa.Affine(rotate=(-20, 20), translate_percent=(
                 -0.2,
                 0.2)),  # rotate by -45 to 45 degrees (affects segmaps)
             iaa.AddToBrightness((-30, 30)),
             iaa.AddToHue((-20, 20)),
             iaa.Fliplr(0.5),
         ],
         random_order=True)
Пример #11
0
 def __init__(self):
     self.seq = iaa.Sequential([
         iaa.Sometimes(
             0.5,
             iaa.OneOf([
                 iaa.AddToHueAndSaturation((-40, 40)),
                 iaa.AddToBrightness((-40, 40))
             ])),
         iaa.Affine(translate_percent=(-0.15, 0.15),
                    scale=(0.8, 1.2),
                    rotate=(-5., 5.),
                    shear=(-2., 2.)),
         iaa.Sometimes(0.1, iaa.Dropout(0.10))
     ])
Пример #12
0
    def augmentor(self, images):
        'Apply data augmentation'
        sometimes = lambda aug: iaa.Sometimes(0.5, aug)
        often = lambda aug: iaa.Sometimes(0.7, aug)

        seq = iaa.Sequential(
            [
                # Best Augmentation Strategy: Colour Augmentation
                often(iaa.WithChannels(0, iaa.Add((-30, 30)))  # RGB = 0,1,2
                      ),
                sometimes(iaa.LinearContrast((0.5, 2.0))),
                sometimes(iaa.AddToBrightness((-30, 30))),
                sometimes(iaa.GaussianBlur(sigma=(0, 0.5)))
            ],
            random_order=True)  # apply augmenters in random order

        return seq.augment_images(images)
Пример #13
0
def get_augmentations():
    def sometimes(aug, p=0.5):
        return iaa.Sometimes(p, aug)

    return iaa.Sequential([
        # sometimes(iaa.Affine(scale=(1, 1.6), translate_percent=0.2)),
        iaa.SomeOf(
            2,
            [
                sometimes(iaa.Multiply()),
                sometimes(iaa.GammaContrast()),
                sometimes(iaa.AddToSaturation()),
                sometimes(iaa.AddToBrightness()),
                # sometimes(iaa.AddToHue()),
                sometimes(iaa.CLAHE())
            ])
    ])
Пример #14
0
    def np_func(img, ann):
        # convert to imgaug keypoints
        keypoints = annotation_to_keypoints(img, ann)
        img = img.astype(np.uint8)

        p = 0.1
        seq = iaa.Sequential([
            iaa.Sometimes(p, iaa.Sequential([iaa.ShearY((-20, 20))])),
            iaa.Sometimes(p, iaa.ChangeColorTemperature((3500, 8000))),
            iaa.Sometimes(p, iaa.AddToBrightness((-15, 15))),
            iaa.Sometimes(p, iaa.AdditiveGaussianNoise(scale=(0, 0.03 * 255), per_channel=True))
        ])

        img, keypoints = seq(image=img, keypoints=keypoints)

        # convert from imgaug keypoints
        ann = keypoints_to_annotation(img, ann, keypoints)

        return img.astype(np.float32), ann
Пример #15
0
def data_augmentation(path):
    ia.seed(2)

    seq = iaa.Sequential([
        iaa.Sometimes(0.5, iaa.Grayscale(alpha=(0.1, 0.5))),
        iaa.Sometimes(0.5, iaa.Multiply((0.5, 1.5), per_channel=0.5)),
        iaa.Sometimes(0.5,
                      iaa.MultiplyHueAndSaturation(mul_saturation=(0.5, 1.5))),
        iaa.Sometimes(0.5, iaa.GaussianBlur(sigma=(0, 2.0))),
        iaa.Sometimes(0.8, iaa.MultiplyBrightness((0.5, 1.5))),
        iaa.AddToBrightness((-30, 30)),
        iaa.Sometimes(0.6,
                      iaa.MultiplyHueAndSaturation(mul_saturation=(0.5, 1.5)))
    ],
                         random_order=True)

    i = 0
    for fname in os.listdir(path):

        try:
            img = imageio.imread(os.path.join(path, fname), pilmode="RGB")
            print(i)
            if i % 5 == 0:
                img_aug = seq.augment_image(img)
                imageio.imwrite(
                    os.path.join(path, fname.replace(".jpg", "_imgaug.jpg")),
                    img_aug)
                fname_txt = fname.replace('.jpg', '.txt')
                print(
                    os.path.join(path,
                                 fname_txt.replace(".txt", "_imgaug.txt")))
                shutil.copyfile(
                    os.path.join(path, fname_txt),
                    os.path.join(path,
                                 fname_txt.replace(".txt", "_imgaug.txt")))

        except:
            print('Error reading img')
        i += 1
Пример #16
0
                                   per_channel=0.5),
         iaa.BlendAlphaElementwise((0.0, 1.0),
                                   foreground=iaa.Add((-15, 15)),
                                   background=iaa.Multiply((0.8, 1.2))),
         iaa.ReplaceElementwise(0.05,
                                iap.Normal(128, 0.4 * 128),
                                per_channel=0.5),
         iaa.Dropout(p=(0, 0.05), per_channel=0.5),
     ])),
 # Brightness + Color + Contrast
 iaa.Sometimes(
     0.5,
     iaa.OneOf([
         iaa.Add(iap.Normal(iap.Choice([-30, 30]), 10)),
         iaa.Multiply((0.75, 1.25)),
         iaa.AddToBrightness((-35, 35)),
         iaa.MultiplyBrightness((0.85, 1.15)),
         iaa.MultiplyAndAddToBrightness(mul=(0.85, 1.15), add=(-10, 10)),
         iaa.BlendAlphaHorizontalLinearGradient(iaa.Add(
             iap.Normal(iap.Choice([-40, 40]), 10)),
                                                start_at=(0, 0.2),
                                                end_at=(0.8, 1)),
         iaa.BlendAlphaHorizontalLinearGradient(iaa.Add(
             iap.Normal(iap.Choice([-40, 40]), 10)),
                                                start_at=(0.8, 1),
                                                end_at=(0, 0.2)),
         iaa.BlendAlphaVerticalLinearGradient(iaa.Add(
             iap.Normal(iap.Choice([-40, 40]), 10)),
                                              start_at=(0.8, 1),
                                              end_at=(0, 0.2)),
         iaa.BlendAlphaVerticalLinearGradient(iaa.Add(
Пример #17
0
 def getImageAug():
     return iaa.Sequential([
         iaa.GaussianBlur(sigma=(0, 1.0)),
         iaa.Fliplr(0.5),
         iaa.AddToBrightness((-30, 30)),
     ])
def get_augmenter_pipeline(strength_enum):
    """
    Data augmentation package

    ### Parameters:
    strength_enum : {ImageAugmentationStrength enum}
        Corresponds to the level of data augmentation that should be applied.

    ### Returns:
    Data augmentation pipeline that handles images and corresponding keypoints simultaneously.
    NOTE that both the keypoints and the images must be passed in one call, or different
    transformations will be applied to them, rendering them useless.

    #### Options:
    ImageAugmentationStrength.heavy:
        - Blur with probability 30% with sigma              2.0
        - Up to 3 of the following:
            - Sharpening                                    0.8 to 1.2, blending factor between (0,1)
            - Hue and saturation change of                  -30 to 30 out of 255
            - One of:
                - Brightness change of                      -30 to 30 out of 255
                - Contrast change of                        0.75 to 1.25
            - One of:
                - Pixel dropout up to                       10% of pixels
                - Gaussian noise up to                      5% of 255
        - Scaling                                           (+/- 25 %)
        - Rotation                                          (+/- 30 deg)

    ImageAugmentationStrength.medium:
        - Blur with probability 30% with sigma              1.5
        - Up to 3 of the following:
            - Sharpening                                    0.85 to 1.15, blending factor between (0,0.5)
            - Hue and saturation change of                  -20 to 20 out of 255
            - One of:
                - Brightness change of                      -25 to 25 out of 255
                - Contrast change of                        0.85 to 1.15
            - One of:
                - Pixel dropout up to                       5% of pixels
                - Gaussian noise up to                      3% of 255
        - Scaling                                           (+/- 20 %)
        - Rotation                                          (+/- 25 deg)

    ImageAugmentationStrength.light:
        - Blur with probability 30% with sigma              1
        - Up to 2 of the following:
            - Sharpening                                    None
            - Hue and saturation change of                  -15 to 15 out of 255
            - One of:
                - Brightness change of                      -20 to 20 out of 255
                - Contrast change of                        0.9 to 1.1
            - One of:
                - Pixel dropout up to                       3% of pixels
                - Gaussian noise up to                      1% of 255
        - Scaling                                           (+/- 15 %)
        - Rotation                                          (+/- 15 deg)
    """

    if strength_enum is ImageAugmentationStrength.heavy:
        iaaGaussianBlurSigmaMax = 2.0

        iaaMaxNumberImageAppearanceOperations = 3
        # Image appearance operations
        iaaApplySharpening = True
        iaaSharpenAlphaMax = 1
        iaaSharpenLightnessMin = 0.8
        iaaSharpenLightnessMax = 1.2
        iaaHueSaturationMin = -30
        iaaHueSaturationMax = 30
        iaaBrightnessMin = -30
        iaaBrightnessMax = 30
        iaaLinearContrastMin = 0.75
        iaaLinearContrastMax = 1.25
        # Picture quality operations, apply only one
        iaaApplyDropoutAndGaussian = True
        iaaDropoutPercentPixels = 0.1
        iaaAdditiveGaussianNoiseScale = 0.05

        # Only up to one of the image size/rotation operations
        iaaCropAndPadPercentMagnitude = 0.25  # add and subtract this from 1.00 (100%, no scaling)
        iaaRotateDegreesMagnitude = 30  # add and subtract this from 0 deg
    elif strength_enum is ImageAugmentationStrength.medium:
        iaaGaussianBlurSigmaMax = 1.5

        iaaMaxNumberImageAppearanceOperations = 3
        # Image appearance operations
        iaaApplySharpening = True
        iaaSharpenAlphaMax = 0.5
        iaaSharpenLightnessMin = 0.85
        iaaSharpenLightnessMax = 1.15
        # Colour and contrast
        iaaHueSaturationMin = -20
        iaaHueSaturationMax = 20
        iaaBrightnessMin = -25
        iaaBrightnessMax = 25
        iaaLinearContrastMin = 0.85
        iaaLinearContrastMax = 1.15
        # Picture quality operations, apply only one
        iaaApplyDropoutAndGaussian = True
        iaaDropoutPercentPixels = 0.05
        iaaAdditiveGaussianNoiseScale = 0.03

        # Only up to one of the image size/rotation operations
        iaaCropAndPadPercentMagnitude = 0.20  # add and subtract this from 1.00 (100%, no scaling)
        iaaRotateDegreesMagnitude = 25  # add and subtract this from 0 deg
    elif strength_enum is ImageAugmentationStrength.light:
        iaaGaussianBlurSigmaMax = 1

        iaaMaxNumberImageAppearanceOperations = 2
        # Image appearance operations
        iaaApplySharpening = False
        iaaSharpenAlphaMax = 0
        iaaSharpenLightnessMin = 1
        iaaSharpenLightnessMax = 1
        # Colour and contrast
        iaaHueSaturationMin = -15
        iaaHueSaturationMax = 15
        iaaBrightnessMin = -20
        iaaBrightnessMax = 20
        iaaLinearContrastMin = 0.9
        iaaLinearContrastMax = 1.1
        # Picture quality operations, apply only one
        iaaApplyDropoutAndGaussian = True
        iaaDropoutPercentPixels = 0.03
        iaaAdditiveGaussianNoiseScale = 0.01

        # Only up to one of the image size/rotation operations
        iaaCropAndPadPercentMagnitude = 0.15  # add and subtract this from 1.00 (100%, no scaling)
        iaaRotateDegreesMagnitude = 15  # add and subtract this from 0 deg
    elif strength_enum is ImageAugmentationStrength.none:
        return None
    else:
        validate_enum(ImageAugmentationStrength, strength_enum.name)
        exit(1)

    # Verify that min are lower than max
    assert iaaSharpenLightnessMin <= iaaSharpenLightnessMax
    assert iaaHueSaturationMin <= iaaHueSaturationMax
    assert iaaBrightnessMin <= iaaBrightnessMax
    assert iaaLinearContrastMin <= iaaLinearContrastMax
    # Verify that the magnitude is given
    assert iaaCropAndPadPercentMagnitude >= 0
    assert iaaRotateDegreesMagnitude >= 0

    iaaSomeOfImageAppearance = [
        # change their color
        iaa.AddToHueAndSaturation((iaaHueSaturationMin, iaaHueSaturationMax)),
        iaa.OneOf([
            iaa.AddToBrightness((iaaBrightnessMin, iaaBrightnessMax)),
            iaa.LinearContrast((iaaLinearContrastMin, iaaLinearContrastMax)),
        ]),
    ]

    # Conditionally add the following transformations
    if iaaApplySharpening:
        iaaSomeOfImageAppearance.append(
            iaa.Sharpen(alpha=(0, iaaSharpenAlphaMax),
                        lightness=(iaaSharpenLightnessMin,
                                   iaaSharpenLightnessMax)), )
    if iaaApplyDropoutAndGaussian:
        # Only apply one of the following because they may overlap and do the same thing
        iaaSomeOfImageAppearance.append(
            iaa.OneOf([
                # randomly remove up to x % of the pixels
                iaa.Dropout((0, iaaDropoutPercentPixels), per_channel=0.5),
                # Add gaussian noise.
                # For 50% of all images, we sample the noise once per pixel.
                # For the other 50% of all images, we sample the noise per pixel AND
                # channel. This can change the color (not only brightness) of the pixels.
                iaa.AdditiveGaussianNoise(
                    loc=0,
                    scale=(0.0, iaaAdditiveGaussianNoiseScale * 255),
                    per_channel=0.2),
            ]))

    # define an augmentation pipeline
    aug_pipeline = iaa.Sequential(
        [
            # apply Gaussian blur with a sigma between 0 and x to 30% of the images
            iaa.Sometimes(0.3, iaa.GaussianBlur((0, iaaGaussianBlurSigmaMax))),
            iaa.SomeOf((0, iaaMaxNumberImageAppearanceOperations),
                       iaaSomeOfImageAppearance),
            # Only apply one of the following because otherwise there is a risk that keypoints will
            # be pointing to a non-existent part of the image
            iaa.SomeOf((0, 1), [
                iaa.CropAndPad(percent=(-1 * iaaCropAndPadPercentMagnitude,
                                        iaaCropAndPadPercentMagnitude),
                               keep_size=True,
                               sample_independently=False),
                iaa.Rotate((-1 * iaaRotateDegreesMagnitude,
                            iaaRotateDegreesMagnitude)),
            ])
        ],
        random_order=True  # apply the augmentations in random order
    )

    ## Usually, we need this line, but as long as we call the pipeline with both the image and keypoint
    ## passed in together, identical augmentations will be applied to both the image and keypoint
    # aug_pipeline_det = aug_pipeline.to_deterministic()

    return aug_pipeline
    def __init__(self):
        self.seq = iaa.Sequential(
            [
                iaa.Fliplr(0.5),
                iaa.Sometimes(0.5, iaa.Crop(percent=(0, 0.1))),

                iaa.Sometimes(0.5, iaa.Affine(
                    rotate=(-20, 20),  # 旋转±20度
                    # shear=(-16, 16),   # 剪切变换±16度,矩形变平行四边形
                    # order=[0, 1],  # 使用最近邻插值 或 双线性插值
                    cval=0,  # 填充值
                    mode=ia.ALL  # 定义填充图像外区域的方法
                )),

                # 使用0~3个方法进行图像增强
                iaa.SomeOf((0, 3),
                           [
                               iaa.Sometimes(0.8, iaa.OneOf([
                                   iaa.GaussianBlur((0, 2.0)),  # 高斯模糊
                                   iaa.AverageBlur(k=(1, 5)),  # 平均模糊,磨砂
                               ])),

                               # 要么运动,要么美颜
                               iaa.Sometimes(0.8, iaa.OneOf([
                                   iaa.MotionBlur(k=(3, 11)),  # 运动模糊
                                   iaa.BilateralBlur(d=(1, 5),
                                                     sigma_color=(10, 250),
                                                     sigma_space=(10, 250)),  # 双边滤波,美颜
                               ])),

                               # 模仿雪花
                               iaa.Sometimes(0.8, iaa.OneOf([
                                   iaa.SaltAndPepper(p=(0., 0.03)),
                                   iaa.AdditiveGaussianNoise(loc=0, scale=(0., 0.05 * 255), per_channel=False)
                               ])),

                               # 对比度
                               iaa.Sometimes(0.8, iaa.LinearContrast((0.6, 1.4), per_channel=0.5)),

                               # 锐化
                               iaa.Sometimes(0.8, iaa.Sharpen(alpha=(0, 1.0), lightness=(0.75, 1.5))),

                               # 整体亮度
                               iaa.Sometimes(0.8, iaa.OneOf([
                                   # 加性调整
                                   iaa.AddToBrightness((-30, 30)),
                                   # 线性调整
                                   iaa.MultiplyBrightness((0.5, 1.5)),
                                   # 加性 & 线性
                                   iaa.MultiplyAndAddToBrightness(mul=(0.5, 1.5), add=(-30, 30)),
                                ])),

                               # 饱和度
                               iaa.Sometimes(0.8, iaa.OneOf([
                                   iaa.AddToSaturation((-75, 75)),
                                   iaa.MultiplySaturation((0., 3.)),
                               ])),

                               # 色相
                               iaa.Sometimes(0.8, iaa.OneOf([
                                   iaa.AddToHue((-255, 255)),
                                   iaa.MultiplyHue((-3.0, 3.0)),
                               ])),

                               # 云雾
                               # iaa.Sometimes(0.3, iaa.Clouds()),

                               # 卡通化
                               # iaa.Sometimes(0.01, iaa.Cartoon()),
                           ],
                           random_order=True
                           )
            ],
            random_order=True
        )
Пример #20
0
        transformed_image = transform(image=image)

    elif augmentation == 'addto_hue_and_saturation':
        transform = iaa.AddToHueAndSaturation((-50, 50), per_channel=True)
        transformed_image = transform(image=image)

    elif augmentation == 'hue_saturation':
        transform = HueSaturationValue(always_apply=True)
        transformed_image = transform(image=image)['image']

    elif augmentation == 'multiply_brightness':
        transform = iaa.MultiplyBrightness((0.1, 1.9))
        transformed_image = transform(image=image)

    elif augmentation == 'addto_brightness':
        transform = iaa.AddToBrightness((-50, 50))
        transformed_image = transform(image=image)

    elif augmentation == 'multiply_and_addtobrightness':
        transform = iaa.MultiplyAndAddToBrightness(mul=(0.5, 1.5), 
                                                   add=(-30, 30))
        transformed_image = transform(image=image)

    elif augmentation == 'to_gray':
        transform = ToGray(always_apply=True)
        transformed_image = transform(image=image)['image']

    elif augmentation == 'posterize':
        transform = Posterize(always_apply=True, num_bits=2)
        transformed_image = transform(image=image)['image']
seq_2 = iaa.Sequential(
        [
        iaa.OneOf(
            [   
            # Blur each image using a median over neihbourhoods that have a random size between 3x3 and 7x7
            sometimes(iaa.MedianBlur(k=(3, 7))),
            # blur images using gaussian kernels with random value (sigma) from the interval [a, b]
            sometimes(iaa.GaussianBlur(sigma=(0.0, 1.0))),
            sometimes(iaa.AdditiveGaussianNoise(loc=0, scale=(0.0, 0.05 * 255), per_channel=0.5))
            ]
        ),
        iaa.Sequential(
            [
            sometimes(iaa.AddToHue((-8, 8))),
            sometimes(iaa.AddToSaturation((-20, 20))),
            sometimes(iaa.AddToBrightness((-26, 26))),
            sometimes(iaa.Lambda(func_images = add_to_contrast))
            ], random_order=True)
        ], random_order=True)
#%%
for p in range(iterations): # how many times to apply random augmentations
    for idx in trange(len(img_path), desc='Augumenting Dataset (iteration {}of{})'.format(p+1, iterations)):
        
        img = cv2.imread(img_path[idx])
        img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
        filepath = xml_path[idx]
        
        full_dict = xmltodict.parse(open( filepath , 'rb' ))
        
        # Extracting the coords and class names from xml file
        names = []
Пример #22
0
def crop_image(image, target):
    image = tf.image.random_crop(image,
                                 [tf.shape(image)[0], *INPUT_SHAPE[:2], 3])
    return image, target


# resize image to 224x224
def resize_image(image, target):
    image = tf.image.resize(image, INPUT_SHAPE[:2])
    return image, target


# augmentation options
AUG = iaa.Sequential([
    iaa.SomeOf((0, 1), [
        iaa.AddToBrightness((-30, 30)),
        iaa.MultiplyBrightness((0.5, 1.5)),
        iaa.MultiplySaturation((0.5, 1.5)),
        iaa.AddToSaturation((-50, 50))
    ]),
    iaa.OneOf([
        iaa.ScaleX((1.0, 1.5)),
        iaa.ScaleY((1.0, 1.5)),
        iaa.Affine(scale={
            "x": (1.0, 1.2),
            "y": (1.0, 1.2)
        }),
        iaa.Affine(rotate=(-20, 20)),
        iaa.PiecewiseAffine(scale=(0.01, 0.05)),
        iaa.Affine(shear=(-16, 16))
    ]),
Пример #23
0
def create_augmenters(height, width, height_augmentable, width_augmentable, only_augmenters):
    def lambda_func_images(images, random_state, parents, hooks):
        return images

    def lambda_func_heatmaps(heatmaps, random_state, parents, hooks):
        return heatmaps

    def lambda_func_keypoints(keypoints, random_state, parents, hooks):
        return keypoints

    def assertlambda_func_images(images, random_state, parents, hooks):
        return True

    def assertlambda_func_heatmaps(heatmaps, random_state, parents, hooks):
        return True

    def assertlambda_func_keypoints(keypoints, random_state, parents, hooks):
        return True

    augmenters_meta = [
        iaa.Sequential([iaa.Noop(), iaa.Noop()], random_order=False, name="Sequential_2xNoop"),
        iaa.Sequential([iaa.Noop(), iaa.Noop()], random_order=True, name="Sequential_2xNoop_random_order"),
        iaa.SomeOf((1, 3), [iaa.Noop(), iaa.Noop(), iaa.Noop()], random_order=False, name="SomeOf_3xNoop"),
        iaa.SomeOf((1, 3), [iaa.Noop(), iaa.Noop(), iaa.Noop()], random_order=True, name="SomeOf_3xNoop_random_order"),
        iaa.OneOf([iaa.Noop(), iaa.Noop(), iaa.Noop()], name="OneOf_3xNoop"),
        iaa.Sometimes(0.5, iaa.Noop(), name="Sometimes_Noop"),
        iaa.WithChannels([1, 2], iaa.Noop(), name="WithChannels_1_and_2_Noop"),
        iaa.Identity(name="Identity"),
        iaa.Noop(name="Noop"),
        iaa.Lambda(func_images=lambda_func_images, func_heatmaps=lambda_func_heatmaps, func_keypoints=lambda_func_keypoints,
                   name="Lambda"),
        iaa.AssertLambda(func_images=assertlambda_func_images, func_heatmaps=assertlambda_func_heatmaps,
                         func_keypoints=assertlambda_func_keypoints, name="AssertLambda"),
        iaa.AssertShape((None, height_augmentable, width_augmentable, None), name="AssertShape"),
        iaa.ChannelShuffle(0.5, name="ChannelShuffle")
    ]
    augmenters_arithmetic = [
        iaa.Add((-10, 10), name="Add"),
        iaa.AddElementwise((-10, 10), name="AddElementwise"),
        #iaa.AddElementwise((-500, 500), name="AddElementwise"),
        iaa.AdditiveGaussianNoise(scale=(5, 10), name="AdditiveGaussianNoise"),
        iaa.AdditiveLaplaceNoise(scale=(5, 10), name="AdditiveLaplaceNoise"),
        iaa.AdditivePoissonNoise(lam=(1, 5), name="AdditivePoissonNoise"),
        iaa.Multiply((0.5, 1.5), name="Multiply"),
        iaa.MultiplyElementwise((0.5, 1.5), name="MultiplyElementwise"),
        iaa.Cutout(nb_iterations=1, name="Cutout-fill_constant"),
        iaa.Dropout((0.01, 0.05), name="Dropout"),
        iaa.CoarseDropout((0.01, 0.05), size_percent=(0.01, 0.1), name="CoarseDropout"),
        iaa.Dropout2d(0.1, name="Dropout2d"),
        iaa.TotalDropout(0.1, name="TotalDropout"),
        iaa.ReplaceElementwise((0.01, 0.05), (0, 255), name="ReplaceElementwise"),
        #iaa.ReplaceElementwise((0.95, 0.99), (0, 255), name="ReplaceElementwise"),
        iaa.SaltAndPepper((0.01, 0.05), name="SaltAndPepper"),
        iaa.ImpulseNoise((0.01, 0.05), name="ImpulseNoise"),
        iaa.CoarseSaltAndPepper((0.01, 0.05), size_percent=(0.01, 0.1), name="CoarseSaltAndPepper"),
        iaa.Salt((0.01, 0.05), name="Salt"),
        iaa.CoarseSalt((0.01, 0.05), size_percent=(0.01, 0.1), name="CoarseSalt"),
        iaa.Pepper((0.01, 0.05), name="Pepper"),
        iaa.CoarsePepper((0.01, 0.05), size_percent=(0.01, 0.1), name="CoarsePepper"),
        iaa.Invert(0.1, name="Invert"),
        # ContrastNormalization
        iaa.JpegCompression((50, 99), name="JpegCompression")
    ]
    augmenters_artistic = [
        iaa.Cartoon(name="Cartoon")
    ]
    augmenters_blend = [
        iaa.BlendAlpha((0.01, 0.99), iaa.Identity(), name="Alpha"),
        iaa.BlendAlphaElementwise((0.01, 0.99), iaa.Identity(), name="AlphaElementwise"),
        iaa.BlendAlphaSimplexNoise(iaa.Identity(), name="SimplexNoiseAlpha"),
        iaa.BlendAlphaFrequencyNoise((-2.0, 2.0), iaa.Identity(), name="FrequencyNoiseAlpha"),
        iaa.BlendAlphaSomeColors(iaa.Identity(), name="BlendAlphaSomeColors"),
        iaa.BlendAlphaHorizontalLinearGradient(iaa.Identity(), name="BlendAlphaHorizontalLinearGradient"),
        iaa.BlendAlphaVerticalLinearGradient(iaa.Identity(), name="BlendAlphaVerticalLinearGradient"),
        iaa.BlendAlphaRegularGrid(nb_rows=(2, 8), nb_cols=(2, 8), foreground=iaa.Identity(), name="BlendAlphaRegularGrid"),
        iaa.BlendAlphaCheckerboard(nb_rows=(2, 8), nb_cols=(2, 8), foreground=iaa.Identity(), name="BlendAlphaCheckerboard"),
        # TODO BlendAlphaSegMapClassId
        # TODO BlendAlphaBoundingBoxes
    ]
    augmenters_blur = [
        iaa.GaussianBlur(sigma=(1.0, 5.0), name="GaussianBlur"),
        iaa.AverageBlur(k=(3, 11), name="AverageBlur"),
        iaa.MedianBlur(k=(3, 11), name="MedianBlur"),
        iaa.BilateralBlur(d=(3, 11), name="BilateralBlur"),
        iaa.MotionBlur(k=(3, 11), name="MotionBlur"),
        iaa.MeanShiftBlur(spatial_radius=(5.0, 40.0), color_radius=(5.0, 40.0),
                          name="MeanShiftBlur")
    ]
    augmenters_collections = [
        iaa.RandAugment(n=2, m=(6, 12), name="RandAugment")
    ]
    augmenters_color = [
        # InColorspace (deprecated)
        iaa.WithColorspace(to_colorspace="HSV", children=iaa.Noop(), name="WithColorspace"),
        iaa.WithBrightnessChannels(iaa.Identity(), name="WithBrightnessChannels"),
        iaa.MultiplyAndAddToBrightness(mul=(0.7, 1.3), add=(-30, 30), name="MultiplyAndAddToBrightness"),
        iaa.MultiplyBrightness((0.7, 1.3), name="MultiplyBrightness"),
        iaa.AddToBrightness((-30, 30), name="AddToBrightness"),
        iaa.WithHueAndSaturation(children=iaa.Noop(), name="WithHueAndSaturation"),
        iaa.MultiplyHueAndSaturation((0.8, 1.2), name="MultiplyHueAndSaturation"),
        iaa.MultiplyHue((-1.0, 1.0), name="MultiplyHue"),
        iaa.MultiplySaturation((0.8, 1.2), name="MultiplySaturation"),
        iaa.RemoveSaturation((0.01, 0.99), name="RemoveSaturation"),
        iaa.AddToHueAndSaturation((-10, 10), name="AddToHueAndSaturation"),
        iaa.AddToHue((-10, 10), name="AddToHue"),
        iaa.AddToSaturation((-10, 10), name="AddToSaturation"),
        iaa.ChangeColorspace(to_colorspace="HSV", name="ChangeColorspace"),
        iaa.Grayscale((0.01, 0.99), name="Grayscale"),
        iaa.KMeansColorQuantization((2, 16), name="KMeansColorQuantization"),
        iaa.UniformColorQuantization((2, 16), name="UniformColorQuantization"),
        iaa.UniformColorQuantizationToNBits((1, 7), name="UniformQuantizationToNBits"),
        iaa.Posterize((1, 7), name="Posterize")
    ]
    augmenters_contrast = [
        iaa.GammaContrast(gamma=(0.5, 2.0), name="GammaContrast"),
        iaa.SigmoidContrast(gain=(5, 20), cutoff=(0.25, 0.75), name="SigmoidContrast"),
        iaa.LogContrast(gain=(0.7, 1.0), name="LogContrast"),
        iaa.LinearContrast((0.5, 1.5), name="LinearContrast"),
        iaa.AllChannelsCLAHE(clip_limit=(2, 10), tile_grid_size_px=(3, 11), name="AllChannelsCLAHE"),
        iaa.CLAHE(clip_limit=(2, 10), tile_grid_size_px=(3, 11), to_colorspace="HSV", name="CLAHE"),
        iaa.AllChannelsHistogramEqualization(name="AllChannelsHistogramEqualization"),
        iaa.HistogramEqualization(to_colorspace="HSV", name="HistogramEqualization"),
    ]
    augmenters_convolutional = [
        iaa.Convolve(np.float32([[0, 0, 0], [0, 1, 0], [0, 0, 0]]), name="Convolve_3x3"),
        iaa.Sharpen(alpha=(0.01, 0.99), lightness=(0.5, 2), name="Sharpen"),
        iaa.Emboss(alpha=(0.01, 0.99), strength=(0, 2), name="Emboss"),
        iaa.EdgeDetect(alpha=(0.01, 0.99), name="EdgeDetect"),
        iaa.DirectedEdgeDetect(alpha=(0.01, 0.99), name="DirectedEdgeDetect")
    ]
    augmenters_edges = [
        iaa.Canny(alpha=(0.01, 0.99), name="Canny")
    ]
    augmenters_flip = [
        iaa.Fliplr(1.0, name="Fliplr"),
        iaa.Flipud(1.0, name="Flipud")
    ]
    augmenters_geometric = [
        iaa.Affine(scale=(0.9, 1.1), translate_percent={"x": (-0.05, 0.05), "y": (-0.05, 0.05)}, rotate=(-10, 10),
                   shear=(-10, 10), order=0, mode="constant", cval=(0, 255), name="Affine_order_0_constant"),
        iaa.Affine(scale=(0.9, 1.1), translate_percent={"x": (-0.05, 0.05), "y": (-0.05, 0.05)}, rotate=(-10, 10),
                   shear=(-10, 10), order=1, mode="constant", cval=(0, 255), name="Affine_order_1_constant"),
        iaa.Affine(scale=(0.9, 1.1), translate_percent={"x": (-0.05, 0.05), "y": (-0.05, 0.05)}, rotate=(-10, 10),
                   shear=(-10, 10), order=3, mode="constant", cval=(0, 255), name="Affine_order_3_constant"),
        iaa.Affine(scale=(0.9, 1.1), translate_percent={"x": (-0.05, 0.05), "y": (-0.05, 0.05)}, rotate=(-10, 10),
                   shear=(-10, 10), order=1, mode="edge", cval=(0, 255), name="Affine_order_1_edge"),
        iaa.Affine(scale=(0.9, 1.1), translate_percent={"x": (-0.05, 0.05), "y": (-0.05, 0.05)}, rotate=(-10, 10),
                   shear=(-10, 10), order=1, mode="constant", cval=(0, 255), backend="skimage",
                   name="Affine_order_1_constant_skimage"),
        iaa.PiecewiseAffine(scale=(0.01, 0.05), nb_rows=4, nb_cols=4, order=1, mode="constant",
                            name="PiecewiseAffine_4x4_order_1_constant"),
        iaa.PiecewiseAffine(scale=(0.01, 0.05), nb_rows=4, nb_cols=4, order=0, mode="constant",
                            name="PiecewiseAffine_4x4_order_0_constant"),
        iaa.PiecewiseAffine(scale=(0.01, 0.05), nb_rows=4, nb_cols=4, order=1, mode="edge",
                            name="PiecewiseAffine_4x4_order_1_edge"),
        iaa.PiecewiseAffine(scale=(0.01, 0.05), nb_rows=8, nb_cols=8, order=1, mode="constant",
                            name="PiecewiseAffine_8x8_order_1_constant"),
        iaa.PerspectiveTransform(scale=(0.01, 0.05), keep_size=False, name="PerspectiveTransform"),
        iaa.PerspectiveTransform(scale=(0.01, 0.05), keep_size=True, name="PerspectiveTransform_keep_size"),
        iaa.ElasticTransformation(alpha=(1, 10), sigma=(0.5, 1.5), order=0, mode="constant", cval=0,
                                  name="ElasticTransformation_order_0_constant"),
        iaa.ElasticTransformation(alpha=(1, 10), sigma=(0.5, 1.5), order=1, mode="constant", cval=0,
                                  name="ElasticTransformation_order_1_constant"),
        iaa.ElasticTransformation(alpha=(1, 10), sigma=(0.5, 1.5), order=1, mode="nearest", cval=0,
                                  name="ElasticTransformation_order_1_nearest"),
        iaa.ElasticTransformation(alpha=(1, 10), sigma=(0.5, 1.5), order=1, mode="reflect", cval=0,
                                  name="ElasticTransformation_order_1_reflect"),
        iaa.Rot90((1, 3), keep_size=False, name="Rot90"),
        iaa.Rot90((1, 3), keep_size=True, name="Rot90_keep_size"),
        iaa.WithPolarWarping(iaa.Identity(), name="WithPolarWarping"),
        iaa.Jigsaw(nb_rows=(3, 8), nb_cols=(3, 8), max_steps=1, name="Jigsaw")
    ]
    augmenters_pooling = [
        iaa.AveragePooling(kernel_size=(1, 16), keep_size=False, name="AveragePooling"),
        iaa.AveragePooling(kernel_size=(1, 16), keep_size=True, name="AveragePooling_keep_size"),
        iaa.MaxPooling(kernel_size=(1, 16), keep_size=False, name="MaxPooling"),
        iaa.MaxPooling(kernel_size=(1, 16), keep_size=True, name="MaxPooling_keep_size"),
        iaa.MinPooling(kernel_size=(1, 16), keep_size=False, name="MinPooling"),
        iaa.MinPooling(kernel_size=(1, 16), keep_size=True, name="MinPooling_keep_size"),
        iaa.MedianPooling(kernel_size=(1, 16), keep_size=False, name="MedianPooling"),
        iaa.MedianPooling(kernel_size=(1, 16), keep_size=True, name="MedianPooling_keep_size")
    ]
    augmenters_imgcorruptlike = [
        iaa.imgcorruptlike.GaussianNoise(severity=(1, 5), name="imgcorruptlike.GaussianNoise"),
        iaa.imgcorruptlike.ShotNoise(severity=(1, 5), name="imgcorruptlike.ShotNoise"),
        iaa.imgcorruptlike.ImpulseNoise(severity=(1, 5), name="imgcorruptlike.ImpulseNoise"),
        iaa.imgcorruptlike.SpeckleNoise(severity=(1, 5), name="imgcorruptlike.SpeckleNoise"),
        iaa.imgcorruptlike.GaussianBlur(severity=(1, 5), name="imgcorruptlike.GaussianBlur"),
        iaa.imgcorruptlike.GlassBlur(severity=(1, 5), name="imgcorruptlike.GlassBlur"),
        iaa.imgcorruptlike.DefocusBlur(severity=(1, 5), name="imgcorruptlike.DefocusBlur"),
        iaa.imgcorruptlike.MotionBlur(severity=(1, 5), name="imgcorruptlike.MotionBlur"),
        iaa.imgcorruptlike.ZoomBlur(severity=(1, 5), name="imgcorruptlike.ZoomBlur"),
        iaa.imgcorruptlike.Fog(severity=(1, 5), name="imgcorruptlike.Fog"),
        iaa.imgcorruptlike.Frost(severity=(1, 5), name="imgcorruptlike.Frost"),
        iaa.imgcorruptlike.Snow(severity=(1, 5), name="imgcorruptlike.Snow"),
        iaa.imgcorruptlike.Spatter(severity=(1, 5), name="imgcorruptlike.Spatter"),
        iaa.imgcorruptlike.Contrast(severity=(1, 5), name="imgcorruptlike.Contrast"),
        iaa.imgcorruptlike.Brightness(severity=(1, 5), name="imgcorruptlike.Brightness"),
        iaa.imgcorruptlike.Saturate(severity=(1, 5), name="imgcorruptlike.Saturate"),
        iaa.imgcorruptlike.JpegCompression(severity=(1, 5), name="imgcorruptlike.JpegCompression"),
        iaa.imgcorruptlike.Pixelate(severity=(1, 5), name="imgcorruptlike.Pixelate"),
        iaa.imgcorruptlike.ElasticTransform(severity=(1, 5), name="imgcorruptlike.ElasticTransform")
    ]
    augmenters_pillike = [
        iaa.pillike.Solarize(p=1.0, threshold=(32, 128), name="pillike.Solarize"),
        iaa.pillike.Posterize((1, 7), name="pillike.Posterize"),
        iaa.pillike.Equalize(name="pillike.Equalize"),
        iaa.pillike.Autocontrast(name="pillike.Autocontrast"),
        iaa.pillike.EnhanceColor((0.0, 3.0), name="pillike.EnhanceColor"),
        iaa.pillike.EnhanceContrast((0.0, 3.0), name="pillike.EnhanceContrast"),
        iaa.pillike.EnhanceBrightness((0.0, 3.0), name="pillike.EnhanceBrightness"),
        iaa.pillike.EnhanceSharpness((0.0, 3.0), name="pillike.EnhanceSharpness"),
        iaa.pillike.FilterBlur(name="pillike.FilterBlur"),
        iaa.pillike.FilterSmooth(name="pillike.FilterSmooth"),
        iaa.pillike.FilterSmoothMore(name="pillike.FilterSmoothMore"),
        iaa.pillike.FilterEdgeEnhance(name="pillike.FilterEdgeEnhance"),
        iaa.pillike.FilterEdgeEnhanceMore(name="pillike.FilterEdgeEnhanceMore"),
        iaa.pillike.FilterFindEdges(name="pillike.FilterFindEdges"),
        iaa.pillike.FilterContour(name="pillike.FilterContour"),
        iaa.pillike.FilterEmboss(name="pillike.FilterEmboss"),
        iaa.pillike.FilterSharpen(name="pillike.FilterSharpen"),
        iaa.pillike.FilterDetail(name="pillike.FilterDetail"),
        iaa.pillike.Affine(scale=(0.9, 1.1),
                           translate_percent={"x": (-0.05, 0.05), "y": (-0.05, 0.05)},
                           rotate=(-10, 10),
                           shear=(-10, 10),
                           fillcolor=(0, 255),
                           name="pillike.Affine"),
    ]
    augmenters_segmentation = [
        iaa.Superpixels(p_replace=(0.05, 1.0), n_segments=(10, 100), max_size=64, interpolation="cubic",
                        name="Superpixels_max_size_64_cubic"),
        iaa.Superpixels(p_replace=(0.05, 1.0), n_segments=(10, 100), max_size=64, interpolation="linear",
                        name="Superpixels_max_size_64_linear"),
        iaa.Superpixels(p_replace=(0.05, 1.0), n_segments=(10, 100), max_size=128, interpolation="linear",
                        name="Superpixels_max_size_128_linear"),
        iaa.Superpixels(p_replace=(0.05, 1.0), n_segments=(10, 100), max_size=224, interpolation="linear",
                        name="Superpixels_max_size_224_linear"),
        iaa.UniformVoronoi(n_points=(250, 1000), name="UniformVoronoi"),
        iaa.RegularGridVoronoi(n_rows=(16, 31), n_cols=(16, 31), name="RegularGridVoronoi"),
        iaa.RelativeRegularGridVoronoi(n_rows_frac=(0.07, 0.14), n_cols_frac=(0.07, 0.14), name="RelativeRegularGridVoronoi"),
    ]
    augmenters_size = [
        iaa.Resize((0.8, 1.2), interpolation="nearest", name="Resize_nearest"),
        iaa.Resize((0.8, 1.2), interpolation="linear", name="Resize_linear"),
        iaa.Resize((0.8, 1.2), interpolation="cubic", name="Resize_cubic"),
        iaa.CropAndPad(percent=(-0.2, 0.2), pad_mode="constant", pad_cval=(0, 255), keep_size=False,
                       name="CropAndPad"),
        iaa.CropAndPad(percent=(-0.2, 0.2), pad_mode="edge", pad_cval=(0, 255), keep_size=False,
                       name="CropAndPad_edge"),
        iaa.CropAndPad(percent=(-0.2, 0.2), pad_mode="constant", pad_cval=(0, 255), name="CropAndPad_keep_size"),
        iaa.Pad(percent=(0.05, 0.2), pad_mode="constant", pad_cval=(0, 255), keep_size=False, name="Pad"),
        iaa.Pad(percent=(0.05, 0.2), pad_mode="edge", pad_cval=(0, 255), keep_size=False, name="Pad_edge"),
        iaa.Pad(percent=(0.05, 0.2), pad_mode="constant", pad_cval=(0, 255), name="Pad_keep_size"),
        iaa.Crop(percent=(0.05, 0.2), keep_size=False, name="Crop"),
        iaa.Crop(percent=(0.05, 0.2), name="Crop_keep_size"),
        iaa.PadToFixedSize(width=width+10, height=height+10, pad_mode="constant", pad_cval=(0, 255),
                           name="PadToFixedSize"),
        iaa.CropToFixedSize(width=width-10, height=height-10, name="CropToFixedSize"),
        iaa.KeepSizeByResize(iaa.CropToFixedSize(height=height-10, width=width-10), interpolation="nearest",
                             name="KeepSizeByResize_CropToFixedSize_nearest"),
        iaa.KeepSizeByResize(iaa.CropToFixedSize(height=height-10, width=width-10), interpolation="linear",
                             name="KeepSizeByResize_CropToFixedSize_linear"),
        iaa.KeepSizeByResize(iaa.CropToFixedSize(height=height-10, width=width-10), interpolation="cubic",
                             name="KeepSizeByResize_CropToFixedSize_cubic"),
    ]
    augmenters_weather = [
        iaa.FastSnowyLandscape(lightness_threshold=(100, 255), lightness_multiplier=(1.0, 4.0),
                               name="FastSnowyLandscape"),
        iaa.Clouds(name="Clouds"),
        iaa.Fog(name="Fog"),
        iaa.CloudLayer(intensity_mean=(196, 255), intensity_freq_exponent=(-2.5, -2.0), intensity_coarse_scale=10,
                       alpha_min=0, alpha_multiplier=(0.25, 0.75), alpha_size_px_max=(2, 8),
                       alpha_freq_exponent=(-2.5, -2.0), sparsity=(0.8, 1.0), density_multiplier=(0.5, 1.0),
                       name="CloudLayer"),
        iaa.Snowflakes(name="Snowflakes"),
        iaa.SnowflakesLayer(density=(0.005, 0.075), density_uniformity=(0.3, 0.9),
                            flake_size=(0.2, 0.7), flake_size_uniformity=(0.4, 0.8),
                            angle=(-30, 30), speed=(0.007, 0.03),
                            blur_sigma_fraction=(0.0001, 0.001), name="SnowflakesLayer"),
        iaa.Rain(name="Rain"),
        iaa.RainLayer(density=(0.03, 0.14),
                      density_uniformity=(0.8, 1.0),
                      drop_size=(0.01, 0.02),
                      drop_size_uniformity=(0.2, 0.5),
                      angle=(-15, 15),
                      speed=(0.04, 0.20),
                      blur_sigma_fraction=(0.001, 0.001),
                      name="RainLayer")
    ]

    augmenters = (
        augmenters_meta
        + augmenters_arithmetic
        + augmenters_artistic
        + augmenters_blend
        + augmenters_blur
        + augmenters_collections
        + augmenters_color
        + augmenters_contrast
        + augmenters_convolutional
        + augmenters_edges
        + augmenters_flip
        + augmenters_geometric
        + augmenters_pooling
        + augmenters_imgcorruptlike
        + augmenters_pillike
        + augmenters_segmentation
        + augmenters_size
        + augmenters_weather
    )

    if only_augmenters is not None:
        augmenters_reduced = []
        for augmenter in augmenters:
            if any([re.search(pattern, augmenter.name) for pattern in only_augmenters]):
                augmenters_reduced.append(augmenter)
        augmenters = augmenters_reduced

    return augmenters