本人kaggle分享链接:https://www.kaggle.com/c/bengaliai-cv19/discussion/126504
效果图: (目标检测中)
代码如下:
代码语言:javascript复制def rand_bbox(size, lam):
W = size[2]
H = size[3]
cut_rat = np.sqrt(1. - lam)
cut_w = np.int(W * cut_rat)
cut_h = np.int(H * cut_rat)
# uniform
cx = np.random.randint(W)
cy = np.random.randint(H)
bbx1 = np.clip(cx - cut_w // 2, 0, W)
bby1 = np.clip(cy - cut_h // 2, 0, H)
bbx2 = np.clip(cx cut_w // 2, 0, W)
bby2 = np.clip(cy cut_h // 2, 0, H)
return bbx1, bby1, bbx2, bby2
def cutmix(data, targets1, targets2, targets3, alpha):