Last active
May 21, 2020 20:55
-
-
Save vitchyr/101d79b84f613cfb63e239223a3b10c3 to your computer and use it in GitHub Desktop.
Python 3 - Minimal example for displaying an image without matplotlib in Google Colab
This file contains hidden or 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
import PIL.Image | |
from io import BytesIO | |
from IPython.display import display, Image | |
import numpy as np | |
def show_img(a, fmt='png'): | |
# https://stackoverflow.com/questions/19471814/display-multiple-images-in-one-ipython-notebook-cell | |
a = np.uint8(a) | |
f = BytesIO() | |
PIL.Image.fromarray(a).save(f, fmt) | |
display(Image(data=f.getvalue())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment