data.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:melanoma-transfer 作者: learningtitans 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号