feat: check for overlapping when pasting
Former-commit-id: 920a2df1e54e3dfc22cf62fe9c892bf945af9b63 [formerly f0c2daaa4d0094fafeddce9c07c6ce020c1704d6] Former-commit-id: 7e74f04ed0cd0d31612f23a44b9832b659bf5408
This commit is contained in:
parent
9b624da832
commit
e089bcc7c4
|
@ -107,9 +107,15 @@ class RandomPaste(A.DualTransform):
|
||||||
|
|
||||||
# generate some positions
|
# generate some positions
|
||||||
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])
|
x = rd.randint(0, target_shape[0] - paste_shape[0])
|
||||||
y = rd.randint(0, target_shape[1] - paste_shape[1])
|
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))
|
positions.append((x, y))
|
||||||
|
|
||||||
params.update(
|
params.update(
|
||||||
|
|
Loading…
Reference in a new issue