diff --git a/src/utils/paste.py b/src/utils/paste.py index 5ad8961..6dbaa6b 100644 --- a/src/utils/paste.py +++ b/src/utils/paste.py @@ -107,9 +107,15 @@ class RandomPaste(A.DualTransform): # generate some positions positions = [] - for _ in range(rd.randint(1, self.nb)): + while len(positions) <= rd.randint(1, self.nb): x = rd.randint(0, target_shape[0] - paste_shape[0]) y = rd.randint(0, target_shape[1] - paste_shape[1]) + + # check for overlapping + for xo, yo in positions: + if (x <= xo + paste_shape[0]) and (y <= yo + paste_shape[1]): + continue + positions.append((x, y)) params.update(