# Deep Realistic Facial Editing via Label-restricted Mask Disentanglement

Authors: Jiaming Song; Fenghua Tong; Zixun Chen
Journal: Computational Intelligence and Neuroscience
 (2022)

---

## Abstract

With the rapid development of GAN (generative adversarial network), recent years have witnessed an increasing number of tasks on reference-guided facial attributes transfer. Most state-of-the-art methods consist of facial information extraction, latent space disentanglement, and target attribute manipulation. However, they either adopt reference-guided translation methods for manipulation or monolithic modules for diverse attribute exchange, which cannot accurately disentangle the exact facial attributes with specific styles from the reference image. In this paper, we propose a deep realistic facial editing method (termed LMGAN) based on target region focusing and dual label constraint. The proposed method, manipulating target attributes by latent space exchange, consists of subnetworks for every individual attribute. Each subnetwork exerts label-restrictions on both the target attributes exchanging stage and the training process aimed at optimizing generative quality and reference-style correlation. Our method performs greatly on disentangled representation and transferring the target attribute’s style accurately. A global discriminator is introduced to combine the generated editing regional image with other nonediting areas of the source image. Both qualitative and quantitative results on the CelebA dataset verify the ability of the proposed LMGAN.


---

## Body

## 1. Introduction

The feature of a facial attribute, also known as style, consists of its characteristic of texture and structure. At present, the approaches to accomplishing exemplar-based facial attribute transfer tasks generally fall into three main categories: exchange of latent feature methods; style injecting methods; and geometry-editing methods. The attributes transfer is tackled by exchanging the disentangled representation at latent space in the first method. GeneGAN [1] especially maps the attribute-related information into one latent block, first, realizing single attribute transfer. On this basis, some methods [2, 3] take pairs of images with the adverse attributes as input, utilizing an improved approach of encoding multiple attributes into corresponding predefined latent blocks, regarding them as carriers for transfer. In these methods, an iterative training strategy which traverses overall target attributes is used to make a simultaneous transfer of multiple attributes successfully. However, due to the discreteness of this strategy and the low-robustness of pairs of adverse-attribute images input ideas, such methods demonstrate the inability of modeling the disentangled representation of various facial attributes simultaneously, which leads to the unexpected transfer of attribute-excluding details from the reference image into the source. Besides, the style of the target attribute cannot be transferred exactly, either.The second method adopts label-based image-to-image translation, which trains various subnetworks to learn the specific mapping into latent space. For mutiattributes task, some methods transfer the attribute’s style by exerting semantic or labeled restrictions on the translator [8–11]. Other methods solve the multistyle problem during attribute transfer by extracting Gaussian noise. In order to tackle both tasks at once [12], StarGANv2 proposed learning the mixed style by indexing the mapped-style code using the target label, injecting the style code into the source image for translation, and realize the conversion of different domains [13]. HiSD proposed a hierarchical style structure and introduced random noise for training, so as to realize style transfer and semantic control on specified attributes. With the high independence of different subnetworks, although excellent representation translation can be achieved within the label domains, there still exists style deviation and loss of structural information from the reference image attributes. Geometry editing methods extract local information of an attribute from the ROI (Region of Interest) of the reference image and inject it into the user-edited region of the source image to fulfil realistic attribute transfer. But such methods of multiattribute layout editing using region guidance are fairly inconvenient for users. Based on these studies, the transfer method focusing on the attribute-edited regions is adopted in our proposed LMGAN.In this paper, we propose an attribute transfer method based on processing local editing region with mask and dual label constraint (LMGAN), aimed at achieving accurate multistyle attribute transfer under the condition of the source’s attribute-excluding features being consistent. As shown in Figure1, for transfer multiple [21] attributes i simultaneously (e.g. ∈g,m, representing ′Eyeglasses′ and ′Mouthslightlyopen′ ), A, B are source image and exemplar image labeled as `without’ tag ygA,ymA and `with’ tag ygB,ymB respectively. Mi is the local editing region of corresponding attribute need to be input into the independent encoder Enci, we predefine the latent blocks extracting attribute unrelated and related information as Si and Zi, imposing label constraints on the latter (if ′ with’ label, block remains unchanged, ′ ithout’ label block is zero setting). Deci decodes the swapped constrained-blocks and embeds the generated partition image into the source. When the label is constrained dually to both the discriminator and feature blocks, the learnable label shows a concentrated effect on the extraction of the targeted style. The independent structure based on local editing regions and subnetworks cannot merely ensure the consistency of the original picture information to the greatest extent, but also accurately transfer the texture and structure related to attributes. Eliminating undesirable adverse-attribute image input and iterative training strategies, such as concise latent feature exchange tactics guarantee the images’ verisimilitude and the model’s disentanglement capability. Both qualitative and quantitative results show that the proposed model is superior to existing advanced models, performing observable achievement in the facial editing field via generating high-quality and diverse facial components. In Figure 2, we show some ideal results of our method on CelebA.Figure 1
The illustration of two facial attributes transfer regarding reference-guided method according to LMGAN. Our model can edits the ROI regions of multiple attributes meanwhile; the editing regions of different attributes could be overlapped and not limited to be standard rectangles.Figure 2
Qualitative results of LMGAN on CelebA. (a) and (b) Multistyle task with different source images and exemplars for Bangs and Eyeglasses. (c) Multiattribute task, aimed at transferring various attributes independently.In summary, the contributions of this paper are as follows:(1)
We propose a model based on editing local regions and exchanging latent features with multi-subnetworks for each individual attribute. Latent space exchange manipulation eliminates poor disentanglement effects caused by iterative training. Attribute-related region input forces the network to focus much more on the learning of target attributes.(2)
A dual-label constraint is imposed on the model. The learnable labels enable feature extraction blocks to accomplish highly attribute-related disentangled representation, instructing models to accurately generate features of attributes with identical texture and structure to the reference.(3)
Both qualitative and quantitative results demonstrate the superiority of our method compared with other state-of-the-art methods.


