From a206f91d6202ca1225df644327c60f15fe0daf6e Mon Sep 17 00:00:00 2001 From: Emmanuel Benazera Date: Sat, 24 Jul 2021 18:15:19 +0000 Subject: [PATCH] fix: avoid lambda in RandomImgAug that prevents DDP --- data/base_dataset.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index 1fcd5965e..85ed38a88 100644 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -484,17 +484,18 @@ def __call__(self, img, mask): else: return img, mask - +def sometimes(aug): + return iaa.Sometimes(0.5, aug) + class RandomImgAug(): def __init__(self,with_mask=True): self.with_mask = with_mask - self.sometimes = lambda aug: iaa.Sometimes(0.5, aug) self.seq = iaa.Sequential( [ iaa.SomeOf((0, 5), [ - self.sometimes(iaa.Superpixels(p_replace=(0, 0.5), n_segments=(100, 200))), # convert images into their superpixel representation + sometimes(iaa.Superpixels(p_replace=(0, 0.5), n_segments=(100, 200))), # convert images into their superpixel representation iaa.OneOf([ iaa.GaussianBlur((0, 3.0)), # blur images with a sigma between 0 and 3.0 iaa.AverageBlur(k=(2, 7)), # blur image using local means with kernel sizes between 2 and 7