Method for constructing a personalized shadow puppet head attribute editing generator

By constructing a personalized shadow puppet head stubble attribute editing generator and combining feature extraction and style fusion technology, the problem in the existing technology that the generated results from face to shadow puppet stubble translation cannot preserve both the facial features and the shadow puppet structure has been solved. Generate images that meet the requirements of shadow puppets.

CN116798092BActive Publication Date: 2024-08-30HARBIN INST OF TECH
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202310591810.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-24
Publication Date
2024-08-30
Estimated Expiration
2043-05-24

AI Technical Summary

Technical Problem

The existing deep learning-based image translation method from face to shadow puppet head stubble is difficult to balance the generated image while maintaining the identifiable features of the face in the original image while taking into account the structural requirements of having a shadow puppet stubble. As a result, the generated results cannot meet the requirements of "it is a shadow puppet" at the same time. "The first batch" and "like myself" requirements.

Method used

Construct a personalized shadow puppet head stubble attribute editing generator, including a side face intermediate feature encoder, a semantic style encoder and a style fusion generator. Through feature extraction, style fusion and loss function design, the generator can maintain the personalized features of the face. At the same time, an image that conforms to the structure of the shadow puppet's head is generated.

Benefits of technology

The generated shadow puppet head stubble has the appearance of the shadow puppet stubble, and at the same time, the original facial features can be seen on the face of the stubble, which is significantly better than the existing method and can effectively retain the shape characteristics and style consistency of the original image. .

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure BDA0004245759340000032
    Figure BDA0004245759340000032
  • Figure BDA0004245759340000035
    Figure BDA0004245759340000035
  • Figure BDA0004245759340000041
    Figure BDA0004245759340000041
Patent Text Reader

Abstract

The invention discloses a method for constructing a personalized shadow puppet stubble attribute editing generator, which relates to the field of computer image generation. The invention solves the problem that the existing deep learning-based human face to shadow puppet stubble translation method is difficult to balance the generated image while maintaining the recognizable features of the human face in the original image and taking into account the structural requirements of the shadow puppet stubble. The invention first constructs a shadow puppet stubble sample set and a human face profile sample set, and then pre-processes the samples in the sample set to obtain a set of training samples. The set of training samples is used to generate the profile face intermediate feature encoder E C , semantic style encoder E S The image generator is trained with the style fusion generator G, and the parameters of the above three are updated by calculating the total loss during the training process to complete the training of the image generator. The present invention is mainly used in the translation from human face images to shadow puppet stubble images.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer image generation. Background Art

[0002] In the field of image generation, generating another image from one image is called image translation. In image translation, when the difference between the original image and the target image is huge, it is a difficult problem to preserve the logical continuity of the original image and the generated result.

[0003] The translation of face images to shadow puppet stubble images is a very different image translation problem. There are usually several approaches to this problem in academia. One is the image translation method related to CycleGAN. These methods use "cycle consistency" to ensure the similarity of the macroscopic feature distribution between the original image and the target image. This macroscopic distribution similarity enables the model to learn a fuzzy mapping relationship. The advantage of this is that the generated shadow puppet stubble image can be a shadow puppet image, but the disadvantage is that it cannot retain the personalized features of the face in the original image, and the face in the generated shadow puppet stubble image has no connection with the face in the original image in terms of shape and content, and is completely distorted. Figure 1 ; Secondly, there are some style transfer methods and image translation methods based on contrastive learning (CUT). These methods usually use loss functions to make the generated image consistent with the original image in shape and structure. Therefore, these methods can preserve the appearance of the face and apply the color style of shadow puppets to them to a certain extent. However, the shadow puppet style is still rare in the generated images and is far from the original shadow puppet images. Specifically, Figure 1 It can be seen that the style transfer and contrast-based learning methods have the advantage of being able to see the recognizable features of the original face image, but cannot guarantee that the generated results meet the requirements of the shadow puppet head (with a hat, face, and beard).

[0004] In summary, the above three existing deep learning-based image translation methods, when faced with the translation problem of human face to shadow puppet stubble, have difficulty balancing the requirement of keeping the recognizable features of the human face in the original image (i.e., the generated image "looks like the person") while having the structural requirements of the shadow puppet stubble (i.e., the generated image "is the shadow puppet stubble"). Either it is too similar to the human face, resulting in it not being a standard stubble image at all; or it is a standard stubble image, but it has nothing to do with the human face in the original image. In the image translation task from human face to shadow puppet stubble, our goal is to ensure that the generated result is indeed a stubble image and maintain the personalized features of the human face to ensure the accuracy of the generated shadow puppet stubble image. The above problems need to be solved urgently. Summary of the invention

[0005] The purpose of the present invention is to solve the problem that the existing deep learning-based translation method of human face to shadow puppet stubble is difficult to balance the problem that the generated image maintains the recognizable features of the human face in the original image while taking into account the structural requirements of the shadow puppet stubble; the present invention provides a method for constructing a personalized shadow puppet stubble attribute editing generator.

[0006] A method for constructing a personalized shadow puppet head attribute editing generator, the generator includes a profile face intermediate feature encoder E C , semantic style encoder E S and a style fusion generator G; the method includes the following process:

[0007] S1. Construct shadow puppet head sample set and human face profile sample set:

[0008] Each sample in the shadow play sample set includes a shadow play image S and a shadow play semantic annotation image M. s ; Each sample in the face profile sample set includes a side face image F and a side face mask image M F ; Semantic annotation of shadow puppet headstock M s There are 8 categories of styles, the first to the eighth category styles are background, face, beard, crown, helmet, hat, scarf and neck;

[0009] S2. Sample pretreatment:

[0010] First, randomly select a sample from the shadow puppet head stubble sample set and the human face profile sample set to obtain the shadow puppet head stubble image S and the shadow puppet head stubble semantic annotation image M. s , side face image F and side face mask image M F ; Then, the semantic annotation map M of the shadow puppet head s , side face image F and side face mask image M F Preprocessing is performed to obtain the corresponding semantic annotation unique heat map of the shadow puppet head Face area map F″ and profile mask alignment map M″ F ; Finally, the shadow puppet head is semantically labeled as a unique heat map The face area in is replaced with the profile mask alignment image M″ F , and obtain the semantic guidance graph Semantic Guided Graph It consists of mask images of the areas where the 8 categories of styles are located;

[0011] S3, the shadow puppet head stubble image S, the face area image F″, and the shadow puppet head stubble semantic annotation unique heat map obtained in step S2 and semantic guidance graph As a set of training samples;

[0012] S4. Set the upper limit of the iteration round to T, and the initial value of t is 1, where t is the iteration round;

[0013] S5. In the tth round of training, the generator is trained using a set of training samples obtained in step S3, specifically:

[0014] S51, profile intermediate feature encoder E C The facial region map F″ is subjected to feature extraction to obtain the facial feature map z; at the same time, the semantic style encoder E S Unique heat map in semantic annotation of shadow puppet head Under the guidance of , the style of the shadow puppet head image S is extracted to obtain the style coding combination st;

[0015] S52, style fusion generator G is used to add noise to the face feature map z and add noise to the semantic guidance map Under the guidance of , various styles are fused on the feature map after adding noise and the style encoding combination st to generate the fusion map S′;

[0016] S6. Total loss calculation and parameter update:

[0017] The fusion image S′ is compared with the face area image F″ and the shadow puppet stubble image S to obtain the total loss L, and the total loss L is used to decode the profile face intermediate feature encoder E C , semantic style encoder E S Update parameters of the style fusion generator G;

[0018] S7. Determine whether t is equal to T. If not, set t=t+1 and execute step S2. If yes, complete the training of the generator and realize the construction of the generator.

[0019] As a preferred embodiment, in step S2, the shadow puppet head stubble semantic annotation map M is s , side face image F and side face mask image M F Preprocessing is performed to obtain the corresponding semantic annotation unique heat map of the shadow puppet head Face area map F″ and profile mask alignment map M″ F The implementation process includes:

[0020] S21. Semantic annotation of the shadow puppet headstock M s Perform single-hot layering processing to obtain the single-hot map of the semantic annotation of the shadow puppet head

[0021] S22, using the side face mask image M F After masking the face area in the side face image F, face scaling is performed to obtain the face area scaling image F′. At the same time, the side face mask image M is also F Perform proportional face scaling to obtain the mask scaling image M′ F ;

[0022] S23, translating the cluster center of the face area zoom map F′ to the shadow puppet stubble semantic annotation unique heat map obtained in step S21 At the cluster center of the middle face area, the face area map F″ is obtained;

[0023] The mask scale map M′ F The cluster center is translated to the unique heat map of the semantic annotation of the shadow puppet head obtained in step S21 At the cluster center of the middle face area, the side face mask alignment map M″ is obtained F .

[0024] Preferably, in step S6, the fusion image S′ is compared and analyzed with the face area image F″ and the shadow puppet stubble image S respectively to obtain the total loss L, which includes:

[0025] S61. Compare and analyze the face area in the fusion image S′ and the face area in the face area image F″ to obtain the face loss L in-face ; Compare and analyze the non-face area in the fusion image S′ with the non-face area in the shadow puppet head image S to obtain the non-face loss L out-face ; Calculate the adversarial loss L between the generator and the preset multi-scale discriminator D GAN (E C ,E S ,G,D);

[0026] S62, according to L in-face , L out-face and L GAN (E C ,E S ,G,D), and get the total loss L, which is:

[0027]

[0028] As a preference, L in-face =λ nce L PatchNCE Formula 2;

[0029] Among them, λ nce is the face loss adjustment parameter, L PatchNCE It is the face area shape consistency loss of the fusion image S′ and the face area image F″.

[0030] As a preference, L out-face =λ percep L percep +λ feat L feat Formula 3;

[0031] Among them, λ percep is the first adjustment parameter for the out-of-face loss, Lpercep is the perceptual loss of the non-face area of ​​the fusion image S′ and the shadow puppet head image S, feat is the second adjustment parameter for the out-of-face loss, L feat It is the feature matching loss of the non-face area between the fusion image S′ and the shadow puppet stubble image S.

[0032] As a preference,

[0033] It represents the expectation that the preset multi-scale discriminator D judges the shadow puppet head stubble image S to be true;

[0034] It indicates the expectation that the preset multi-scale discriminator D judges that the fusion image S′ generated by the face region image F″ is false;

[0035] D(S) is the output of the preset multi-scale discriminator D when the input of the preset multi-scale discriminator D is the shadow puppet head stubble image S;

[0036] D(S′) is the output of the preset multi-scale discriminator D when the input of the preset multi-scale discriminator D is the fusion graph S′.

[0037] As a preference, the face scaling factor

[0038] Among them, t S Semantic annotation of shadow puppet headstock s The number of pixels in the middle face area; t F The side face mask image M F The number of pixels in the mid-face area.

[0039] Preferably, the style fusion generator G includes 7 style fusion residual blocks, 5 upsampling modules and an output head module; and from left to right are the first to the seventh style fusion residual blocks;

[0040] The input end of the first style fusion residual block is used as the input end of the style fusion generator G to receive the face feature map z;

[0041] The first style fusion residual block is used to add noise to the feature map it receives and also to add noise to the semantic guidance map. Under the guidance of , the feature map after adding noise is firstly extracted, then style fused with style coding combination st, and finally the fused feature map is enhanced to obtain the first residual fusion feature map, which is sent to the first upsampling module;

[0042] The first upsampling module is used to perform nearest neighbor upsampling on the received first residual fusion feature map to double the size of the first residual fusion feature map, obtain the feature map after the first upsampling, and send it to the second style fusion residual block;

[0043] The second style fusion residual block is used to add noise to the feature map it receives; it is also used to add noise to the semantic guidance map. Under the guidance of , the feature map after adding noise is firstly extracted, then style fused with style coding combination st, and finally the fused feature map is enhanced to obtain the second residual fusion feature map, which is sent to the third style fusion residual block;

[0044] The third style fusion residual block is used to add noise to the feature map it receives; it is also used to add noise to the semantic guidance map. Under the guidance of , the feature map after adding noise is firstly extracted, then style fused with style coding combination st, and finally the fused feature map is enhanced to obtain the third residual fusion feature map, which is sent to the second upsampling module;

[0045] The second upsampling module is used to perform nearest neighbor upsampling on the received third residual fusion feature map to double the size of the third residual fusion feature map, obtain the feature map after the second upsampling, and send it to the fourth style fusion residual block;

[0046] The fourth style fusion residual block is used to add noise to the feature map it receives; it is also used to add noise to the semantic guidance map. Under the guidance of , the feature map after adding noise is firstly extracted, then style fused with style coding combination st, and finally the fused feature map is enhanced to obtain the fourth residual fusion feature map, which is sent to the third upsampling module;

[0047] The third upsampling module is used to perform nearest neighbor upsampling on the received fourth residual fusion feature map to double the size of the fourth residual fusion feature map, obtain the feature map after the third upsampling, and send it to the fifth style fusion residual block;

[0048] The fifth style fusion residual block is used to add noise to the feature map it receives; it is also used to Under the guidance of , the feature map after adding noise is firstly extracted, then style fused with style coding combination st, and finally the fused feature map is enhanced to obtain the fifth residual fusion feature map, which is sent to the fourth upsampling module;

[0049] The fourth upsampling module is used to perform nearest neighbor upsampling on the received fifth residual fusion feature map to double the size of the fifth residual fusion feature map, obtain the feature map after the fourth upsampling, and send it to the sixth style fusion residual block;

[0050] The sixth style fusion residual block is used to add noise to the feature map it receives; it is also used to add noise to the semantic guidance map Under the guidance of , the feature map after adding noise is firstly extracted, then style fused with style coding combination st, and finally the fused feature map is enhanced to obtain the sixth residual fusion feature map, which is sent to the fifth upsampling module;

[0051] The fifth upsampling module is used to perform nearest neighbor upsampling on the received sixth residual fusion feature map, so as to double the size of the sixth residual fusion feature map and obtain the feature map after the fifth upsampling;

[0052] The seventh style fusion residual block is used to add noise to the feature map it receives; it is also used to add noise to the semantic guidance map Under the guidance of , the feature map after adding noise is firstly extracted, then style fused with style coding combination st, and finally the fused feature map is enhanced to obtain the seventh residual fusion feature map, which is sent to the output head module;

[0053] The output head module is used to adjust the number of channels of the seventh residual fusion feature map to 3, and then perform nonlinear activation to form a fusion map S′, which is used as the output of the style fusion generator G.

[0054] Preferably, the internal structures of the seven style fusion residual blocks are the same;

[0055] Each style fusion residual block includes 3 normalized style fusion networks, 4 adders, 1 multiplier and 1 image channel importance extraction network; wherein, the first and second normalized style fusion networks, and the first, second and fourth adders constitute the main branch; the third normalized style fusion network, the third adder, the multiplier and the image channel importance extraction network constitute the residual branch;

[0056] The first adder is used to add the first noise N1 to the feature map received by the style fusion residual block in which it is located, and the feature map after adding the first noise N1 is sent to the first normalized style fusion network;

[0057] The first normalized style fusion network is used to normalize the feature map after adding the first noise N1, obtain the normalized feature map after adding the first noise N1, and add the first noise N1 to the semantic guidance map. Under the guidance of , the normalized feature map after adding the first noise N1 is fused with the style coding combination st for each category to obtain the first style fusion feature map, and the first style fusion feature map is sequentially activated and convolved to obtain the first feature map of the main branch;

[0058] The second adder is used to add the second noise N2 to the first feature map of the main branch, and the feature map after adding the second noise N2 is sent to the second normalized style fusion network;

[0059] The second normalized style fusion network is used to normalize the received feature map after adding the second noise N2, obtain the normalized feature map after adding the second noise N2, and add it to the semantic guidance map Under the guidance of , the normalized feature map after adding the second noise N2 is fused with the style coding combination st for each category to obtain the second style fusion feature map, and the second style fusion feature map is sequentially subjected to nonlinear activation and convolution operations to obtain the second feature map of the main branch;

[0060] The third adder is used to add the third noise N3 to the feature map received by the style fusion residual block in which it is located, and the feature map after adding the third noise N3 is sent to the third normalized style fusion network;

[0061] The third normalized style fusion network is used to normalize the received feature map after adding the third noise N3, obtain the normalized feature map after adding the third noise N3, and add the third noise N3 to the semantic guidance map. Under the guidance of , the normalized feature map after adding the third noise N3 is fused with the style coding combination st for each category to obtain the third style fusion feature map, and the third style fusion feature map is sequentially subjected to nonlinear activation and convolution operations to obtain the first feature map of the residual branch;

[0062] Image channel importance extraction network, used to extract the weights of each channel in the first feature map of the residual branch;

[0063] A multiplier, used to perform weighted processing on the weight of each channel and the corresponding channel of the first feature map of the residual branch to obtain the second feature map of the residual branch after feature enhancement;

[0064] The fourth adder is used to perform a feature map residual connection between the second feature map of the residual branch and the second feature map of the main branch to obtain a residual fusion feature map, which is used as the output of the style fusion residual block.

[0065] As a preferred method, (i) the first normalized style fusion network, in the semantic guidance graph Under the guidance of , the normalized feature map after adding the first noise N1 is fused with the style coding combination st for each category. The specific process of obtaining the first style fusion feature map is as follows:

[0066] S52-11, perform two linear transformations with different parameters on each category style in the style coding combination st to obtain the mean value γ corresponding to each category style i and variance β i , i=0,1……6,7;

[0067] γ i is the mean value corresponding to the i+1th category style, β i is the variance corresponding to the i+1th category style;