## 2. Related Work

### 2.1. Generative Adversarial Networks

The potential of GANs [14] is widely released and pervades various fields, especially image processing. Many methods have been used to improve the stability of GANs’ training [15–17]. Many modern tasks, including image domain conversion [4, 6, 9, 18–21], image inpainting [22–23], and semantic generation [24–29] can be implemented by GAN successfully. Inspired by these methods, we propose a new GAN-based framework that achieves facial editing via label-restricted and mask-focusing disentangled representation.


### 2.2. Facial Attribute Transfer

Early research [30–31] injected predefined simple binary tags and feature vectors into the image. However, this binary tag method shows an undesirable effect of disentanglement and extraction of information from attributes. Later, GeneGAN solved this problem by training latent feature blocks with paired images possessing adverse attributes, but the disadvantage of only one attribute being able to be exchanged is inconvenient for users expecting to achieve multiattributes transfer. DnaGAN [2, 32–36], ELEGANT [3] adopted iterative training strategy to realize the multiattribute disentangled representation but it demonstrated undesirable transferred and reconstructed effects with huge transformation of nonediting facial information and style deviation of target attribute as shown in Figure 3(a). Subsequently, the traditional image translation [4, 19, 20, 25, 26, 37–39] methods were created, but they often lead to some unnecessary outcomes, such as age, background changes, and so on. Besides, specific facial attributes with diverse styles, like Bangs and Eyeglasses, cannot be edited, respectively. HiSD further improved the quality of exemplar-based facial editing results by adding many independent subnetwork and hierarchical structures to disentanglement. However, in the attributes transfer task, the styles extracted from different reference images show high similarity reflecting in the results as seen in Figure 4. Moreover, the extracted structural characteristic style is also not inconsistent to the exemplar as in Figure 3(b).Figure 3
Different methods for transfer Eyeglasses attribute: (a) ELEGANT, encodes all features into in latent blocks and exchanges target one. (b) HiSD utilizes extractor F to acquire attribute-related style code and injects it into specific translator T. (c) Our LMGAN with concise structure.Figure 4
Qualitative comparison of LMGAN with other two baseline methods. (a) Eyeglasses. (b) Bangs. (c) Smiling.
(a)(b)(c)SMILE [25] and SEAN [26] which are based on editing users’ assigned feature region can generate realistic results. However, it is necessary to manually edit the precise mask as the input and output. The complicated operation adds great difficulty for users.The abovementioned methods cannot simultaneously take the simplicity and accuracy of attribute transfer into account based on reference images compared with our model as shown in Figure3(c).


## 2.1. Generative Adversarial Networks

The potential of GANs [14] is widely released and pervades various fields, especially image processing. Many methods have been used to improve the stability of GANs’ training [15–17]. Many modern tasks, including image domain conversion [4, 6, 9, 18–21], image inpainting [22–23], and semantic generation [24–29] can be implemented by GAN successfully. Inspired by these methods, we propose a new GAN-based framework that achieves facial editing via label-restricted and mask-focusing disentangled representation.


## 2.2. Facial Attribute Transfer

Early research [30–31] injected predefined simple binary tags and feature vectors into the image. However, this binary tag method shows an undesirable effect of disentanglement and extraction of information from attributes. Later, GeneGAN solved this problem by training latent feature blocks with paired images possessing adverse attributes, but the disadvantage of only one attribute being able to be exchanged is inconvenient for users expecting to achieve multiattributes transfer. DnaGAN [2, 32–36], ELEGANT [3] adopted iterative training strategy to realize the multiattribute disentangled representation but it demonstrated undesirable transferred and reconstructed effects with huge transformation of nonediting facial information and style deviation of target attribute as shown in Figure 3(a). Subsequently, the traditional image translation [4, 19, 20, 25, 26, 37–39] methods were created, but they often lead to some unnecessary outcomes, such as age, background changes, and so on. Besides, specific facial attributes with diverse styles, like Bangs and Eyeglasses, cannot be edited, respectively. HiSD further improved the quality of exemplar-based facial editing results by adding many independent subnetwork and hierarchical structures to disentanglement. However, in the attributes transfer task, the styles extracted from different reference images show high similarity reflecting in the results as seen in Figure 4. Moreover, the extracted structural characteristic style is also not inconsistent to the exemplar as in Figure 3(b).Figure 3
Different methods for transfer Eyeglasses attribute: (a) ELEGANT, encodes all features into in latent blocks and exchanges target one. (b) HiSD utilizes extractor F to acquire attribute-related style code and injects it into specific translator T. (c) Our LMGAN with concise structure.Figure 4
Qualitative comparison of LMGAN with other two baseline methods. (a) Eyeglasses. (b) Bangs. (c) Smiling.
(a)(b)(c)SMILE [25] and SEAN [26] which are based on editing users’ assigned feature region can generate realistic results. However, it is necessary to manually edit the precise mask as the input and output. The complicated operation adds great difficulty for users.The abovementioned methods cannot simultaneously take the simplicity and accuracy of attribute transfer into account based on reference images compared with our model as shown in Figure3(c).


## 3. Methods

