Code Monkey home page Code Monkey logo

Comments (4)

williamyang1991 avatar williamyang1991 commented on May 30, 2024
  1. Could you share how you modified pSp encoder with Z+?
    I could not find the details in the paper and codes.
    It seems you didn't use VAE encoder of the AgileGAN and also didn't inference Z mean and Z standard.
    The modification of pSp encoder is only passing output (Z+) of pSp encdoer to mapping layer indviually? Am I right?

Yes, the encoder just maps the input image to Z+ output without using VAE.

  1. How did you train the pSp encoder with Z+? Or you used the pretrained pSp encoder model directly?

(I) I modify the stylegan model (pSp decoder) so that it accepts Z+ input:

z_plus_latent=False,
):
if not input_is_latent:
if not z_plus_latent:
styles = [self.style(s) for s in styles]
else:
styles_ = []
for s in styles:
style_ = []
for i in range(s.shape[1]):
style_.append(self.style(s[:,i]).unsqueeze(1))
styles_.append(torch.cat(style_,dim=1))
styles = styles_

(2) I modify pSp encoder so that it passes the options z_plus_latent and return_z_plus_latent to the pSp decoder

def forward(self, x, resize=True, latent_mask=None, input_code=False, randomize_noise=True,
inject_latent=None, return_latents=False, alpha=None, z_plus_latent=False, return_z_plus_latent=True):

images, result_latent = self.decoder([codes],
input_is_latent=input_is_latent,
randomize_noise=randomize_noise,
return_latents=return_latents,
z_plus_latent=z_plus_latent)

and return Z+
if return_latents:
if z_plus_latent and return_z_plus_latent:
return images, codes

(3) I modify the function train() and validate() of coach.py in the official pSp code, so that it passes our training option opts.z_plus_latent to the pSp model.

  • changing Line 91 to y_hat, latent = self.net.forward(x, return_latents=True, z_plus_latent=self.opts.z_plus_latent)
  • changing Line 135 to y_hat, latent = self.net.forward(x, return_latents=True, z_plus_latent=self.opts.z_plus_latent)

(4) Finally, I train pSp from scratch using the following training settings:

python scripts/train.py \
--dataset_type=ffhq_encode \
--exp_dir=./logs/ffhq_encoder_zplus/ \
--workers=4 \
--batch_size=8 \
--test_batch_size=8 \
--test_workers=8 \
--val_interval=2500 \
--save_interval=5000 \
--encoder_type=GradualStyleEncoder \
--start_from_latent_avg \
--lpips_lambda=0.8 \
--l2_lambda=1 \
--id_lambda=0.1 \
--z_plus_latent

Hope this solves your questions.

from dualstylegan.

kasim0226 avatar kasim0226 commented on May 30, 2024

Thank you for your clear reply!

from dualstylegan.

Abhishekvats1997 avatar Abhishekvats1997 commented on May 30, 2024

@williamyang1991 are the changes you suggested to the psp decoder (stylegan) and psp code both to be made in the original psp code repo and then train ? In order to obtain the z plus encoder

from dualstylegan.

williamyang1991 avatar williamyang1991 commented on May 30, 2024

@williamyang1991 are the changes you suggested to the psp decoder (stylegan) and psp code both to be made in the original psp code repo and then train ? In order to obtain the z plus encoder

Yes, I modify both the encoder and decoder.

from dualstylegan.

Related Issues (20)

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.