Giter Club home page Giter Club logo

idinvert's Introduction

GenForce Lib for Generative Modeling

An efficient PyTorch library for deep generative modeling. May the Generative Force (GenForce) be with You.

image

Updates

  • Encoder Training: We support training encoders on top of pre-trained GANs for GAN inversion.
  • Model Converters: You can easily migrate your already started projects to this repository. Please check here for more details.

Highlights

  • Distributed training framework.
  • Fast training speed.
  • Modular design for prototyping new models.
  • Model zoo containing a rich set of pretrained GAN models, with Colab live demo to play.

Installation

  1. Create a virtual environment via conda.

    conda create -n genforce python=3.7
    conda activate genforce
  2. Install cuda and cudnn. (We use CUDA 10.0 in case you would like to use TensorFlow 1.15 for model conversion.)

    conda install cudatoolkit=10.0 cudnn=7.6.5
  3. Install torch and torchvision.

    pip install torch==1.7 torchvision==0.8
  4. Install requirements

    pip install -r requirements.txt

Quick Demo

We provide a quick training demo, scripts/stylegan_training_demo.py, which allows to train StyleGAN on a toy dataset (500 animeface images with 64 x 64 resolution). Try it via

./scripts/stylegan_training_demo.sh

We also provide an inference demo, synthesize.py, which allows to synthesize images with pre-trained models. Generated images can be found at work_dirs/synthesis_results/. Try it via

python synthesize.py stylegan_ffhq1024

You can also play the demo at Colab.

Play with GANs

Test

Pre-trained models can be found at model zoo.

  • On local machine:

    GPUS=8
    CONFIG=configs/stylegan_ffhq256_val.py
    WORK_DIR=work_dirs/stylegan_ffhq256_val
    CHECKPOINT=checkpoints/stylegan_ffhq256.pth
    ./scripts/dist_test.sh ${GPUS} ${CONFIG} ${WORK_DIR} ${CHECKPOINT}
  • Using slurm:

    CONFIG=configs/stylegan_ffhq256_val.py
    WORK_DIR=work_dirs/stylegan_ffhq256_val
    CHECKPOINT=checkpoints/stylegan_ffhq256.pth
    GPUS=8 ./scripts/slurm_test.sh ${PARTITION} ${JOB_NAME} \
        ${CONFIG} ${WORK_DIR} ${CHECKPOINT}

Train

All log files in the training process, such as log message, checkpoints, synthesis snapshots, etc, will be saved to the work directory.

  • On local machine:

    GPUS=8
    CONFIG=configs/stylegan_ffhq256.py
    WORK_DIR=work_dirs/stylegan_ffhq256_train
    ./scripts/dist_train.sh ${GPUS} ${CONFIG} ${WORK_DIR} \
        [--options additional_arguments]
  • Using slurm:

    CONFIG=configs/stylegan_ffhq256.py
    WORK_DIR=work_dirs/stylegan_ffhq256_train
    GPUS=8 ./scripts/slurm_train.sh ${PARTITION} ${JOB_NAME} \
        ${CONFIG} ${WORK_DIR} \
        [--options additional_arguments]

Play with Encoders for GAN Inversion

Train

  • On local machine:

    GPUS=8
    CONFIG=configs/stylegan_ffhq256_encoder_y.py
    WORK_DIR=work_dirs/stylegan_ffhq256_encoder_y
    ./scripts/dist_train.sh ${GPUS} ${CONFIG} ${WORK_DIR} \
        [--options additional_arguments]
  • Using slurm:

    CONFIG=configs/stylegan_ffhq256_encoder_y.py
    WORK_DIR=work_dirs/stylegan_ffhq256_encoder_y
    GPUS=8 ./scripts/slurm_train.sh ${PARTITION} ${JOB_NAME} \
        ${CONFIG} ${WORK_DIR} \
        [--options additional_arguments]

Contributors

Member Module
Yujun Shen models and running controllers
Yinghao Xu runner and loss functions
Ceyuan Yang data loader
Jiapeng Zhu evaluation metrics
Bolei Zhou cheerleader

NOTE: The above form only lists the person in charge for each module. We help each other a lot and develop as a TEAM.

We welcome external contributors to join us for improving this library.

License

The project is under the MIT License.

Acknowledgement

We thank PGGAN, StyleGAN, StyleGAN2, StyleGAN2-ADA for their work on high-quality image synthesis. We thank IDInvert and GHFeat for their contribution to GAN inversion. We also thank MMCV for the inspiration on the design of controllers.

BibTex

We open source this library to the community to facilitate the research of generative modeling. If you do like our work and use the codebase or models for your research, please cite our work as follows.

