StyleGAN generates fully black images

I have been using this code to create a StyeGAN AI with keras that i found here https://keras.io/examples/generative/stylegan/. When i train with 1 step per epoch it generates images with color. But the moment that I use 10000 steps per epoch, as the documentation recommends, the results are always plain black images. I think it may be something with how the celeb_a data set is loaded in as I found another version of the code that had better results. https://github.com/soon-yau/stylegan_keras/blob/main/stylegan.ipynb. Sadly the way this code loads in the the dataset does not work anymore. Does anybody how to manually download the dataset or even if the problem of the black images has occurred before?

Thanks in advance and have a nice day.

1 Like

@Silent_Gamer,

Apologies for the delayed reply. Thank you for reporting the issue.

I came across couple of blockers while executing the Face image generation with StyleGAN tutorial with Tensorflow 2.12.

  1. The input images are normalized twice, so it generates black images. To fix this, we should exclude ds_train = ds_train.map(lambda x: x / 255.0)

  2. Since we are trying to restore a checkpoint from a legacy keras optimizer into a V2.12, we should update the optimizer references in the code to be an instance of tf.keras.optimizers.legacy.Optimizer , e.g.: tf.keras.optimizers.legacy.Adam as shown below

d_optimizer=tf.keras.optimizers.legacy.Adam(**opt_cfg),
g_optimizer=tf.keras.optimizers.legacy.Adam(**opt_cfg),

I just submitted #PR1358, which will fix the issue.

Thank you!

@Silent_Gamer,

The previously referenced PR was merged successfully.

Thank you!