CN113256513B - Face beautifying method and system based on antagonistic neural network - Google Patents

Face beautifying method and system based on antagonistic neural network Download PDF

Info

Publication number
CN113256513B
CN113256513B CN202110514754.9A CN202110514754A CN113256513B CN 113256513 B CN113256513 B CN 113256513B CN 202110514754 A CN202110514754 A CN 202110514754A CN 113256513 B CN113256513 B CN 113256513B
Authority
CN
China
Prior art keywords
portrait
natural
style
loss
beautified
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110514754.9A
Other languages
Chinese (zh)
Other versions
CN113256513A (en
Inventor
王鼎
谢衍涛
宋娜
陈继
梅启鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Gexiang Technology Co ltd
Original Assignee
Hangzhou Gexiang Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Gexiang Technology Co ltd filed Critical Hangzhou Gexiang Technology Co ltd
Priority to CN202110514754.9A priority Critical patent/CN113256513B/en
Publication of CN113256513A publication Critical patent/CN113256513A/en
Application granted granted Critical
Publication of CN113256513B publication Critical patent/CN113256513B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • G06T5/77
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/213Feature extraction, e.g. by transforming the feature space; Summarisation; Mappings, e.g. subspace methods
    • G06F18/2132Feature extraction, e.g. by transforming the feature space; Summarisation; Mappings, e.g. subspace methods based on discrimination criteria, e.g. discriminant analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V40/00Recognition of biometric, human-related or animal-related patterns in image or video data
    • G06V40/10Human or animal bodies, e.g. vehicle occupants or pedestrians; Body parts, e.g. hands
    • G06V40/16Human faces, e.g. facial parts, sketches or expressions
    • G06V40/168Feature extraction; Face representation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10024Color image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20081Training; Learning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30196Human being; Person
    • G06T2207/30201Face

Abstract

The application relates to a portrait beautifying method and system based on an antagonistic neural network, wherein the method comprises the following steps: acquiring a beautified portrait and a natural portrait, wherein the beautified portrait is subjected to beautification style extraction to obtain an beautification style code, the beautification style code is generated through an beautification portrait generator to obtain an beautification style characteristic, the natural portrait is subjected to natural portrait style extraction through a natural portrait style extraction to obtain a natural style code, and the natural style code is generated through a natural portrait generator to obtain a natural style characteristic; the beautification and natural style characteristics are mixed step by step to obtain mixed characteristics, the mixed characteristics are converted into beautified natural portrait through a mixed generator, and the beautified natural portrait and unprocessed natural portrait are combined to generate a pair sample set; and finally, training the migrator through the paired sample set, and beautifying the portrait of the user through the trained migrator to obtain a portrait beautifying picture of the user. The accuracy and the efficiency of portrait beautification are improved, and the design cost is reduced.

Description

Face beautifying method and system based on antagonistic neural network
Technical Field
The application relates to the technical field of image processing, in particular to a portrait beautifying method and system based on an antagonistic neural network.
Background
With the development of consumer electronics technology, consumers can shoot portrait more and more conveniently by using photographing equipment, and the technical demand for beautifying portrait photos on the market is stronger and stronger; the portrait photo beautification technology belongs to the technical field of image processing, and generates more favorable image effects by processing the areas of the skin, the five sense organs, the hair and the like of the portrait. Portrait beautification has been a research hotspot in the field of image processing for many years because of its great commercial value. The traditional image processing method is to carry out algorithm decomposition on a beautified target and combine a plurality of basic algorithms to realize beautification; after the development of deep learning technology, the neural network can learn beautification styles from a large number of beautification samples and apply the beautification styles to new portrait photos. However, both the conventional decomposition algorithm and the emerging deep learning algorithm have various limitations in practical applications.
In the related technology, the traditional decomposition algorithm needs to manually decompose the beautifying effect into specific basic algorithms such as blurring, color adjustment, superposition and the like, which has high requirements on an algorithm engineer, so that the algorithm engineer needs to be familiar with the beautifying style and design a delicate algorithm, has enough robust performance to deal with various illumination conditions, and has high design difficulty; the method based on the neural network can greatly reduce the difficulty of algorithm design, but the algorithm with better effect is generally a supervised learning algorithm, the algorithm usually needs a large number of paired samples, and the samples are usually obtained by manual adjustment of designers, so a large number of samples usually need a large amount of manual investment, and the implementation cost is very high; in addition, in recent years, the method for editing the portrait by using the generative antagonistic neural network can avoid the problem of artificially making a sample, but faces the problem of feature entanglement, and cannot edit a certain feature independently, for example, a user only wants to beautify the portrait but changes the screen background or the gender of a person at the same time.
At present, no effective solution is provided for the problem of feature entanglement or high sample design cost in the process of beautifying the portrait in the related art.
Disclosure of Invention
The embodiment of the application provides a portrait beautifying method and system based on an antagonistic neural network, which at least solve the problems of feature entanglement or high sample design cost in beautifying the portrait in the related art.
In a first aspect, an embodiment of the present application provides a method for beautifying a portrait based on an antagonistic neural network, the method including:
acquiring a beautified portrait and a natural portrait, wherein the beautified portrait is subjected to beautification portrait style extraction to obtain an beautification style code, the beautification style code is generated through an beautification portrait generator to obtain an beautification style characteristic, the natural portrait is subjected to natural portrait style extraction through a natural portrait style extraction to obtain a natural style code, and the natural style code is generated through a natural portrait generator to obtain a natural style characteristic;
mixing the beautification style characteristics and the natural style characteristics step by step to obtain mixed characteristics, converting the mixed characteristics into beautified natural portrait through a mixed generator, and combining the beautified natural portrait with the natural portrait to generate a pair sample set;
training the migrator through the paired sample sets to obtain a trained migrator, and beautifying the portrait of the user through the trained migrator to obtain a portrait beautifying picture of the user, wherein the migrator is of a U-NET network structure.
In some of these embodiments, prior to combining the natural portrait and the beautified natural portrait into a set of pairwise samples, the method includes:
respectively training the beautified portrait style extractor, the beautified portrait generator, the natural portrait style extractor, the natural portrait generator and the mixed generator, wherein the training sequence is as follows: the first order is to train the beautified portrait generator and the natural portrait generator, the second order is to train the natural portrait style extractor and the beautified portrait style extractor, and the third order is to train the hybrid generator.
In some of these embodiments, training the beautified portrait generator and the natural portrait generator comprises:
and alternately training the beautified portrait generator and the natural portrait generator respectively through the beautified style code and the natural style code until convergence, wherein the beautified portrait generator and the natural portrait generator are both conditional generation type confrontation network structures.
In some of these embodiments, training the natural portrait style extractor and the beautified portrait style extractor comprises:
and taking the L2 norm between the input image and the reconstructed image as a loss function, training the natural portrait style extractor through the natural portrait and the trained natural portrait generator, and training the beautified portrait style extractor through the beautified portrait and the trained beautified portrait generator.
In some of these embodiments, training the mix generator comprises:
acquiring the beautified human image map and the natural human image map, and training the mixed generator through a comprehensive Loss function until convergence, wherein the comprehensive Loss function LosstotalComprises the following steps:
Losstotal=w1*Losssty+w2*Lossback+w3*Lossdis+w4*LossID
wherein, w1,w2,w3,w4Is a coefficient of thumb, LossstyBeing a Loss of style function, LossbackLoss function for background reconstruction, LossdisFor discriminating Loss functions, LossIDIs a portrait consistency loss function.
In some embodiments, the blending the beautification style features and the natural style features step by step to obtain blended features includes:
and mixing the beautification style characteristics and the natural style characteristics step by step according to the resolution size to obtain mixed characteristics.
In a second aspect, an embodiment of the present application provides a system for beautifying a human image based on an antagonistic neural network, the system including:
the generation module is used for acquiring a beautified portrait and a natural portrait, wherein the beautified portrait is subjected to beautification style extraction to obtain an beautification style code, the beautification style code is generated by the beautification portrait generator to obtain an beautification style characteristic, the natural portrait is subjected to natural portrait style extraction to obtain a natural style code, the natural style code is generated by the natural portrait generator to obtain a natural style characteristic,
mixing the beautification style characteristics and the natural style characteristics step by step to obtain mixed characteristics, converting the mixed characteristics into beautified natural portrait through a mixed generator, and combining the beautified natural portrait with the natural portrait to generate a pair sample set;
and the beautifying module is used for training the migrator through the paired sample set to obtain a trained migrator, and beautifying the portrait of the user through the trained migrator to obtain a portrait beautifying picture of the user, wherein the migrator is of a U-NET network structure.
In some of these embodiments, the system further comprises a training module,
the training module is used for training the beautified portrait style extractor, the beautified portrait generator, the natural portrait style extractor, the natural portrait generator and the mixed generator respectively before the natural portrait and the beautified natural portrait are combined to generate a paired sample set, wherein the training sequence is as follows: the first order is to train the beautified portrait generator and the natural portrait generator, the second order is to train the natural portrait style extractor and the beautified portrait style extractor, and the third order is to train the hybrid generator.
In a third aspect, an embodiment of the present application provides an electronic device, which includes a memory, a processor, and a computer program stored on the memory and executable on the processor, and the processor executes the computer program to implement the method for beautifying a human image based on an anti-neural network according to the first aspect.
In a fourth aspect, the present application provides a storage medium, on which a computer program is stored, where the program is executed by a processor to implement the method for beautifying a human image based on an antagonistic neural network as described in the first aspect.
The portrait beautifying method based on the antagonistic neural network obtains an beautified portrait and a natural portrait, wherein the beautified portrait is subjected to beautification portrait style extraction to obtain an beautified style code, the beautified style code is generated through a beautified portrait generator to obtain beautification style characteristics, the natural portrait is subjected to natural portrait style extraction to obtain a natural style code, and the natural style code is generated through a natural portrait generator to obtain natural style characteristics; then, mixing the beautification style characteristics and the natural style characteristics step by step to obtain mixed characteristics, converting the mixed characteristics into beautified natural portrait through a mixed generator, and combining the beautified natural portrait with unprocessed natural portrait to generate a paired sample set; and finally, training the migrator through the paired sample sets to obtain the trained migrator, and beautifying the portrait of the user through the trained migrator to obtain a portrait beautifying picture of the user, wherein the migrator is of a U-NET network structure.
Compared with the problems of feature entanglement or high sample design cost in the manual collection of paired samples and the manual calculation of a calculation method in the prior art, the paired samples are generated through a generation type antagonistic neural network, the accurate paired samples are used for effectively restricting the migration device to migrate only specified style features, and only one style sample illustration and specified beautification parts, such as five sense organs or hair, need to be specified, the beautification style of the sample illustration can be applied to the specified parts of the portrait photo of the user, other image features in the photo are not changed, the accuracy and the efficiency of portrait beautification are improved, and the design cost is reduced.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the application and not to limit the application. In the drawings:
FIG. 1 is a flow diagram of a method of portrait beautification according to an embodiment of the present application;
FIG. 2 is a schematic diagram of a condition generating countermeasure network architecture in accordance with an embodiment of the present application;
FIG. 3 is a schematic diagram of a hybrid generator network according to an embodiment of the present application;
FIG. 4 is a schematic diagram of a training architecture of a blend generator according to an embodiment of the present application;
FIG. 5 is a schematic diagram of a pair of sample generators according to an embodiment of the present application;
FIG. 6 is a block diagram of a system for portrait enhancement according to an embodiment of the present application;
FIG. 7 is a block diagram of another system for portrait enhancement according to an embodiment of the present application;
fig. 8 is an internal structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be described and illustrated below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments provided in the present application without any inventive step are within the scope of protection of the present application. Moreover, it should be appreciated that in the development of any such actual implementation, as in any engineering or design project, numerous implementation-specific decisions must be made to achieve the developers' specific goals, such as compliance with system-related and business-related constraints, which may vary from one implementation to another.
Reference in the specification to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the specification. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of ordinary skill in the art will explicitly and implicitly appreciate that the embodiments described herein may be combined with other embodiments without conflict.
Unless defined otherwise, technical or scientific terms referred to herein shall have the ordinary meaning as understood by those of ordinary skill in the art to which this application belongs. Reference to "a," "an," "the," and similar words throughout this application are not to be construed as limiting in number, and may refer to the singular or the plural. The use of the terms "including," "comprising," "having," and any variations thereof herein, is meant to cover a non-exclusive inclusion; for example, a process, method, system, article, or apparatus that comprises a list of steps or modules (elements) is not limited to the listed steps or elements, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus. Reference to "connected," "coupled," and the like in this application is not intended to be limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. Reference herein to "a plurality" means greater than or equal to two. "and/or" describes an association relationship of associated objects, meaning that three relationships may exist, for example, "A and/or B" may mean: a exists alone, A and B exist simultaneously, and B exists alone. Reference herein to the terms "first," "second," "third," and the like, are merely to distinguish similar objects and do not denote a particular ordering for the objects.
The application provides a portrait beautification method based on an antagonistic neural network, and fig. 1 is a flow chart of the portrait beautification method according to the embodiment of the application, and as shown in fig. 1, the flow chart comprises the following steps:
step S101, acquiring a beautified portrait and a natural portrait, wherein the beautified portrait is subjected to beautification style extraction to obtain an beautification style code, the beautification style code is generated through a beautification portrait generator to obtain an beautification style characteristic, the natural portrait is subjected to natural portrait style extraction through a natural portrait style extractor to obtain a natural style code, and the natural style code is generated through a natural portrait generator to obtain a natural style characteristic;
optionally, in this embodiment, the image generator G is a beauty portrait generatorSAnd natural portrait generator GHThe same conditional generation type countermeasure network structure is adopted, fig. 2 is a schematic diagram of the conditional generation type countermeasure network structure according to the embodiment of the present application, as shown in fig. 2; in a generator G, Const is a constant of 4x4x512, the input style code V modulates the style of a generation model step by step through an AdaIN module, then Convolution and upsampling are carried out on style characteristics modulated by AdaIN to 2 times of resolution by Convolition +2Xup, and the style characteristics output by the ith stage are expressed as F through a plurality of cascaded AdaIN and Convolition +2Xup processing processes, wherein the style characteristics output by the ith stage are expressed as FiFinally, converting the style characteristics into RGB images by Convolition and outputting the RGB images; it should be noted that the number of cascaded AdaIN and conversion +2Xup can be determined according to the size of the output target image, for example, if the image side is n, the number of cascaded layers is log2(n) of (a). In addition, the RGB image is input to a discriminator D in fig. 2, which is also a convolutional neural network, to discriminate whether the output image of the generator belongs to the sample space;
optionally, the beautified portrait style extractor E in this embodimentSAnd natural portrait style extractor EHAre convolutional neural networks for extracting the style code of the input image for the generator to reconstruct the input image, such as RGB portrait image IinInputting the input into an extractor E, outputting to obtain a style code VinThen V is put ininInput to a generator G to generate a reconstructed image IoutWherein, if IoutAnd IinIf they are the same, the description indicates VinCan express IinThe style of (1);
step S102, mixing the beautification style characteristics and the natural style characteristics step by step to obtain mixed characteristics, converting the mixed characteristics into beautified natural portrait through a mixed generator, and combining the beautified natural portrait with the natural portrait to generate a paired sample set;
FIG. 3 is a schematic diagram of a network structure of a hybrid generator according to an embodiment of the present application, as shown in FIG. 3, in this embodiment, a beautified style portrait S is extracted by an beautified style extractor E in step S101SAnd beautified portrait generator GSObtaining beautification style characteristic F after processingSSimilarly, the natural portrait H is subjected to the natural portrait style extractor E in step S101HAnd natural portrait generator GHAfter processing, natural style characteristics F are obtainedH(ii) a Preferably, the beautification style characteristics F are matched according to the resolution sizeSAnd natural style feature FHMixing step by step to obtain a mixed characteristic FMThen F is put inMInput the hybrid generator G as shown in FIG. 3MIn the middle, the beautified natural portrait H is obtainedS
The specific ith-level mixing mode is shown as the following formula 1:
Figure BDA0003057738330000061
the high resolution layer in the generated model G generally corresponds to the appearance of the image, and the beautifying target of the invention is mainly to change the appearance of the portrait, so the mixed characteristic FMThe lower layer directly uses the natural portrait characteristics, and the upper layer uses FSAnd FHCorresponding to weighted mixture of feature layers, wherein the weighted mixture of each level is performed according to feature channels, weight M in formula 1iObtained by convolutional neural network FMap learning.
The unprocessed natural portrait H and the beautified natural portrait H are obtained by the stepsSPreferably, the pair samples are generated by combining the natural human figure and the beautified natural human figureBefore collection, to output image HSThe beautification style of the image generator is the same as that of the beautification portrait S, the consistency of the portrait (the same person can be identified) and the consistency of the background area and the natural portrait H are kept, a target function needs to be set, and the beautification portrait style extractors E in the paired sample generators are respectively used for extracting the beautification portrait style of the image generator in sequenceSBeautifying portrait GSNatural portrait style extractor EHNatural portrait generator GHAnd mixing generator GMTraining is carried out, wherein the training sequence is as follows: the first order is for the beautified portrait generator GSAnd natural portrait generator GHTraining is carried out, the second order is to the natural portrait style extractor EHAnd an image beautifying style extractor ESTraining is carried out, the third order being to mix the generator GMAnd (5) training. The specific training steps for the paired sample generators are as follows:
s1, for beautifying portrait generator GSAnd natural portrait generator GHTraining is carried out; optionally, a common alternative training method of a generative confrontation neural network is used, and it should be noted that the generative confrontation neural network has two parts, namely a generator G and a discriminator D, where the generator is to generate a realistic image, and the discriminator is to judge whether the image generated by G is realistic enough; in the initial state, neither the generator G nor the discriminator D has the expected capability, and the generator G needs to be trained by "fixing the discriminator D, then training the discriminator D by fixing the generator G", which is a continuous alternate mode to train the discriminator D and the generator G, and finally, convergence is achieved. In this embodiment, the generator G for beautifying the portrait is inputted with the random beautifying style code and the natural style codeSNatural portrait generator GHTraining is performed until convergence. Specifically, beautified portrait samples and natural portrait samples are collected respectively, and beautified portrait generator G is trained by beautified style portrait samplesSAnd a discriminator DSTraining natural portrait generator G with natural portrait sampleHAnd a discriminator DH
S2, extractor E for natural portrait styleHAnd beautified portrait style extractor ESTraining is carried out; optionally, inputting an image IinAnd reconstructing an image IoutL2 norm therebetween as a loss function and through the natural portrait sample and the trained natural portrait generator GHTraining natural portrait style extractor EHThrough beautifying the figure and the trained beautifying figure generator GSTraining beautified portrait style extractor ES. Wherein an image I is inputinAnd reconstructing an image IoutThe norm between L2 is shown in equation 2 below:
Lossrec=||Iin-Iout||2 (2)
in the embodiment, the trained generator G is combined to train the style extractor E, so that the reconstructed image and the input image can be kept consistent as much as possible, and the accuracy of portrait beautification is improved.
S3, for the mixed generator GMTraining is performed, and fig. 4 is a schematic diagram of a training structure of a hybrid generator according to an embodiment of the present application, as shown in fig. 4. Optionally, acquiring a beautified portrait sample and a natural portrait sample, and using the beautified portrait generator G trained in the above stepsSNatural portrait generator GHAnd a natural portrait style extractor EHAnd beautified portrait style extractor ESAnd through the synthetic loss function to the mixed generator GMTraining is carried out until convergence, wherein the Loss function Loss is synthesizedtotalAs shown in the following formula 3:
Losstotal=w1*Losssty+w2*Lossback+w3*Lossdis+w4*LossID (3)
wherein, w1,w2,w3,w4Is a coefficient of thumb, LossstyBeing a Loss of style function, LossbackLoss function for background reconstruction, LossdisTo discriminate Loss functions, LossIDIs a portrait consistency loss function.
Further, the Loss of style function LossstyFor restraining beautified natural human figure HSBeautifying style and portraitS is consistent; in particular, a beautified portrait generator GSExtraction of HSStyle feature F ofHSThen with FHSResolution highest layer FHSlReconstructing a stylistic feature F of SSlThe reconstruction method comprises the following steps: to FSlEach feature of (1) is in FHSlSearching the nearest neighbor feature to obtain
Figure BDA0003057738330000081
For example, but not limited to, a nearest neighbor feature search function NB can be selected and then FSlAnd with
Figure BDA0003057738330000082
The distance norm of (L) 2 represents the style Loss, where the specific style Loss function LossstyAs shown in the following formulas 4 and 5:
Figure BDA0003057738330000083
Figure BDA0003057738330000084
PM=segment(HS) (5)
wherein PM is a binary diagram, and represents H when the PM value is 1SThe area needing to be beautified, such as hair, face, skin and the like, is 0, and the area does not need to be beautified; PM is represented by HSThe image segmenter segment input into FIG. 4;
loss function Loss of background reconstructionbackImage H for ensuring generation of objective functionSThe same as the background portion of the natural portrait H, i.e., the same region other than the portrait. Wherein the background reconstruction Loss function LossbackAs shown in the following formula 6:
Lossback=‖(1.0-PM)*(H-HS)‖2 (6)
loss of discrimination Lossdis: using a discriminator DSAnd DHConstraint generating portrait HSThe beautified area and the background area belong to respective sample spacesAnd (b) as shown in the following formula 7:
Lossdis=DS(PM*HS)+DH((1.0-PM)*HS) (7)
loss of portrait consistency LossID: generating a portrait for a constraint HSAnd (3) consistency with the natural portrait H, extracting the face features by using the existing face recognizer faceID and calculating the L2 distance norm thereof, as shown in the following formula 8:
LossID=‖FaceID(H)-FaceID(HS)‖2 (8)
fig. 5 is a schematic diagram of a pair of sample generators according to an embodiment of the present application, and as shown in fig. 5, training of the pair of sample generators is completed through the above steps, so that a trained pair of sample generators is obtained. Selecting a beautification style sample SiAnd selecting some natural portrait samples HiInputting the input into a trained pair sample generator to generate a style SiBeautify natural portrait Hsi,(Hi,Hsi) A pair of supervised samples is formed, finally a large number of H are passediGenerating a paired sample SetsiThe paired sample set generated by the method has higher accuracy, reduces the influence of feature winding in the image, and can effectively restrict the migrator to only migrate the specified style features without changing other image features;
step S103, training the migrator through the paired sample set to obtain a trained migrator, and beautifying the portrait of the user through the trained migrator to obtain a portrait beautifying picture of the user, wherein the migrator is of a U-NET network structure.
Preferably, the migration device T is used in a portrait beautification prediction stage to convert the user portrait into a user portrait beautification map. Since the pair of sample generators G are generally larger in scale and more complex in computation, the migrator T needs to be trained separately for deployment to the client. Optionally, the migration device T may use, but is not limited to, a U-NET network structure, and furthermore, an objective function of the migration device T is shown in the following formula 9:
LossT=‖(Hsi-T(Hi))‖2 (9)
wherein, T (H)i) An output image representing the migrator;
the present embodiment employs the paired sample Set generated in step S102siAnd training the migration device T by using the loss function shown in the formula 9, so that the migration device learns the capability of beautifying the portrait and keeping the consistency of other parts of the image.
After the training of the transfer device T is completed, the portrait of the user is beautified through the trained transfer device T to obtain an beautification style SiThe user figure beautification picture is predicted.
Through the above steps S101 to S103, the embodiment of the present application is divided into two stages, i.e., a model training stage and a model prediction stage, in the model training stage, a pair of sample generators G and a style migration tool T are respectively trained, where the pair of sample generators includes: beautified portrait GSNatural portrait generation GHBeautified portrait style extractor ESNatural portrait style extractor EHAnd mixing generator GM. Firstly, training a paired sample generator G, then generating a large number of beautification style paired samples based on a designated beautification area and beautification style samples by utilizing the G, and finally training a style shifter T by utilizing the paired samples; after the model training is finished, the user portrait is beautified and predicted through the trained style migrator T, a user portrait beautification picture is obtained, the model prediction is finished, the problems of feature winding, high sample design cost and complex algorithm in the process of beautifying the portrait are solved, the accuracy and the efficiency of portrait beautification are improved, and the design cost is reduced.
It should be noted that the steps illustrated in the above-described flow diagrams or in the flow diagrams of the figures may be performed in a computer system, such as a set of computer-executable instructions, and that, although a logical order is illustrated in the flow diagrams, in some cases, the steps illustrated or described may be performed in an order different than presented herein.
The embodiment also provides a portrait beautifying system based on an antagonistic neural network, which is used for implementing the above embodiments and preferred embodiments, and the description of the system is omitted. As used hereinafter, the terms "module," "unit," "subunit," and the like may implement a combination of software and/or hardware for a predetermined function. Although the means described in the embodiments below are preferably implemented in software, an implementation in hardware, or a combination of software and hardware is also possible and contemplated.
Fig. 6 is a block diagram of a system for human image beautification according to an embodiment of the present application, and as shown in fig. 6, the system includes a generation module 61 and an beautification module 62:
the generation module 61 is used for acquiring a beautified portrait and a natural portrait, wherein the beautified portrait is subjected to beautification style extraction to obtain an beautification style code, the beautification style code is generated by the beautification portrait generator to obtain an beautification style characteristic, the natural portrait is subjected to natural portrait style extraction to obtain a natural style code, the natural style code is generated by the natural portrait generator to obtain a natural style characteristic, the beautification style characteristic and the natural style characteristic are mixed step by step to obtain a mixed characteristic, the mixed characteristic is converted into an beautified natural portrait by the mixed generator, and the beautified natural portrait and the natural portrait are combined to generate a pair sample set; and the beautifying module 62 is used for training the migrator through the paired sample set to obtain a trained migrator, and beautifying the portrait of the user through the trained migrator to obtain a portrait beautifying picture of the user, wherein the migrator is of a U-NET network structure, so that the problems of feature winding, high sample design cost and complex algorithm during portrait beautifying are solved, the accuracy and efficiency of portrait beautifying are improved, and the design cost is reduced.
In some embodiments, the system further includes a training module, and fig. 7 is a block diagram of another human figure beautifying system according to the embodiment of the present application, and as shown in fig. 7, the system includes a generating module 61, a beautifying module 62, and a training module 71. The training module 71 is configured to train a beautified portrait style extractor, a beautified portrait generator, a natural portrait style extractor, a natural portrait generator, and a mixed generator before combining the natural portrait and the beautified natural portrait to generate a pair sample set, where the training sequence is: the first order is to train the beautified portrait creator and the natural portrait creator, the second order is to train the natural portrait style extractor and the beautified portrait style extractor, and the third order is to train the hybrid creator.
It should be noted that, for specific examples in the embodiment of the present system, reference may be made to the examples described in the foregoing embodiment and optional implementation manners, and details of the embodiment are not described herein again.
Note that each of the modules may be a functional module or a program module, and may be implemented by software or hardware. For a module implemented by hardware, the modules may be located in the same processor; or the modules can be respectively positioned in different processors in any combination.
The present embodiment also provides an electronic device comprising a memory having a computer program stored therein and a processor configured to execute the computer program to perform the steps of any of the above method embodiments.
Optionally, the electronic apparatus may further include a transmission device and an input/output device, wherein the transmission device is connected to the processor, and the input/output device is connected to the processor.
In addition, in combination with the method for beautifying portrait based on the antagonistic neural network in the above embodiments, the embodiments of the present application may provide a storage medium to implement. The storage medium having stored thereon a computer program; the computer program, when executed by a processor, implements any of the above embodiments of a method for enhancing a human image based on an antagonistic neural network.
In one embodiment, a computer device is provided, which may be a terminal. The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a method for enhancing a human image based on an antagonistic neural network. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.
In an embodiment, fig. 8 is a schematic internal structure diagram of an electronic device according to an embodiment of the present application, and as shown in fig. 8, there is provided an electronic device, which may be a server, and its internal structure diagram may be as shown in fig. 8. The electronic device comprises a processor, a network interface, an internal memory and a non-volatile memory connected by an internal bus, wherein the non-volatile memory stores an operating system, a computer program and a database. The processor is used for providing calculation and control capabilities, the network interface is used for being connected and communicated with an external terminal through a network, the internal memory is used for providing an environment for the operation of an operating system and a computer program, the computer program is executed by the processor to realize a portrait beautification method based on the antagonistic neural network, and the database is used for storing data.
Those skilled in the art will appreciate that the structure shown in fig. 8 is a block diagram of only a portion of the structure relevant to the present disclosure, and does not constitute a limitation on the electronic device to which the present disclosure may be applied, and that a particular electronic device may include more or less components than those shown, or combine certain components, or have a different arrangement of components.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above may be implemented by hardware instructions of a computer program, which may be stored in a non-volatile computer-readable storage medium, and when executed, the computer program may include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
It should be understood by those skilled in the art that various technical features of the above-described embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above-described embodiments are not described, however, so long as there is no contradiction between the combinations of the technical features, they should be considered as being within the scope of the present description.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (9)