The proposed LMGAN aimed to extract, disentangle, manipulate, and transfer the target attributes. The main structure is designed to cascade and couple functional blocks to realize every process, and each block is optimized by several training objectives, which are responsible for a certain function to generate high-quality images. In this section, we provide an overall introduction of our proposed framework. Then, each training objective is elaborated upon.


### 3.1. Framework

Let A and B be two-faced images withn binary attributes LA=l1A,…,lnA and LB=l1B,…,lnB. First, mask attention-focusing method [40–44] is imposed on both images, as shown in Figure 5(a). Unlike generative frameworks encoding the whole picture into latent space, we adopt a certain mask to extract the ROI for each target attribute. The masked region encompasses the essential information representing the target attribute and omits irrelevant features in the background. For tag i∈1,…,n, ROI of target attribute Ai∗ and Bi∗ is extracted from Mi, construing a high-density information container for itself.(1)Ai∗=A⊙Mi,Bi∗=B⊙Mi.Figure 5
Overall structure of LMGAN. (a) Single attribute training. (b) Multiple attributes parallel training with global discriminator to keep image overall fidelity.The background of A and B can be represented by(2)Abk=A−A⊙M1+…+Mn,Bbk=B−B⊙M1+…+Mn.The generator moduleG is introduced to disentangle features and rebuild face image. Genc and Gdec are symmetrical network structures responsible for encoding and decoding, respectively. Inspired by HiSD, we adopt separated encoder Genci where i∈1,…,n to map focused image A∗ and B∗ into latent representation:(3)EAi∗=GenciAi∗,EBi∗=GenciBi∗.EAi∗ and EBi∗ are the latent feature need to be divided into attribute-related code Zi and unrelated codeSi :(4)EAi∗=ZAi∗,SAi∗,EBi∗=ZBi∗,SBi∗,where ZAi∗,ZBi∗ forming strong representations for target attribute and SAi∗,SBi∗ represent other irrelevant ones. To ensure the transfer quality, module classifier C is utilized to manipulate the close-open of each attribute block, as shown in Figure 5(b). For attribute i∈1,…,n, classifier module maps attribute-relevant code ZAi∗,ZBi∗ into manipulated latent form:(5)Z˜Ai∗=CiZAi∗,liA,Z˜Bi∗=CiZBi∗,liB.For given binary attributesLA and, if liA=0 the code of the attribute is set zero using dot product as shown in Figure 5(a) to restrict the extracting effect. Otherwise, the attribute is turned on to keep the original generated latent code intact. Meanwhile, the same operation is done to LB. With such a method, attribute-related code is manipulated, reformed, and refined into a learnable and highly style-correlated representation. Both the reconstruction and transfer processes.Are performed in the network to guarantee the generative realism and attribute shifting validity. For the reconstruction step, the manipulated latent codeZ˜Ai∗,Z˜Bi∗ is juxtaposed with irrelevant feature code SAi∗,SBi∗ to build reconstruct latent code:(6)EAi∗′=Z˜Ai∗,SAi∗,EBi∗′=Z˜Bi∗,SBi∗.For the transfer step, manipulated latent code is exchanged:(7)EAi∗″=Z˜Bi∗,SAi∗,EBi∗″=Z˜Ai∗,SBi∗.This parallel training strategy manages to utilize disentangled features in latent space and reconstruct realistic target attributes on any other faces. Finally,Gdec maps reconstruction and transfer latent codes into target attribute facial editing region. The reconstruction images Ai∗′ and Bi∗′ are given by(8)Ai∗′=GdeciEAi∗′,Bi∗′=CdeciEBi∗′.And the transfer images Ai∗″ and Bi∗″ are given by(9)Ai∗″=GdeciEAi∗″,Bi∗″=GdeciEBi∗″.Notice that we deal with one attribute simultaneously. Forn attributes, each one is allocated a separate encoder, classifier, and decoder. In addition, the reconstruction and transfer will also be processed attribute-independently. Given a specific attribute i,Di is applied to the attention-focused image generated by Gdeci. However, no background information is extracted for Di to discriminate the image monolithically, which would lead to division around ROI. So Dg is introduced as a whole image repair module. The reconstructed image can be represented by(10)A′=Abk+A1∗′+…+An∗′,B′=Bbk+B1∗′+…+Bn∗′.And the attributes transfer image can be represented by(11)A″=Abk+A1∗″+…+An∗″,B″=Bbk+B1∗″+…+Bn∗″.Because it is insufficient to discriminate whether the image belongs to the label domain based only onDi, a classification judger Ji is replenished to tell the label of the generative image and compare it with the designed one. By the joint constraints of Di,Dg and Ji, generative network is able to transfer the target attribute with characteristic style from the exemplar to the source image.


### 3.2. Training Objectives

In order to reach the Nash balance of the integrated generative adversarial network, three losses, namely, reconstruction loss, classification loss, and adversarial loss, are combined to optimize the network.


#### 3.2.1. Reconstruction Loss

For the output image of the reconstruction path, reconstruction loss is introduced to as vital criteria for generator.(12)Lreci=∥Ai∗′−Ai∗∥+∥Bi∗′−Bi∗∥.How much the reconstruction image is familiar with the original one reflects the multifeature disentanglement performance and detail restoration degree of a model. By minimizingL1 losses, can map possibly much more detailed features embedded in attention-focusing images into latent space, and Gdec can be better instructed for reconstruction. Then, the well trained reconstruction network can be replanted in transforming target attribute and keep the generative image looks real.


#### 3.2.2. Classification Loss

