def RandomCrop(rand_seed,img, top,left,height=224, width=224,u=0.5,aug_factor=9/8):
#first zoom in by a factor of aug_factor of input img,then random crop by(height,width)
# if rand_seed < u:
if 1:
# h,w,c = img.shape
# img = cv2.resize(img, (round(aug_factor*w), round(aug_factor*h)), interpolation=cv2.INTER_LINEAR)
# h, w, c = img.shape
new_h, new_w = height,width
# top = np.random.randint(0, h - new_h)
# left = np.random.randint(0, w - new_w)
img = img[top: top + new_h,
left: left + new_w]
return img
评论列表
文章目录