Data Fatching
import PIL.Image as Image
import os
import torch
images=torch.zeros(len(df),3,128,128)
for i in range(len(df)):
    ak=Image.open(("/content/VOC2012/SegmentationObject")+"/"+df['a'][i]+".png")
    ak=transform(ak) 
    images[i]=ak

Transform–
from torchvision import transforms
transform=transforms.Compose([
  transforms.CenterCrop((128,128)),
  transforms.ToTensor(),
 ])

Back to PIL Code-
to_pil = torchvision.transforms.ToPILImage()
tar = to_pil(img[0])

tar is(Image after converting back to PIL(above code))–

original image-

Is this because of CenterCROP in the transform.
Or what is the problem.
cv2(Open CV) help me and no color loss happens in cv2.