[0068] S52-12, through 8 categories of style processing channels, the semantic guidance map is The mask image of the area where the corresponding category style is located and the normalized feature map after adding the first noise N1, the mean value γ corresponding to this category style i , variance β i and fusion parameter b i The style fusion is performed under the action of the style fusion function to obtain the fusion map of each category style, where b0+b1+b2+b3+b4+b5+b6+b7=1, b i is the fusion parameter corresponding to the i+1th category style, specifically:

[0069] The processing process of the second category style processing channel is as follows: after the mask image of the area where the second category style is located is multiplied by the normalized feature map after adding the first noise N1, the facial shape consistency correction is performed in sequence, and it is multiplied by the mean γ1 corresponding to the second category style, and then summed with the variance β1 corresponding to the second category style, and then multiplied by the fusion parameter b1 to obtain the fusion image of the second category style;

[0070] The processing process of the first and any one of the third to eighth category style processing channels is as follows:

[0071] The mask image of the area where any category style other than the second category style is located is multiplied by the normalized feature map after adding the first noise N1, and then multiplied by the mean γ corresponding to the category style. j After multiplication, the variance β corresponding to the style of this category j After summing, it is combined with the fusion parameter b j Multiply them to obtain the fusion map of the style of this category, j = 0, 2, 3, 4, 5, 6, 7;

[0072] S52-13, merging the fusion images of all categories of styles to obtain the first style fusion feature image;

[0073] (ii) The second normalized style fusion network, in the semantic guidance graph Under the guidance of , the normalized feature map after adding the second noise N2 is fused with the style coding combination st for each category, and the specific process of obtaining the second style fusion feature map is as follows:

[0074] S52-21, perform two linear transformations with different parameters on each category style in the style coding combination st to obtain the mean value γ corresponding to each category style i and variance β i , i=0,1……6,7;

[0075] γ i is the mean value corresponding to the i+1th category style, β i is the variance corresponding to the i+1th category style;

[0076] S52-22, through 8 categories of style processing channels, the semantic guidance map is The mask image of the area where the corresponding category style is located and the normalized feature map after adding the second noise N2, the mean value γ corresponding to this category style i , variance β i and fusion parameter b i The style fusion is performed under the action of the style fusion function to obtain the fusion map of each category style, where b0+b1+b2+b3+b4+b5+b6+b7=1, b i is the fusion parameter corresponding to the i+1th category style, specifically:

[0077] The processing process of the second category style processing channel is as follows: after the mask image of the area where the second category style is located is multiplied by the normalized feature map after adding the second noise N2, facial shape consistency correction is performed in sequence, and it is multiplied by the mean γ1 corresponding to the second category style, and then summed with the variance β1 corresponding to the second category style, and then multiplied by the fusion parameter b1 to obtain the fusion image of the second category style;

[0078] The processing process of any one of the first, third to eighth category style processing channels is as follows:

[0079] The mask image of the area where any category style other than the second category style is located is multiplied by the normalized feature map after adding the second noise N2, and then multiplied by the mean γ corresponding to the category style. j After multiplication, the variance β corresponding to the style of this category j After summing, it is combined with the fusion parameter b j Multiply them to obtain the fusion map of the style of this category, j = 0, 2, 3, 4, 5, 6, 7;

[0080] S52-23, merging the fusion images of all categories of styles to obtain a second style fusion feature image;

[0081] (III) The third normalized style fusion network, in the semantic guidance graph Under the guidance of , the normalized feature map after adding the third noise N3 is fused with the style coding combination st for each category, and the implementation method of obtaining the third style fusion feature map includes:

[0082] S52-31, perform two linear transformations with different parameters on each category style in the style coding combination st to obtain the mean value γ corresponding to each category style i and variance β i , i=0,1……6,7;

[0083] γ i is the mean value corresponding to the i+1th category style, β i is the variance corresponding to the i+1th category style;

[0084] S52-32, through 8 categories of style processing channels, the semantic guidance map is The mask image of the area where the corresponding category style is located and the normalized feature map after adding the third noise N3, the mean value γ corresponding to this category style i , variance β i and fusion parameter b i The style fusion is performed under the action of the style fusion function to obtain the fusion map of each category style, where b0+b1+b2+b3+b4+b5+b6+b7=1, b i is the fusion parameter corresponding to the i+1th category style, specifically:

[0085] The processing process of the second category style processing channel is as follows: after the mask image of the area where the second category style is located is multiplied by the normalized feature map after adding the third noise N3, facial shape consistency correction is performed in sequence, and after multiplication by the mean γ1 corresponding to the second category style, the sum is calculated with the variance β1 corresponding to the second category style, and then multiplied by the fusion parameter b1 to obtain the fusion image of the second category style;

[0086] The processing process of the first and any one of the third to eighth category style processing channels is as follows:

[0087] The mask image of the area where any category style other than the second category style is located is multiplied by the normalized feature map after adding the third noise N3, and then multiplied by the mean γ corresponding to the category style. j After multiplication, the variance β corresponding to the style of this category jAfter summing, it is combined with the fusion parameter b j Multiply them to obtain the fusion map of the style of this category, j = 0, 2, 3, 4, 5, 6, 7;

[0088] S52-33. Merge the fusion maps of all categories of styles to obtain the third style fusion feature map.

[0089] Advantages of the present invention:

[0090] 1. The method for constructing a personalized shadow puppet head stubble attribute editing generator described in the present invention can generate a head stubble image that meets the requirements of the shadow puppet head stubble, and the face can also retain the personalized content of the human face.

[0091] 2. The total loss design of the present invention is divided into three parts: face loss, non-face loss, and adversarial loss. Face loss is responsible for constraining the generated face content to conform to the characteristics of the original face. Non-face loss is mainly the style constraint of the hat crown, beard, neck, and background. Adversarial loss constrains the generated result to conform to the basic characteristics of the shadow puppet stubble. The face loss is obtained by comparing and analyzing the face area in the fusion image S′ with the face area in the face area image F″. The non-face loss is obtained by comparing and analyzing the non-face area in the fusion image S′ with the non-face area in the shadow puppet stubble image S. The adversarial loss means that the network training process of the present invention is a generative adversarial network GAN adversarial training, and the adversarial loss is applied to the discriminator and the generator. This process can be achieved through existing technologies. The face loss based on contrastive learning constrains the face generation effect, and the loss constraints are imposed on the features of the original side face image and the generated image from the multi-scale feature level, so that the generated face can retain certain shape features and facial content stability of the original face; the non-face area loss can effectively constrain the style consistency of the parts outside the face, and reconstruct the texture of the non-face area at multiple levels from the perception level and the feature consistency level, which plays a role in stabilizing the generated stubble style.

[0092] 3. The normalized style fusion network of the present invention can effectively make the generated results obey the guidance of the generated guidance map, and pay special attention to the facial area. Specifically, the shape and affine transformation of the facial area can be constrained through facial shape consistency correction, so that a more original face in the side face image can be generated.

[0093] 4. Verification tests have proven that the method of the present invention is significantly superior to other existing methods and can achieve the goal of generating a shadow puppet head that looks like a shadow puppet head, while also showing the features of the original human face on the face of the head. BRIEF DESCRIPTION OF THE DRAWINGS

[0094] Figure 1 This is a comparison chart of the effects of the two existing image translation methods, CycleGAN and CUT;

[0095] Figure 2 It is a schematic diagram of the principle of the method for constructing a personalized shadow puppet head stubble attribute editing generator according to the present invention;

[0096] Figure 3 is a schematic diagram of a set of training samples input into the generator of the present invention;

[0097] Figure 4 This is a schematic diagram of the principle of the style fusion residual block;

[0098] Figure 5 It is a schematic diagram of the principle of normalized style fusion in the normalized style fusion network; N k is the Kth noise, and K=1,2,3;

[0099] Figure 6 is a schematic diagram of the result of image translation using the method of the present invention;

[0100] Figure 7 This is a comparison chart between the effects of the present invention and the existing image translation methods CycleGAN and CUT. DETAILED DESCRIPTION

[0101] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0102] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.

[0103] In the image translation task of human face to shadow puppet stubble, the existing deep learning-based translation method of human face to shadow puppet stubble is difficult to balance the problem of generating an image that maintains the recognizable features of the original face while taking into account the structural requirements of the shadow puppet stubble. In other words, the existing deep learning method is difficult to balance the relationship between "being a shadow puppet stubble" and "looking like the real person". Figure 2 The image generator shown is a deep learning network model SFST-Net. The image generator of the present invention can achieve the goal of generating a shadow puppet head with the appearance of a shadow puppet head through a series of input images, and the features of the original human face can be seen on the face of the head.

[0104] Specific implementation method 1: The following is combined Figure 2 The method for constructing a personalized shadow puppet head stubble attribute editing generator in this embodiment is described, and the generator includes a side face intermediate feature encoder E C, semantic style encoder E S and a style fusion generator G; the method includes the following process:

[0105] S1. Construct shadow puppet head sample set and human face profile sample set:

[0106] Each sample in the shadow play sample set includes a shadow play image S and a shadow play semantic annotation image M. s ; Each sample in the face profile sample set includes a side face image F and a side face mask image M F ; Semantic annotation of shadow puppet headstock M s There are 8 categories of styles, the first to the eighth category styles are background, face, beard, crown, helmet, hat, scarf and neck;

[0107] S2. Sample pretreatment:

[0108] First, randomly select a sample from the shadow puppet head stubble sample set and the human face profile sample set to obtain the shadow puppet head stubble image S and the shadow puppet head stubble semantic annotation image M. s , side face image F and side face mask image M F ; Then, the semantic annotation map M of the shadow puppet head s , side face image F and side face mask image M F Preprocessing is performed to obtain the corresponding semantic annotation unique heat map of the shadow puppet head Face area map F″ and profile mask alignment map M″ F ; Finally, the shadow puppet head is semantically labeled as a unique heat map The face area in is replaced with the profile mask alignment image M″ F , and obtain the semantic guidance graph Semantic Guided Graph It consists of mask images of the areas where the 8 categories of styles are located;

[0109] S3, the shadow puppet head stubble image S, the face area image F″, and the shadow puppet head stubble semantic annotation unique heat map obtained in step S2 and semantic guidance graph As a set of training samples;

[0110] S4. Set the upper limit of the iteration round to T, and the initial value of t is 1, where t is the iteration round;

[0111] S5. In the tth round of training, the generator is trained using a set of training samples obtained in step S3, specifically:

[0112] S51, profile intermediate feature encoder E C The facial region map F″ is subjected to feature extraction to obtain the facial feature map z; at the same time, the semantic style encoder E S Unique heat map in semantic annotation of shadow puppet head Under the guidance of , the style of the shadow puppet head image S is extracted to obtain the style coding combination st;

[0113] S52, style fusion generator G is used to add noise to the face feature map z and add noise to the semantic guidance map Under the guidance of , various styles are fused on the feature map after adding noise and the style encoding combination st to generate the fusion map S′;

[0114] S6. Total loss calculation and parameter update:

[0115] The fusion image S′ is compared with the face area image F″ and the shadow puppet stubble image S to obtain the total loss L, and the total loss L is used to decode the profile face intermediate feature encoder E C , semantic style encoder E S Update parameters of the style fusion generator G;

[0116] S7. Determine whether t is equal to T. If not, set t=t+1 and execute step S2. If yes, complete the training of the generator and realize the construction of the generator.

[0117] Profile face intermediate feature encoder E C , semantic style encoder E S and style fusion generator G are both implemented using neural networks;

[0118] In order to extract facial features, a profile face intermediate feature encoder E is designed. C , profile face intermediate feature encoder E C It can be realized by using existing technology, and in specific application, the profile middle feature encoder E C The structure may include 5 downsampling convolutional layers, and can extract the deep features of the face image in the input face area map F″ to obtain the face feature map z.

[0119] In order to extract the style of shadow puppets, a semantic style encoder E is designed. S , the semantic style encoder E S This can be achieved using existing technology. When applied, this is a structure of 2 layers of downsampling convolution + 1 layer of upsampling convolution + regional average pooling. The shadow puppet head stubble image S is obtained through 2 layers of downsampling convolution + 1 layer of upsampling convolution to obtain a feature map, which is input into regional average pooling. Regional average pooling also receives a shadow puppet head stubble semantic annotation map M. s As input, regional average pooling will generate the semantic annotation map M of the shadow puppet head stubble. s The area where each category style is located is pooled once. sThere are 8 categories of styles in it, and the first to eighth categories of styles are background, face, beard, crown, helmet, hat, scarf and neck respectively; therefore, the semantic annotation map M of the shadow puppet stubble s A total of 8 labels will be marked, and the regional average pooling will be performed 8 times, and finally a style encoding combination st of size 8×512 will be obtained. Each style encoding is a vector of size 1×512, representing the style of this label. Among them, the crown, helmet, hat, and scarf in the 8 categories of styles all belong to the category of the crown of the shadow puppet head. In specific applications, the semantic annotation map of the shadow puppet head is M s The image may contain any combination of the eight categories, generally five or more styles. Background, face, beard and neck are common to each image. For example, it contains five styles, namely, background, face, beard, neck and crown. For example, it contains six styles, namely, background, face, beard, neck, crown and scarf. Figure 2 In the example, a shadow puppet head stubble image S is provided to provide style, a face region image F″ is used as face input, and a shadow puppet head stubble semantic annotation unique heat map is provided. A semantic guidance map is used to guide the semantic style encoder to extract the style. Used to indicate where the style should be applied.

[0120] See also Figure 3 In step S2, the shadow puppet headstock semantic annotation map M is s , side face image F and side face mask image M F Preprocessing is performed to obtain the corresponding semantic annotation unique heat map of the shadow puppet head Face area map F″ and profile mask alignment map M″ F The implementation process includes:

[0121] S21. Semantic annotation of the shadow puppet headstock M s Perform single-hot layering processing to obtain the single-hot map of the semantic annotation of the shadow puppet head

[0122] S22, using the side face mask image M F After masking the face area in the side face image F, face scaling is performed to obtain the face area scaling image F′. At the same time, the side face mask image M is also F Perform proportional face scaling to obtain the mask scaling image M′ F ;

[0123] S23, translating the cluster center of the face area zoom map F′ to the shadow puppet stubble semantic annotation unique heat map obtained in step S21 At the cluster center of the middle face area, the face area map F″ is obtained;

[0124] The mask scale map M′ FThe cluster center is translated to the unique heat map of the semantic annotation of the shadow puppet head obtained in step S21 At the cluster center of the middle face area, the side face mask alignment map M″ is obtained F .

[0125] In specific applications, the coefficient of face scaling in step S22 is Among them, t S Semantic annotation of shadow puppet headstock s The number of pixels in the middle face area; t F The side face mask image M F The number of pixels in the mid-face area.

[0126] Furthermore, in step S6, the fusion image S′ is compared and analyzed with the face area image F″ and the shadow puppet stubble image S, and the implementation method of obtaining the total loss L includes:

[0127] S61. Compare and analyze the face area in the fusion image S′ and the face area in the face area image F″ to obtain the face loss L in-face ; Compare and analyze the non-face area in the fusion image S′ with the non-face area in the shadow puppet head image S to obtain the non-face loss L out-face ; Calculate the adversarial loss L between the generator and the preset multi-scale discriminator D GAN (E C ,E S ,G,D);

[0128] S62, according to L in-face , L out-face and L GAN (E C ,E S ,G,D), and get the total loss L, which is:

[0129]

[0130] Among them, L in-face =λ nce L PatchNCE Formula 2;

[0131] L out-face =λ percep L percep +λ feat L feat Formula 3;

[0132]

[0133] In formula 2, λ nce is the face loss adjustment parameter, L PatchNCEis the face area shape consistency loss of the fusion image S′ and the face area image F″;

[0134] In formula 3, λ percep is the first adjustment parameter for the out-of-face loss, L percep is the perceptual loss of the non-face area of ​​the fusion image S′ and the shadow puppet head image S, feat is the second adjustment parameter for the out-of-face loss, L feat It is the feature matching loss of the non-face area between the fusion image S′ and the shadow puppet stubble image S.

[0135] In formula 4, It represents the expectation that the preset multi-scale discriminator D judges the shadow puppet head stubble image S to be true; It represents the expectation that the preset multi-scale discriminator D judges that the fusion image S′ generated by the face area map F″ is false; D(S) is the output of the preset multi-scale discriminator D when the input of the preset multi-scale discriminator D is the shadow puppet stubble image S; D(S′) is the output of the preset multi-scale discriminator D when the input of the preset multi-scale discriminator D is the fusion image S′.

[0136] The total loss design of the present invention is divided into three parts, namely, face loss, non-face loss and adversarial loss. Face loss is responsible for constraining the generated facial content to conform to the features of the original face. Non-face loss is mainly a style constraint on the crown, beard, neck and background. Adversarial loss constrains the generated result to conform to the basic features of the shadow puppet stubble. Face loss is obtained by comparing and analyzing the face area in the fusion image S′ with the face area in the face area image F″. Non-face loss is a comparison and analysis of the area outside the face in the fusion image S′ with the area outside the face in the shadow puppet stubble image S. Adversarial loss means that the network training process of the present invention is a generative adversarial network GAN adversarial training, and adversarial loss is applied to the discriminator and the generator.

[0137] See also Figure 2 ,Furthermore, the style fusion generator G includes 7 style fusion residual blocks, 5 upsampling modules and an output head module; and from left to right are the first to the seventh style fusion residual blocks;

[0138] The input end of the first style fusion residual block is used as the input end of the style fusion generator G to receive the face feature map z;

[0139] The first style fusion residual block is used to add noise to the feature map it receives and also to add noise to the semantic guidance map. Under the guidance of , the feature map after adding noise is firstly extracted, then style fused with style coding combination st, and finally the fused feature map is enhanced to obtain the first residual fusion feature map, which is sent to the first upsampling module;

