anvoynov / GANLatentDiscovery

The authors official implementation of Unsupervised Discovery of Interpretable Directions in the GAN Latent Space
416 stars 52 forks source link

how to check the results after training? #7

Closed eps696 closed 4 years ago

eps696 commented 4 years ago

i've completed the training on my stylegan2 model, and would like to explore the results - could you describe how to do that? how many directions have been found, how to check them explicitly, etc.?

provided jupyter notebook gives very little clues about that, it shows only your hand-picked results.

anvoynov commented 4 years ago

Hi @eps696, once the training completed, the run_train.py script generates interpolation charts for each direction and three randomly sampled latents: https://github.com/anvoynov/GANLatentDiscovery/blob/master/run_train.py#L94 it saves images to <out_dir>/charts_s* with two different scale amplitudes. Apparently, this is the easiest way to inspect the learned directions.

The jupyter notebook is quite universal, there is no hand-picked constant. It only shows how to load and inspect the provided pretrained models. Once you want to use it for your run, you should update the passes in load_from_dir call in the first block. The second block visualizes interpolations along a direction inspection_dim for different latents. Just replace inspection_dim = annotated[0] with an assign to a desired direction index.

eps696 commented 4 years ago

@anvoynov thank you very much for prompt response. so, i load all found vectors/directions as

for i in range(512):
    interpolation_deformed = interpolate(G, zs[i].unsqueeze(0), .. dim=i, deformator=deformator)

and look for those directions which make visual disentagled sense, right?

anvoynov commented 4 years ago

Yes, though (imho) it seems better to fix the latents zs for all directions.

eps696 commented 4 years ago

ah indeed, thanks for advice. btw, is it max_latent_ind that defines the amount of searched directions (K from the paper)? (i've tested the code on StyleGAN2 model, and it explored 512 directions by default)

eps696 commented 4 years ago

pardon me, seems i've been looking at some obsolete code; found directions_count param on new updates

anvoynov commented 4 years ago

Yes, after the recent commit max_latent_ind is directions_count once other parameters are default.