def load_augment(fname, w, h, aug_params=no_augmentation_params,
transform=None, sigma=0.0, color_vec=None):
"""Load augmented image with output shape (w, h).
Default arguments return non augmented image of shape (w, h).
To apply a fixed transform (color augmentation) specify transform
(color_vec).
To generate a random augmentation specify aug_params and sigma.
"""
img = load_image(fname)
img = perturb(img, augmentation_params=aug_params, target_shape=(w, h))
#if transform is None:
# img = perturb(img, augmentation_params=aug_params, target_shape=(w, h))
#else:
# img = perturb_fixed(img, tform_augment=transform, target_shape=(w, h))
#randString = str(np.random.normal(0,1,1))
#im = Image.fromarray(img.transpose(1,2,0).astype('uint8'))
#figName = fname.split("/")[-1]
#im.save("imgs/"+figName+randString+".jpg")
np.subtract(img, MEAN[:, np.newaxis, np.newaxis], out=img)
#np.divide(img, STD[:, np.newaxis, np.newaxis], out=img)
#img = augment_color(img, sigma=sigma, color_vec=color_vec)
return img
评论列表
文章目录