1. A method for enhancing a portrait based on an antagonistic neural network, the method comprising:
acquiring a beautified portrait and a natural portrait, wherein the beautified portrait is subjected to beautification portrait style extraction to obtain an beautification style code, the beautification style code is generated through an beautification portrait generator to obtain an beautification style characteristic, the natural portrait is subjected to natural portrait style extraction through a natural portrait style extraction to obtain a natural style code, and the natural style code is generated through a natural portrait generator to obtain a natural style characteristic;
mixing the beautification style features and the natural style features step by step to obtain mixed features, converting the mixed features into beautified natural portrait through a mixed generator, and combining the beautified natural portrait with the natural portrait to generate a paired sample set, wherein the concrete steps of training the mixed generator comprise: acquiring the beautified human image map and the natural human image map, and training the mixed generator through a comprehensive Loss function until convergence, wherein the comprehensive Loss function LosstotalComprises the following steps:
Losstotal=w1*Losssty+w2*Lossback+w3*Lossdis+w4*LossID
wherein, w1,w2,w3,w4Is a coefficient of thumb, LossstyBeing a Loss of style function, LossbackLoss function for background reconstruction, LossdisFor discriminating Loss functions, LossIDIn order to be a function of the loss of consistency of the portrait,
in particular, the Loss of style function LossstyFor restraining beautified natural human figure HSThe beautification style of the image generator G is consistent with the beautification of the figure SSExtraction of HSStyle feature F ofHSThen with FHSResolution highest layer F ofHSlReconstructing a stylistic feature F of SSlTo FSlEach feature of (1) is in FHSlSearching the nearest neighbor feature to obtain
Figure FDA0003577967210000011
The specific calculation is shown as the following formula:
Figure FDA0003577967210000012
Figure FDA0003577967210000013
wherein PM is a binary diagram, and represents H when the PM value is 1SWhen the area needing to be beautified is 0, the area needing not to be beautified is shown, PM is obtained by an image divider segment, and NB is a nearest neighbor feature search function;
loss function Loss for background reconstructionbackImages H for ensuring generation of objective functionSThe same as the background portion of the natural portrait H, i.e. the same region outside the portrait, is calculated as follows:
Lossback=||(1.0-PM)*(H-HS)||2
loss of discrimination LossdisDiscriminator D using generative antagonistic neural networkSAnd DHConstraint generating portrait HSThe beautified area and the background area belong to respective sample spaces, and the specific calculation is shown as the following formula:
Lossdis=DS(PM*HS)+DH((1.0-PM)*HS)
loss of portrait consistency LossIDGenerating a portrait for the constraint HSAnd the consistency with the character of the natural portrait H, extracting the face characteristics by using the existing face recognizer faceID and calculating the L2 distance norm, wherein the specific calculation is shown as the following formula:
LossID=||FaceID(H)-FaceID(HS)||2
training the migrator through the paired sample set to obtain a trained migrator, and beautifying the portrait of the user through the trained migrator to obtain a portrait beautifying picture of the user, wherein the migrator is of a U-NET network structure.
2. The method of claim 1, wherein prior to combining the natural portrait and the beautified natural portrait to generate a set of paired samples, the method comprises:
respectively training the beautified portrait style extractor, the beautified portrait generator, the natural portrait style extractor, the natural portrait generator and the mixed generator, wherein the training sequence is as follows: the first order is to train the beautified portrait generator and the natural portrait generator, the second order is to train the natural portrait style extractor and the beautified portrait style extractor, and the third order is to train the hybrid generator.
3. The method of claim 2, wherein training the beautified portrait generator and the natural portrait generator comprises:
and alternately training the beautified portrait generator and the natural portrait generator respectively through the beautified style code and the natural style code until convergence, wherein the beautified portrait generator and the natural portrait generator are both conditional generation type confrontation network structures.
4. The method of claim 2 or 3, wherein training the natural portrait style extractor and the beautified portrait style extractor comprises:
and taking the L2 norm between the input image and the reconstructed image as a loss function, training the natural portrait style extractor through the natural portrait and the trained natural portrait generator, and training the beautified portrait style extractor through the beautified portrait and the trained beautified portrait generator.
5. The method of claim 1, wherein the blending the beautification style features and the natural style features in a progressive manner to obtain blended features comprises:
and mixing the beautification style characteristics and the natural style characteristics step by step according to the resolution size to obtain mixed characteristics.
6. A system for enhancing a human figure based on an antagonistic neural network, the system comprising:
the generation module is used for acquiring a beautified portrait and a natural portrait, wherein the beautified portrait is subjected to beautification style extraction to obtain an beautification style code, the beautification style code is generated by the beautification portrait generator to obtain an beautification style characteristic, the natural portrait is subjected to natural portrait style extraction to obtain a natural style code, the natural style code is generated by the natural portrait generator to obtain a natural style characteristic,
mixing the beautification style features and the natural style features step by step to obtain mixed features, converting the mixed features into beautified natural portrait through a mixed generator, and combining the beautified natural portrait with the natural portrait to generate a paired sample set, wherein the concrete steps of training the mixed generator comprise: acquiring the beautified human image map and the natural human image map, and training the mixed generator through a comprehensive Loss function until convergence, wherein the comprehensive Loss function LosstotalComprises the following steps:
Losstotal=w1*Losssty+w2*Lossback+w3*Lossdis+w4*LossID
wherein, w1,w2,w3,w4Is a coefficient of thumb, LossstyBeing a Loss of style function, LossbackLoss function for background reconstruction, LossdisFor discriminating Loss functions, LossIDIn order to be a function of the loss of consistency of the portrait,
in particular, the style Loss function LossstyFor restraining beautified natural human figure HSThe beautification style of the image generator G is consistent with the beautification of the figure SSExtraction of HSStyle feature F ofHSThen with FHSResolution highest layer FHSlReconstructing a stylistic feature F of SSlTo FSlEach feature of (1) is in FHSlSearching the nearest neighbor feature to obtain
Figure FDA0003577967210000031
The specific calculation is shown as the following formula:
Figure FDA0003577967210000032
Figure FDA0003577967210000033
wherein PM is a binary diagram, and represents H when the PM value is 1SWhen the area needing to be beautified is 0, the area needing not to be beautified is shown, PM is obtained by an image divider segment, and NB is a nearest neighbor feature search function;
loss function Loss of background reconstructionbackImages H for ensuring generation of objective functionSThe same as the background portion of the natural portrait H, i.e. the same region outside the portrait, is calculated as follows:
Lossback=||(1.0-PM)*(H-HS)||2
loss of discrimination LossdisDiscriminator D using generative antagonistic neural networkSAnd DHConstraint generating portrait HSThe beautified area and the background area belong to respective sample spaces, and the specific calculation is shown as the following formula:
Lossdis=DS(PM*HS)+DH((1.0-PM)*HS)
loss of portrait consistency LossIDGenerating a portrait for the constraint HSAnd the consistency with the character of the natural portrait H, extracting the face characteristics by using the existing face recognizer faceID and calculating the L2 distance norm, wherein the specific calculation is shown as the following formula:
LossID=||FaceID(H)-FaceID(HS)||2
and the beautifying module is used for training the migrator through the paired sample set to obtain a trained migrator, and beautifying the portrait of the user through the trained migrator to obtain a portrait beautifying picture of the user, wherein the migrator is of a U-NET network structure.
7. The system of claim 6, further comprising a training module,
the training module is used for training the beautified portrait style extractor, the beautified portrait generator, the natural portrait style extractor, the natural portrait generator and the mixed generator respectively before the natural portrait and the beautified natural portrait are combined to generate a paired sample set, wherein the training sequence is as follows: the first order is to train the beautified portrait generator and the natural portrait generator, the second order is to train the natural portrait style extractor and the beautified portrait style extractor, and the third order is to train the hybrid generator.
8. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the computer program to perform the method for enhancing a human image based on an antagonistic neural network according to any one of claims 1 to 5.
9. A storage medium having a computer program stored thereon, wherein the computer program is configured to execute the method for enhancing a human image based on an antagonistic neural network according to any one of claims 1 to 5 when the computer program is executed.
CN202110514754.9A 2021-05-10 2021-05-10 Face beautifying method and system based on antagonistic neural network Active CN113256513B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110514754.9A CN113256513B (en) 2021-05-10 2021-05-10 Face beautifying method and system based on antagonistic neural network

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110514754.9A CN113256513B (en) 2021-05-10 2021-05-10 Face beautifying method and system based on antagonistic neural network

