Spaces:
Runtime error
Runtime error
File size: 1,220 Bytes
68896f3 |
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 31 32 33 34 |
import imgaug as ia
from imgaug import augmenters as iaa
def get():
def sometimes(aug): return iaa.Sometimes(0.5, aug)
return iaa.Sequential(
[
iaa.PadToSquare(position='center'),
# iaa.Fliplr(0.5), # horizontal flips
# sometimes(iaa.Multiply((0.8, 1.2), per_channel=0.2),),
# sometimes(iaa.Add((-10, 10), per_channel=0.5)), # change brightness of images (by -10 to 10 of original value)
# sometimes(iaa.AddToHueAndSaturation((-20, 20))), # change hue and saturation
sometimes(iaa.AddToBrightness((-30, 30))),
sometimes(iaa.LinearContrast((0.75, 1.5))), # Strengthen or weaken the contrast in each image.
sometimes(iaa.CropAndPad(
percent=(-0.05, 0.1),
pad_mode=ia.ALL,
pad_cval=(0, 255)
)),
sometimes(iaa.Affine(
scale={"x": (0.8, 1.2), "y": (0.8, 1.2)},
translate_percent={"x": (-0.2, 0.2), "y": (-0.2, 0.2)},
rotate=(-15, 15)
)),
iaa.Resize({"height": 1024, "width": 1024})
],
random_order=False
)
|