genforce / idinvert

[ECCV 2020] In-Domain GAN Inversion for Real Image Editing
https://genforce.github.io/idinvert/
MIT License
461 stars 65 forks source link

Incorrect image shape when reading from TFRecordDataset #35

Closed yuval-alaluf closed 4 years ago

yuval-alaluf commented 4 years ago

Hi all,
I am trying to train IDInvert using a new StyleGAN model. To do so, I first prepared my training and test data using your provided dataset_tool.py script and set the resolution of my data to be 512x512.
However, when I run the train_encoder.py script it appears that the data is read at a resolution of 16x16.

This issue is probably not related to your particular implementation, but maybe you have come across this issue in the past and can provide me with some insight as to what might causing this?

My best guess is that you are using a tf.data.TFRecordDataset to load the data in the training_loop_encoder.py script while the training of the generator uses dataset.TFRecordDataset. Could this be causing the difference?

Thanks in advance!

yuval-alaluf commented 4 years ago

It seems like changing the get_train_data function in training_loop_encoder to utilize the TFRecordDataset class in training/datasets solves this issue.

In any case, is there any chance you can look into this issue? If it helps I am using the docker from StyleGAN-ADA which can be found here: https://github.com/NVlabs/stylegan2-ada

Could the fact that they use tensorflow 1.14 be causing this issue?

ShenYujun commented 4 years ago

Since the training of encoder only focuses on the largest resolution, it does not rely on the progressive training strategy. Therefore, you should specify a particular file (e.g., xxxx-r09.tfrecords for 512x512 resolution), instead of the dataset folder, for both the training_data and the test_data arguments.

yuval-alaluf commented 4 years ago

Thanks a lot for the clarification!
I completely missed the fact that the different .tfrecords files correspond to different resolutions! Now everything works as expected. Thanks again!