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')
评论列表
文章目录