harskish / ganspace

Discovering Interpretable GAN Controls [NeurIPS 2020]
Apache License 2.0
1.78k stars 264 forks source link

Manipulating my own npy file #26

Closed ahmetdadak closed 3 years ago

ahmetdadak commented 3 years ago

Hello Sir, I am a newbie. I am trying to manipulate (changing smile, age, gender...) an image encoded by StyleGAN2 (using pixel2style2pixel). I have a .npy file (shape (18,512)). I want it to manipulate using your repository but I don't know how to do it. Is there a way to do so?

harskish commented 3 years ago

notebooks/figure_teaser.ipynb is a good place to start. The line w = [w]*model.get_max_latents() creates a list of 18 (1,512) vectors, which matches what you have. The editing itself is just applying offsets individually to each of the 18 layers:

for l in range(start, end):
    w[l] = w[l] + lat_comp[idx]*lat_std[idx]*delta

In order to find the component indices (idx) and layer ranges (start, end), you'd have to use one of our exploration tools, either interactive.py or the Colab Notebook

One thing to keep in mind is that, for common edits such as smile or gender, you might be better off using supervised methods such as InterFaceGAN . Our approach is best suited for exploring new datasets and finding uncommon edits.