id-gan-pytorch
id-gan-pytorch copied to clipboard
interpolate
Hi, I want to know how get the sample_interpolate.png as you showed, need to train a direction vector, right? thanks
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
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 Thanks for your reply, I will have a try again.