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

saving PTI latent vector w projection to npz file #24

Closed
johndpope opened this issue Aug 19, 2021 · 2 comments
Closed

saving PTI latent vector w projection to npz file #24

johndpope opened this issue Aug 19, 2021 · 2 comments

Comments

@johndpope
Copy link

johndpope commented Aug 19, 2021

Is this achievable? I want to take result and throw it in here - https://github.com/l4rz/stylegan2-clip-approach

Or is this misguided...it's going to destroy the heart of soul of this repo? When I run the projections from pytorch stylegan2-ada the interpretation is crap. not as good as this repo...

@johndpope johndpope changed the title saving PTI projection to npz file saving PTI latent vector w projection to npz file Aug 19, 2021
@danielroich
Copy link
Owner

danielroich commented Aug 21, 2021

hey @johndpope,
Of course! all you need to do is to use "w_pivot_tensor.cpu().detach().numpy()" and then save it as npz using the savez function from numpy. You can find more details about the usage here

Notice that PTI already outputs the new generator and the corresponding W vectors. In order to achieve what you are asking you need to add a saving operation for the npz output format and add a new output format for the generator. Currently is saved in the classic torch format without pickling ( I have used torch.save() to save the tuned generator).

Another option if you want free-text guided editing is to borrow inspiration from StyleCLIP Optimization. Usage demo can be found here.

In general - you can bypass outputting .npz file and pickling the generator by just changing the input format of the given github repositories. It might be easier (even though both methods should not take a long time)

I have already experimented with free-text editing + PTI. The results were truly amazing, the downside was the sensitivity of those methods to the hyperparameters.

@johndpope
Copy link
Author

johndpope commented Aug 26, 2021

UPDATE - LATEST.
npz

so tacking this on to end of notebook gets the data in correct format. Thanks!

plot_image_from_w(w_pivot, new_G)
np.savez(f'projected_w.npz', w=w_pivot.cpu().detach().numpy())

some of my notes here
https://gist.github.com/johndpope/c5b77f8cc7d7d008be7f15079a9378bf

so I get the npz file

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