images.py 文件源码

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

项目:ntm-one-shot 作者: tristandeleu 项目源码 文件源码
def load_transform(image_path, angle=0., s=(0, 0), size=(20, 20)):
    # Load the image
    original = imread(image_path, flatten=True)
    # Rotate the image
    rotated = np.maximum(np.minimum(rotate(original, angle=angle, cval=1.), 1.), 0.)
    # Shift the image
    shifted = shift(rotated, shift=s)
    # Resize the image
    resized = np.asarray(scipy.misc.imresize(rotated, size=size), dtype=theano.config.floatX) / 255.
    # Invert the image
    inverted = 1. - resized
    max_value = np.max(inverted)
    if max_value > 0.:
        inverted /= max_value
    return inverted
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号