def augmentation(image, imageB, org_width=160,org_height=224, width=190, height=262):
max_angle=20
image=resize(image,(width,height))
imageB=resize(imageB,(width,height))
angle=np.random.randint(max_angle)
if np.random.randint(2):
angle=-angle
image=rotate(image,angle,resize=True)
imageB=rotate(imageB,angle,resize=True)
xstart=np.random.randint(width-org_width)
ystart=np.random.randint(height-org_height)
image=image[xstart:xstart+org_width,ystart:ystart+org_height]
imageB=imageB[xstart:xstart+org_width,ystart:ystart+org_height]
if np.random.randint(2):
image=cv2.flip(image,1)
imageB=cv2.flip(imageB,1)
if np.random.randint(2):
imageB=cv2.flip(imageB,0)
# image=resize(image,(org_width,org_height))
return image,imageB
# print(image.shape)
# plt.imshow(image)
# plt.show()
# Helper to build a conv -> BN -> relu block
评论列表
文章目录