Skip to content

Commit b733ad1

Browse files
authored
Merge pull request #17 from adamlerer/save_image
fix bugs in save_image
2 parents 8560d58 + 19a27a2 commit b733ad1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

torchvision/utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ def make_grid(tensor, nrow=8, padding=2):
1616
for i in range(numImages):
1717
tensor[i].copy_(tensorlist[i])
1818
if tensor.dim() == 2: # single image H x W
19-
tensor = torch.view(1, tensor.size(0), tensor.size(1))
20-
tensor = torch.cat((tensor, tensor, tensor), 0)
19+
tensor = tensor.view(1, tensor.size(0), tensor.size(1))
2120
if tensor.dim() == 3: # single image
21+
if tensor.size(0) == 1:
22+
tensor = torch.cat((tensor, tensor, tensor), 0)
2223
return tensor
2324
if tensor.dim() == 4 and tensor.size(1) == 1: # single-channel images
2425
tensor = torch.cat((tensor, tensor, tensor), 1)

0 commit comments

Comments
 (0)