[0140] The first upsampling module is used to perform nearest neighbor upsampling on the received first residual fusion feature map to double the size of the first residual fusion feature map, obtain the feature map after the first upsampling, and send it to the second style fusion residual block;

[0141] The second style fusion residual block is used to add noise to the feature map it receives; it is also used to add noise to the semantic guidance map. Under the guidance of , the feature map after adding noise is firstly extracted, then style fused with style coding combination st, and finally the fused feature map is enhanced to obtain the second residual fusion feature map, which is sent to the third style fusion residual block;

[0142] The third style fusion residual block is used to add noise to the feature map it receives; it is also used to add noise to the semantic guidance map. Under the guidance of , the feature map after adding noise is firstly extracted, then style fused with style coding combination st, and finally the fused feature map is enhanced to obtain the third residual fusion feature map, which is sent to the second upsampling module;

[0143] The second upsampling module is used to perform nearest neighbor upsampling on the received third residual fusion feature map to double the size of the third residual fusion feature map, obtain the feature map after the second upsampling, and send it to the fourth style fusion residual block;

[0144] The fourth style fusion residual block is used to add noise to the feature map it receives; it is also used to add noise to the semantic guidance map. Under the guidance of , the feature map after adding noise is firstly extracted, then style fused with style coding combination st, and finally the fused feature map is enhanced to obtain the fourth residual fusion feature map, which is sent to the third upsampling module;

[0145] The third upsampling module is used to perform nearest neighbor upsampling on the received fourth residual fusion feature map to double the size of the fourth residual fusion feature map, obtain the feature map after the third upsampling, and send it to the fifth style fusion residual block;

[0146] The fifth style fusion residual block is used to add noise to the feature map it receives; it is also used to Under the guidance of , the feature map after adding noise is firstly extracted, then style fused with style coding combination st, and finally the fused feature map is enhanced to obtain the fifth residual fusion feature map, which is sent to the fourth upsampling module;

[0147] The fourth upsampling module is used to perform nearest neighbor upsampling on the received fifth residual fusion feature map to double the size of the fifth residual fusion feature map, obtain the feature map after the fourth upsampling, and send it to the sixth style fusion residual block;

[0148] The sixth style fusion residual block is used to add noise to the feature map it receives; it is also used to add noise to the semantic guidance map Under the guidance of , the feature map after adding noise is firstly extracted, then style fused with style coding combination st, and finally the fused feature map is enhanced to obtain the sixth residual fusion feature map, which is sent to the fifth upsampling module;

[0149] The fifth upsampling module is used to perform nearest neighbor upsampling on the received sixth residual fusion feature map, so as to double the size of the sixth residual fusion feature map and obtain the feature map after the fifth upsampling;

[0150] The seventh style fusion residual block is used to add noise to the feature map it receives; it is also used to add noise to the semantic guidance map. Under the guidance of , the feature map after adding noise is firstly extracted, then style fused with style coding combination st, and finally the fused feature map is enhanced to obtain the seventh residual fusion feature map, which is sent to the output head module;

[0151] The output head module is used to adjust the number of channels of the seventh residual fusion feature map to 3, and then perform nonlinear activation to form a fusion map S′, which is used as the output of the style fusion generator G.

[0152] In order to realize image generation, a style fusion generator G is designed. The style fusion generator G contains a structure of 7 style fusion residual blocks. The internal structure of the 7 style fusion residual blocks is exactly the same, the difference is that their inputs are different. Each level of style fusion residual block is used to add noise to the facial feature map output by the previous level and then perform feature extraction, style fusion, and feature enhancement in sequence. The advantage of multiple feature extraction and feature enhancement is that it can enable the generator to learn the features of each category of shadow puppet stubble areas at different feature scales, making the generation result better.

[0153] Multiple upsampling modules are used to perform nearest neighbor upsampling to double the size of the first residual fusion feature map. The advantage of doubling the size at each level is that the feature map is converted from low resolution to high resolution, so as to generate more realistic images at high resolution.

[0154] See also Figure 4, Furthermore, the internal structures of the 7 style fusion residual blocks are the same; each style fusion residual block includes 3 normalized style fusion networks, 4 adders, 1 multiplier and 1 image channel importance extraction network; among them, the first and second normalized style fusion networks, and the first, second and fourth adders constitute the main branch; the third normalized style fusion network, the third adder, the multiplier and the image channel importance extraction network constitute the residual branch;

[0155] The first adder is used to add the first noise N1 to the feature map received by the style fusion residual block in which it is located, and the feature map after adding the first noise N1 is sent to the first normalized style fusion network;

[0156] The first normalized style fusion network is used to normalize the feature map after adding the first noise N1, obtain the normalized feature map after adding the first noise N1, and add the first noise N1 to the semantic guidance map. Under the guidance of , the normalized feature map after adding the first noise N1 is fused with the style coding combination st for each category to obtain the first style fusion feature map, and the first style fusion feature map is sequentially activated and convolved to obtain the first feature map of the main branch;

[0157] The second adder is used to add the second noise N2 to the first feature map of the main branch, and the feature map after adding the second noise N2 is sent to the second normalized style fusion network;

[0158] The second normalized style fusion network is used to normalize the received feature map after adding the second noise N2, obtain the normalized feature map after adding the second noise N2, and add it to the semantic guidance map Under the guidance of , the normalized feature map after adding the second noise N2 is fused with the style coding combination st for each category to obtain the second style fusion feature map, and the second style fusion feature map is sequentially subjected to nonlinear activation and convolution operations to obtain the second feature map of the main branch;

[0159] The third adder is used to add the third noise N3 to the feature map received by the style fusion residual block in which it is located, and the feature map after adding the third noise N3 is sent to the third normalized style fusion network;

[0160] The third normalized style fusion network is used to normalize the received feature map after adding the third noise N3, obtain the normalized feature map after adding the third noise N3, and add the third noise N3 to the semantic guidance map. Under the guidance of , the normalized feature map after adding the third noise N3 is fused with the style coding combination st for each category to obtain the third style fusion feature map, and the third style fusion feature map is sequentially subjected to nonlinear activation and convolution operations to obtain the first feature map of the residual branch;

[0161] Image channel importance extraction network, used to extract the weights of each channel in the first feature map of the residual branch;

[0162] A multiplier, used to perform weighted processing on the weight of each channel and the corresponding channel of the first feature map of the residual branch to obtain the second feature map of the residual branch after feature enhancement;

[0163] The fourth adder is used to perform a feature map residual connection between the second feature map of the residual branch and the second feature map of the main branch to obtain a residual fusion feature map, which is used as the output of the style fusion residual block.

[0164] For specific applications, see Figure 4 Each style fusion residual block consists of a main branch and a residual branch. The main branch is used to extract features, and the residual branch is used to extract residual features. The effect of setting up two branches is that in this way, the residual neural network can avoid problems such as gradient vanishing and gradient exploding while maintaining the network depth, thereby improving the convergence speed and accuracy of the network.

[0165] The style fusion generator G contains 7 style fusion residual blocks, and the internal structures of the 7 style fusion residual blocks are exactly the same. The difference lies in their different inputs. Each level of style fusion residual block is used to add noise to the face feature map output by the previous level and then perform feature extraction, style fusion, and feature enhancement in sequence. For details, see Figure 1 The internal structure of the style fusion generator G in the first style fusion residual block. The feature maps received by the first adder and the fourth adder are both the side face intermediate feature encoder E. CThe output face feature map z; the feature maps received by the first adder and the fourth adder in the second style fusion residual block are both the feature maps after the first upsampling output by the first upsampling module; the feature maps received by the first adder and the fourth adder in the third style fusion residual block are both the feature maps after the second residual fusion output by the second style fusion residual block; the feature maps received by the first adder and the fourth adder in the fourth style fusion residual block are both the feature maps after the second upsampling output by the second upsampling module; the feature maps received by the first adder and the fourth adder in the fifth style fusion residual block are both the feature maps after the third upsampling output by the third upsampling module; the feature maps received by the first adder and the fourth adder in the sixth style fusion residual block are both the feature maps after the fourth upsampling output by the fourth upsampling module; the feature maps received by the first adder and the fourth adder in the seventh style fusion residual block are both the feature maps after the fifth upsampling output by the fifth upsampling module.

[0166] The key to achieving style fusion in the style fusion residual block is style fusion normalization (such as Figure 5 ). Style fusion normalization requires input feature maps, style encoding combination st and semantic guidance map First, random Gaussian noise is added to the feature map, then instance normalization is performed, and then the semantic guidance map is Guided by , we take the region where each category style of the feature map is located and apply the corresponding style in the style encoding combination st.