Classification loss utilizes the cross entropy between the known label and theith attribute predicted by the Judger Ji to guide feature exchanging of transfer path, ensuring the transferred images possess the same attributes as the reference image. Classification loss optimizes the generator Gi as follows:(13)LclsGi=−liBlogJiAi∗″−1−liBlog1−JiAi∗″−liAlogJiBi∗″−1−liAlog1−JiBi∗″.JiAi∗″ represents the anticipated label of i -th attribute for transferred image. After exchanging attribute-related features, the transferred image is supposed to have the same label as the reference attention-focusing image. It enhances the stability of the generative network after reconstruction in the latent space while forcing the structure to revive the correct attributes.(14)LclsJi=−liAlogJiAi∗−1−liAlog1−JiAi∗−liBlogJiBi∗−1−liBlog1−JiBi∗.The Judger of each attribute is trained by optimizing the mapping network from original image to labels. By this mean,Ji is able to accurately resolve target attributes from arbitrary images.


#### 3.2.3. Adversarial Loss

The adversarial loss encourages realistic generation of encoder and decoder. On the other hand, it also optimize the estimate of discriminator. WGAN [15, 16] idea is applied to each discriminator Di the generator Gi as follows:(15)LadvGi=−EDiAi∗″−EDiBi∗″.For the generator Gi and Judger Ji, maximizing the discriminate estimation instructs them to generate images as real as possible. In addition, Ladvg is introduced to eliminate division around ROI by constraining every Gi and global discriminator Dg.(16)LadvGg=−EDgA″−EDgB″.By minimizing the difference between discriminate estimation of original image and attribute exchanged image, we keep local generatorGi under optimal functional state with good result integrated into attribute independent areas. In addition, Dg is trained by taking whole image as input.


#### 3.2.4. Full Loss

Finally, the full objective for blocksGi, Ji,Di, and Dg can be written as linear combination form:(17)minGiLGi=λ1LadvGi+λ2LclsGi+λ3Lreci,minDi,JiLD,Ji=λ4LclsJi+λ5LadvDi,λ2 and λ3 represent hyperparameters controlling the proportion of attribute classification and image reconstruction in the final generative image. The combined restriction from λ1,2,3,4,5 keeps output images identical with the original ones in target-irrelevant feature and switch attribute exactly. In addition, the following two losses regarding training the Dg the optimize the Di ‘s results, which blend perfectly with images outside the editing area.(18)minGiLadvGg,minDgLadvDg.


## 3.1. Framework

Let A and B be two-faced images withn binary attributes LA=l1A,…,lnA and LB=l1B,…,lnB. First, mask attention-focusing method [40–44] is imposed on both images, as shown in Figure 5(a). Unlike generative frameworks encoding the whole picture into latent space, we adopt a certain mask to extract the ROI for each target attribute. The masked region encompasses the essential information representing the target attribute and omits irrelevant features in the background. For tag i∈1,…,n, ROI of target attribute Ai∗ and Bi∗ is extracted from Mi, construing a high-density information container for itself.(1)Ai∗=A⊙Mi,Bi∗=B⊙Mi.Figure 5
Overall structure of LMGAN. (a) Single attribute training. (b) Multiple attributes parallel training with global discriminator to keep image overall fidelity.The background of A and B can be represented by(2)Abk=A−A⊙M1+…+Mn,Bbk=B−B⊙M1+…+Mn.The generator moduleG is introduced to disentangle features and rebuild face image. Genc and Gdec are symmetrical network structures responsible for encoding and decoding, respectively. Inspired by HiSD, we adopt separated encoder Genci where i∈1,…,n to map focused image A∗ and B∗ into latent representation:(3)EAi∗=GenciAi∗,EBi∗=GenciBi∗.EAi∗ and EBi∗ are the latent feature need to be divided into attribute-related code Zi and unrelated codeSi :(4)EAi∗=ZAi∗,SAi∗,EBi∗=ZBi∗,SBi∗,where ZAi∗,ZBi∗ forming strong representations for target attribute and SAi∗,SBi∗ represent other irrelevant ones. To ensure the transfer quality, module classifier C is utilized to manipulate the close-open of each attribute block, as shown in Figure 5(b). For attribute i∈1,…,n, classifier module maps attribute-relevant code ZAi∗,ZBi∗ into manipulated latent form:(5)Z˜Ai∗=CiZAi∗,liA,Z˜Bi∗=CiZBi∗,liB.For given binary attributesLA and, if liA=0 the code of the attribute is set zero using dot product as shown in Figure 5(a) to restrict the extracting effect. Otherwise, the attribute is turned on to keep the original generated latent code intact. Meanwhile, the same operation is done to LB. With such a method, attribute-related code is manipulated, reformed, and refined into a learnable and highly style-correlated representation. Both the reconstruction and transfer processes.Are performed in the network to guarantee the generative realism and attribute shifting validity. For the reconstruction step, the manipulated latent codeZ˜Ai∗,Z˜Bi∗ is juxtaposed with irrelevant feature code SAi∗,SBi∗ to build reconstruct latent code:(6)EAi∗′=Z˜Ai∗,SAi∗,EBi∗′=Z˜Bi∗,SBi∗.For the transfer step, manipulated latent code is exchanged:(7)EAi∗″=Z˜Bi∗,SAi∗,EBi∗″=Z˜Ai∗,SBi∗.This parallel training strategy manages to utilize disentangled features in latent space and reconstruct realistic target attributes on any other faces. Finally,Gdec maps reconstruction and transfer latent codes into target attribute facial editing region. The reconstruction images Ai∗′ and Bi∗′ are given by(8)Ai∗′=GdeciEAi∗′,Bi∗′=CdeciEBi∗′.And the transfer images Ai∗″ and Bi∗″ are given by(9)Ai∗″=GdeciEAi∗″,Bi∗″=GdeciEBi∗″.Notice that we deal with one attribute simultaneously. Forn attributes, each one is allocated a separate encoder, classifier, and decoder. In addition, the reconstruction and transfer will also be processed attribute-independently. Given a specific attribute i,Di is applied to the attention-focused image generated by Gdeci. However, no background information is extracted for Di to discriminate the image monolithically, which would lead to division around ROI. So Dg is introduced as a whole image repair module. The reconstructed image can be represented by(10)A′=Abk+A1∗′+…+An∗′,B′=Bbk+B1∗′+…+Bn∗′.And the attributes transfer image can be represented by(11)A″=Abk+A1∗″+…+An∗″,B″=Bbk+B1∗″+…+Bn∗″.Because it is insufficient to discriminate whether the image belongs to the label domain based only onDi, a classification judger Ji is replenished to tell the label of the generative image and compare it with the designed one. By the joint constraints of Di,Dg and Ji, generative network is able to transfer the target attribute with characteristic style from the exemplar to the source image.