@misc{genforce2020,
  title =        {GenForce},
  author =       {Shen, Yujun and Xu, Yinghao and Yang, Ceyuan and Zhu, Jiapeng and Zhou, Bolei},
  howpublished = {\url{https://github.com/genforce/genforce}},
  year =         {2020}
}

idinvert's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

idinvert's Issues

ModuleNotFoundError: No module named 'tensorflow.contrib.nccl'

error when training encoder.
gpu: t4
linux
tensorflow version 1

Creating the run dir: results/00014-stylegan-encoder-1gpu-256x256-ffhq
Copying files to the run dir
WARNING:tensorflow:From /content/idinvert/dnnlib/tflib/tfutil.py:34: The name tf.Dimension is deprecated. Please use tf.compat.v1.Dimension instead.

WARNING:tensorflow:From /content/idinvert/dnnlib/tflib/tfutil.py:74: The name tf.variable_scope is deprecated. Please use tf.compat.v1.variable_scope instead.

WARNING:tensorflow:From /content/idinvert/dnnlib/tflib/tfutil.py:128: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.

Using TensorFlow backend.
dnnlib: Running training.training_loop_encoder.training_loop() on localhost...
WARNING:tensorflow:From /content/idinvert/dnnlib/tflib/tfutil.py:97: The name tf.get_default_session is deprecated. Please use tf.compat.v1.get_default_session instead.

WARNING:tensorflow:From /content/idinvert/dnnlib/tflib/tfutil.py:109: The name tf.set_random_seed is deprecated. Please use tf.compat.v1.set_random_seed instead.

WARNING:tensorflow:From /content/idinvert/dnnlib/tflib/tfutil.py:132: The name tf.ConfigProto is deprecated. Please use tf.compat.v1.ConfigProto instead.

WARNING:tensorflow:From /content/idinvert/training/training_loop_encoder.py:109: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.

Constructing networks...
WARNING:tensorflow:From /content/idinvert/dnnlib/tflib/network.py:142: The name tf.get_default_graph is deprecated. Please use tf.compat.v1.get_default_graph instead.

WARNING:tensorflow:From /content/idinvert/dnnlib/tflib/network.py:150: The name tf.AUTO_REUSE is deprecated. Please use tf.compat.v1.AUTO_REUSE instead.

WARNING:tensorflow:From /content/idinvert/dnnlib/tflib/tfutil.py:76: The name tf.VariableScope is deprecated. Please use tf.compat.v1.VariableScope instead.

WARNING:tensorflow:From /content/idinvert/dnnlib/tflib/network.py:151: The name tf.get_variable_scope is deprecated. Please use tf.compat.v1.get_variable_scope instead.

WARNING:tensorflow:From /content/idinvert/dnnlib/tflib/network.py:182: The name tf.global_variables is deprecated. Please use tf.compat.v1.global_variables instead.

WARNING:tensorflow:From /content/idinvert/dnnlib/tflib/tfutil.py:200: The name tf.assign is deprecated. Please use tf.compat.v1.assign instead.

WARNING:tensorflow:From <string>:373: where (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.where in 2.0, which has the same broadcast rule as np.where
Traceback (most recent call last):
  File "train_encoder.py", line 69, in <module>
    main()
  File "train_encoder.py", line 65, in main
    dnnlib.submit_run(**kwargs)
  File "/content/idinvert/dnnlib/submission/submit.py", line 290, in submit_run
    run_wrapper(submit_config)
  File "/content/idinvert/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 "/content/idinvert/dnnlib/util.py", line 257, in call_func_by_name
    return func_obj(*args, **kwargs)
  File "/content/idinvert/training/training_loop_encoder.py", line 125, in training_loop
    num_layers=num_layers, is_training=True, num_gpus=submit_config.num_gpus, **Encoder_args)
  File "/content/idinvert/dnnlib/tflib/network.py", line 88, in __init__
    module, self._build_func_name = util.get_module_from_obj_name(func_name)
  File "/content/idinvert/dnnlib/util.py", line 219, in get_module_from_obj_name
    importlib.import_module(module_name) # may raise ImportError
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/content/idinvert/training/networks_encoder.py", line 11, in <module>
    from tensorflow.contrib.nccl.ops import gen_nccl_ops
ModuleNotFoundError: No module named 'tensorflow.contrib.nccl'

Training encoder for 1024x1024 images

I wanted to try and train an encoder for the full HD 1024x1024 images.

  • Is there a reason this was not attempted in the paper?
  • Upon doing this, the encoder network becomes insanely large (236M params) since the input shape to the final FC layer is now huge

FID metrics

First of all, thank you for your great works!

I'm curious about your FID metrics (Table 1 in your paper).
Did you compare 500 fake images with 50000 real images?
It seems to that because of high FID scores.

If so, wouldn't it better comparing 500 fake images and corresponding 500 real images?

image

Thank you :)

why face with eyeglasses when aged?

I edit real faces, all the aged faces with eyeglasses, it is strange. Should the face attributes be disentangled? Anyone encounter this question? Any solutions?

How to set gpu id in train.py

Hi guys

Thanks for providing your great work. I was able to run train.py. But I'm wondering how to set the gpu id in train.py. Do you have a suggestion. I would be very thankful.

Thanks

Question about discriminator

Thanks for your great work..But i have some problems about the discriminator..

Does the discriminator (appears in encoder training process) is the StyleGAN discriminator or a discriminator trained from scratch with the encoder?

Training problems

I've tried several different versions of tensorflow, but all of them reported errors which seems related to environment when I tried to run train_encoder.py.
I would appreciate it very much if you could give more details about your training environment. Thanks so much!

indoor scene

Thanks for your work. It is a very nice paper. I have a simple question.

Have you try this method on indoor image? For example, in higan, which also comes from your group, it show manipulation for indoor images. Do you think idinvert could invert indoor images and do the same manipulation as higan?

Thank you for your help.

Error occurs when running invert.py

Hi everyone,

When running invert.py according to your instructions I get the following error at line 157:

Traceback (most recent call last):
File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1334, in _do_call
return fn(*args)
File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1319, in _run_fn
options, feed_dict, fetch_list, target_list, run_metadata)
File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1407, in _call_tf_sessionrun
run_metadata)
tensorflow.python.framework.errors_impl.UnimplementedError: Depthwise convolution on CPU is only supported for NHWC format
[[{{node G_synthesis_2/8x8/Conv0_up/Blur2D/depthwise}} = DepthwiseConv2dNative[T=DT_FLOAT, data_format="NCHW", dilations=[1, 1, 1, 1], padding="SAME", strides=[1, 1, 1, 1], _device="/job:localhost/replica:0/task:0/device:CPU:0"](G_synthesis_2/8x8/Conv0_up/Conv2D, G_synthesis_2/8x8/Conv0_up/Blur2D/filter)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 929, in run
run_metadata_ptr)
File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1152, in _run
feed_dict_tensor, options, run_metadata)
File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1328, in _do_run
run_metadata)
File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1348, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.UnimplementedError: Depthwise convolution on CPU is only supported for NHWC format
[[node G_synthesis_2/8x8/Conv0_up/Blur2D/depthwise (defined at :47) = DepthwiseConv2dNative[T=DT_FLOAT, data_format="NCHW", dilations=[1, 1, 1, 1], padding="SAME", strides=[1, 1, 1, 1], _device="/job:localhost/replica:0/task:0/device:CPU:0"](G_synthesis_2/8x8/Conv0_up/Conv2D, G_synthesis_2/8x8/Conv0_up/Blur2D/filter)]]

Caused by op 'G_synthesis_2/8x8/Conv0_up/Blur2D/depthwise', defined at:
File "/home/amir/.pycharm_helpers/pydev/pydevd.py", line 2141, in
main()
File "/home/amir/.pycharm_helpers/pydev/pydevd.py", line 2132, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/home/amir/.pycharm_helpers/pydev/pydevd.py", line 1441, in run
return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
File "/home/amir/.pycharm_helpers/pydev/pydevd.py", line 1448, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "/home/amir/.pycharm_helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/amir/idinvert/invert.py", line 191, in
main()
File "/home/amir/idinvert/invert.py", line 90, in main
x_rec = Gs.components.synthesis.get_output_for(wp, randomize_noise=False)
File "/home/amir/idinvert/dnnlib/tflib/network.py", line 222, in get_output_for
out_expr = self._build_func(*final_inputs, **build_kwargs)
File "", line 562, in G_synthesis
File "", line 557, in grow
File "", line 526, in block
File "", line 473, in blur
File "", line 106, in blur2d
File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/ops/custom_gradient.py", line 111, in decorated
return _graph_mode_decorator(f, *args, **kwargs)
File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/ops/custom_gradient.py", line 132, in _graph_mode_decorator
result, grad_fn = f(*args)
File "", line 100, in func
File "", line 47, in _blur2d
File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/ops/nn_impl.py", line 461, in depthwise_conv2d
op=op)
File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/ops/nn_ops.py", line 364, in with_space_to_batch
return new_op(input, None)
File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/ops/nn_ops.py", line 520, in call
return self.call(inp, filter)
File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/ops/nn_ops.py", line 354, in
return lambda inp, _: op(inp, num_spatial_dims, padding)
File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/ops/nn_impl.py", line 453, in op
name=name)
File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 2112, in depthwise_conv2d_native
name=name)
File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 488, in new_func
return func(*args, **kwargs)
File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3274, in create_op
op_def=op_def)
File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1770, in init
self._traceback = tf_stack.extract_stack()

UnimplementedError (see above for traceback): Depthwise convolution on CPU is only supported for NHWC format
[[node G_synthesis_2/8x8/Conv0_up/Blur2D/depthwise (defined at :47) = DepthwiseConv2dNative[T=DT_FLOAT, data_format="NCHW", dilations=[1, 1, 1, 1], padding="SAME", strides=[1, 1, 1, 1], _device="/job:localhost/replica:0/task:0/device:CPU:0"](G_synthesis_2/8x8/Conv0_up/Conv2D, G_synthesis_2/8x8/Conv0_up/Blur2D/filter)]]

It seems that it tries to do the networks operations on cpu. I have access to a gpu with id 0. I don't know where the right device is set. Could you maybe explain that error.

Regards

Some problems for training encoder.

Hey man, thanks for your great work! I have some problems during training encoder. I'd really appreciate it if you could anwser me the following questions:

  1. What is the minimum GPU requirement for training encoder?
  2. And can you tell me more details of the results of Table 1 in your paper? How much training iters for Domain-guided Encoder and for In-domain Inversion.

Thank you very much!

About encoding result on random images

Thank you for your great work!!

I have tested the model with some random images from internet, the encoding results and manipulation results is not really good as compared to other images included in your examples folders.

Screen Shot 2020-08-06 at 15 16 46

Screen Shot 2020-08-06 at 15 15 27

How can I improve the model for better encoding images like those?

For the interpolation, can we adjust the copied style range to interpolate coarse style, middle style and fine style?
image

By the way, the model trained based on StyleGAN, so can the encoded latent can be fed into a StyleGAN generator?

more training examples for manipulation

Dear Genforce group,

Thank you for your great work, I really like your work 'in-domain gan'.

As you state in the paper, in order to do image manipulation (male -> female), you use interfacegan to find the manipulation direction in wp, w or z. Since you use wp which is 14x more dimentions than w, you will need to generate more data to train the linear SVM, right? Interfacegan manipulates on w and train svm with 500k generated images, how many images you need to train svm on wp?

Notice that interfacegan uses standard stylegan, and wp is just broadcasting of w, they have the same intrinsic dimentions, so it can use the same amount of images to train on either w or wp. But in 'in-domain gan', you retrain the stylegan with different w instead of repeated w, so wp has larger intrinsic dimentions than each w.

Looking forward for your reply. Thanks in advance.

running problems

Hi, when I am running the code to train the generator, the output shown in the command line seems be keeping at tick59. But it is still running... Is it ok?

SyntaxError: invalid syntax

When I try to train the generator, the error appears as below:

Traceback (most recent call last):
File "train.py", line 11, in
import dnnlib
File "/stylegan/dnnlib/init.py", line 20
submit_config: SubmitConfig = None # Package level variable for SubmitConfig which is only valid when inside the run function.
^
SyntaxError: invalid syntax

Could you give me some advice?

the number of optimization iteration

Thank you for your great works again :)

I'm curious about the number of optimization iteration.

In your code, it is 100 iterations, but in the paper the optimization process consumes 142s per image.

What is the number of optimization iteration in your paper?

Thank you in advance.

My own data set

Hello, I'm new to this and I need your help.
I trained StyleGAN on my own dataset, using your scripts in genforce.
Now I need to learn how to invert images to the StyleGAN latent space, that is, I want to get styleganinv, what do I need for this?

Inversion goes to collapse

@zhujiapeng @ShenYujun @zhoubolei
I like your works including InterFaceGAN.

