Last active
November 27, 2019 22:05
-
-
Save vmarkovtsev/41c7e517ee492cd1cc34c191acf79055 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def save_image(tensor: Union[np.ndarray, tf.Tensor], path: str): | |
if hasattr(tensor, "numpy"): | |
tensor = tensor.numpy() | |
tensor = np.clip(tensor, 0, 255) # <<< this is new | |
Image.fromarray(np.squeeze(tensor).astype(np.uint8), "RGB").save(path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment