Skip to content

Instantly share code, notes, and snippets.

@vitchyr
Last active May 21, 2020 20:55
Show Gist options
  • Save vitchyr/101d79b84f613cfb63e239223a3b10c3 to your computer and use it in GitHub Desktop.
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
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