[0167] As an example, the application method is to use a style coding combination st containing 8 style codes, each of which is a vector of size 1×512, and pass it through a shared linear layer to obtain γ i and β i , γ i and β i Expand to the size of the entire feature map, making the feature map ×γ i +β i , so that the style is applied to the corresponding area. In particular, for the shadow puppet face area, a shape invariant module (STN) is added to learn the affine transformation of the face. Finally, the semantic guidance map The area where the category style is located in the style feature map is applied, and the learnable fusion parameter b j To fuse, we get the output feature map.

[0168] For further information, see Figure 5 , the composition of the normalized style fusion network in each style fusion residual block is the same, and each normalized style fusion network operates step by step from top to bottom. Specifically,

[0169] (I) The first normalized style fusion network, in the semantic guidance graph Under the guidance of , the normalized feature map after adding the first noise N1 is fused with the style coding combination st for each category. The specific process of obtaining the first style fusion feature map is as follows:

[0170] S52-11, perform two linear transformations with different parameters on each category style in the style coding combination st to obtain the mean value γ corresponding to each category style i and variance β i , i=0,1……6,7;

[0171] γ i is the mean value corresponding to the i+1th category style, β i is the variance corresponding to the i+1th category style;

[0172] S52-12, through 8 categories of style processing channels, the semantic guidance map is The mask image of the area where the corresponding category style is located and the normalized feature map after adding the first noise N1, the mean value γ corresponding to this category style i , variance β i and fusion parameter b i The style fusion is performed under the action of the style fusion function to obtain the fusion map of each category style, where b0+b1+b2+b3+b4+b5+b6+b7=1, b i is the fusion parameter corresponding to the i+1th category style, specifically:

[0173] The processing process of the second category style processing channel is as follows: after the mask image of the area where the second category style is located is multiplied by the normalized feature map after adding the first noise N1, the facial shape consistency correction is performed in sequence, and it is multiplied by the mean γ1 corresponding to the second category style, and then summed with the variance β1 corresponding to the second category style, and then multiplied by the fusion parameter b1 to obtain the fusion image of the second category style;

[0174] The processing process of the first and any one of the third to eighth category style processing channels is as follows:

[0175] The mask image of the area where any category style other than the second category style is located is multiplied by the normalized feature map after adding the first noise N1, and then multiplied by the mean γ corresponding to the category style. j After multiplication, the variance β corresponding to the style of this category j After summing, it is combined with the fusion parameter b j Multiply them to obtain the fusion map of the style of this category, j = 0, 2, 3, 4, 5, 6, 7;

[0176] S52-13, merging the fusion images of all categories of styles to obtain the first style fusion feature image;

[0177] (ii) The second normalized style fusion network, in the semantic guidance graph Under the guidance of , the normalized feature map after adding the second noise N2 is fused with the style coding combination st for each category, and the specific process of obtaining the second style fusion feature map is as follows:

[0178] S52-21, perform two linear transformations with different parameters on each category style in the style coding combination st to obtain the mean value γ corresponding to each category style i and variance β i , i=0,1……6,7;

[0179] γ i is the mean value corresponding to the i+1th category style, β i is the variance corresponding to the i+1th category style;

[0180] S52-22, through 8 categories of style processing channels, the semantic guidance map is The mask image of the area where the corresponding category style is located and the normalized feature map after adding the second noise N2, the mean value γ corresponding to this category style i , variance β i and fusion parameter b i The style fusion is performed under the action of the style fusion function to obtain the fusion map of each category style, where b0+b1+b2+b3+b4+b5+b6+b7=1, b i is the fusion parameter corresponding to the i+1th category style, specifically:

[0181] The processing process of the second category style processing channel is as follows: after the mask image of the area where the second category style is located is multiplied by the normalized feature map after adding the second noise N2, facial shape consistency correction is performed in sequence, and it is multiplied by the mean γ1 corresponding to the second category style, and then summed with the variance β1 corresponding to the second category style, and then multiplied by the fusion parameter b1 to obtain the fusion image of the second category style;

[0182] The processing process of the first and any one of the third to eighth category style processing channels is as follows:

[0183] The mask image of the area where any category style other than the second category style is located is multiplied by the normalized feature map after adding the second noise N2, and then multiplied by the mean γ corresponding to the category style. j After multiplication, the variance β corresponding to the style of this category j After summing, it is combined with the fusion parameter b jMultiply them to obtain the fusion map of the style of this category, j = 0, 2, 3, 4, 5, 6, 7;

[0184] S52-23, merging the fusion images of all categories of styles to obtain a second style fusion feature image;

[0185] (III) The third normalized style fusion network, in the semantic guidance graph Under the guidance of , the normalized feature map after adding the third noise N3 is fused with the style coding combination st for each category, and the implementation method of obtaining the third style fusion feature map includes:

[0186] S52-31, perform two linear transformations with different parameters on each category style in the style coding combination st to obtain the mean value γ corresponding to each category style i and variance β i , i=0,1……6,7;

[0187] γ i is the mean value corresponding to the i+1th category style, β i is the variance corresponding to the i+1th category style;

[0188] S52-32, through 8 categories of style processing channels, the semantic guidance map is The mask image of the area where the corresponding category style is located and the normalized feature map after adding the third noise N3, the mean value γ corresponding to this category style i , variance β i and fusion parameter b i The style fusion is performed under the action of the style fusion function to obtain the fusion map of each category style, where b0+b1+b2+b3+b4+b5+b6+b7=1, b i is the fusion parameter corresponding to the i+1th category style, specifically:

[0189] The processing process of the second category style processing channel is as follows: after the mask image of the area where the second category style is located is multiplied by the normalized feature map after adding the third noise N3, facial shape consistency correction is performed in sequence, and after multiplication by the mean γ1 corresponding to the second category style, the sum is calculated with the variance β1 corresponding to the second category style, and then multiplied by the fusion parameter b1 to obtain the fusion image of the second category style;

[0190] The processing process of the first and any one of the third to eighth category style processing channels is as follows:

[0191] The mask image of the area where any category style other than the second category style is located is multiplied by the normalized feature map after adding the third noise N3, and then multiplied by the mean γ corresponding to the category style.j After multiplication, the variance β corresponding to the style of this category j After summing, it is combined with the fusion parameter b j Multiply them to obtain the fusion map of the style of this category, j = 0, 2, 3, 4, 5, 6, 7;

[0192] S52-33. Merge the fusion maps of all categories of styles to obtain the third style fusion feature map.

[0193] In the preferred embodiment, in specific applications, the second category style corresponds to "face". Therefore, the face category style processing channel adds a face shape consistency correction link compared to other category processing channels to constrain the shape and affine transformation of the face area. Each category style processing channel generates a head stubble image that conforms to the basic logic of shadow puppet head stubble for each category area identified in the generated semantic guidance map.

[0194] As an example, the face shape consistency correction step can be implemented by a shape consistency module (STN).

[0195] As an example, the mean value γ corresponding to each category style i and variance β i When , a two-layer MLP is used for linear transformation.

[0196] Verification test:

[0197] The method of the present invention is used to carry out verification experiments. Figure 6 It can be seen that the present invention has carried out 6 groups of experiments, in which each row is regarded as a group. The generated results of each group of experiments can show that the facial area map obtained in the original side face image is well integrated with the styles of various categories in the shadow puppet head stubble image under the guidance of the semantic guidance map, and has a better generation result. It can generate a head stubble image that meets the requirements of the shadow puppet head stubble, and the face can also retain the personalized content of the human face.

[0198] The face loss based on contrastive learning constrains the face generation effect. Loss constraints are imposed on the feature blocks of the original image and the generated image from the multi-scale feature level, which can make the generated face retain certain shape features and facial content stability of the original face. The loss of the outer area of ​​the face based on the perceptual loss and feature matching loss can effectively constrain the style consistency of the parts outside the face, and reconstruct the texture of the outer area of ​​the face at multiple levels from the perceptual level and the feature consistency level, which plays a role in stabilizing the generated style.

[0199] The normalized style fusion network of the present invention can effectively make the generated results obey the guidance of the generated guide map, and pay special attention to the face area. Specifically, the shape and affine transformation of the face area can be constrained through the shape consistency module (STN), so that it can generate a face in a more original side face image. Figure 6 It can be seen that the generated results are relatively realistic, indicating that the present invention has a relatively excellent generation effect.

[0200] Figure 7 This is a comparison chart of the effects of the method of the present invention and the existing image translation methods CycleGAN and CUT. Figure 7 From the generation results, the method of the present invention is obviously superior to other existing methods, and can achieve the goal of generating a shadow puppet head that looks like a shadow puppet head, and the features of the original human face can be seen on the face of the head.

[0201] Although the present invention is described herein with reference to specific embodiments, it should be understood that these embodiments are merely examples of the principles and applications of the present invention. It should therefore be understood that many modifications may be made to the exemplary embodiments and that other arrangements may be devised without departing from the spirit and scope of the present invention as defined by the appended claims. It should be understood that the various dependent claims and features described herein may be combined in a manner different from that described in the original claims. It should also be understood that features described in conjunction with individual embodiments may be used in other described embodiments.

Claims

