| | import warnings |
| | warnings.simplefilter(action='ignore', category=FutureWarning) |
| |
|
| | import numpy as np |
| | np.bool = np.bool_ |
| | import imgaug.augmenters as iaa |
| | from PIL import Image |
| |
|
| |
|
| | |
| | seq = iaa.Sequential( |
| | [ |
| | |
| | iaa.OneOf([ |
| | iaa.AdditiveGaussianNoise( |
| | loc=0, scale=(0.0, 0.05*255), per_channel=0.5 |
| | ), |
| | iaa.AdditiveLaplaceNoise(scale=(0.0, 0.05*255), per_channel=0.5), |
| | iaa.AdditivePoissonNoise(lam=(0.0, 0.05*255), per_channel=0.5) |
| | ]), |
| | |
| | |
| | iaa.SomeOf((0, 1), [ |
| | iaa.OneOf([ |
| | iaa.GaussianBlur((0, 3.0)), |
| | iaa.AverageBlur(k=(2, 7)), |
| | iaa.MedianBlur(k=(3, 11)), |
| | ]), |
| | iaa.MotionBlur(k=(3, 36)), |
| | ]), |
| | ], |
| | |
| | random_order=True |
| | ) |
| |
|
| |
|
| | def image_corrupt(image: Image): |
| | image_arr = np.array(image) |
| | image_arr = image_arr[None, ...] |
| | |
| | image_arr = seq(images=image_arr) |
| | |
| | image = Image.fromarray(image_arr[0]) |
| | return image |
| |
|