Skip to content

Commit 08c4177

Browse files
gpleisssoumith
authored andcommitted
make_grid doesn't exclude last images in python2 (#95)
In python2, calling `make_grid` won't display the last images if the number of images doesn't divide `nrow`. Int division... This should fix that!
1 parent 6fc69a4 commit 08c4177

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

torchvision/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def make_grid(tensor, nrow=8, padding=2):
2727
# make the mini-batch of images into a grid
2828
nmaps = tensor.size(0)
2929
xmaps = min(nrow, nmaps)
30-
ymaps = int(math.ceil(nmaps / xmaps))
30+
ymaps = int(math.ceil(float(nmaps) / xmaps))
3131
height, width = int(tensor.size(2) + padding), int(tensor.size(3) + padding)
3232
grid = tensor.new(3, height * ymaps, width * xmaps).fill_(tensor.max())
3333
k = 0

0 commit comments

Comments
 (0)