数据增强之mixup
数据增强之mixup,就是做一个图像融合,简单理解就是两张图像的叠加。具体细节见:https://blog.csdn.net/u013685264/article/details/122622919
具体效果如下:
原图:
mixup后:
代码实现:
import cv2
import numpy as np
# MixUP
img1 = cv2.imread('dog.png')
img1 = cv2.resize(img1, (1960, 1080))
img2 = cv2.imread('cat.png')
img2 = cv2.resize(img2, (1960, 1080))
alpha = 1.0
lam = np.random.beta(alpha, alpha)
print(lam)
mixed_img = lam * img1 + (1 - lam) * img2
cv2.imwrite('mixed_img.jpeg', mixed_img)