You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yes.
you just need to change this line to your encoder to return W+ latent code of your face image, or directly load your W+ latent code to replace instyle:
Thank you for the quick reply. As I understand when use_res is set to True the generator should return the reconstructed. I did this and the image returned from generator is very different from the encoded one. What might be the reason?
This is the result of encoding:
This is the result after feeding the W+ latent code to generator with input_is_latent=True, z_plus_latent=False and use_res=False
Have you tried directly using StyleGAN (generator.generator) with instyle as input?
Another possible reason is that your encoder might optimize both the latent input and the nosie input.
So you might have to set the noise the same as what you get from your encoder.
I have added wplus encoder.
You can specify --wplus to use the original pSp encoder to extract the W+ intrinsic style code, which may better preserve the face features of the content image.
If you use a new encoder, that returns an optimized style code instyle1 and an optimized noise noise1, you need to use
Because you post questions under this issue Changing the encoder, and you quote me reply to Karllas in your first question,
I assume you want to know how to replace the encoder with a new one (ReStyle/HyperStyle) as the first poster Karllas.
Activity
williamyang1991 commentedon May 23, 2022
Yes.
you just need to change this line to your encoder to return W+ latent code of your face image, or directly load your W+ latent code to replace
instyle:DualStyleGAN/style_transfer.py
Lines 103 to 104 in 64285b1
And then here set
input_is_latent=Trueandz_plus_latent=Falseto indicate your instyle is W+ latent code rather than Z+ latent code.DualStyleGAN/style_transfer.py
Lines 126 to 127 in 64285b1
Karllas commentedon May 23, 2022
Thank you for the quick reply. As I understand when use_res is set to True the generator should return the reconstructed. I did this and the image returned from generator is very different from the encoded one. What might be the reason?
williamyang1991 commentedon May 23, 2022
You should use False to only use the intrinsic path to reconstruct the image
DualStyleGAN/model/dualstylegan.py
Line 97 in 64285b1
Karllas commentedon May 23, 2022
This is the result of encoding:


This is the result after feeding the W+ latent code to generator with input_is_latent=True, z_plus_latent=False and use_res=False
williamyang1991 commentedon May 23, 2022
You need to set
args.truncation=1to use the original intrinsic style codeDualStyleGAN/style_transfer.py
Lines 126 to 127 in 64285b1
Karllas commentedon May 23, 2022
The generator's result is still different. How to keep as much identity of the face when applying some style?

williamyang1991 commentedon May 23, 2022
If you use
DualStyleGAN should act the same as StyleGAN
Have you tried directly using StyleGAN (generator.generator) with
instyleas input?Another possible reason is that your encoder might optimize both the latent input and the nosie input.
So you might have to set the noise the same as what you get from your encoder.
Karllas commentedon May 24, 2022
It worked. Thank you!
3maoyap commentedon Jun 6, 2022
What encoder did you change and did it work well?
weiweiecho commentedon Jul 13, 2022
hi ,what did you do to make it work
weiweiecho commentedon Jul 18, 2022
@Karllas hi ,what did you do to make it work?
watertianyi commentedon Mar 11, 2023
Can you talk about how to modify the code, it is not easy to understand here?
williamyang1991 commentedon Mar 11, 2023
I have added wplus encoder.
You can specify
--wplusto use the original pSp encoder to extract the W+ intrinsic style code, which may better preserve the face features of the content image.If you use a new encoder, that returns an optimized style code
instyle1and an optimized noisenoise1, you need to usefor precise reconstruction.
watertianyi commentedon Mar 13, 2023
如果你使用一个新的编码器,返回一个优化的样式代码instyle1和一个优化的噪声noise1,你需要使用
img_gen, _ = generator([instyle1], None, input_is_latent=True, z_plus_latent=False, noise=noise1, randomize_noise=False,
truncation=1, truncation_latent=0, use_res=False)
新的编码器跟噪声这是哪里来的
@williamyang1991
williamyang1991 commentedon Mar 13, 2023
This issue's title is "Changing the encoder"
And in the first pose, you can find the new encoder link
watertianyi commentedon Mar 13, 2023
@williamyang1991 你的意思是将psp编码器换成上述两个编码器中的一个吗
williamyang1991 commentedon Mar 13, 2023
Because you post questions under this issue
Changing the encoder, and you quote me reply to Karllas in your first question,I assume you want to know how to replace the encoder with a new one (ReStyle/HyperStyle) as the first poster Karllas.