Color Inversion Issue in CycleGAN: Possible PyTorch Version Problem?

When I ran CycleGAN locally with the same code as the assignment, despite going through a sufficient number of epochs, the results seem to exhibit color inversion, as shown in the attached images. Could this be a PyTorch version issue?"

Are there any other additional files in the lab directory that might be needed?

No, there are no additional files. The same code produces such results when run on Python version 3.8.0 and PyTorch version 1.11.0.

An image would have 3 (RGB)-4 channels with pixel values ranging from 0-255. If you get color inversion then the mapping of pixels from one framework to another might be reversed, thats all I can think of.

But typically we normalize the pixels before doing any training, because it just works better. That’s also a possible cause of problems as there are a couple of different ways to do that normalization. The most common is just to divide by 255. so that you get pixel values between 0 and 1. That is good for the training behavior and also has the advantage that most image libraries will just automatically handle images scaled that way. But sometimes I’ve seen notebooks that rescale the images to have the range [-1,1] with mean 0.

It’s worth taking a look at the CycleGAN notebook to see how they handle this.

It’s also a good theory to consider Pytorch “versionitis”. The GANs courses were published 3 years ago (I think) and things evolve pretty quickly in this space in general, so it would not be shocking if some current APIs have changed behavior in the interim.

1 Like

Thank you. I will try to resolve it with your guidance.

1 Like

Thank you. I will try to address it with consideration for normalization and the PyTorch version.