mmgeneration
mmgeneration copied to clipboard
Interpolate through a set of latent values?
Hi,
Is it possible to interpolate using a set of differant latent variables, rather then as it currently does which is I'm guessing random endpoints.
I can see that from the styleGAN projector that you can get the latent_n value from a specified image. If I was to save this value is it possible to use it somehow within the interpolate_sample.py code. I would like to generate a series of images which are the interpolations between N+ images form the training set (in this case use closest latent_n).
I was just curious if anyone knew of a good way to do it :)
Hi @cdrwolfe, it's a good issue. To quickly implement your work, you can use the sample_from_path
function in interpolate_sample.py
and pass the projected latents into lantent_a
and latent_b
. Also, I will support interpolation between saved latents soon.
Cheers!,
I've implemented a hack using as you described using the two latents a and b. I just have one or two questions.
The latent_n from my point of view is saved for each image to a .pt so i can use later. It seems to be a [3,512] tensor and using the above approach if i interpolate between two latents and save their images. Lookig at line+ 229 of interpolate_sample.py:
results = results.reshape(-1, ch, h, w)
For a 50 interval interpolation...
When i run it using my latents this approach basically flattens the [3, 50, 3, 512] into a [150, 3, 512] or 150 images, where each 50 is a sequence of latent_a to latent_b. Using the standard interpolate_sample.py it seems I don't get this, which is what i want, instead i get basically 3 X the number of images of the same thing, (interpolation between latents a and b).
Why does the latent [3,512] seem to have 3 latent codes which are then used to create 3 differant versions of the same thing? I thought perhaps I should take the 3 sets of images and try and get their mean for a combiend single set of images, but couldn't figure out how :).
Anyrate I look forward to your solution :)
I have added this function in #167 . You can use stylegan_projector.py
to produce projection file. Then just add --proj-latent xxx/project_result.pt
at the end of interpolation command line. I'm sorry for adding this function a little late.