From abbfd695232b1bfcbd8e122e2aeb37fcc3d146d5 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Mon, 14 Nov 2022 18:54:49 +0100 Subject: [PATCH] Copy-Paste zero value fix (#10152) * Copy-Paste zero value fix Signed-off-by: Glenn Jocher * Update augmentations.py Signed-off-by: Glenn Jocher Signed-off-by: Glenn Jocher --- utils/augmentations.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/utils/augmentations.py b/utils/augmentations.py index 7c8e0bc..1eae5db 100644 --- a/utils/augmentations.py +++ b/utils/augmentations.py @@ -250,12 +250,10 @@ def copy_paste(im, labels, segments, p=0.5): if (ioa < 0.30).all(): # allow 30% obscuration of existing labels labels = np.concatenate((labels, [[l[0], *box]]), 0) segments.append(np.concatenate((w - s[:, 0:1], s[:, 1:2]), 1)) - cv2.drawContours(im_new, [segments[j].astype(np.int32)], -1, (255, 255, 255), cv2.FILLED) + cv2.drawContours(im_new, [segments[j].astype(np.int32)], -1, (1, 1, 1), cv2.FILLED) - result = cv2.bitwise_and(src1=im, src2=im_new) - result = cv2.flip(result, 1) # augment segments (flip left-right) - i = result > 0 # pixels to replace - # i[:, :] = result.max(2).reshape(h, w, 1) # act over ch + result = cv2.flip(im, 1) # augment segments (flip left-right) + i = cv2.flip(im_new, 1).astype(bool) im[i] = result[i] # cv2.imwrite('debug.jpg', im) # debug return im, labels, segments