Skip to content

Instantly share code, notes, and snippets.

@usr-ein
Created June 3, 2021 14:27
Show Gist options
  • Save usr-ein/7df58ba2329cb0a8b769cb57385c43af to your computer and use it in GitHub Desktop.
Save usr-ein/7df58ba2329cb0a8b769cb57385c43af to your computer and use it in GitHub Desktop.
View numpy arrays images side by side in Jupyter
from PIL import Image
import io
from ipywidgets import widgets
import IPython.display as display
def view(*arrs):
ims = []
for arr in arrs:
output = io.BytesIO()
im = Image.fromarray(arr).resize((500,500), Image.NEAREST)
im.save(output, format="PNG")
ims += [widgets.Image(
value=output.getvalue(),
format='png',
width=500,
height=500,
)]
sidebyside = widgets.HBox(ims)
display.display(sidebyside)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment