Unverified 提交 abbfd695 authored 作者: Glenn Jocher's avatar Glenn Jocher 提交者: GitHub

Copy-Paste zero value fix (#10152)

* Copy-Paste zero value fix Signed-off-by: 's avatarGlenn Jocher <glenn.jocher@ultralytics.com> * Update augmentations.py Signed-off-by: 's avatarGlenn Jocher <glenn.jocher@ultralytics.com> Signed-off-by: 's avatarGlenn Jocher <glenn.jocher@ultralytics.com>
上级 f33718f3
...@@ -250,12 +250,10 @@ def copy_paste(im, labels, segments, p=0.5): ...@@ -250,12 +250,10 @@ def copy_paste(im, labels, segments, p=0.5):
if (ioa < 0.30).all(): # allow 30% obscuration of existing labels if (ioa < 0.30).all(): # allow 30% obscuration of existing labels
labels = np.concatenate((labels, [[l[0], *box]]), 0) labels = np.concatenate((labels, [[l[0], *box]]), 0)
segments.append(np.concatenate((w - s[:, 0:1], s[:, 1:2]), 1)) 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(im, 1) # augment segments (flip left-right)
result = cv2.flip(result, 1) # augment segments (flip left-right) i = cv2.flip(im_new, 1).astype(bool)
i = result > 0 # pixels to replace
# i[:, :] = result.max(2).reshape(h, w, 1) # act over ch
im[i] = result[i] # cv2.imwrite('debug.jpg', im) # debug im[i] = result[i] # cv2.imwrite('debug.jpg', im) # debug
return im, labels, segments return im, labels, segments
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论