## 3.2. Training Objectives

In order to reach the Nash balance of the integrated generative adversarial network, three losses, namely, reconstruction loss, classification loss, and adversarial loss, are combined to optimize the network.


### 3.2.1. Reconstruction Loss

For the output image of the reconstruction path, reconstruction loss is introduced to as vital criteria for generator.(12)Lreci=∥Ai∗′−Ai∗∥+∥Bi∗′−Bi∗∥.How much the reconstruction image is familiar with the original one reflects the multifeature disentanglement performance and detail restoration degree of a model. By minimizingL1 losses, can map possibly much more detailed features embedded in attention-focusing images into latent space, and Gdec can be better instructed for reconstruction. Then, the well trained reconstruction network can be replanted in transforming target attribute and keep the generative image looks real.


### 3.2.2. Classification Loss

Classification loss utilizes the cross entropy between the known label and theith attribute predicted by the Judger Ji to guide feature exchanging of transfer path, ensuring the transferred images possess the same attributes as the reference image. Classification loss optimizes the generator Gi as follows:(13)LclsGi=−liBlogJiAi∗″−1−liBlog1−JiAi∗″−liAlogJiBi∗″−1−liAlog1−JiBi∗″.JiAi∗″ represents the anticipated label of i -th attribute for transferred image. After exchanging attribute-related features, the transferred image is supposed to have the same label as the reference attention-focusing image. It enhances the stability of the generative network after reconstruction in the latent space while forcing the structure to revive the correct attributes.(14)LclsJi=−liAlogJiAi∗−1−liAlog1−JiAi∗−liBlogJiBi∗−1−liBlog1−JiBi∗.The Judger of each attribute is trained by optimizing the mapping network from original image to labels. By this mean,Ji is able to accurately resolve target attributes from arbitrary images.


### 3.2.3. Adversarial Loss

The adversarial loss encourages realistic generation of encoder and decoder. On the other hand, it also optimize the estimate of discriminator. WGAN [15, 16] idea is applied to each discriminator Di the generator Gi as follows:(15)LadvGi=−EDiAi∗″−EDiBi∗″.For the generator Gi and Judger Ji, maximizing the discriminate estimation instructs them to generate images as real as possible. In addition, Ladvg is introduced to eliminate division around ROI by constraining every Gi and global discriminator Dg.(16)LadvGg=−EDgA″−EDgB″.By minimizing the difference between discriminate estimation of original image and attribute exchanged image, we keep local generatorGi under optimal functional state with good result integrated into attribute independent areas. In addition, Dg is trained by taking whole image as input.


### 3.2.4. Full Loss

Finally, the full objective for blocksGi, Ji,Di, and Dg can be written as linear combination form:(17)minGiLGi=λ1LadvGi+λ2LclsGi+λ3Lreci,minDi,JiLD,Ji=λ4LclsJi+λ5LadvDi,λ2 and λ3 represent hyperparameters controlling the proportion of attribute classification and image reconstruction in the final generative image. The combined restriction from λ1,2,3,4,5 keeps output images identical with the original ones in target-irrelevant feature and switch attribute exactly. In addition, the following two losses regarding training the Dg the optimize the Di ‘s results, which blend perfectly with images outside the editing area.(18)minGiLadvGg,minDgLadvDg.


## 3.2.1. Reconstruction Loss

For the output image of the reconstruction path, reconstruction loss is introduced to as vital criteria for generator.(12)Lreci=∥Ai∗′−Ai∗∥+∥Bi∗′−Bi∗∥.How much the reconstruction image is familiar with the original one reflects the multifeature disentanglement performance and detail restoration degree of a model. By minimizingL1 losses, can map possibly much more detailed features embedded in attention-focusing images into latent space, and Gdec can be better instructed for reconstruction. Then, the well trained reconstruction network can be replanted in transforming target attribute and keep the generative image looks real.


## 3.2.2. Classification Loss

Classification loss utilizes the cross entropy between the known label and theith attribute predicted by the Judger Ji to guide feature exchanging of transfer path, ensuring the transferred images possess the same attributes as the reference image. Classification loss optimizes the generator Gi as follows:(13)LclsGi=−liBlogJiAi∗″−1−liBlog1−JiAi∗″−liAlogJiBi∗″−1−liAlog1−JiBi∗″.JiAi∗″ represents the anticipated label of i -th attribute for transferred image. After exchanging attribute-related features, the transferred image is supposed to have the same label as the reference attention-focusing image. It enhances the stability of the generative network after reconstruction in the latent space while forcing the structure to revive the correct attributes.(14)LclsJi=−liAlogJiAi∗−1−liAlog1−JiAi∗−liBlogJiBi∗−1−liBlog1−JiBi∗.The Judger of each attribute is trained by optimizing the mapping network from original image to labels. By this mean,Ji is able to accurately resolve target attributes from arbitrary images.


