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

how to get the npy file of w_plus? #13

Open
snow1929 opened this issue Sep 18, 2022 · 14 comments
Open

how to get the npy file of w_plus? #13

snow1929 opened this issue Sep 18, 2022 · 14 comments

Comments

@snow1929
Copy link

how to get the npy file of w_plus?

@betterze
Copy link
Owner

We use e4e encoder to invert real images into w+ space. We provide pretrained e4e models for FFHQ512, FFHQ512_dog, FFHQ512_dog_cat in here.

Please clone the e4e repo and download the pretrained models, and run

python scripts/inference.py \
--images_dir=/path/to/images/directory \
--save_dir=/path/to/saving/directory \
path/to/checkpoint.pt 

in e4e folder. The w_plus latent codes will be in the save_dir. Then you just need to save the torch file to npy file.

@snow1929
Copy link
Author

@betterze
Thanks you for explaining the code of model.
As I try to run the code
There is an error happened.
But I have no idea how to fix it.
Would you please give me some suggestion for dealing it ?

python3 projector_z.py --outdir=./example/dog/  --target=./example/dog/ --network=./checkpoint/ffhq512_dog.pkl

image

@snow1929
Copy link
Author

I run the sample code on colab
And the error of tensor is happend
Is there anything wrong?
image

@betterze
Copy link
Owner

@snow1929 which tensorflow version you are using? I use 1.14

@snow1929
Copy link
Author

snow1929 commented Sep 28, 2022

I use tensorflow 1.15
image
I try to change the version of tensorflow and run it again.
thank you

@betterze
Copy link
Owner

I run the sample code on colab And the error of tensor is happend Is there anything wrong? image

This error is related to the environment (gcc). Pls install the environment following stylegan2-ada.

@snow1929
Copy link
Author

snow1929 commented Oct 1, 2022

Hi @betterze ,
I have already check the source of image.
All of the image is 512x512.
Thus, I have no idea how to fix this trouble.

image

Traceback (most recent call last):
  File "Compare.py", line 89, in <module>
    main()
  File "Compare.py", line 79, in main
    out=np.concatenate([imgs,invert,target],axis=1)
  File "<__array_function__ internals>", line 6, in concatenate
ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 2, the array at index 0 has size 512 and the array at index 2 has size 256

@betterze
Copy link
Owner

betterze commented Oct 1, 2022

Would you mind printing the shape of [imgs,invert,target] separately?

@snow1929
Copy link
Author

snow1929 commented Oct 1, 2022

name = ['flickr_dog_000043.jpg', 'flickr_dog_000045.jpg', 'flickr_dog_000054.jpg', 'flickr_dog_000059.jpg']
imgs_shape= (512, 512, 3)
invert_shape= (512, 512, 3)
target_shape= (256, 256, 3)

image

@betterze
Copy link
Owner

betterze commented Oct 1, 2022

The target images are in shape (256,256), rather than (512, 512). So it causes the error.

@betterze
Copy link
Owner

betterze commented Oct 1, 2022

Which target model (target_pkl) you are using?

@snow1929
Copy link
Author

snow1929 commented Oct 1, 2022

I choose the model of "stylegan2-ffhq512_dog_cat-config-f.pkl" as target_pkl!!
image

@betterze
Copy link
Owner

betterze commented Oct 1, 2022

The images in the target_path are in (256, 256), could you doublecheck this. Go to the folder and check the image size.

Remove all images in the target_path, and rerun

python I2I.py --network $target_pkl \
  	      --source_path $source_path \
  	      --target_path $target_path	


python Compare.py --source_img_path $source_img_path \
  	      --source_path $source_path \
  	      --target_path $target_path \
  	      --save_path $compare_html 

@snow1929
Copy link
Author

snow1929 commented Nov 9, 2022

@betterze
If I want to use e4e encoder to invert real images into w+ space with my own dataset.

how to get "checkpoint.pt"

I have to finished the prtrained model by [e4e encoder]?
Or, can I invert the stylegan-ada prtrained model to pt filetype?
how to do it?

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

2 participants