Image looks different after torchvision.transforms

I use cv2 to read and resize the image and the top image is the result. Then I want to use torchvision.transforms to do data augmentation for this image. I applied RandomHorizontalFlip(), but the result shows quite different with the top one.Screen Shot 2020-04-04 at 6.38.58 PM
Why do they looks like so different? How can I do data augmentation in Pytorch?

Thank you!

I’m not sure how you’ve visualized the images, but note that OpenCV uses BGR color format by default, while PIL, which is used in torchvision.transforms uses RGB.

That being said, did you try to permute the dimensions using view or reshape, as the image might also be interleaved. It’s a bit hard to tell, as the images are quite noisy.