Skip to main content
. 2022 Jan 21;15:785808. doi: 10.3389/fnbot.2021.785808

Algorithm 1.

Training ShapeEditor using gradient descent.

Input:
     Iattr: Image containing attribute information
     Iid: Image containing identity information
     P: Identity-attribute image pair space
Functions:
     Encoder ShapeEditor:P W+
     Generator G:W+I
     LossLid: Calculate the identity loss between Iid and Iout.
     LossLattr: Calculate the attribute loss between Iattr and Iout.
     LossLrec: Calculate the reconstruction loss between Iid(Iattr) and Iout.
Output:
     I: Image space
     W+: Potential vector space of StyleGAN
     Iout: Synthesized face-swapping image
1:       for number of training iterations do:
2:            for Iid, Iattr randomly selected in training dataset do:
3:                 Generate the W+ space vector using [Iid, Iattr]
4:                      ShapeEditor:P W+
5:                 Generate the face-swapping image Iout using the W+ space vector
6:                           G:W+I
7:                 Calculate the identity loss Lid, the attribute loss Lattr, and the reconstruction loss Lrec
8:                 Update ShapeEditor with loss
9:            end
10:  end.