## 3.2.3. Adversarial Loss

The adversarial loss encourages realistic generation of encoder and decoder. On the other hand, it also optimize the estimate of discriminator. WGAN [15, 16] idea is applied to each discriminator Di the generator Gi as follows:(15)LadvGi=−EDiAi∗″−EDiBi∗″.For the generator Gi and Judger Ji, maximizing the discriminate estimation instructs them to generate images as real as possible. In addition, Ladvg is introduced to eliminate division around ROI by constraining every Gi and global discriminator Dg.(16)LadvGg=−EDgA″−EDgB″.By minimizing the difference between discriminate estimation of original image and attribute exchanged image, we keep local generatorGi under optimal functional state with good result integrated into attribute independent areas. In addition, Dg is trained by taking whole image as input.


## 3.2.4. Full Loss

Finally, the full objective for blocksGi, Ji,Di, and Dg can be written as linear combination form:(17)minGiLGi=λ1LadvGi+λ2LclsGi+λ3Lreci,minDi,JiLD,Ji=λ4LclsJi+λ5LadvDi,λ2 and λ3 represent hyperparameters controlling the proportion of attribute classification and image reconstruction in the final generative image. The combined restriction from λ1,2,3,4,5 keeps output images identical with the original ones in target-irrelevant feature and switch attribute exactly. In addition, the following two losses regarding training the Dg the optimize the Di ‘s results, which blend perfectly with images outside the editing area.(18)minGiLadvGg,minDgLadvDg.


## 4. Results and Discussion

In this section, we introduce our experiment method and evaluate the transfer effect from qualitative and quantitative perspective.


### 4.1. Training Details

We evaluate the proposed LMGAN on the CelebA dataset [45] consisting of 200599 face images, with 40 attributes binary labels. In the editable attributes, ‘Bangs,’ ‘Eyeglasses’, and ‘Smiling’ are selected in our experiments because they are more challenging to transfer in previous studies. For the network training, Adam optimizer is used in experiments with β1=0.5 and β2=0.999. The hyperparameters from λ1 to λ5 are assigned as 1,10,100,100,1, respectively.


### 4.2. Baseline

We use HiSD, ELEGANT as our baselines to test the performance of LMGAN. LMGAN is designed to generate high-fidelity images in reference attribute-alternation tasks, so we choose the reference-guided mode in baseline models with multitask architecture to compare. All the baseline models are trained and tested under official implementation. We briefly introduced the structure and main differences between these baseline models and our LMGAN in the part below.


#### 4.2.1. HiSD

To control the target attribute, HiSD mapped reference extracted code to parameters of a generative convoluted network, during which no exchanging in latent space took place. The manipulation can be called a reference style guided generation of target attribute, however, identical detail of reference image cannot be guaranteed.


#### 4.2.2. ELEGANT

ELEGANT, adopting the latent exchanging technique disentangled multiple attributes in a monolithic generative module, which made it prone to multifeature contamination during iterative training. On the contrary, modules in LMGAN are independently trained for each attribute, and thus, key information can be well preserved in latent space.


### 4.3. Qualitative Evaluation

To compare the transfer effect of LMGAN with state-of-art methods HiSD and ELEGENT in reference-based transfer task, three typical attributes including Bangs, Eyeglasses, and Smiling are chosen to display the detail reconstruction quality and attribute transfer accuracy. ELEGENT cannot effectively disentangle target attributes and only fragmentary attributes are merged into the output images. HiSD does have a good performance on attribute transfer, however, when we focus on attributes with complex texture and structural details, for example Bangs and Eyeglasses, the transfer attributes cannot well resemble the original exemplar. On the contrary, transfers using HiSD are concomitant with great randomness and uncontrollability. The proposed LMGAN can better handle the problem; not only are target attributes realistically melded into the original image, but they also have the identical structure and texture with the original ones. As shown in Figure4, transferred with LMGAN, the shape of the eyeglasses is a better reproduction of the exemplar ones so does the thickness and orientation of hair clusters.Our LMGAN enables users to change multiattributes at will by controlling the close-open of each block. Given a source image and a multiattribute reference image, users can transfer specific attributes by allocating an n-bit label vector. Take tree attributes (Bangs, Eyeglasses, and Smiling). For example, each figure in the tribit label vector controls whether to transfer Bangs, Eyeglasses, or Smiling from the reference image. As shown in Figure6, label vector can well manipulate disentangled attributes without affecting region of other attributes.Figure 6
Multiple attributes transfer controlled by label vector.


### 4.4. Quantitative Evaluation

We evaluate LMGAN and baseline models from the following aspect: realism, disentanglement, and attribute style correlation.


#### 4.4.1. Realism

To quantitatively estimate the realism of reconstruction, Frechet Inception Distance (FID) [46] is adopted. Five random images with bangs are selected as reference for every test image without bangs, which is generated by LMGAN and other baselines. Then, FID is calculated between the reference-guide transferred image and the real image with bangs. Table 1 displays the quantitative evaluation of the competing methods. The average FID distance is lower for LMGAN compared with other baseline models, which represents the efficient decoupling ability and verisimilitude reconstruction of our methods.Table 1
Comparisons of realism, disentanglement, and attribute style correlation of baselines and our methods. Lower realism value represents higher realistic degree; higher disentanglement value represents better disentangle effect.
MethodRealismDisentanglement (%)Attribute style correlationELEGANT23.8351.376.11HiSD21.5569.272.04Ours20.2884.4070.95


