InterDigitalInc / latent-transformer

Official implementation for paper: A Latent Transformer for Disentangled Face Editing in Images and Videos.
https://arxiv.org/abs/2106.11895
Other
143 stars 22 forks source link

How to get negative attribute direction #10

Closed shartoo closed 7 months ago

shartoo commented 7 months ago

I tranined the network with some other version of StyleGAN and produce some good result, it transform postive attribute defined by CelebA-HQ(40 attributes,such Bald, Male) very well. But how can i transform image by the negative attributes direction,namely Male to Female? Your code show some example as below in test.py

w_1 = trainer.T_net(w_0.view(w_0.size(0), -1), alpha.unsqueeze(0).to(device))
w_1 = w_1.view(w_0.size())
w_1 = torch.cat((w_1[:,:11,:], w_0[:,11:,:]), 1)
x_1, _ = trainer.StyleGAN([w_1], input_is_latent=True, randomize_noise=False)

if alpha is negative value ,it transform image by negative attribute direction,but such kind of tranform will result in very bad image.

Source image

3_Male_4

To negative Male (Female)

3_Male_0

To Postive No_Beard 3_No_Beard