“torchvision.transforms.ToTensor()‘ didn't scale to 0~1

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?

Looking at the ToTensor implementation, we can see that it converts to the float dtype after scaling. So if a float type tensor appears here or elsewhere in the pipeline, it is usually expected to have already been scaled. You can change the method used to load the images or just add the scaling yourself (there’s no strong reason it has to be in ToTensor)