#### 4.4.2. Disentanglement

Given a certain target-irrelevant attribute, like gender for example, the disentanglement ability is evaluated by transferring every image of a male without bangs with five randomly selected females with bangs as reference and calculating the average FID between the transferred image and the real male image with bangs. If a model reflects good disentanglement ability, no target-irrelevant attribute will be extracted and transferred into the original image, so the FID will be low. A quantitative comparison in Table1 shows that the proposed LMGAN achieves a better disentanglement effect compared with other baselines.


#### 4.4.3. Attribute Style Correlation

LMGAN exhibits strong attribute reconstruction accuracy. However, currently, no metrics can evaluate how the transferred attribute resembles the original one, so the user study method is chosen to quantify texture and structure similarity. Users are given the reference image with bangs and transferred images generated by LMGAN along with other baseline models. The percentages are decided by free voting to choose the image whose bangs have the most similarity with the exemplar image. The results in Table1 show that users prefer transferred images generated by LMGAN more considering attribute style correlation, which means our proposed method can better reconstruct the target attribute.


### 4.5. Ablation Experiment

In this experiment, we measure the importance of the classifier module in disentangling and manipulating the target attribute. In an ablation test, latent code generated by the encoder directly switches the attribute-relevant layer without being classified by labels. As previously speculated, attribute is fuzzily displayed, which means the ablation model is not able to accurately disentangle target attribute. Irrelevant style is also brought from the reference image to generate a stylistically diverse area and show an obvious sense of fragmentation. Table2 displays the FID result of the ablation test and Figure 7. The result for each attribute is not comparable to the result generated by the complete model. We suspected that label classifying plays a vital role in instructing generative modules to distinguish the exact attribute features we needed and perform complete extraction while avoiding target-irrelevant feature from contaminating the reconstruction code.Table 2
Quantitative results of the ablation study.
SettingRealismDisentanglementW/o C28.6473.57Full20.2870.95Figure 7
Qualitative results of the ablation study.


## 4.1. Training Details

We evaluate the proposed LMGAN on the CelebA dataset [45] consisting of 200599 face images, with 40 attributes binary labels. In the editable attributes, ‘Bangs,’ ‘Eyeglasses’, and ‘Smiling’ are selected in our experiments because they are more challenging to transfer in previous studies. For the network training, Adam optimizer is used in experiments with β1=0.5 and β2=0.999. The hyperparameters from λ1 to λ5 are assigned as 1,10,100,100,1, respectively.


## 4.2. Baseline

We use HiSD, ELEGANT as our baselines to test the performance of LMGAN. LMGAN is designed to generate high-fidelity images in reference attribute-alternation tasks, so we choose the reference-guided mode in baseline models with multitask architecture to compare. All the baseline models are trained and tested under official implementation. We briefly introduced the structure and main differences between these baseline models and our LMGAN in the part below.


### 4.2.1. HiSD

To control the target attribute, HiSD mapped reference extracted code to parameters of a generative convoluted network, during which no exchanging in latent space took place. The manipulation can be called a reference style guided generation of target attribute, however, identical detail of reference image cannot be guaranteed.


### 4.2.2. ELEGANT

ELEGANT, adopting the latent exchanging technique disentangled multiple attributes in a monolithic generative module, which made it prone to multifeature contamination during iterative training. On the contrary, modules in LMGAN are independently trained for each attribute, and thus, key information can be well preserved in latent space.


## 4.2.1. HiSD

To control the target attribute, HiSD mapped reference extracted code to parameters of a generative convoluted network, during which no exchanging in latent space took place. The manipulation can be called a reference style guided generation of target attribute, however, identical detail of reference image cannot be guaranteed.


## 4.2.2. ELEGANT

ELEGANT, adopting the latent exchanging technique disentangled multiple attributes in a monolithic generative module, which made it prone to multifeature contamination during iterative training. On the contrary, modules in LMGAN are independently trained for each attribute, and thus, key information can be well preserved in latent space.


## 4.3. Qualitative Evaluation

To compare the transfer effect of LMGAN with state-of-art methods HiSD and ELEGENT in reference-based transfer task, three typical attributes including Bangs, Eyeglasses, and Smiling are chosen to display the detail reconstruction quality and attribute transfer accuracy. ELEGENT cannot effectively disentangle target attributes and only fragmentary attributes are merged into the output images. HiSD does have a good performance on attribute transfer, however, when we focus on attributes with complex texture and structural details, for example Bangs and Eyeglasses, the transfer attributes cannot well resemble the original exemplar. On the contrary, transfers using HiSD are concomitant with great randomness and uncontrollability. The proposed LMGAN can better handle the problem; not only are target attributes realistically melded into the original image, but they also have the identical structure and texture with the original ones. As shown in Figure4, transferred with LMGAN, the shape of the eyeglasses is a better reproduction of the exemplar ones so does the thickness and orientation of hair clusters.Our LMGAN enables users to change multiattributes at will by controlling the close-open of each block. Given a source image and a multiattribute reference image, users can transfer specific attributes by allocating an n-bit label vector. Take tree attributes (Bangs, Eyeglasses, and Smiling). For example, each figure in the tribit label vector controls whether to transfer Bangs, Eyeglasses, or Smiling from the reference image. As shown in Figure6, label vector can well manipulate disentangled attributes without affecting region of other attributes.Figure 6
Multiple attributes transfer controlled by label vector.


