image_processing.py 文件源码

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

项目:text-to-image 作者: paarthneekhara 项目源码 文件源码
def load_image_array(image_file, image_size):
    img = skimage.io.imread(image_file)
    # GRAYSCALE
    if len(img.shape) == 2:
        img_new = np.ndarray( (img.shape[0], img.shape[1], 3), dtype = 'uint8')
        img_new[:,:,0] = img
        img_new[:,:,1] = img
        img_new[:,:,2] = img
        img = img_new

    img_resized = skimage.transform.resize(img, (image_size, image_size))

    # FLIP HORIZONTAL WIRH A PROBABILITY 0.5
    if random.random() > 0.5:
        img_resized = np.fliplr(img_resized)


    return img_resized.astype('float32')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号