keras-io
keras-io copied to clipboard
Problem: Face image generation with StyleGAN generates darker and darker output.
Problem: Face image generation with StyleGAN generates darker and darker output. I am running the stylegan.py example, doing a training, and the more steps_per_epochs i use, the darker the output becomes, For instance, with steps_per_epoch = 2048, all the output is black. Something is wrong. I did not change anything in the example code except increasing steps_per_epoch in the given train() function.
The output that is generated by loading the pre-trained model is ok, as shown on https://keras.io/examples/generative/stylegan/
I found the bug in stylegan.py: The input images are 'normalized' twice, so that they become very dark.
The first normalization is done here:
ds_train = ds_train.map(lambda x: x / 255.0)
the second (in resize_image) by this:
image = tf.cast(image, tf.float32)/127.5 - 1.
The latter one is correct, and should be the only normalization step. Delete the ' ds_train = ds_train.map(lambda x: x / 255.0)' line to fix the bug. Interestingly, the GAN was working, but unexpectedly learning to output very very dark images ;)
they never answer in here bro :/
Hey! Would you mind tagging the original author? Usually they are the best first resource to contact for fixing the tutorial. If now, tag me again and we can get the fix included
@LukeWood @fchollet @yarri-oss Please integrate the StyleGAN bug fix mentioned above.
LGTM but would ask @soon-yau to confirm as well because I'm not sure I tested agains the correct public version of Celeb A
@yarri-oss the "ds_train = ds_train.map(lambda x: x / 255.0)" was wrongly inserted in your last commit. You can create a PR to remove it.