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

I had trained a styleGAN in my dataset, but in this ckpt, we miss the key named 'latent_avg', how to get it? #30

Closed
ssxxx1a opened this issue May 25, 2021 · 3 comments

Comments

@ssxxx1a
Copy link

ssxxx1a commented May 25, 2021

thanks.

@omertov
Copy link
Owner

omertov commented May 27, 2021

Hi @ssxxx1a.
The average latent is obtained from sampling many (usually thousands) of latent codes and averaging them to get the average code.
Usually the repositories provide a build in function for obtaining this average code, for example see this function in rosinality's repository.

After obtaining the average code, you should save it as a part of the checkpoint under the 'latent_avg' key.

Best,
Omer

@yuval-alaluf
Copy link

To add to @omertov's answer, when you initialize the network in the following lines:

# Initialize network
self.net = pSp(self.opts).to(self.device)

you can add the following snippet:

if self.net.latent_avg is None:			
    self.net.latent_avg = self.net.decoder.mean_latent(int(1e5))[0].detach()

This will estimate the average latent and store it as part of the network. Then training can continue as is normal.

@ssxxx1a ssxxx1a closed this as completed May 28, 2021
@ssxxx1a ssxxx1a reopened this May 28, 2021
@ssxxx1a
Copy link
Author

ssxxx1a commented May 28, 2021

ohhh!
thanks both for your reply !

@ssxxx1a ssxxx1a closed this as completed May 28, 2021
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

3 participants