Increasing size of images in torchvision.utils.make_grid

I have 32 images of size 3 x 128 x 128 in a single batch. I want to display them as a grid, so I used the torchvision.utils.make_grid function as in the code below. But the images in the grid are very small. Is there anyway to increase the size of the grid ?

def show(img):
    npimg = img.numpy()
    plt.imshow(np.transpose(npimg, (1,2,0)), interpolation='nearest')

image_data.shape # torch.Size([32, 3, 128, 128])
m = make_grid(image_datas, nrow=8, scale_each = True, normalize = True, padding = 4)
show(m)

You could increase the size of the shown image directly in plt.imshow or alternatively save the image and use your default viewer.

I assume the output is small as matplotlib tries to scale it down to fit your notebook/IDE

1 Like