## 4.4. Quantitative Evaluation

We evaluate LMGAN and baseline models from the following aspect: realism, disentanglement, and attribute style correlation.


### 4.4.1. Realism

To quantitatively estimate the realism of reconstruction, Frechet Inception Distance (FID) [46] is adopted. Five random images with bangs are selected as reference for every test image without bangs, which is generated by LMGAN and other baselines. Then, FID is calculated between the reference-guide transferred image and the real image with bangs. Table 1 displays the quantitative evaluation of the competing methods. The average FID distance is lower for LMGAN compared with other baseline models, which represents the efficient decoupling ability and verisimilitude reconstruction of our methods.Table 1
Comparisons of realism, disentanglement, and attribute style correlation of baselines and our methods. Lower realism value represents higher realistic degree; higher disentanglement value represents better disentangle effect.
MethodRealismDisentanglement (%)Attribute style correlationELEGANT23.8351.376.11HiSD21.5569.272.04Ours20.2884.4070.95


### 4.4.2. Disentanglement

Given a certain target-irrelevant attribute, like gender for example, the disentanglement ability is evaluated by transferring every image of a male without bangs with five randomly selected females with bangs as reference and calculating the average FID between the transferred image and the real male image with bangs. If a model reflects good disentanglement ability, no target-irrelevant attribute will be extracted and transferred into the original image, so the FID will be low. A quantitative comparison in Table1 shows that the proposed LMGAN achieves a better disentanglement effect compared with other baselines.


### 4.4.3. Attribute Style Correlation

LMGAN exhibits strong attribute reconstruction accuracy. However, currently, no metrics can evaluate how the transferred attribute resembles the original one, so the user study method is chosen to quantify texture and structure similarity. Users are given the reference image with bangs and transferred images generated by LMGAN along with other baseline models. The percentages are decided by free voting to choose the image whose bangs have the most similarity with the exemplar image. The results in Table1 show that users prefer transferred images generated by LMGAN more considering attribute style correlation, which means our proposed method can better reconstruct the target attribute.


## 4.4.1. Realism

To quantitatively estimate the realism of reconstruction, Frechet Inception Distance (FID) [46] is adopted. Five random images with bangs are selected as reference for every test image without bangs, which is generated by LMGAN and other baselines. Then, FID is calculated between the reference-guide transferred image and the real image with bangs. Table 1 displays the quantitative evaluation of the competing methods. The average FID distance is lower for LMGAN compared with other baseline models, which represents the efficient decoupling ability and verisimilitude reconstruction of our methods.Table 1
Comparisons of realism, disentanglement, and attribute style correlation of baselines and our methods. Lower realism value represents higher realistic degree; higher disentanglement value represents better disentangle effect.
MethodRealismDisentanglement (%)Attribute style correlationELEGANT23.8351.376.11HiSD21.5569.272.04Ours20.2884.4070.95


## 4.4.2. Disentanglement

Given a certain target-irrelevant attribute, like gender for example, the disentanglement ability is evaluated by transferring every image of a male without bangs with five randomly selected females with bangs as reference and calculating the average FID between the transferred image and the real male image with bangs. If a model reflects good disentanglement ability, no target-irrelevant attribute will be extracted and transferred into the original image, so the FID will be low. A quantitative comparison in Table1 shows that the proposed LMGAN achieves a better disentanglement effect compared with other baselines.


## 4.4.3. Attribute Style Correlation

LMGAN exhibits strong attribute reconstruction accuracy. However, currently, no metrics can evaluate how the transferred attribute resembles the original one, so the user study method is chosen to quantify texture and structure similarity. Users are given the reference image with bangs and transferred images generated by LMGAN along with other baseline models. The percentages are decided by free voting to choose the image whose bangs have the most similarity with the exemplar image. The results in Table1 show that users prefer transferred images generated by LMGAN more considering attribute style correlation, which means our proposed method can better reconstruct the target attribute.


## 4.5. Ablation Experiment

In this experiment, we measure the importance of the classifier module in disentangling and manipulating the target attribute. In an ablation test, latent code generated by the encoder directly switches the attribute-relevant layer without being classified by labels. As previously speculated, attribute is fuzzily displayed, which means the ablation model is not able to accurately disentangle target attribute. Irrelevant style is also brought from the reference image to generate a stylistically diverse area and show an obvious sense of fragmentation. Table2 displays the FID result of the ablation test and Figure 7. The result for each attribute is not comparable to the result generated by the complete model. We suspected that label classifying plays a vital role in instructing generative modules to distinguish the exact attribute features we needed and perform complete extraction while avoiding target-irrelevant feature from contaminating the reconstruction code.Table 2
Quantitative results of the ablation study.
SettingRealismDisentanglementW/o C28.6473.57Full20.2870.95Figure 7
Qualitative results of the ablation study.


## 5. Conclusions

In this paper, we propose a deep realistic facial editing method via label-restricted mask disentanglement. LMGAN combines the advantages of latent block exchange and the domain translation methods. The multistyle transfer of facial attributes is solved by using an independent subnetwork structure, ROI focusing with masks, and dual label constraints in LMGAN. Despite less pixel information and a simpler network structure, extensive quantitative and qualitative experiments have demonstrated the effectiveness of the method. We believe that the method proposed in this paper can achieve good results in the field of other attribute transfer tasks.



---

*Source: 5652730-2022-11-23.xml*