I test some FFHQ images (from 00000.png to 00029.png, 30 images) using the In-Domain GAIN Inversion method. I found for some examples, the output of the encoder seems good but during some iterations that the results do not seem correct. The following two images using 100 iterations and 1,000 iterations. But the result even becomes worse. For example, the problem of 00000.png was corrected during long iterations, but 00002.png no big difference. In addition, the 00015.png becomes worse.
Do you have some ideas about this?

100_iters

1000_iters

python train_encoder.py

When i am trying to training the encoder, I got the error as below:

tensorflow.python.framework.errors_impl.FailedPreconditionError: datasets/custom-dataset; Is a directory
[[{{node IteratorGetNext}}]]

due to NCCL requirement, will not work on Windows

Because of no NCCL support for windows, the dependencies of this project prevent it from running on Windows:
tensorflow/tensorflow#21470

This appears to be the only place that nccl is used, and from what I understand (could be wrong) is that NCCL is only needed for multiple-gpu operations anyways.

g = nccl_ops.all_sum(g)

Any ideas on how to remove the NCCL requirement to allow this project to run in Windows?

typo

"Change repleated $w$ for all layers to different $w$s (Line 428-435 in file training/networks_stylegan.py)."

"Change repleated $w$ for all layers to different $w$s (Line 423 and Line 428-435 in file training/networks_stylegan.py)."

:)

How to obtain projected direction given pretained boundaries?

I tried to get age/eyeglass boundry using the method discribed in the paper "interfacegan", e.g. n = n_age - (n_age^T * n_eyeglass) * n_eyeglass with the boundary file age.npy and glass.npy provided, but when I manipute age/eyeglasses attribute, the images hardly changed as expected. If there is any difference when manipulating w and wp?

Incorrect image shape when reading from TFRecordDataset

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!

About the manipulation layer parameter.

Hello, thanks for the excellent work!
I found that the boundaries learned by interfacegan contains the manipulation layer parameter. But i don't found explanation about the manipulation layer in the interfacegan paper. So I wonder is the manipulation layer learned by experience? Or the boundaries are learned specifically on the manipulation layer? Thanks a lot!

ValueError exception when running train_encoder.py

Hi,

Many thanks for the incredible work at genforce and for making it available to the world.

I got an unexpected exception when trying to train the encoder. Looking at the code, it appears to be caused by the code that creates the image snapshots.

If I would have to guess, perhaps there is something wrong with the .tfrecord files I'm using? No errors training the generator, though. Is it a requirement to use dataset_tool from the idinvert repo to generate the .tfrecord files?

Here's log.txt and the traceback:

dnnlib: Running training.training_loop_encoder.training_loop() on localhost...
Constructing networks...

E_gpu0 Params OutputShape WeightShape


Input_img - (?, 3, 256, 256) -
FromImg 4992 (?, 64, 256, 256) (5, 5, 3, 64)
Downscale2D - (?, 64, 128, 128) -
E_block_0 119616 (?, 128, 128, 128) (3, 3, 64, 64)
Downscale2D_1 - (?, 128, 64, 64) -
E_block_1 476800 (?, 256, 64, 64) (3, 3, 128, 128)
Downscale2D_2 - (?, 256, 32, 32) -
E_block_2 1903872 (?, 512, 32, 32) (3, 3, 256, 256)
Downscale2D_3 - (?, 512, 16, 16) -
E_block_3 4721664 (?, 512, 16, 16) (3, 3, 512, 512)
Downscale2D_4 - (?, 512, 8, 8) -
E_block_4 4721664 (?, 512, 8, 8) (3, 3, 512, 512)
Downscale2D_5 - (?, 512, 4, 4) -
E_block_5 4721664 (?, 512, 4, 4) (3, 3, 512, 512)
Latent_out 58741760 (?, 7168) (8192, 7168)


Total 75412032

Gs Params OutputShape WeightShape


