About transform,my input image is grayscale, why need swaping color axis?

/Users/radiology/anaconda/lib/python2.7/site-packages/torchvision-0.1.8-py2.7.egg/torchvision/transforms.py in call(self, pic)
39 if isinstance(pic, np.ndarray):
40 # handle numpy array
—> 41 img = torch.from_numpy(pic.transpose((2, 0, 1)))
42 # backard compability
43 return img.float().div(255)

Do i need to add one more axis for this?

1 Like