1. A method for constructing a personalized shadow puppet head attribute editing generator, characterized in that: The generator includes the profile intermediate feature encoder E C , semantic style encoder E S and a style fusion generator G; the method includes the following process: S1. Construct shadow puppet head sample set and human face profile sample set: Each sample in the shadow play sample set includes a shadow play image S and a shadow play semantic annotation image M. s ; Each sample in the face profile sample set includes a side face image F and a side face mask image M F ; Semantic annotation of shadow puppet headstock M s There are 8 categories of styles, the first to the eighth category styles are background, face, beard, crown, helmet, hat, scarf and neck; S2. Sample pretreatment: First, randomly select a sample from the shadow puppet head stubble sample set and the human face profile sample set to obtain the shadow puppet head stubble image S and the shadow puppet head stubble semantic annotation image M. s , side face image F and side face mask image M F ; Then, the semantic annotation map M of the shadow puppet head s , side face image F and side face mask image M F Preprocessing is performed to obtain the corresponding semantic annotation unique heat map of the shadow puppet head Face area map F″ and profile mask alignment map M″ F ; Finally, the shadow puppet head is semantically labeled as a unique heat map The face area in is replaced with the profile mask alignment image M″ F , and obtain the semantic guidance graph Semantic Guided Graph It consists of mask images of the areas where the 8 categories of styles are located; Get the semantic annotation unique heat map of the shadow play head Face area map F″ and profile mask alignment map M″ F The implementation process includes: S21. Semantic annotation of the shadow puppet headstock M s Perform single-hot layering processing to obtain the single-hot map of the semantic annotation of the shadow puppet head S22, using the side face mask image M F After masking the face area in the side face image F, face scaling is performed to obtain the face area scaling image F′. At the same time, the side face mask image M is also F Perform proportional face scaling to obtain the mask scaling image M′ F ; S23, translating the cluster center of the face area zoom map F′ to the shadow puppet stubble semantic annotation unique heat map obtained in step S21 At the cluster center of the middle face area, the face area map F″ is obtained; The mask scale map M′ F The cluster center is translated to the unique heat map of the semantic annotation of the shadow puppet head obtained in step S21 At the cluster center of the middle face area, the side face mask alignment map M″ is obtained F ; S3, the shadow puppet head stubble image S, the face area image F″, and the shadow puppet head stubble semantic annotation unique heat map obtained in step S2 and semantic guidance graph As a set of training samples; S4. Set the upper limit of the iteration round to T, and the initial value of t is 1, where t is the iteration round; S5. In the tth round of training, the generator is trained using a set of training samples obtained in step S3, specifically: S51, profile intermediate feature encoder E C The facial region map F″ is subjected to feature extraction to obtain the facial feature map z; at the same time, the semantic style encoder E S Unique heat map in semantic annotation of shadow puppet head Under the guidance of , the style of the shadow puppet head image S is extracted to obtain the style coding combination st; S52, style fusion generator G is used to add noise to the face feature map z and add noise to the semantic guidance map Under the guidance of , various styles are fused on the feature map after adding noise and the style encoding combination st to generate the fusion map S′; S6. Total loss calculation and parameter update: The fusion image S′ is compared with the face area image F″ and the shadow puppet stubble image S to obtain the total loss L, and the total loss L is used to decode the profile face intermediate feature encoder E C , semantic style encoder E S Update parameters of the style fusion generator G; S7. Determine whether t is equal to T. If not, set t=t+1 and execute step S2. If yes, complete the training of the generator and realize the construction of the generator.

2. The method for constructing a personalized shadow puppet stubble attribute editing generator according to claim 1 is characterized in that: In step S6, the fusion image S′ is compared and analyzed with the face area image F″ and the shadow puppet stubble image S, and the implementation method of obtaining the total loss L includes: S61. Compare and analyze the face area in the fusion image S′ and the face area in the face area image F″ to obtain the face loss L in-face ; Compare and analyze the non-face area in the fusion image S′ with the non-face area in the shadow puppet head image S to obtain the non-face loss L out-face ; Calculate the adversarial loss L between the generator and the preset multi-scale discriminator D GAN (E C ,E S ,G,D); S62, according to L in-face , L out-face and L GAN (E C ,E S ,G,D), and get the total loss L, which is:

3. The method for constructing a personalized shadow puppet stubble attribute editing generator according to claim 2 is characterized in that: L in-face =λ nce L PatchNCE Formula 2; Among them, λ nce is the face loss adjustment parameter, L PatchNCE It is the face area shape consistency loss of the fusion image S′ and the face area image F″.

4. The method for constructing a personalized shadow puppet head stubble attribute editing generator according to claim 2 is characterized in that: L out-face =λ percep L percep +λ feat L feat Formula 3; Among them, λ percep is the first adjustment parameter for the out-of-face loss, L percep is the perceptual loss of the non-face area of ​​the fusion image S′ and the shadow puppet head image S, feat is the second adjustment parameter for the out-of-face loss, L feat It is the feature matching loss of the non-face area between the fusion image S′ and the shadow puppet stubble image S.

5. The method for constructing a personalized shadow puppet stubble attribute editor generator according to claim 2 is characterized in that: in, It represents the expectation that the preset multi-scale discriminator D judges the shadow puppet head stubble image S to be true; It represents the expectation that the preset multi-scale discriminator D judges that the fusion image S′ generated by the face area map F″ is false; D(S) is the output of the preset multi-scale discriminator D when the input of the preset multi-scale discriminator D is the shadow puppet stubble image S; D(S′) is the output of the preset multi-scale discriminator D when the input of the preset multi-scale discriminator D is the fusion image S′.

6. The method for constructing a personalized shadow puppet stubble attribute editor generator according to claim 1, characterized in that: Face scaling factor Among them, t S Semantic annotation of shadow puppet headstock s The number of pixels in the middle face area; t F The side face mask image M F The number of pixels in the mid-face area.

7. The method for constructing a personalized shadow puppet stubble attribute editor generator according to claim 1, characterized in that: The style fusion generator G includes 7 style fusion residual blocks, 5 upsampling modules and an output head module; and from left to right are the first to the seventh style fusion residual blocks; The input end of the first style fusion residual block is used as the input end of the style fusion generator G to receive the face feature map z; The first style fusion residual block is used to add noise to the feature map it receives and also to add noise to the semantic guidance map. Under the guidance of , the feature map after adding noise is firstly extracted, then style fused with style coding combination st, and finally the fused feature map is enhanced to obtain the first residual fusion feature map, which is sent to the first upsampling module; The first upsampling module is used to perform nearest neighbor upsampling on the received first residual fusion feature map to double the size of the first residual fusion feature map, obtain the feature map after the first upsampling, and send it to the second style fusion residual block; The second style fusion residual block is used to add noise to the feature map it receives; it is also used to add noise to the semantic guidance map. Under the guidance of , the feature map after adding noise is firstly extracted, then style fused with style coding combination st, and finally the fused feature map is enhanced to obtain the second residual fusion feature map, which is sent to the third style fusion residual block; The third style fusion residual block is used to add noise to the feature map it receives; it is also used to add noise to the semantic guidance map. Under the guidance of , the feature map after adding noise is firstly extracted, then style fused with style coding combination st, and finally the fused feature map is enhanced to obtain the third residual fusion feature map, which is sent to the second upsampling module; The second upsampling module is used to perform nearest neighbor upsampling on the received third residual fusion feature map to double the size of the third residual fusion feature map, obtain the feature map after the second upsampling, and send it to the fourth style fusion residual block; The fourth style fusion residual block is used to add noise to the feature map it receives; it is also used to add noise to the semantic guidance map. Under the guidance of , the feature map after adding noise is firstly extracted, then style fused with style coding combination st, and finally the fused feature map is enhanced to obtain the fourth residual fusion feature map, which is sent to the third upsampling module; The third upsampling module is used to perform nearest neighbor upsampling on the received fourth residual fusion feature map to double the size of the fourth residual fusion feature map, obtain the feature map after the third upsampling, and send it to the fifth style fusion residual block; The fifth style fusion residual block is used to add noise to the feature map it receives; it is also used to Under the guidance of , the feature map after adding noise is firstly extracted, then style fused with style coding combination st, and finally the fused feature map is enhanced to obtain the fifth residual fusion feature map, which is sent to the fourth upsampling module; The fourth upsampling module is used to perform nearest neighbor upsampling on the received fifth residual fusion feature map to double the size of the fifth residual fusion feature map, obtain the feature map after the fourth upsampling, and send it to the sixth style fusion residual block; The sixth style fusion residual block is used to add noise to the feature map it receives; it is also used to add noise to the semantic guidance map Under the guidance of , the feature map after adding noise is firstly extracted, then style fused with style coding combination st, and finally the fused feature map is enhanced to obtain the sixth residual fusion feature map, which is sent to the fifth upsampling module; The fifth upsampling module is used to perform nearest neighbor upsampling on the received sixth residual fusion feature map, so as to double the size of the sixth residual fusion feature map and obtain the feature map after the fifth upsampling; The seventh style fusion residual block is used to add noise to the feature map it receives; it is also used to add noise to the semantic guidance map. Under the guidance of , the feature map after adding noise is firstly extracted, and then style fused with style coding combination st, and finally the fused feature map is enhanced to obtain the seventh residual fusion feature map, which is sent to the output head module; The output head module is used to adjust the number of channels of the seventh residual fusion feature map to 3, and then perform nonlinear activation to form a fusion map S′, which is used as the output of the style fusion generator G.

