Skip to content

Instantly share code, notes, and snippets.

View uduse's full-sized avatar
🚀
Building at Astrus (astrus.ai)

Zeyi Wang uduse

🚀
Building at Astrus (astrus.ai)
View GitHub Profile
@uduse
uduse / show_array.py
Last active November 27, 2017 15:06 — forked from zori/showarray.py
Minimal code for rendering a numpy array as an image in a Jupyter notebook in memory. Forked and updated for Python 3.
import PIL.Image
from io import BytesIO
import IPython.display
import numpy as np
def show_array(a, fmt='png'):
f = BytesIO()
PIL.Image.fromarray(np.uint8(a)).save(f, fmt)
IPython.display.display(IPython.display.Image(data=f.getvalue()))