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

several errors on train_encoder #6

Closed ghost closed 4 years ago

ghost commented 4 years ago

Thank you for great work,

I have some problems about train_encoder.py file.

1) Do we need to give exactly 1 .tfrecords file into the system for training encoder, because when i give multiple files at once (by creating an array of filenames) it says sizes are incompatible.

(tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot batch tensors with different shapes in component 0. First element had shape [1,32,32] and element 1 had shape [1,4,4].)

I have multiple files because i used dataset_tool.py from original stylegan which creates several numbers of tfrecords files when you use 'create_from_images' command. I tried to merge these tfrecords files into 1 but the error stayed same. When i only use the largest sized tfrecord file incompatible error is gone but it rised the error below and i dont think it is related with dataset:

FailedPreconditionError: Attempting to use uninitialized value learning_rate_step [[node learning_rate_step/read (defined at /auto/k2/korkmaz/Downloads/idinvert-master/training/training_loop_encoder.py:127) ]]

Full error log:

File "/auto/k2/korkmaz/Downloads/idinvert-master/train_encoder.py", line 65, in main()

File "/auto/k2/korkmaz/Downloads/idinvert-master/train_encoder.py", line 62, in main dnnlib.submit_run(**kwargs)

File "/auto/k2/korkmaz/Downloads/idinvert-master/dnnlib/submission/submit.py", line 290, in submit_run run_wrapper(submit_config)

File "/auto/k2/korkmaz/Downloads/idinvert-master/dnnlib/submission/submit.py", line 242, in run_wrapper util.call_func_by_name(func_name=submit_config.run_func_name, submit_config=submit_config, **submit_config.run_func_kwargs)

File "/auto/k2/korkmaz/Downloads/idinvert-master/dnnlib/util.py", line 257, in call_func_by_name return func_obj(*args, **kwargs)

File "/auto/k2/korkmaz/Downloads/idinvert-master/training/training_loop_encoder.py", line 192, in trainingloop , recon, adv = sess.run([E_train_op, E_loss_rec, E_loss_adv], feed_dict_1)

File "/auto/k2/korkmaz/Downloads/style_gan/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 950, in run run_metadata_ptr)

File "/auto/k2/korkmaz/Downloads/style_gan/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1173, in _run feed_dict_tensor, options, run_metadata)

File "/auto/k2/korkmaz/Downloads/style_gan/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1350, in _do_run run_metadata)

File "/auto/k2/korkmaz/Downloads/style_gan/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1370, in _do_call raise type(e)(node_def, op, message)

2) It seems the train_encoder is implemented for RGB images, but i am using grayscale images and modified several lines whenever it rised errors about differences between shapes. Is there any option for channel number that i did not see or do i need to modify those lines by myself ?

Thank you in advance.

ghost commented 4 years ago

I was using Python3.5 updating to 3.6 solved the FailedPreconditionError about not initialized variable, but still wondering the other issues, thanks.

zhujiapeng commented 4 years ago
  1. Our encoder doesn't have a progressive architecture, so you just need to give one .tfrecords file, which contains all images you want to train the encoder.
  2. Sorry about this, we haven't tested our encoder on grayscale images. I am not sure what kind of errors you met, one way is you could triple the gray channel when you prepare your dataset.