-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaugmentation.py
30 lines (28 loc) · 958 Bytes
/
augmentation.py
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
from imgaug import augmenters as iaa
def face_augment_pipe():
sometimes = lambda a: iaa.Sometimes(0.5, a)
aug_pipe = iaa.Sequential(
[
sometimes(iaa.Affine(
rotate=(-10, 10),
scale=(0.9, 1.1),
mode=['constant', 'edge']
)),
iaa.OneOf([
iaa.Noop(),
iaa.GaussianBlur((0, 3)),
iaa.MedianBlur(k=(1, 7)),
]),
iaa.SomeOf((0, None),
[
iaa.Add((-20, 20)), # change brightness of images.
iaa.SigmoidContrast(gain=(3, 10), cutoff=(0.4, 0.6)),
iaa.Sharpen(alpha=(0.0, 0.5), lightness=(0.0, 0.8)),
iaa.Noop()
],
random_order=True
)
],
random_order=True,
)
return aug_pipe