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

domain translation using latents #45

Closed
Axelsalamartin opened this issue Jun 17, 2020 · 1 comment
Closed

domain translation using latents #45

Axelsalamartin opened this issue Jun 17, 2020 · 1 comment

Comments

@Axelsalamartin
Copy link

Is it possible to easily translate a source image from one domain to another using latent and not ref images?

I see a fucntion translate_using_latent(nets, args, x_src, y_trg_list, z_trg_list, psi, filename): in utils.py (line 78) but it is never used and I am not sure of how "y_trg_list" and "z_trg_list" are supposed to be.

@Axelsalamartin
Copy link
Author

In the end I managed to make it work easily by using the translate_using_latent() located in utils.py :

I used it in the sample function located in Solver.py (line 174).
I replaced :

  • utils.translate_using_reference(nets_ema, args, src.x, ref.x, ref.y, fname) (line 186)
    by :
  • utils.translate_using_latent(nets_ema, args, src.x, [torch.ones(src.x.size(0)).long().to('cuda')],[torch.randn(src.x.size(0), 16).to('cuda')], .5, fname)

so [torch.ones(src.x.size(0)).long().to('cuda')] is the y_target list, here it is all ones so all source images will be change to the domain 1 which is 'male' in the case of the celeb A pretrained network.

[torch.randn(src.x.size(0), 16).to('cuda')] is the list of latent vector that'll be used in the mapping_network alongside the y_target list to get the styles which will be used in the generator with the source images to generate the fake images.

The best way would be to then create a function sample_with_latent in Solver.py but this was just to make it work really quickly :)

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

1 participant