Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use Multi-Code method for StyleGAN? #3

Open
zhufeida opened this issue Apr 9, 2020 · 8 comments
Open

How to use Multi-Code method for StyleGAN? #3

zhufeida opened this issue Apr 9, 2020 · 8 comments

Comments

@zhufeida
Copy link

zhufeida commented Apr 9, 2020

Hi, in derivable_generator.py, several configurations are listed. However, there is no multi-code configuration for StyleGAN. In fact, StyleGAN's design is different from pggan, where w is inserted into each middle layers of the generator by AdaIN. How to use multi-code scheme in StyleGAN scenario?

def get_derivable_generator(gan_model_name, generator_type, args):
    if generator_type == 'PGGAN-z':  # Single latent code
        return PGGAN(gan_model_name)
    elif generator_type == 'StyleGAN-z':
        return StyleGAN(gan_model_name, 'z')
    elif generator_type == 'StyleGAN-w':
        return StyleGAN(gan_model_name, 'w')
    elif generator_type == 'StyleGAN-w+':
        return StyleGAN(gan_model_name, 'w+')
    elif generator_type == 'PGGAN-Multi-Z':  # Multiple Latent Codes
        return PGGAN_multi_z(gan_model_name, args.composing_layer, args.z_number, args)
    else:
        raise Exception('Please indicate valid `generator_type`')
@yue95213
Copy link

Same issue!

@JasonGUTU
Copy link
Collaborator

Hi, @yue95213 and @zhufeida. Thank you for your question. It worth noticing that the stylegan has multi-code design natively (the style code for each layer) and the stylegan-w+ is for the inversion using these codes. Use multi-code strategy on stylegan is equivalent to an over-parameterization version of stylegan-w+ inversion. So in the released code, we recommend using stylegan-w+.

@betterze
Copy link

What parameters you are using for invert stylegan? I use

python multi_code_inversion.py --gan_model stylegan_bedroom 

--target_images ./examples/gan_inversion/bedroom 

 --outputs ./gan_inversion_bedroom2 

--inversion_type StyleGAN-w+

However, the results are not very realistic. What parameters should I use?

@JasonGUTU
Copy link
Collaborator

JasonGUTU commented Apr 20, 2020

What parameters you are using for invert stylegan? I use

python multi_code_inversion.py --gan_model stylegan_bedroom 

--target_images ./examples/gan_inversion/bedroom 

 --outputs ./gan_inversion_bedroom2 

--inversion_type StyleGAN-w+

However, the results are not very realistic. What parameters should I use?

Have you tried on face images? How does the face experiment work?
And try to use Norm initialization. The initialization method is influential for stylegan.

@Xiaomao136
Copy link

python multi_code_inversion.py
--gan_model stylegan2_ffhq
--target_images ./examples/face
--outputs ./gan_inversion_face
--composing_layer 8
--z_number 20
--iterations 3000
--inversion_type StyleGAN-w+
--init_type Normal
--optimization Adam
--loss_type VGG

Traceback (most recent call last):
File "multi_code_inversion.py", line 112, in
main(args)
File "multi_code_inversion.py", line 37, in main
latent_estimates, history = inversion.invert(generator, y_gt, loss, batch_size=1, video=args.video)
File "/content/drive/My Drive/stylegan2/source code/mganprior/inversion/inversion_methods.py", line 24, in invert
input_size_list = generator.input_size()
File "/content/drive/My Drive/stylegan2/source code/mganprior/derivable_models/derivable_generator.py", line 77, in input_size
return [(self.stylegan.net.synthesis.num_layers, 512)]
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 772, in getattr
type(self).name, name))
torch.nn.modules.module.ModuleAttributeError: 'StyleGAN2GeneratorNet' object has no attribute 'net'

@liuliuliu11
Copy link

@Xiaomao136 Hello, have you solved this bug?

@Xiaomao136
Copy link

Xiaomao136 commented Oct 9, 2020 via email

@fungtion
Copy link

@JasonGUTU using stylegan_w+ for face is still far from ideal, can you show that how to split stylegan? I did that following PGGAN-Multi-Z, but it reported error that in x = self.epilogue(x, w), the shape of w is desired to be [1, 512], but actually [1, 18, 512], I've no idea what happened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants