omertov / encoder4editing

Official implementation of "Designing an Encoder for StyleGAN Image Manipulation" (SIGGRAPH 2021) https://arxiv.org/abs/2102.02766
MIT License
945 stars 154 forks source link

there is something wrong in sefa editings #51

Closed onefish51 closed 3 years ago

onefish51 commented 3 years ago

Hi. Thanks for your great work!

at first , I uesed the code and input image in colab

result1 = editor.apply_sefa(latents, indices=[2, 3, 4, 5], start_distance=0., end_distance=15.0, step=6)
result1.save('out_edit_sefa1.png')

image emmm ,I guess it edit face in pose direction .

but when I changed the input image image

it edit face in hair style!

Besides I want to edit face in other direction(Eyeglasses, Gender, Hair Color ...),so I changed indices like this :

# indices = "0-1" #@param ['all', '0-1', '2-5', '6-13']

result = editor.apply_sefa(latents, indices=[0, 1], start_distance=0., end_distance=15.0, step=3)
result.save('out_edit_sefa.png')

result1 = editor.apply_sefa(latents, indices=[2, 3, 4, 5], start_distance=0., end_distance=15.0, step=6)
result1.save('out_edit_sefa1.png')

result2 = editor.apply_sefa(latents, indices=list(range(6, 14)), start_distance=0., end_distance=15.0, step=6)
result2.save('out_edit_sefa2.png')

result3 = editor.apply_sefa(latents, indices='all', start_distance=0, end_distance=15.0, step=6)
result3.save('out_edit_sefa3.png')

result : image

image

image

image

omertov commented 3 years ago

Hi @onefish51! As SeFa decomposes the affine layers weights matrix to obtain meaningfull latent directions, they are not bound to relate to a specific semantic attribute, as opposed to the supervised methods. for example, with InterFaceGAN you can obtain an editing direction corresponding to a specific attribute (while also being able to disentangle it from other semantic attributes based on conditioning).

It seems like the edits are inconsistent accross different latent codes (this is the issue if I understand correctly), so I would suggest asking your question in SeFa's repo since the implementation here should match the official one without modifications (you can test it by using the same latent codes here and in the official repo).

Best, Omer