-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Open
Description
Segmentation labels (annotation) are usually provided as a matrix of labels (integers).
For this task the same augmentation as the images should be performed, except interpolation should be 'nearest neighbours' rather than bilinear or similar one.
Some form of retrieving the sampled parameters (for example: rotation angle was 32 degrees) would be usefull so we could re-create the same augmentation, but with different interpolation.
Deterministic augmentation doesn't help in this case.
In the meantime, as a workaround we can use:
from imgaug import augmenters as iaa
rotate_max=30
seq = iaa.Sequential([
iaa.Fliplr(0.5), # horizontally flip 50% of the images
],random_state=0)
rotate=iaa.Affine(rotate=(0, rotate_max),mode='edge')
rotate_nn_interpolation=iaa.Affine(rotate=(0, rotate_max),order=[0],mode='edge')
seq_nn_interpolation=seq.deepcopy()
seq.append(rotate)
seq_nn_interpolation.append(rotate_nn_interpolation)
aug_seed=0
for batch in...:
batch_images = images[batch, :, :, :]
batch_labels = labels[batch, :,:]
seq.reseed(aug_seed)
seq_nn_interpolation.reseed(aug_seed)
batch_images=seq.augment_images(batch_images)
batch_labels=seq_nn_interpolation.augment_images(batch_labels)
aug_seed+=1
zacwellmer, gasvn, eugenelawrence, sashulyak, ostrobrod and 2 more
Metadata
Metadata
Assignees
Labels
No labels