latents_in - (?, 512) -
labels_in - (?, 0) -
lod - () -
dlatent_avg - (512,) -
G_mapping/latents_in - (?, 512) -
G_mapping/labels_in - (?, 0) -
G_mapping/PixelNorm - (?, 512) -
G_mapping/Dense0 262656 (?, 512) (512, 512)
G_mapping/Dense1 262656 (?, 512) (512, 512)
G_mapping/Dense2 262656 (?, 512) (512, 512)
G_mapping/Dense3 262656 (?, 512) (512, 512)
G_mapping/Dense4 262656 (?, 512) (512, 512)
G_mapping/Dense5 262656 (?, 512) (512, 512)
G_mapping/Dense6 262656 (?, 512) (512, 512)
G_mapping/Dense7 3677184 (?, 7168) (512, 7168)
G_mapping/Reshape - (?, 14, 512) -
G_mapping/dlatents_out - (?, 14, 512) -
Truncation - (?, 14, 512) -
G_synthesis/dlatents_in - (?, 14, 512) -
G_synthesis/4x4/Const 534528 (?, 512, 4, 4) (512,)
G_synthesis/4x4/Conv 2885632 (?, 512, 4, 4) (3, 3, 512, 512)
G_synthesis/ToRGB_lod6 1539 (?, 3, 4, 4) (1, 1, 512, 3)
G_synthesis/8x8/Conv0_up 2885632 (?, 512, 8, 8) (3, 3, 512, 512)
G_synthesis/8x8/Conv1 2885632 (?, 512, 8, 8) (3, 3, 512, 512)
G_synthesis/ToRGB_lod5 1539 (?, 3, 8, 8) (1, 1, 512, 3)
G_synthesis/Upscale2D - (?, 3, 8, 8) -
G_synthesis/Grow_lod5 - (?, 3, 8, 8) -
G_synthesis/16x16/Conv0_up 2885632 (?, 512, 16, 16) (3, 3, 512, 512)
G_synthesis/16x16/Conv1 2885632 (?, 512, 16, 16) (3, 3, 512, 512)
G_synthesis/ToRGB_lod4 1539 (?, 3, 16, 16) (1, 1, 512, 3)
G_synthesis/Upscale2D_1 - (?, 3, 16, 16) -
G_synthesis/Grow_lod4 - (?, 3, 16, 16) -
G_synthesis/32x32/Conv0_up 2885632 (?, 512, 32, 32) (3, 3, 512, 512)
G_synthesis/32x32/Conv1 2885632 (?, 512, 32, 32) (3, 3, 512, 512)
G_synthesis/ToRGB_lod3 1539 (?, 3, 32, 32) (1, 1, 512, 3)
G_synthesis/Upscale2D_2 - (?, 3, 32, 32) -
G_synthesis/Grow_lod3 - (?, 3, 32, 32) -
G_synthesis/64x64/Conv0_up 1442816 (?, 256, 64, 64) (3, 3, 512, 256)
G_synthesis/64x64/Conv1 852992 (?, 256, 64, 64) (3, 3, 256, 256)
G_synthesis/ToRGB_lod2 771 (?, 3, 64, 64) (1, 1, 256, 3)
G_synthesis/Upscale2D_3 - (?, 3, 64, 64) -
G_synthesis/Grow_lod2 - (?, 3, 64, 64) -
G_synthesis/128x128/Conv0_up 426496 (?, 128, 128, 128) (3, 3, 256, 128)
G_synthesis/128x128/Conv1 279040 (?, 128, 128, 128) (3, 3, 128, 128)
G_synthesis/ToRGB_lod1 387 (?, 3, 128, 128) (1, 1, 128, 3)
G_synthesis/Upscale2D_4 - (?, 3, 128, 128) -
G_synthesis/Grow_lod1 - (?, 3, 128, 128) -
G_synthesis/256x256/Conv0_up 139520 (?, 64, 256, 256) (3, 3, 128, 64)
G_synthesis/256x256/Conv1 102656 (?, 64, 256, 256) (3, 3, 64, 64)
G_synthesis/ToRGB_lod0 195 (?, 3, 256, 256) (1, 1, 64, 3)
G_synthesis/Upscale2D_5 - (?, 3, 256, 256) -
G_synthesis/Grow_lod0 - (?, 3, 256, 256) -
G_synthesis/images_out - (?, 3, 256, 256) -
G_synthesis/lod - () -
G_synthesis/noise0 - (1, 1, 4, 4) -
G_synthesis/noise1 - (1, 1, 4, 4) -
G_synthesis/noise2 - (1, 1, 8, 8) -
G_synthesis/noise3 - (1, 1, 8, 8) -
G_synthesis/noise4 - (1, 1, 16, 16) -
G_synthesis/noise5 - (1, 1, 16, 16) -
G_synthesis/noise6 - (1, 1, 32, 32) -
G_synthesis/noise7 - (1, 1, 32, 32) -
G_synthesis/noise8 - (1, 1, 64, 64) -
G_synthesis/noise9 - (1, 1, 64, 64) -
G_synthesis/noise10 - (1, 1, 128, 128) -
G_synthesis/noise11 - (1, 1, 128, 128) -
G_synthesis/noise12 - (1, 1, 256, 256) -
G_synthesis/noise13 - (1, 1, 256, 256) -
images_out - (?, 3, 256, 256) -


Total 29500757

D Params OutputShape WeightShape


images_in - (?, 3, 256, 256) -
labels_in - (?, 0) -
lod - () -
FromRGB_lod0 256 (?, 64, 256, 256) (1, 1, 3, 64)
256x256/Conv0 36928 (?, 64, 256, 256) (3, 3, 64, 64)
256x256/Conv1_down 73856 (?, 128, 128, 128) (3, 3, 64, 128)
Downscale2D - (?, 3, 128, 128) -
FromRGB_lod1 512 (?, 128, 128, 128) (1, 1, 3, 128)
Grow_lod0 - (?, 128, 128, 128) -
128x128/Conv0 147584 (?, 128, 128, 128) (3, 3, 128, 128)
128x128/Conv1_down 295168 (?, 256, 64, 64) (3, 3, 128, 256)
Downscale2D_1 - (?, 3, 64, 64) -
FromRGB_lod2 1024 (?, 256, 64, 64) (1, 1, 3, 256)
Grow_lod1 - (?, 256, 64, 64) -
64x64/Conv0 590080 (?, 256, 64, 64) (3, 3, 256, 256)
64x64/Conv1_down 1180160 (?, 512, 32, 32) (3, 3, 256, 512)
Downscale2D_2 - (?, 3, 32, 32) -
FromRGB_lod3 2048 (?, 512, 32, 32) (1, 1, 3, 512)
Grow_lod2 - (?, 512, 32, 32) -
32x32/Conv0 2359808 (?, 512, 32, 32) (3, 3, 512, 512)
32x32/Conv1_down 2359808 (?, 512, 16, 16) (3, 3, 512, 512)
Downscale2D_3 - (?, 3, 16, 16) -
FromRGB_lod4 2048 (?, 512, 16, 16) (1, 1, 3, 512)
Grow_lod3 - (?, 512, 16, 16) -
16x16/Conv0 2359808 (?, 512, 16, 16) (3, 3, 512, 512)
16x16/Conv1_down 2359808 (?, 512, 8, 8) (3, 3, 512, 512)
Downscale2D_4 - (?, 3, 8, 8) -
FromRGB_lod5 2048 (?, 512, 8, 8) (1, 1, 3, 512)
Grow_lod4 - (?, 512, 8, 8) -
8x8/Conv0 2359808 (?, 512, 8, 8) (3, 3, 512, 512)
8x8/Conv1_down 2359808 (?, 512, 4, 4) (3, 3, 512, 512)
Downscale2D_5 - (?, 3, 4, 4) -
FromRGB_lod6 2048 (?, 512, 4, 4) (1, 1, 3, 512)
Grow_lod5 - (?, 512, 4, 4) -
4x4/MinibatchStddev - (?, 513, 4, 4) -
4x4/Conv 2364416 (?, 512, 4, 4) (3, 3, 513, 512)
4x4/Dense0 4194816 (?, 512) (8192, 512)
4x4/Dense1 513 (?, 1) (512, 1)
scores_out - (?, 1) -


