Skip to content

param nrow in make_grid is misleading #249

@alykhantejani

Description

@alykhantejani
import torch
import torchvision
label_img = torch.rand(100, 3, 32, 32)
x = torchvision.utils.make_grid(label_img, nrow=20, padding=10)
torchvision.transforms.ToPILImage()(x).save("example.png")

produces this image:
example

which has 5 rows and 20 columns. Although the docs say

nrow (int, optional) – Number of rows in grid. Final grid size is (B / nrow, nrow). Default is 8.

Which says the output will actually be (B/nrow, nrow). Perhaps this param should be called ncol, or we should change the output shape to be (nrow, B/nrow)?

I think, to keep backward compatibility changing the output shape to (nrow, B/nrow) would make more sense.

Happy to send a PR if you agree?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions