import imgaug as ia
import numpy as np
from imgaug import augmenters as iaa


# take numpy image and augment
def augment_image(image, times=10):
    st = lambda aug: iaa.Sometimes(0.5, aug)

    seq = iaa.Sequential([
            iaa.Fliplr(0.5),
            st(iaa.Crop(percent=(0, 0.1))),
            st(iaa.GaussianBlur((0, 3.0))),
            st(iaa.AdditiveGaussianNoise(loc=0, scale=(0.0, 0.05*255), per_channel=0.5)),
            st(iaa.Add((-10, 10), per_channel=0.5)),
            st(iaa.Multiply((0.5, 1.5), per_channel=0.5)),
            st(iaa.ContrastNormalization((0.5, 2.0), per_channel=0.5)),
            st(iaa.Affine(
                scale={"x": (0.8, 1.2), "y": (0.8, 1.2)},
                translate_px={"x": (-16, 16), "y": (-16, 16)},
                rotate=(-45, 45),
                shear=(-16, 16),
                order=[0, 1],
                cval=(0, 1.0),
                mode=ia.ALL
            )),
            st(iaa.ElasticTransformation(alpha=(0.5, 3.5), sigma=0.25))
        ],
        random_order=True
    )

    augmented = []
    for i in range(times):
        augmented.append(image)

    aug_list = seq.augment_images(augmented)
    return aug_list

@@ -396,12 +396,8 @@
 0.05
-*255
 ), p
@@ -502,14 +502,14 @@
 ((0.
-5
+9
 , 1.
-5
+1
 ), p
@@ -922,80 +922,8 @@
 )),%0A
-            st(iaa.ElasticTransformation(alpha=(0.5, 3.5), sigma=0.25))%0A
     

tweak image augmentation parameters