utils.py 文件源码

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

项目:FeatureMapInversion 作者: xzqjack 项目源码 文件源码
def PostprocessImage(img):
    """
    Postprocess target style image    
    1. add the images dataset mean to optimized image
    2. swap axis (b,g,r) to (r,g,b) and save it

    Parameters
    --------
    img: ndarray (1x3xMxN), optimized image

    Returns
    out : ndarray (3xMxN), Postprocessed image   
    """

    img = np.resize(img, (3, img.shape[2], img.shape[3]))
    img[0, :] += 123.68
    img[1, :] += 116.779
    img[2, :] += 103.939
    img = np.swapaxes(img, 0, 2)
    img = np.swapaxes(img, 0, 1)
    img = np.clip(img, 0, 255)
    return img.astype('uint8')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号