Functions and utilites to display Images
import torch
from fastcore.test import *
from PIL import Image

subplots[source]

subplots(nrows=1, ncols=1, figsize=None, imsize=3, suptitle=None, sharex=False, sharey=False, squeeze=True, subplot_kw=None, gridspec_kw=None, **kwargs)

Create subplots

_, axs = subplots()
test_eq(axs.shape, [1])
plt.close()
_, axs = subplots(2, 3)
test_eq(axs.shape, [2, 3])
plt.close()

show_image[source]

show_image(im, ax=None, figsize=None, title=None, ctx=None, cmap=None, norm=None, aspect=None, interpolation=None, alpha=None, vmin=None, vmax=None, origin=None, extent=None, filternorm=True, filterrad=4.0, resample=None, url=None, data=None, **kwargs)

Show a PIL or PyTorch image on ax.

show_image can show PIL images...

im = Image.open("images/puppy.jpg")
ax = show_image(im, cmap="Greys", figsize=(2, 2))

...and color images with standard CHW dim order...

im2 = np.array(Image.open("images/puppy.jpg"))
ax = show_image(im2, figsize=(2, 2))

... also color images with HWC dim order...

im3 = torch.as_tensor(im2).permute(2, 0, 1)
ax = show_image(im3, figsize=(2, 2))

show_titled_image[source]

show_titled_image(o, ax=None, figsize=None, title=None, ctx=None, cmap=None, norm=None, aspect=None, interpolation=None, alpha=None, vmin=None, vmax=None, origin=None, extent=None, filternorm=True, filterrad=4.0, resample=None, url=None, data=None, **kwargs)

Call show_image destructuring o to (img,title)

show_titled_image((im3, "A puppy"), figsize=(2, 2))

Show all images ims as subplots with rows using titles. suptitle provides a way to create a figure title for all images. If you use suptitle, constrained_layout is used unless you set constrained_layout to False.

show_images[source]

show_images(ims, nrows=1, ncols=None, titles=None, figsize=None, imsize=3, suptitle=None, sharex=False, sharey=False, squeeze=True, subplot_kw=None, gridspec_kw=None)

Show all images ims as subplots with rows using titles.

show_images((im2, im3), titles=("puppy", "puppy"), suptitle="Image", imsize=3)

imshow_tensors uses torchvision.utils.make_grid to create a grid of Images from tensors and displays them.

imshow_tensors[source]

imshow_tensors(inp, title=None, nrow:int=8, padding:int=2, normalize:bool=False, value_range:Optional[Tuple[int, int]]=None, scale_each:bool=False, pad_value:int=0)

Imshow for Tensor and optionally add a title.

batch = torch.from_numpy(np.hstack([im2, im2])).permute(2, 0, 1)
imshow_tensors(batch, normalize=False, nrow=1)

show_title[source]

show_title(o, ax=None, ctx=None, label=None, color='black', **kwargs)

Set title of ax to o, or print o if ax is None