8. The method for constructing a personalized shadow puppet stubble attribute editor generator according to claim 7, characterized in that: The internal structures of the 7 style fusion residual blocks are the same; Each style fusion residual block includes 3 normalized style fusion networks, 4 adders, 1 multiplier and 1 image channel importance extraction network; wherein, the first and second normalized style fusion networks, and the first, second and fourth adders constitute the main branch; the third normalized style fusion network, the third adder, the multiplier and the image channel importance extraction network constitute the residual branch; The first adder is used to add the first noise N1 to the feature map received by the style fusion residual block in which it is located, and the feature map after adding the first noise N1 is sent to the first normalized style fusion network; The first normalized style fusion network is used to normalize the feature map after adding the first noise N1, obtain the normalized feature map after adding the first noise N1, and add the first noise N1 to the semantic guidance map. Under the guidance of , the normalized feature map after adding the first noise N1 is fused with the style coding combination st for each category to obtain the first style fusion feature map, and the first style fusion feature map is sequentially activated and convolved to obtain the first feature map of the main branch; The second adder is used to add the second noise N2 to the first feature map of the main branch, and the feature map after adding the second noise N2 is sent to the second normalized style fusion network; The second normalized style fusion network is used to normalize the received feature map after adding the second noise N2, obtain the normalized feature map after adding the second noise N2, and add it to the semantic guidance map Under the guidance of , the normalized feature map after adding the second noise N2 is fused with the style coding combination st for each category to obtain the second style fusion feature map, and the second style fusion feature map is sequentially subjected to nonlinear activation and convolution operations to obtain the second feature map of the main branch; The third adder is used to add the third noise N3 to the feature map received by the style fusion residual block in which it is located, and the feature map after adding the third noise N3 is sent to the third normalized style fusion network; The third normalized style fusion network is used to normalize the received feature map after adding the third noise N3, obtain the normalized feature map after adding the third noise N3, and add the third noise N3 to the semantic guidance map. Under the guidance of , the normalized feature map after adding the third noise N3 is fused with the style coding combination st for each category to obtain the third style fusion feature map, and the third style fusion feature map is sequentially subjected to nonlinear activation and convolution operations to obtain the first feature map of the residual branch; Image channel importance extraction network, used to extract the weights of each channel in the first feature map of the residual branch; A multiplier, used to perform weighted processing on the weight of each channel and the corresponding channel of the first feature map of the residual branch to obtain the second feature map of the residual branch after feature enhancement; The fourth adder is used to perform a feature map residual connection between the second feature map of the residual branch and the second feature map of the main branch to obtain a residual fusion feature map, which is used as the output of the style fusion residual block.

9. The method for constructing a personalized shadow puppet head stubble attribute editing generator according to claim 8 is characterized in that: (I) The first normalized style fusion network, in the semantic guidance graph Under the guidance of , the normalized feature map after adding the first noise N1 is fused with the style coding combination st for each category. The specific process of obtaining the first style fusion feature map is as follows: S52-11, perform two linear transformations with different parameters on each category style in the style coding combination st to obtain the mean value γ corresponding to each category style i and variance β i , i=0,1……6,7; γ i is the mean value corresponding to the i+1th category style, β i is the variance corresponding to the i+1th category style; S52-12, through 8 categories of style processing channels, the semantic guidance map is The mask image of the area where the corresponding category style is located and the normalized feature map after adding the first noise N1, the mean value γ corresponding to this category style i , variance β i and fusion parameter b i The style fusion is performed under the action of the style fusion function to obtain the fusion map of each category style, where b0+b1+b2+b3+b4+b5+b6+b7=1, b i is the fusion parameter corresponding to the i+1th category style, specifically: The processing process of the second category style processing channel is as follows: after the mask image of the area where the second category style is located is multiplied by the normalized feature map after adding the first noise N1, the facial shape consistency correction is performed in sequence, and it is multiplied by the mean γ1 corresponding to the second category style, and then summed with the variance β1 corresponding to the second category style, and then multiplied by the fusion parameter b1 to obtain the fusion image of the second category style; The processing process of the first and any one of the third to eighth category style processing channels is as follows: The mask image of the area where any category style other than the second category style is located is multiplied by the normalized feature map after adding the first noise N1, and then multiplied by the mean γ corresponding to the category style. j After multiplication, the variance β corresponding to the style of this category j After summing, it is combined with the fusion parameter b j Multiply them to obtain the fusion map of the style of this category, j = 0, 2, 3, 4, 5, 6, 7; S52-13, merging the fusion images of all categories of styles to obtain the first style fusion feature image; (ii) The second normalized style fusion network, in the semantic guidance graph Under the guidance of , the normalized feature map after adding the second noise N2 is fused with the style coding combination st for each category, and the specific process of obtaining the second style fusion feature map is as follows: S52-21, perform two linear transformations with different parameters on each category style in the style coding combination st to obtain the mean value γ corresponding to each category style i and variance β i , i=0,1……6,7; γ i is the mean value corresponding to the i+1th category style, β i is the variance corresponding to the i+1th category style; S52-22, through 8 categories of style processing channels, the semantic guidance map is The mask image of the area where the corresponding category style is located and the normalized feature map after adding the second noise N2, the mean value γ corresponding to this category style i , variance β i and fusion parameter b i The style fusion is performed under the action of the style fusion function to obtain the fusion map of each category style, where b0+b1+b2+b3+b4+b5+b6+b7=1, b i is the fusion parameter corresponding to the i+1th category style, specifically: The processing process of the second category style processing channel is as follows: after the mask image of the area where the second category style is located is multiplied by the normalized feature map after adding the second noise N2, facial shape consistency correction is performed in sequence, and it is multiplied by the mean γ1 corresponding to the second category style, and then summed with the variance β1 corresponding to the second category style, and then multiplied by the fusion parameter b1 to obtain the fusion image of the second category style; The processing process of the first and any one of the third to eighth category style processing channels is as follows: The mask image of the area where any category style other than the second category style is located is multiplied by the normalized feature map after adding the second noise N2, and then multiplied by the mean γ corresponding to the category style. j After multiplication, the variance β corresponding to the style of this category j After summing, it is combined with the fusion parameter b j Multiply them to obtain the fusion map of the style of this category, j = 0, 2, 3, 4, 5, 6, 7; S52-23, merging the fusion images of all categories of styles to obtain a second style fusion feature image; (III) The third normalized style fusion network, in the semantic guidance graph Under the guidance of , the normalized feature map after adding the third noise N3 is fused with the style coding combination st for each category, and the implementation method of obtaining the third style fusion feature map includes: S52-31, perform two linear transformations with different parameters on each category style in the style coding combination st to obtain the mean value γ corresponding to each category style i and variance β i , i=0,1……6,7; γ i is the mean value corresponding to the i+1th category style, β i is the variance corresponding to the i+1th category style; S52-32, through 8 categories of style processing channels, the semantic guidance map is The mask image of the area where the corresponding category style is located and the normalized feature map after adding the third noise N3, the mean value γ corresponding to this category style i , variance β i and fusion parameter b i The style fusion is performed under the action of the style fusion function to obtain the fusion map of each category style, where b0+b1+b2+b3+b4+b5+b6+b7=1, b i is the fusion parameter corresponding to the i+1th category style, specifically: The processing process of the second category style processing channel is as follows: after the mask image of the area where the second category style is located is multiplied by the normalized feature map after adding the third noise N3, facial shape consistency correction is performed in sequence, and after multiplication by the mean γ1 corresponding to the second category style, the sum is calculated with the variance β1 corresponding to the second category style, and then multiplied by the fusion parameter b1 to obtain the fusion image of the second category style; The processing process of the first and any one of the third to eighth category style processing channels is as follows: The mask image of the area where any category style other than the second category style is located is multiplied by the normalized feature map after adding the third noise N3, and then multiplied by the mean γ corresponding to the category style. j After multiplication, the variance β corresponding to the style of this category j After summing, it is combined with the fusion parameter b j Multiply them to obtain the fusion map of the style of this category, j = 0, 2, 3, 4, 5, 6, 7; S52-33. Merge the fusion maps of all categories of styles to obtain the third style fusion feature map.

Citation Information

Patent Citations

  • Method for realizing shadow play style migration through improved cyclic generative adversarial network

    CN113781294A

  • Unsupervised domain aligned face condition image generation method based on Top-k sorting

    CN115731317A

  • Personalized shadow puppet face generation method based on constraint generative adversarial network

    CN115841418A