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

Render npy not showing correct image #8

Closed
miolamio opened this issue Jan 14, 2020 · 13 comments
Closed

Render npy not showing correct image #8

miolamio opened this issue Jan 14, 2020 · 13 comments

Comments

@miolamio
Copy link

Hi! Great work, thank you!

I was wondering if you could post an example of how to render an image from NPY file, I tried to load an image and generate it using Gs.run(latent1, None), but it seems I get another image as a result.

Thanks!

@rolux
Copy link
Owner

rolux commented Jan 14, 2020

@miolamio: I guess you'd have to show me the code you're running.

@miolamio
Copy link
Author

@rolux, I managed to render a correct image using this code here with slight modifications! All works, thank you for your support!

@WJ-Lai
Copy link

WJ-Lai commented Apr 13, 2020

@rolux, I managed to render a correct image using this code here with slight modifications! All works, thank you for your support!

Hi, could you please tell me how you did it? I encounter the same problem.
I use npy file to th generator but the image was not the same as the output image.

@Pinnh
Copy link

Pinnh commented Jul 1, 2020

It happens because optimization is not only latent but noises , when regularity of noises is small,some information is encoded in noises,the output image is produced by latent and noise, if you use only latent to generate image ,these two images are different

@robbaker292
Copy link

@Pinnh I have a similar issue. The numpy file produced by project_images.py is shape (18,512) whereas StyleGAN2 uses (1,512). Extracting each of the 18 slices all produce different images and none of these are even close to the input image.

Along with the latents, do I need to extract something else, or combine each slice in some way? I was expecting project_images.py to produce a npy array I could insert straight back into StyleGAN, but it seems not.

@woctezuma
Copy link

No. Your 18x512 array w is valid and can be fed to Gs.components.synthesis.run(). That is related to #21. Here is a Gist.

@robbaker292
Copy link

No. Your 18x512 array w is valid and can be fed to Gs.components.synthesis.run(). That is related to #21. Here is a Gist.

Thanks, that makes a bit more sense. However, I'm asking if the latents that represent that new image are available in (1,512) (perhaps as an output of synthesis?) for inserting back into the original stylegan2 code i.e. back in the images = Gs.run(z, None, **Gs_kwargs) line in run_generator.py of StyleGAN2?

@woctezuma
Copy link

woctezuma commented Sep 22, 2020

You can get a 1x512 array w (not z) with the projection procedure available in the official StyleGAN2 repository.

The 18x512 array w^+ which you obtained using the projection procedure in this repository is the result of a trick to get higher image fidelity to the target, and that is all there is to it.

@robbaker292
Copy link

Thanks. How does one convert w to z?

@woctezuma
Copy link

There is no built-in method to do so. It is an inverse problem.

@robbaker292
Copy link

Okay, well thanks for your help 👍

@woctezuma
Copy link

woctezuma commented Sep 22, 2020

For reference: https://github.com/minyoungg/pix2latent

Text
Results

@Pinnh
Copy link

Pinnh commented Sep 23, 2020

One thing that I want to mention is Latent can't encode every thing in StyleGAN, so when you do inverse optimization , there are also some distances between input image and image that generate by latent of StyleGAN, say faces' cosine similarity(CosSim), so when you use Latent and Noises to optimize the CosSim you can get even 99.5% closer to input but when you edit the latent to do the warp transform, you will find that the details are position invariant

Ref paper: Image2StyleGAN++: How to Edit the Embedded Images

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

6 participants