def deprocess_img_and_save(img, filename):
"""Undo pre-processing on an image, and save it."""
img = img[0, :, :, :]
add_imagenet_mean(img)
img = img[::-1].transpose((1, 2, 0))
img = np.clip(img, 0, 255).astype(np.uint8)
img = median_filter(img, size=(3, 3, 1))
try:
imsave(filename, img)
except OSError as e:
print(e)
sys.exit(1)
评论列表
文章目录