Total 23052353

Building Graph on GPU 0
Building Graph on GPU 1
Building testing graph...
Getting training data...
Optimization starts!!!
Iter: 000000 recon_loss: 0.6908 adv_loss: 0.1358 d_r_loss: 0.3838 d_f_loss: 0.4184 d_reg: 0.0683 time:21s
Iter: 000050 recon_loss: 0.4536 adv_loss: 0.1509 d_r_loss: 0.3033 d_f_loss: 0.2664 d_reg: 0.1203 time:2m 03s
Iter: 000100 recon_loss: 0.3741 adv_loss: 0.1978 d_r_loss: 0.1764 d_f_loss: 0.1475 d_reg: 0.1859 time:3m 42s
Iter: 000150 recon_loss: 0.4159 adv_loss: 0.1959 d_r_loss: 0.2112 d_f_loss: 0.1248 d_reg: 0.2401 time:5m 21s
Iter: 000200 recon_loss: 0.4182 adv_loss: 0.1677 d_r_loss: 0.1778 d_f_loss: 0.2468 d_reg: 0.2434 time:7m 00s
Iter: 000250 recon_loss: 0.4088 adv_loss: 0.1463 d_r_loss: 0.2826 d_f_loss: 0.2760 d_reg: 0.2503 time:8m 39s
Iter: 000300 recon_loss: 0.4374 adv_loss: 0.1626 d_r_loss: 0.2324 d_f_loss: 0.2215 d_reg: 0.2145 time:10m 18s
Iter: 000350 recon_loss: 0.4204 adv_loss: 0.1349 d_r_loss: 0.3165 d_f_loss: 0.2742 d_reg: 0.2216 time:11m 57s
Iter: 000400 recon_loss: 0.4152 adv_loss: 0.1598 d_r_loss: 0.2791 d_f_loss: 0.2067 d_reg: 0.2191 time:13m 36s
Iter: 000450 recon_loss: 0.4083 adv_loss: 0.1477 d_r_loss: 0.3626 d_f_loss: 0.2404 d_reg: 0.2136 time:15m 15s
Iter: 000500 recon_loss: 0.4392 adv_loss: 0.1666 d_r_loss: 0.3399 d_f_loss: 0.2035 d_reg: 0.2288 time:16m 54s
Iter: 000550 recon_loss: 0.4462 adv_loss: 0.1416 d_r_loss: 0.1786 d_f_loss: 0.2402 d_reg: 0.2195 time:18m 33s
Iter: 000600 recon_loss: 0.3907 adv_loss: 0.1528 d_r_loss: 0.2858 d_f_loss: 0.2014 d_reg: 0.2031 time:20m 12s
Iter: 000650 recon_loss: 0.4291 adv_loss: 0.1333 d_r_loss: 0.1841 d_f_loss: 0.2675 d_reg: 0.2020 time:21m 51s
Iter: 000700 recon_loss: 0.4557 adv_loss: 0.1238 d_r_loss: 0.2788 d_f_loss: 0.3539 d_reg: 0.2099 time:23m 30s
Iter: 000750 recon_loss: 0.4234 adv_loss: 0.1384 d_r_loss: 0.2545 d_f_loss: 0.2659 d_reg: 0.2164 time:25m 09s
Iter: 000800 recon_loss: 0.4068 adv_loss: 0.1595 d_r_loss: 0.3547 d_f_loss: 0.1850 d_reg: 0.2159 time:26m 51s
Iter: 000850 recon_loss: 0.4170 adv_loss: 0.1254 d_r_loss: 0.3539 d_f_loss: 0.3013 d_reg: 0.2199 time:28m 30s
Iter: 000900 recon_loss: 0.4169 adv_loss: 0.1431 d_r_loss: 0.3396 d_f_loss: 0.2748 d_reg: 0.2101 time:30m 11s
Iter: 000950 recon_loss: 0.4328 adv_loss: 0.1403 d_r_loss: 0.1860 d_f_loss: 0.2507 d_reg: 0.2057 time:31m 50s
Iter: 001000 recon_loss: 0.4246 adv_loss: 0.1395 d_r_loss: 0.2495 d_f_loss: 0.2478 d_reg: 0.2162 time:33m 29s
Iter: 001050 recon_loss: 0.4207 adv_loss: 0.1147 d_r_loss: 0.2124 d_f_loss: 0.3612 d_reg: 0.2228 time:35m 08s
Iter: 001100 recon_loss: 0.3931 adv_loss: 0.1415 d_r_loss: 0.4792 d_f_loss: 0.2361 d_reg: 0.1948 time:36m 47s
Iter: 001150 recon_loss: 0.4295 adv_loss: 0.1231 d_r_loss: 0.2721 d_f_loss: 0.3117 d_reg: 0.2000 time:38m 26s
Iter: 001200 recon_loss: 0.3966 adv_loss: 0.1348 d_r_loss: 0.3569 d_f_loss: 0.2381 d_reg: 0.2061 time:40m 02s
Iter: 001250 recon_loss: 0.4007 adv_loss: 0.1097 d_r_loss: 0.2767 d_f_loss: 0.3597 d_reg: 0.2027 time:41m 41s
Iter: 001300 recon_loss: 0.4392 adv_loss: 0.1316 d_r_loss: 0.2217 d_f_loss: 0.2693 d_reg: 0.2128 time:43m 20s
Iter: 001350 recon_loss: 0.4290 adv_loss: 0.1236 d_r_loss: 0.3017 d_f_loss: 0.3025 d_reg: 0.2032 time:44m 59s
Iter: 001400 recon_loss: 0.4203 adv_loss: 0.1271 d_r_loss: 0.3310 d_f_loss: 0.2832 d_reg: 0.2099 time:46m 38s
Iter: 001450 recon_loss: 0.4115 adv_loss: 0.1171 d_r_loss: 0.3016 d_f_loss: 0.3156 d_reg: 0.2031 time:48m 17s
Iter: 001500 recon_loss: 0.3993 adv_loss: 0.1201 d_r_loss: 0.2723 d_f_loss: 0.3320 d_reg: 0.1909 time:49m 56s
Iter: 001550 recon_loss: 0.3839 adv_loss: 0.1343 d_r_loss: 0.3669 d_f_loss: 0.2735 d_reg: 0.1945 time:51m 35s
Iter: 001600 recon_loss: 0.4208 adv_loss: 0.1104 d_r_loss: 0.2530 d_f_loss: 0.3461 d_reg: 0.1930 time:53m 17s
Iter: 001650 recon_loss: 0.4352 adv_loss: 0.1229 d_r_loss: 0.2545 d_f_loss: 0.3369 d_reg: 0.1977 time:54m 56s
Iter: 001700 recon_loss: 0.4403 adv_loss: 0.1192 d_r_loss: 0.3191 d_f_loss: 0.3290 d_reg: 0.1944 time:56m 35s
Iter: 001750 recon_loss: 0.3838 adv_loss: 0.1265 d_r_loss: 0.2571 d_f_loss: 0.2577 d_reg: 0.2040 time:58m 14s
Iter: 001800 recon_loss: 0.4028 adv_loss: 0.1437 d_r_loss: 0.3599 d_f_loss: 0.2610 d_reg: 0.1905 time:59m 53s
Iter: 001850 recon_loss: 0.4085 adv_loss: 0.1089 d_r_loss: 0.2759 d_f_loss: 0.3384 d_reg: 0.1958 time:1h 01m 32s
Iter: 001900 recon_loss: 0.3930 adv_loss: 0.1114 d_r_loss: 0.2733 d_f_loss: 0.3467 d_reg: 0.2007 time:1h 03m 11s
Iter: 001950 recon_loss: 0.4068 adv_loss: 0.1112 d_r_loss: 0.2926 d_f_loss: 0.3603 d_reg: 0.1914 time:1h 04m 50s
Iter: 002000 recon_loss: 0.3942 adv_loss: 0.1057 d_r_loss: 0.3776 d_f_loss: 0.3608 d_reg: 0.1978 time:1h 06m 29s
Traceback (most recent call last):
File "train_encoder.py", line 69, in
main()
File "train_encoder.py", line 65, in main
dnnlib.submit_run(**kwargs)
File "/root/idinvert/dnnlib/submission/submit.py", line 290, in submit_run
run_wrapper(submit_config)
File "/root/idinvert/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 "/root/idinvert/dnnlib/util.py", line 257, in call_func_by_name
return func_obj(*args, **kwargs)
File "/root/idinvert/training/training_loop_encoder.py", line 212, in training_loop
recon = sess.run(fake_X_val, feed_dict={real_test: batch_images_test})
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 929, in run
run_metadata_ptr)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 1128, in _run
str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (2, 3, 128, 128) for Tensor 'Input/real_image_test:0', which has shape '(2, 3, 256, 256)'

