id-gan-pytorch icon indicating copy to clipboard operation
id-gan-pytorch copied to clipboard

interpolate

Open Young1403 opened this issue 6 years ago • 3 comments

Hi, I want to know how get the sample_interpolate.png as you showed, need to train a direction vector, right? thanks

Young1403 avatar Apr 02 '20 06:04 Young1403

as the paper said, I generate samples by modifying values of each dimension in the disentangled latent code c while fixing the rest, but person's identity changes a lot, not seem to be the same person

Young1403 avatar Apr 03 '20 03:04 Young1403

I have used code like this:

i = 14 # index of latent variable

with torch.no_grad():
    noise = torch.randn(1024, 512 + 20).to('cuda')
    latent_mean = g_ema.get_latent(noise).mean(0)

with torch.no_grad():
    vae_in = torch.randn(1, 20).to('cuda').repeat(8, 1)
    vae_in[:, i] = torch.linspace(-3, 2, 8)
    noise_in = torch.randn(8, 512).to('cuda')
    noise_in = noise_in.view(1, 8, 512).repeat(8, 1, 1).transpose(0, 1).reshape(64, -1)
    gen_in = torch.cat([noise_in, vae_in.repeat(8, 1)], 1)
    img, _ = g_ema([gen_in], truncation=0.7, truncation_latent=latent_mean)

rosinality avatar Apr 03 '20 05:04 rosinality

@rosinality Thanks for your reply, I will have a try again.

Young1403 avatar Apr 03 '20 06:04 Young1403