Publications (2)

Publication Number Publication Date
CN113256513A CN113256513A (en) 2021-08-13
CN113256513B true CN113256513B (en) 2022-07-01

Family

ID=77222894

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110514754.9A Active CN113256513B (en) 2021-05-10 2021-05-10 Face beautifying method and system based on antagonistic neural network

Country Status (1)

Country Link
CN (1) CN113256513B (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101140623A (en) * 2007-09-29 2008-03-12 华为技术有限公司 Video frequency objects recognition method and system based on supporting vectors machine
CN109410131A (en) * 2018-09-28 2019-03-01 杭州格像科技有限公司 The face U.S. face method and system of confrontation neural network are generated based on condition
CN110458750A (en) * 2019-05-31 2019-11-15 北京理工大学 A kind of unsupervised image Style Transfer method based on paired-associate learning
CN110796593A (en) * 2019-10-15 2020-02-14 腾讯科技(深圳)有限公司 Image processing method, device, medium and electronic equipment based on artificial intelligence
CN111046763A (en) * 2019-11-29 2020-04-21 广州久邦世纪科技有限公司 Portrait cartoon method and device
CN111292262A (en) * 2020-01-19 2020-06-16 腾讯科技(深圳)有限公司 Image processing method, image processing apparatus, electronic device, and storage medium
CN111862274A (en) * 2020-07-21 2020-10-30 有半岛(北京)信息科技有限公司 Training method for generating confrontation network, and image style migration method and device
CN111950432A (en) * 2020-08-07 2020-11-17 武汉理工大学 Makeup style migration method and system based on regional style consistency

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109447895B (en) * 2018-09-03 2021-06-08 腾讯科技(武汉)有限公司 Picture generation method and device, storage medium and electronic device
CN109829849B (en) * 2019-01-29 2023-01-31 达闼机器人股份有限公司 Training data generation method and device and terminal

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101140623A (en) * 2007-09-29 2008-03-12 华为技术有限公司 Video frequency objects recognition method and system based on supporting vectors machine
CN109410131A (en) * 2018-09-28 2019-03-01 杭州格像科技有限公司 The face U.S. face method and system of confrontation neural network are generated based on condition
CN110458750A (en) * 2019-05-31 2019-11-15 北京理工大学 A kind of unsupervised image Style Transfer method based on paired-associate learning
CN110796593A (en) * 2019-10-15 2020-02-14 腾讯科技(深圳)有限公司 Image processing method, device, medium and electronic equipment based on artificial intelligence
CN111046763A (en) * 2019-11-29 2020-04-21 广州久邦世纪科技有限公司 Portrait cartoon method and device
CN111292262A (en) * 2020-01-19 2020-06-16 腾讯科技(深圳)有限公司 Image processing method, image processing apparatus, electronic device, and storage medium
CN111862274A (en) * 2020-07-21 2020-10-30 有半岛(北京)信息科技有限公司 Training method for generating confrontation network, and image style migration method and device
CN111950432A (en) * 2020-08-07 2020-11-17 武汉理工大学 Makeup style migration method and system based on regional style consistency

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
Zhitong Huang ; Ching Yee Suen.Identity-Preserved Face Beauty Transformation with Conditional Generative Adversarial Networks.《IEEE》.2021, *
苗序娟等.图像风格迁移技术概况及研究现状.《现代计算机》.2021, *
黄菲.基于生成对抗网络的异质人脸图像生成.《中国优秀硕士学位论文全文数据库-信息科技辑》.2021, *

Also Published As

Publication number Publication date
CN113256513A (en) 2021-08-13

Similar Documents

Publication Publication Date Title
He et al. Conditional sequential modulation for efficient global image retouching
Chen et al. Deep photo enhancer: Unpaired learning for image enhancement from photographs with gans
Svoboda et al. Two-stage peer-regularized feature recombination for arbitrary image style transfer
Tan et al. Michigan: multi-input-conditioned hair image generation for portrait editing
KR102477794B1 (en) Image processing method, device and apparatus, and storage medium
CN109361934B (en) Image processing method, device, equipment and storage medium
CN105488472B (en) A kind of digital cosmetic method based on sample form
JP7246811B2 (en) Data processing method, data processing device, computer program, and computer device for facial image generation
CN112132741B (en) Face photo image and sketch image conversion method and system
CN110599395A (en) Target image generation method, device, server and storage medium
CN111815534A (en) Real-time skin makeup migration method, device, electronic device and readable storage medium
CN112164005B (en) Image color correction method, device, equipment and storage medium
CN111275613A (en) Editing method for generating confrontation network face attribute by introducing attention mechanism
CN111161405B (en) Three-dimensional reconstruction method for animal hair
Saquil et al. Ranking cgans: Subjective control over semantic image attributes
Liang et al. Unpaired medical image colorization using generative adversarial network
CN110415184A (en) A kind of multi-modality images Enhancement Method based on orthogonal first space
CN110852940A (en) Image processing method and related equipment
Ji et al. ColorFormer: Image colorization via color memory assisted hybrid-attention transformer
Liu et al. Very lightweight photo retouching network with conditional sequential modulation
Zhou et al. Personalized and occupational-aware age progression by generative adversarial networks
Rao et al. MS-GAN: multi-scale GAN with parallel class activation maps for image reconstruction
CN112883806B (en) Video style migration method and device based on neural network, computer equipment and storage medium
CN113256513B (en) Face beautifying method and system based on antagonistic neural network
CN103810687B (en) Image processing method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant