i use this function to preprocess the image of numpy.ndarray type.But it seemed not to divide to 255.
The source code is as follows:
if isinstance(pic, np.ndarray):
# handle numpy array
if pic.ndim == 2:
pic = pic[:, :, None]
img = torch.from_numpy(pic.transpose((2, 0, 1)))
# backward compatibility
if isinstance(img, torch.ByteTensor):
return img.float().div(255)
else:
return img
It looked like it is not the ‘torch.ByteTensor’ type, so didn’t be divided to 255.
What is the reason?