While converting a PIL image into a tensor why the pixels are changing?
transform = transforms.Compose([transforms.ToPILImage(), transforms.ToTensor()])

Before applying the transformation



After applying the transformation



Q.1 Why the pixel values are changed?
Q.2 How to correct this?

I was able to solve this problem by normalizing the input data before transforming it.
The problem was that ToPILImage() was discarding all the values which were greater than 1 hence the bright pixels became dark.