Here's submit_config.txt:

{ 'ask_confirmation': False,
'batch_size': 32,
'batch_size_test': 2,
'host_name': 'localhost',
'image_size': 256,
'num_gpus': 2,
'print_info': False,
'run_desc': 'stylegan-encoder-2gpu-256x256-ffhq',
'run_dir': 'results/00006-stylegan-encoder-2gpu-256x256-ffhq',
'run_dir_extra_files': None,
'run_dir_ignore': ['pycache', '.pyproj', '.sln', '*.suo', '.cache', '.idea', '.vs', '.vscode', 'results', 'datasets', 'cache'],
'run_dir_root': 'results',
'run_func_kwargs': { 'D_loss_args': {'func_name': 'training.loss_encoder.D_logistic_simplegp', 'r1_gamma': 10.0},
'D_opt_args': {'beta1': 0.9, 'beta2': 0.99, 'epsilon': 1e-08},
'E_loss_args': {'D_scale': 0.08, 'feature_scale': 5e-05, 'func_name': 'training.loss_encoder.E_loss', 'perceptual_img_size': 256},
'E_opt_args': {'beta1': 0.9, 'beta2': 0.99, 'epsilon': 1e-08},
'Encoder_args': {'func_name': 'training.networks_encoder.Encoder'},
'dataset_args': {'data_test': '/root/datasets/custom/custom-r07.tfrecords', 'data_train': '/root/datasets/custom/custom-r08.tfrecords'},
'decoder_pkl': {'decoder_pkl': '/root/network-snapshot-015800.pkl'},
'lr_args': {'decay_rate': 0.8, 'decay_step': 3390, 'learning_rate': 0.0001, 'stair': False},
'max_iters': 13562,
'mirror_augment': True,
'tf_config': {'rnd.np_random_seed': 1000}},
'run_func_name': 'training.training_loop_encoder.training_loop',
'run_id': 6,
'run_name': '00006-stylegan-encoder-2gpu-256x256-ffhq',
'submit_target': <SubmitTarget.LOCAL: 1>,
'task_name': 'root-00006-stylegan-encoder-2gpu-256x256-ffhq',
'user_name': 'root'}

The command line parameters I used are:

python train_encoder.py ~/datasets/custom/custom-r08.tfrecords ~/datasets/custom/custom-r07.tfrecords ~/network-snapshot-015800.pkl --num_gpus 2

Can't Interpolate Non-Face Images

When I upload an image of the Eiffel Tower, i get the following:

IndexError                                Traceback (most recent call last)

<ipython-input-6-3463c31d9724> in <module>()
     24 if uploaded:
     25   src_image_name = list(uploaded.keys())[0]
---> 26   src_image = align(inverter, src_image_name)
     27   if src_image.shape[2] == 4:
     28     src_image = src_image[:, :, :3]

1 frames

<ipython-input-3-3730a37eebf4> in align(inverter, image_path)
    204   """Aligns an unloaded image."""
    205   aligned_image = align_face(image_path,
--> 206                              align_size=inverter.G.resolution)
    207   return aligned_image
    208 

<ipython-input-3-3730a37eebf4> in align_face(image_path, align_size)
    179   model = FaceLandmarkDetector(align_size)
    180   face_infos = model.detect(image_path)
--> 181   face_infos = face_infos[0]
    182   img = model.align(face_infos)
    183   return img

IndexError: list index out of range

I'm running the code using colab.

Encoder train on crawled face or FFHQ

Thanks for your great work. I have run your repo and notice that, the inverted result on your example and image generate by pretrain stylegan generator is good, but when running on random image from the internet, the result is really bad. Is your encoder train on FFHQ or some random image from internet. In addition, the example image in your repo is random or take from your training set on encoder network. Thanks you.

about the W space

I want to konw the details about the W space in the paper , It's W+ in the image2stylegan or just W?

Problems about training encoder

We have applied the train_encoder.py file for other datasets with the provided settings. But we got image with nan value after several steps. Have you met such a problem?

Another question about loading encoder is that when we load the pretrained weights of the network file (face_256x256) you provided, the process stuck at line ", recon, adv_ = sess.run([E_train_op, E_loss_rec, E_loss_adv], feed_dict)". Also, we met "v10: {'is_template_graph': False, 'components': {}}" when constructing the graph.

How to preprocess LSUN?

Hi Yujun @ShenYujun. Facial images need to be aligned first. But I don't know how to preprocess LSUN's images. Directly resizing them to 256 x 256?

About resolution in styleGAN

Thanks for your great work. When you train styleGAN, which resolution is selected as the highest resolution? 256 or 1024?

Details about training the encoder

Thank you for your great work!! That'cool!!
I would like to ask, do you mean to train the Encoder with the FFHQ dataset, and then use 7000 real face images for testing? May I share the 7000 real face images you collected?I would appreciate it very much if you could give more details about encoder training. Thanks very much!

several errors on train_encoder

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 training_loop
, 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)

  1. 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.

Training an encoder using pretrained StyleGAN

Hi,

I wanted to ask if there are any pretrained models linked with this repository that do not include the encoder. The one linked with the repository readme ("styleganinv_face_256.pkl") has an encoder as well and when I use it for the train_encoder,py script, it unpacks 4 values (E, G, D, Gs) whereas in the code (training_loop_encoder.py - line 122), it expects 3 values (G,D,Gs). I fixed it by changing training_loop_encoder.py - line 122
from:
G, D, Gs = misc.load_pkl(decoder_pkl.decoder_pkl)
to:
_, G, D, Gs = misc.load_pkl(decoder_pkl.decoder_pkl)

However, I am not sure if there are other models available that fit with the original code. I would appreciate any comments regarding this. Thank you.

About the training of Encoder: approx. training time needed to successfully reconstruct the real image

Thank you for your great work!

I am training the encoder for my own dataset with the default hyperparameters.

However, in the early stage (~160 kimgs), the adv loss seems to dominate the recon loss (the reconstructed images are meaningful but related to the encoded images).

I would like to know what is the training time needed (or trained kimgs needed) to see the reconstructed images to start to look similar to the encoded images, empirically?

If not, what is the possible issue to cause that?

Thank you!

CUDA, cuDNN and NCCL versions

Hi,

I am using 2 Tesla v100s. My program gets killed when using mode than 1 gpu.
Screenshot 2021-05-07 082333

When using 8 Tesla_t4, it gets killed as well (with some memory errors which were removed by allowing growth and limiting memory fraction)
Screenshot 2021-05-06 174203

My guess is it could be due to incompatibility issues. Which version of CUDA, cuDNN and NCCL versions are you using for your implementation? I am currently using:

  • CUDA-11.0
  • cuDNN 7.0.6-cuda-10.1
  • NCCL 2.9.6-1/cuda-10.2

Any help would be appreciated.

Regards,

colab issue

EOFError Traceback (most recent call last)
in ()
1 inverter = build_inverter(model_name, iteration=100,
----> 2 regularization_loss_weight=0)
3 output.clear()
4 print('Upload the target image you want to diffuse or use the default image by clicking Cancel upload button.')
5 uploaded = files.upload()

7 frames
/usr/local/lib/python3.6/dist-packages/torch/serialization.py in _legacy_load(f, map_location, pickle_module, **pickle_load_args)
753 "functionality.".format(type(f)))
754
--> 755 magic_number = pickle_module.load(f, **pickle_load_args)
756 if magic_number != MAGIC_NUMBER:
757 raise RuntimeError("Invalid magic number; corrupt file?")

EOFError: Ran out of input

Same idea with StyleGAN-Encoder repo?

Thanks for your work. The motivation is really inspiring, but I have two questions:

  1. The pipeline of your work is really similar to StyleGAN-Encoder. Can you explain the difference?

  2. In-domain is an insightful idea, but I cannot get how you invert the image to the semantic-adaptive domain. Using the domain-guided encoder? However, I think that it can only push the inverted image to be realism enough but is unable to ensure the semantic-adaptive characteristic since no explicit or implicit semantic-related constraints are applied. In other words, it indeed conducts the same thing with previous works, i.e., Image2StyleGAN.

train model for different $w$

Thank you for your great work. I have a simple question.

In the training section, you mention that 'change repleated $w$ for all layers to different $w$s'. There are a few pretrained models in stylegan which use repleated $w$, could I just adapt the weights from them or I need to retrain the model?

Thank you for your help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.