WO2021083069A1 - Method and device for training face swapping model - Google Patents

Method and device for training face swapping model Download PDF

Info

Publication number
WO2021083069A1
WO2021083069A1 PCT/CN2020/123582 CN2020123582W WO2021083069A1 WO 2021083069 A1 WO2021083069 A1 WO 2021083069A1 CN 2020123582 W CN2020123582 W CN 2020123582W WO 2021083069 A1 WO2021083069 A1 WO 2021083069A1
Authority
WO
WIPO (PCT)
Prior art keywords
face
sample set
model
template
training
Prior art date
Application number
PCT/CN2020/123582
Other languages
French (fr)
Chinese (zh)
Inventor
徐伟
罗琨
陈晓磊
Original Assignee
上海掌门科技有限公司
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 上海掌门科技有限公司 filed Critical 上海掌门科技有限公司
Publication of WO2021083069A1 publication Critical patent/WO2021083069A1/en

Links

Images

Classifications

    • 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
    • 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
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/04Context-preserving transformations, e.g. by using an importance map
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/74Image or video pattern matching; Proximity measures in feature spaces
    • G06V10/75Organisation of the matching processes, e.g. simultaneous or sequential comparisons of image or video features; Coarse-fine approaches, e.g. multi-scale approaches; using context analysis; Selection of dictionaries
    • G06V10/751Comparing pixel values or logical combinations thereof, or feature values having positional relevance, e.g. template matching
    • 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/172Classification, e.g. identification
    • 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/10004Still image; Photographic 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/20Special algorithmic details
    • G06T2207/20084Artificial neural networks [ANN]
    • 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

Definitions

  • the embodiments of the present application relate to the field of computer technology, in particular to a method and device for training a face-changing model.
  • GAN Generative Adversarial Networks
  • the embodiment of the application proposes a method and device for training a face-changing model.
  • an embodiment of the present application provides a method for training a face-changing model, including: receiving a face-changing model training request sent by a user, wherein the face-changing model training request includes the face before the face change provided by the user The sample set and the specified template face identification; from the pre-training model set corresponding to the template face identification, the pre-training model that matches the face sample set before the face change is determined, wherein the pre-training model set includes a sample set group based on the target face The pre-trained model of the template face sample set corresponding to the template face identifier; the template face sample set that matches the face sample set before the face change is determined from the template face sample set; the machine learning method is based on Training the determined pre-training model with the face sample set before the face change and the determined template face sample set to obtain the face change model.
  • determining from the pre-training model set corresponding to the template face identifier the pre-training model that matches the face sample set before the face change includes: if there is a pre-trained model corresponding to the template face identifier in the user's historical face change record The training model determines the pre-training model corresponding to the template face identifier as the pre-training model matching the face sample set before the face change.
  • determining from the pre-training model set corresponding to the template face identifiers the pre-training model that matches the face sample set before the face change further includes: if there is no template face identifier corresponding to the user's historical face change records The pre-training model for identifying the face attribute information of the face sample set before the face change; based on the recognized face attribute information, the pre-training model is determined from the pre-training model set.
  • the face attribute information includes information in at least one of the following dimensions: gender, age group, race, facial accessories, and face shape.
  • identifying the face attribute information of the face sample set before the face change includes: inputting the face sample set before the face change into a pre-trained first classification model to obtain the gender of the face sample set before the face change , Age, race, and facial accessories, where the first classification model is a classification model based on a convolutional neural network.
  • identifying the face attribute information of the face sample set before the face change includes: extracting the face classification features of the face sample set before the face change; inputting the extracted face classification features to the pre-training
  • the second classification model is to obtain the face shape of the face sample set before the face change, where the second classification model is a classification model based on a support vector machine.
  • extracting the facial classification features of the face sample set before the face change includes: extracting the face feature point information of the face sample set before the face change; calculating the face feature point information based on the extracted face feature point information The face measurement parameters of the face sample set before the face; the extracted face feature point information and the calculated face measurement parameters are combined into the face classification features of the face sample set before the face change.
  • determining a pre-training model from the pre-training model set based on the recognized face attribute information includes: determining a pre-training model subset matching the recognized face attribute information from the pre-training model set; computing; The similarity between the face sample set before the face change and the target face sample set corresponding to the pre-training model in the pre-training model subset; based on the calculated similarity, the pre-training model is determined from the pre-training model subset.
  • calculating the similarity between the face sample set before the face change and the target face sample set corresponding to the pre-trained model in the pre-training model subset includes: extracting the average facial features of the face sample set before the face change Vector; Calculate the cosine similarity between the extracted average face feature vector and the average face feature vector of the target face sample set corresponding to the pre-training model in the pre-training model subset.
  • determining, from the template face sample set group, the template face sample set that matches the face sample set before the face change includes: extracting the face richness features of the face sample set before the face change; The degree of matching between the extracted face richness features and the face richness features of the template face sample set in the template face sample set group; based on the calculated matching degree, the template face is determined from the template face sample set group Sample set.
  • extracting the face richness features of the face sample set before the face change includes: extracting the face feature information of the face sample set before the face change; performing histogram statistics on the face feature information to obtain the face change The face richness feature of the previous face sample set.
  • the facial feature information includes information in at least one of the following dimensions: facial feature points, facial angles, and facial expressions.
  • calculating the matching degree between the extracted face richness features and the face richness features of the template face sample set in the template face sample set group includes: using a histogram matching method to calculate the extracted The degree of matching between the face richness features of the template face sample set and the face richness feature of the template face sample set in the template face sample set group.
  • determining the template face sample set from the template face sample set group includes: if there is a template person in the template face sample set group with a matching degree greater than a preset matching degree threshold Face sample set, select the template face sample set with the highest matching degree from the template face sample set group; if there is no template face sample set with the matching degree greater than the preset matching degree threshold in the template face sample set group, select the template face sample set from the template face sample set group. Select a universal template face sample set from the face sample set group.
  • the pre-training model set is trained by the following steps: acquiring multiple target face samples; dividing the multiple target face samples into target face sample set groups according to face attributes, where the same target face The face attributes of the target face samples in the sample set are similar; for the target face sample set in the target face sample set group, based on the target face sample set and the template face sample set matching the target face sample set Train the generative confrontation network to get the pre-training model.
  • the pre-training model includes a generative model and a discriminant model; and using machine learning methods, the determined pre-training model is trained based on the face sample set before the face change and the determined template face sample set, to obtain
  • the face-changing model includes: inputting the face sample set before changing the face into the generated model of the determined pre-training model to obtain the face sample set after the face changing; the face sample set after the face changing and the determined template face sample Set input to the discriminant model of the pre-trained model determined to obtain the discriminant result, where the discriminant result is used to represent the probability that the face sample set after face change and the determined template face sample set are the real sample set; adjust based on the discriminant result
  • the parameters of the generative model and the discriminant model of the determined pre-training model are used to obtain the face sample set after the face changing.
  • adjusting the parameters of the generated model and the discrimination model of the determined pre-training model based on the discrimination result includes: determining whether the discrimination result meets the constraint condition; if the discrimination result does not satisfy the constraint condition, adjusting the determined parameter based on the discrimination result
  • the generation model of the pre-training model and the parameters of the discrimination model, and the determined pre-training model is trained again based on the face sample set before the face change and the determined template face sample set; if the discrimination result meets the constraint conditions, it is determined to change
  • the face model training is completed, and the face sample set after the face change output last time by the generation model of the determined pre-training model is sent to the user.
  • an embodiment of the present application provides an apparatus for training a face-changing model, including: a receiving unit configured to receive a face-changing model training request sent by a user, wherein the face-changing model training request includes the user provided The face sample set before the face change and the designated template face identifier; the first determining unit is configured to determine the pre-training model matching the face sample set before the face change from the pre-training model set corresponding to the template face identifier, Among them, the pre-training model set includes a model pre-trained based on the target face sample set group and the template face sample set group corresponding to the template face identifier; the second determining unit is configured to determine from the template face sample set group A template face sample set that matches the face sample set before the face change; the training unit is configured to use a machine learning method, based on the pre-training determined by the face sample set before the face change and the determined template face sample set The model is trained to obtain a face-changing model.
  • the first determining unit includes: a first determining subunit configured to, if there is a pre-trained model corresponding to the template face identifier in the user’s historical face-changing record, the pre-trained model corresponding to the template face identifier Determined as a pre-trained model that matches the face sample set before the face change.
  • the first determining unit further includes: a recognition sub-unit configured to recognize the person in the face sample set before the face change if there is no pre-trained model corresponding to the template face identifier in the user's historical face change record Face attribute information; the second determining subunit is configured to determine the pre-training model from the pre-training model set based on the recognized face attribute information.
  • the face attribute information includes information in at least one of the following dimensions: gender, age group, race, facial accessories, and face shape.
  • the recognition subunit includes: a first classification module configured to input the face sample set before the face change into the pre-trained first classification model to obtain the gender and age group of the face sample set before the face change , Race, and facial accessories, where the first classification model is a classification model based on a convolutional neural network.
  • the recognition subunit includes: an extraction module configured to extract facial facial classification features of a face sample set before the face change; a second classification module configured to input the extracted facial facial classification features To the pre-trained second classification model, the face shape of the face sample set before the face change is obtained, where the second classification model is a classification model based on a support vector machine.
  • the extraction module is further configured to: extract face feature point information of the face sample set before the face change; based on the extracted face feature point information, calculate the face measurement of the face sample set before the face change Parameters: Combine the extracted facial feature point information and the calculated facial measurement parameters into the facial classification features of the face sample set before the face change.
  • the second determining subunit includes: a first determining module configured to determine a subset of pre-trained models matching the recognized face attribute information from a set of pre-training models; a calculation module configured to calculate The similarity between the face sample set before the face change and the target face sample set corresponding to the pre-training model in the pre-training model subset; the second determining module is configured to determine from the pre-training model subset based on the calculated similarity Pre-trained model.
  • the calculation module is further configured to: extract the average face feature vector of the face sample set before the face change; calculate the extracted average face feature vector and the target corresponding to the pre-trained model in the pre-trained model subset The cosine similarity of the average face feature vector of the face sample set.
  • the second determining unit includes: an extraction subunit configured to extract face richness features of a face sample set before the face change; a calculation subunit configured to calculate the extracted face richness features The matching degree with the face richness feature of the template face sample set in the template face sample set group; the third determining subunit is configured to determine the template from the template face sample set group based on the calculated matching degree Set of human face samples.
  • the extraction subunit is further configured to: extract the face feature information of the face sample set before the face change; perform histogram statistics on the face feature information to obtain the face richness of the face sample set before the face change Degree characteristics.
  • the facial feature information includes information in at least one of the following dimensions: facial feature points, facial angles, and facial expressions.
  • the calculation subunit is further configured to: use a histogram matching method to calculate the difference between the extracted face richness feature and the face richness feature of the template face sample set in the template face sample set group. suitability.
  • the third determining subunit is further configured to: if there is a template face sample set with a matching degree greater than a preset matching degree threshold in the template face sample set group, select the matching from the template face sample set group The template face sample set with the highest degree; if there is no template face sample set with a matching degree greater than the preset matching degree threshold in the template face sample set group, select a general template face sample set from the template face sample set group .
  • the pre-training model set is trained by the following steps: acquiring multiple target face samples; dividing the multiple target face samples into target face sample set groups according to face attributes, where the same target face The face attributes of the target face samples in the sample set are similar; for the target face sample set in the target face sample set group, based on the target face sample set and the template face sample set matching the target face sample set Train the generative confrontation network to get the pre-training model.
  • the pre-training model includes a generative model and a discriminant model
  • the training unit includes: a generating subunit configured to input the set of face samples before the face change into the generative model of the determined pre-training model to obtain the face change The posterior face sample set; the discriminant subunit is configured to input the face sample set after face change and the determined template face sample set into the discriminant model of the determined pre-training model to obtain the discriminant result, where the discriminant result is used To characterize the probability that the face sample set and the determined template face sample set are the real sample set after the face change; the adjustment subunit is configured to adjust the parameters of the determined pre-training model generation model and the discrimination model based on the discrimination result .
  • the adjustment subunit is further configured to: determine whether the discrimination result meets the constraint condition; if the discrimination result does not satisfy the constraint condition, adjust the parameters of the determined pre-training model generation model and the discrimination model based on the discrimination result, and Train the determined pre-training model again based on the face sample set before the face change and the determined template face sample set; if the discrimination result meets the constraint conditions, it is determined that the face change model training is completed, and the determined pre-training model The face sample set after the face change last time output by the generative model is sent to the user.
  • the embodiments of the present application provide a computer device, which includes: one or more processors; a storage device on which one or more programs are stored; when one or more programs are stored by one or more Execution by two processors, so that one or more processors implement the method described in any implementation manner of the first aspect.
  • an embodiment of the present application provides a computer-readable medium on which a computer program is stored, and when the computer program is executed by a processor, the method as described in any implementation manner in the first aspect is implemented.
  • the method and device for training a face-changing model provided by the embodiments of the application firstly receive a face-changing model training request sent by a user; then, determine and change the set of pre-training models corresponding to the template face identifier in the face-changing model training request.
  • the pre-training model that matches the face sample set before the face change in the face model training request; then, from the template face sample set corresponding to the template face identifier, it is determined to match the face sample set before the face change in the face change model training request
  • the machine learning method is used to train the determined pre-training model based on the face sample set before the face change and the determined template face sample set to obtain the face change model.
  • the pre-training model to train the face-changing model avoids "zero-start” training, saves the time-consuming training of the face-changing model, and improves the training efficiency of the face-changing model.
  • the in-depth face-changing technology plays a positive role in practical applications and experience effects.
  • Fig. 1 is an exemplary system architecture in which some embodiments of the present application can be applied;
  • Fig. 2 is a flowchart of an embodiment of a method for training a face-changing model according to the present application
  • Fig. 3 is a flowchart of another embodiment of the method for training a face-changing model according to the present application
  • Fig. 4 is a schematic structural diagram of a computer system suitable for implementing computer equipment of some embodiments of the present application.
  • Fig. 1 shows an exemplary system architecture 100 to which an embodiment of the method for training a face-changing model of the present application can be applied.
  • the system architecture 100 may include devices 101 and 102 and a network 103.
  • the network 103 is a medium used to provide a communication link between the devices 101 and 102.
  • the network 103 may include various connection types, such as wired, wireless target communication links, or fiber optic cables, and so on.
  • the devices 101 and 102 may be hardware devices or software that support network connections to provide various network services.
  • the device can be various electronic devices, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, servers, and so on.
  • a hardware device it can be implemented as a distributed device group composed of multiple devices, or as a single device.
  • the device is software, it can be installed in the electronic devices listed above.
  • software it can be implemented as multiple software or software modules for providing distributed services, or as a single software or software module. There is no specific limitation here.
  • devices can provide corresponding network services by installing corresponding client applications or server applications.
  • client application After the device has installed the client application, it can be embodied as a client in network communication.
  • server application After the server application is installed, it can be embodied as a server in network communication.
  • the device 101 is embodied as a client, and the device 102 is embodied as a server.
  • the device 101 may be a client with image processing software installed, and the device 102 may be a server of the image processing software.
  • the method for training a face-changing model provided in the embodiment of the present application may be executed by the device 102.
  • FIG. 1 the number of networks and devices in FIG. 1 is merely illustrative. According to implementation needs, there can be any number of networks and devices.
  • FIG. 2 it shows a process 200 of an embodiment of the method for training a face-changing model according to the present application.
  • the method for training a face-changing model may include the following steps:
  • Step 201 Receive a face-changing model training request sent by a user.
  • the execution subject of the method for training a face-changing model may receive a face-changing model training request sent by a user.
  • the face-changing model training request may include the face sample set before the face-changing provided by the user and the designated template face identifier.
  • the face sample set before the face change may be a sample set of which the user wants to replace the face.
  • the face sample set before the face change may be one or more face images before the face change, or it may be a multi-frame video frame of the face video before the face change.
  • the template face may be the face that the user wants to replace.
  • the template face identification can be composed of letters, numbers, symbols, etc., and is the only identification of the template face.
  • image processing software may be installed on the user's terminal device (for example, the device 101 shown in FIG. 1).
  • the user can open the image processing software and enter the main page. Edit buttons can be set on the main page.
  • the edit button When the user clicks the edit button, the locally stored image list and/or video list can be displayed for the user to select.
  • the user selects one or more images from the image list, the one or more images selected by the user can be determined as the face sample set provided by the user before the face change.
  • the multi-frame video frame of the video selected by the user can be determined as the face sample set provided by the user before the face change.
  • the user will enter the image processing page.
  • the face sample set before the face change can be displayed on the image processing page.
  • a face-changing button can also be set on the image processing page. When the user clicks the face-changing button, a list of template faces that can be replaced can be displayed. When the user selects a template face from the template face list, the template face selected by the user can be determined as the user-specified template face, and its identifier is the user-specified template face identifier.
  • the terminal device can send a face-changing model training request including the face sample set before the face-changing provided by the user and the designated template face identifier to the above-mentioned execution subject.
  • Step 202 Determine a pre-training model matching the set of face samples before the face change from the pre-training model set corresponding to the template face identifier.
  • the above-mentioned execution subject may determine a pre-training model matching the set of face samples before the face change from the set of pre-training models corresponding to the template face identifier designated by the user. For example, the above-mentioned execution subject may randomly select a pre-training model from a set of pre-training models corresponding to a template face identifier designated by the user.
  • the execution subject may determine the pre-training model corresponding to the template face identifier as the A pre-trained model for matching the face sample set in front of the face.
  • a historical face-changing record is generated.
  • the historical face change record may record the template face identifier and the pre-training model identifier used during the historical face change process.
  • the above-mentioned execution subject may directly determine the pre-training model corresponding to the template face identifier as the pre-training model to be used this time.
  • a template face identifier corresponds to a pre-training model set.
  • the same pre-training model set can be used to train face-changing models of different face attribute information of the same template face.
  • the pre-trained model set of the same template face may include a pre-trained model based on the target face sample set group of the same target face and the template face sample set group of the same template face.
  • a pair of target face sample set and template face sample set can be used to train a pre-training model of the same face attribute information. It can be seen that the face attribute information of the target face samples in the same target face sample set is similar, and the face attributes of the template face samples in the sample set of the same template face are similar. In addition, the face attribute information of the target face sample set and the template face sample set used to train the same pre-training model are also similar.
  • face attribute information may include information of multiple dimensions.
  • face attribute information may include, but is not limited to, information of at least one of the following dimensions: gender (such as male, female), age group (such as teenagers, middle-aged, Old age), race (such as white, yellow, black), facial accessories (such as whether to wear facial accessories), face shape (such as round face, triangle face, oval face, square face), etc. .
  • the pre-training model set is trained through the following steps:
  • the multiple target face samples may be a batch of target face samples of the same target face.
  • the multiple target face samples are divided into target face sample set groups.
  • the face attribute information of the target face samples in the same target face sample set is similar.
  • the target face sample whose face attribute information is ⁇ male, middle-aged, yellow, no glasses, round face ⁇ belongs to a target face sample set.
  • the target face sample whose face attribute information is ⁇ male, middle-aged, yellow, wearing glasses, round face ⁇ belongs to another target face sample set.
  • each target face sample set will be marked with a corresponding label to record the corresponding face attribute information.
  • the generative confrontation network is trained based on the target face sample set and the template face sample set matching the target face sample set to obtain pre-training model.
  • the face attribute information of the template face samples in the same template face sample set is similar.
  • the face attribute information of the template face sample set matching the target face sample set is similar to the face attribute information of the target face sample set. For example, if the face attribute information of the target face sample set is ⁇ male, middle-aged, yellow, no glasses, round face ⁇ , then the face attributes of the template face sample set that matches the target face sample set The information has a high probability of ⁇ male, middle-aged, yellow race, no glasses, round face ⁇ .
  • Step 203 Determine a template face sample set matching the face sample set before the face change from the template face sample set group.
  • the above-mentioned execution subject may determine a template face sample set that matches the face sample set before the face change from the template face sample set group. For example, the above-mentioned execution subject can select a template face sample set similar to the face attribute information of the face sample set before the face change from the template face sample set group, and determine it as a template matching the face sample set before the face change Set of human face samples.
  • Step 204 Using a machine learning method, train the determined pre-training model based on the face sample set before the face change and the determined template face sample set to obtain the face change model.
  • the above-mentioned execution subject may use a machine learning method to train the determined pre-training model based on the face sample set before the face change and the determined template face sample set to obtain the face change model.
  • the above-mentioned execution subject may take the face sample set before the face change and the determined template face sample set as input, and obtain the corresponding output through the processing of the determined pre-training model. If the output satisfies the unconstrained condition, the parameters of the determined pre-training model are adjusted, and the face sample set before the face change and the determined template face sample set are input again to continue training. If the output meets the preset conditions, the model training is completed.
  • the pre-training model is a trained generative confrontation network
  • the pre-training model may include a trained generative model and a trained discriminant model.
  • the generative model is mainly used to learn the distribution of real images to make the images generated by itself more realistic, so as to fool the discriminant model.
  • the discriminant model needs to judge the authenticity of the received image.
  • the generative model strives to make the generated image more realistic, while the discriminative model strives to identify the true and false of the image. This process is equivalent to a two-person game.
  • the generative model and the discriminant model In constant confrontation, the two networks finally reached a dynamic equilibrium: the images generated by the generative model were close to the distribution of real images, and the discriminant model could not identify true and false images.
  • the above-mentioned execution subject may train the face-changing model through the following steps:
  • the face sample set before the face change is input into the determined generation model of the pre-training model to obtain the face sample set after the face change.
  • the face sample set after the face change and the determined template face sample set are input into the determined discriminant model of the pre-training model, and the discriminant result is obtained.
  • the discrimination result can be used to characterize the probability that the face sample set after the face change and the determined template face sample set are the real sample set.
  • the parameters of the determined pre-training model generation model and the discrimination model are adjusted based on the discrimination result.
  • the above-mentioned execution subject will determine whether the judgment result meets the constraint conditions. If the discrimination result does not satisfy the constraint condition, the above-mentioned execution subject may adjust the parameters of the determined pre-training model generation model and discrimination model based on the discrimination result. Subsequently, the determined pre-training model is trained again based on the face sample set before the face change and the determined template face sample set. If the result of the discrimination satisfies the constraint condition, the above-mentioned execution subject may determine that the face-changing model training is completed, and send the face sample set after the face-changing output of the determined generation model of the pre-training model to the user. Among them, the face sample set after the face change last output by the generative model is the sample set where the face before the face change is replaced with the template face.
  • a face-changing model training request sent by a user is received; then, the pre-training model set corresponding to the template face identifier in the face-changing model training request is determined and the face-changing model is determined.
  • the pre-training model that matches the face sample set before the face change in the training request; then, from the template face sample set group corresponding to the template face identifier, determine the template that matches the face sample set before the face change in the face change model training request Face sample set; Finally, a machine learning method is used to train the determined pre-training model based on the face sample set before the face change and the determined template face sample set to obtain the face change model.
  • the pre-training model to train the face-changing model avoids "zero-start” training, saves the time-consuming training of the face-changing model, and improves the training efficiency of the face-changing model.
  • the in-depth face-changing technology plays a positive role in practical applications and experience effects.
  • FIG. 3 shows a process 300 of another embodiment of the method for training a face-changing model according to the present application.
  • the method for training a face-changing model may include the following steps:
  • Step 301 Receive a face-changing model training request sent by the user.
  • step 301 has been described in detail in step 201 in the embodiment shown in FIG. 2, and will not be repeated here.
  • Step 302 If there is no pre-training model corresponding to the template face identifier in the user's historical face change record, identify the face attribute information of the face sample set before the face change.
  • face attribute information of the face sample set in front of the face may include information of multiple dimensions.
  • face attribute information may include, but is not limited to, information of at least one of the following dimensions: gender (such as male, female), age group (such as teenagers, middle-aged, Old age), race (such as white, yellow, black), facial accessories (such as whether to wear facial accessories), face shape (such as round face, triangle face, oval face, square face), etc. .
  • the above-mentioned execution subject may input the face sample set before the face change into the pre-trained first classification model to obtain the gender, age group, and person of the face sample set before the face change.
  • Information of at least one dimension in species and facial accessories can be a classification model based on Convolutional Neural Networks (CNN) (such as AlexNet, GoogleNet, ResNet, etc.). Get it through training.
  • CNN Convolutional Neural Networks
  • the above-mentioned execution subject may first extract the facial classification features of the face sample set before the face change; and then input the extracted facial facial classification features into the pre-trained second
  • the classification model obtains the face shape of the face sample set before the face change.
  • the second classification model may be obtained by training a classification model based on Support Vector Machine (SVM).
  • SVM Support Vector Machine
  • the facial feature classification feature may include facial feature point information and facial measurement parameters.
  • the above-mentioned execution subject can first extract the face feature point information of the face sample set before the face change; then, based on the extracted face feature point information, calculate the face measurement parameters of the face sample set before the face change; The extracted face feature point information and the calculated face measurement parameters are combined into the face classification feature of the face sample set before the face change.
  • the algorithm for extracting facial feature point information may include, but is not limited to, dlib, LBF, and so on.
  • the face measurement parameters calculated based on the facial feature point information may include, but are not limited to, face width (Wshape), jaw width (Wmandible), shape face height (Hshape), and so on.
  • the face width can be equal to the Euclidean distance between the left and right zygomatic points.
  • the width of the mandible can be equal to the Euclidean distance between the left and right mandibular corner points.
  • the height of the morphological surface can be equal to the Euclidean distance between the nasion point and the submental point.
  • Step 303 Based on the recognized face attribute information, a pre-training model is determined from the pre-training model set.
  • the above-mentioned execution subject may determine the pre-training model from the pre-training model set based on the recognized face attribute information. For example, the above-mentioned execution subject may select a pre-training model that best matches the recognized face attribute information from a set of pre-training models.
  • the above-mentioned execution subject may first determine from the pre-training model set a subset of the pre-training model that matches the recognized face attribute information; and then calculate the face sample set before the face change and The similarity of the target face sample set corresponding to the pre-training model in the pre-training model subset; finally, based on the calculated similarity, the pre-training model is determined from the pre-training model subset.
  • the above-mentioned execution subject can first extract the average face feature vector of the face sample set before the face change; then calculate the extracted average face feature vector and the target face sample set corresponding to the pre-training model in the pre-training model subset. The cosine similarity of the average face feature vector.
  • the algorithm for extracting the average face feature vector may be, for example, a face recognition algorithm (such as VggFace).
  • the target face sample set corresponding to the pre-training model is the target face sample set used when the pre-training model is pre-trained.
  • Step 304 Extract the face richness features of the face sample set before the face change.
  • the above-mentioned execution subject may extract the face richness features of the face sample set before the face change.
  • the above-mentioned execution subject may first extract the face feature information of the face sample set before the face change; then perform histogram statistics on the face feature information to obtain the face sample before the face change Set of face richness characteristics.
  • the facial feature information may include, but is not limited to, information in at least one of the following dimensions: facial feature points, facial angles, facial expressions, and so on.
  • Methods for extracting facial feature information may include, but are not limited to, face detection, facial feature point extraction, facial angle recognition, facial expression recognition, and so on.
  • Step 305 Calculate the matching degree between the extracted face richness feature and the face richness feature of the template face sample set in the template face sample set group.
  • the above-mentioned execution subject may calculate the degree of matching between the extracted face richness feature and the face richness feature of the template face sample set in the template face sample set group.
  • the value of the matching degree is usually between 0 and 1, 0 means no match at all, and 1 means complete match.
  • the face richness features of the template face sample set can be pre-selected and extracted, and the extraction method is the same as the face richness feature extraction method of the face sample set before the face change, and will not be repeated here.
  • the above-mentioned execution subject may use the histogram matching method to calculate the extracted face richness features and the face richness of the template face sample set in the template face sample set group. The degree of matching of the feature.
  • Step 306 Determine a template face sample set from the template face sample set group based on the calculated matching degree.
  • the above-mentioned execution subject may determine the template face sample set from the template face sample set group based on the calculated matching degree. For example, the above-mentioned execution subject may select the template face sample set with the highest matching degree from the template face sample set group.
  • the above-mentioned execution subject may compare the matching degree of the template face sample set in the template face sample set group with a preset matching degree threshold (for example, 0.7). If there is a template face sample set with a matching degree greater than a preset matching degree threshold in the template face sample set group, the above-mentioned execution subject may select the template face sample set with the highest matching degree from the template face sample set group. If there is no template face sample set with a matching degree greater than the preset matching degree threshold in the template face sample set group, the above-mentioned execution subject may select a general template face sample set from the template face sample set group. Generally, a universal template face sample set is preset in the template face sample set group.
  • a preset matching degree threshold for example, 0.7
  • Step 307 Use a machine learning method to train the determined pre-training model based on the face sample set before the face change and the determined template face sample set to obtain the face change model.
  • step 307 has been described in detail in step 204 in the embodiment shown in FIG. 2, and will not be repeated here.
  • the process 300 of the method for training a face-changing model in this embodiment highlights the determination of the pre-training model based on the face attribute information and the richness based on the face.
  • the sample set trains the pre-trained model with the most similar face attribute information, improves the face-changing effect of the trained face-changing model, and makes the output of the face-changing model more realistic.
  • FIG. 4 shows a schematic structural diagram of a computer system 400 suitable for implementing a computer device (for example, the device 102 shown in FIG. 1) of an embodiment of the present application.
  • the computer device shown in FIG. 4 is only an example, and should not bring any limitation to the function and scope of use of the embodiments of the present application.
  • the computer system 400 includes a central processing unit (CPU) 401, which can be based on a program stored in a read-only memory (ROM) 402 or a program loaded from a storage part 408 into a random access memory (RAM) 403 And perform various appropriate actions and processing.
  • ROM read-only memory
  • RAM random access memory
  • various programs and data required for the operation of the system 400 are also stored.
  • the CPU 401, the ROM 402, and the RAM 403 are connected to each other through a bus 404.
  • An input/output (I/O) interface 405 is also connected to the bus 404.
  • the following components are connected to the I/O interface 405: an input part 406 including a keyboard, a mouse, etc.; an output part 407 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and speakers, etc.; a storage part 408 including a hard disk, etc. ; And a communication section 409 including a network interface card such as a LAN card, a modem, and the like. The communication section 409 performs communication processing via a network such as the Internet.
  • the driver 410 is also connected to the I/O interface 405 as needed.
  • a removable medium 411 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 410 as required, so that the computer program read from it is installed into the storage section 408 as required.
  • an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart.
  • the computer program may be downloaded and installed from the network through the communication part 409, and/or installed from the removable medium 411.
  • CPU central processing unit
  • the computer-readable medium described in this application may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two.
  • the computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or a combination of any of the above. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable Programmable read only memory (EPROM or flash memory), optical fiber, portable compact disk read only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above.
  • a computer-readable storage medium may be any tangible medium that contains or stores a program, and the program may be used by or in combination with an instruction execution system, apparatus, or device.
  • a computer-readable signal medium may include a data signal propagated in a baseband or as a part of a carrier wave, and a computer-readable program code is carried therein. This propagated data signal can take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing.
  • the computer-readable signal medium may also be any computer-readable medium other than the computer-readable storage medium.
  • the computer-readable medium may send, propagate, or transmit the program for use by or in combination with the instruction execution system, apparatus, or device .
  • the program code contained on the computer-readable medium can be transmitted by any suitable medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
  • the computer program code used to perform the operations of this application can be written in one or more programming languages or a combination thereof.
  • the programming languages include object-oriented programming languages-such as Java, Smalltalk, C++, and also conventional The procedural programming language-such as "C" language or similar programming language.
  • the program code can be executed entirely on the user's computer, partly on the user's computer, executed as an independent software package, partly on the user's computer and partly executed on a remote computer, or entirely executed on the remote computer or electronic device.
  • the remote computer can be connected to the user's computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (for example, through an Internet service provider). Internet connection).
  • LAN local area network
  • WAN wide area network
  • Internet service provider for example, AT&T, MCI, Sprint, EarthLink, MSN, GTE, etc.
  • each block in the flowchart or block diagram may represent a module, program segment, or part of code, and the module, program segment, or part of code contains one or more for realizing the specified logical function Executable instructions.
  • the functions marked in the block may also occur in a different order from the order marked in the drawings. For example, two blocks shown in succession can actually be executed substantially in parallel, and they can sometimes be executed in the reverse order, depending on the functions involved.
  • each block in the block diagram and/or flowchart, and the combination of the blocks in the block diagram and/or flowchart can be implemented by a dedicated hardware-based system that performs the specified functions or operations Or it can be realized by a combination of dedicated hardware and computer instructions.
  • the units involved in the embodiments described in the present application can be implemented in software or hardware.
  • the described unit may also be provided in the processor.
  • a processor includes a receiving unit, a first determining unit, a second determining unit, and a training unit.
  • the names of these units do not constitute a limitation on the unit itself in this case.
  • the receiving unit can also be described as "a unit that receives a face-changing model training request sent by a user".
  • this application also provides a computer-readable medium.
  • the computer-readable medium may be included in the computer equipment described in the above-mentioned embodiments; it may also exist alone without being assembled into the computer equipment. in.
  • the above-mentioned computer-readable medium carries one or more programs.
  • the computer device When the above-mentioned one or more programs are executed by the computer device, the computer device: receives a face-changing model training request sent by a user, wherein, in the face-changing model training request Including the face sample set before the face change and the specified template face identifier provided by the user; the pre-training model matching the face sample set before the face change is determined from the pre-training model set corresponding to the template face identifier, where the pre-training model The set includes pre-trained models based on the target face sample set group and the template face sample set group corresponding to the template face identifier; the template face that matches the face sample set before the face change is determined from the template face sample set group Sample set: Using machine learning methods, the determined pre-training model is trained based on the face sample set before the face change and the determined template face sample set to obtain the face change model.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • General Physics & Mathematics (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Software Systems (AREA)
  • Multimedia (AREA)
  • Evolutionary Computation (AREA)
  • Oral & Maxillofacial Surgery (AREA)
  • Artificial Intelligence (AREA)
  • Computing Systems (AREA)
  • Molecular Biology (AREA)
  • Biomedical Technology (AREA)
  • Mathematical Physics (AREA)
  • General Engineering & Computer Science (AREA)
  • Computational Linguistics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Biophysics (AREA)
  • Human Computer Interaction (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Medical Informatics (AREA)
  • Image Analysis (AREA)
  • Image Processing (AREA)

Abstract

Disclosed in embodiments of the present application are a method and device for training a face swapping model. A specific embodiment of the method comprises: receiving a face swapping model training request sent by a user, wherein the face swapping model training request comprises a face sample set provided by the user before face swapping and a specified template face identifier; determining, from a pre-training model set corresponding to the template face identifier, a pre-training model matching the face sample set before face swapping, wherein the pre-training model set comprises a pre-trained model on the basis of a target face sample set group and a template face sample set group corresponding to the template face identifier; determining, from the template face sample set group, a template face sample set matching the face sample set before face swapping; and training the determined pre-training model on the basis of the face sample set before face swapping and the determined template face sample set by using a machine learning method to obtain a face swapping model. The embodiment saves the training time of the face swapping model and improves the training efficiency of the face swapping model.

Description

用于训练换脸模型的方法和设备Method and equipment for training face-changing model 技术领域Technical field
本申请实施例涉及计算机技术领域,具体涉及用于训练换脸模型的方法和设备。The embodiments of the present application relate to the field of computer technology, in particular to a method and device for training a face-changing model.
背景技术Background technique
目前流行的深度换脸框架中,通常采用生成式对抗网络(Generative Adversarial Networks,GAN)的技术,能够得到令人满意的人脸生成效果。在通用的生成式对抗网络框架的模型训练上,虽然在足够的样本和算力基础上,能够保证生成高质量的人脸,但仍然存在训练时间漫长的问题,这将会影响深度换脸技术在实际应用中的前景以及用户体验。In the current popular deep face swapping framework, the technology of Generative Adversarial Networks (GAN) is usually used to obtain satisfactory face generation effects. In the model training of the general generative confrontation network framework, although the high-quality face can be guaranteed to be generated on the basis of sufficient samples and computing power, there is still the problem of long training time, which will affect the deep face-changing technology Prospects and user experience in practical applications.
发明内容Summary of the invention
本申请实施例提出了用于训练换脸模型的方法和设备。The embodiment of the application proposes a method and device for training a face-changing model.
第一方面,本申请实施例提供了一种用于训练换脸模型的方法,包括:接收用户发送的换脸模型训练请求,其中,换脸模型训练请求中包括用户提供的换脸前人脸样本集和指定的模板人脸标识;从模板人脸标识对应的预训练模型集中确定与换脸前人脸样本集匹配的预训练模型,其中,预训练模型集包括基于目标人脸样本集组和模板人脸标识对应的模板人脸样本集组预先训练过的模型;从模板人脸样本集组中确定与换脸前人脸样本集匹配的模板人脸样本集;利用机器学习方法,基于换脸前人脸样本集和所确定的模板人脸样本集对所确定的预训练模型进行训练,得到换脸模型。In the first aspect, an embodiment of the present application provides a method for training a face-changing model, including: receiving a face-changing model training request sent by a user, wherein the face-changing model training request includes the face before the face change provided by the user The sample set and the specified template face identification; from the pre-training model set corresponding to the template face identification, the pre-training model that matches the face sample set before the face change is determined, wherein the pre-training model set includes a sample set group based on the target face The pre-trained model of the template face sample set corresponding to the template face identifier; the template face sample set that matches the face sample set before the face change is determined from the template face sample set; the machine learning method is based on Training the determined pre-training model with the face sample set before the face change and the determined template face sample set to obtain the face change model.
在一些实施例中,从模板人脸标识对应的预训练模型集中确定与换脸前人脸样本集匹配的预训练模型,包括:若用户的历史换脸记录中存在模板人脸标识对应的预训练模型,将模板人脸标识对应的预训练模型确定为与换脸前人脸样本集匹配的预训练模型。In some embodiments, determining from the pre-training model set corresponding to the template face identifier the pre-training model that matches the face sample set before the face change includes: if there is a pre-trained model corresponding to the template face identifier in the user's historical face change record The training model determines the pre-training model corresponding to the template face identifier as the pre-training model matching the face sample set before the face change.
在一些实施例中,从模板人脸标识对应的预训练模型集中确定与换脸前人脸样本集匹配的预训练模型,还包括:若用户的历史换脸记录中不存在模板人脸标识对应的预训练模型,识别换脸前人脸样本集的人脸属性信息;基于所识别的人脸属性信息,从预训练模型集中确定预训练模型。In some embodiments, determining from the pre-training model set corresponding to the template face identifiers the pre-training model that matches the face sample set before the face change, further includes: if there is no template face identifier corresponding to the user's historical face change records The pre-training model for identifying the face attribute information of the face sample set before the face change; based on the recognized face attribute information, the pre-training model is determined from the pre-training model set.
在一些实施例中,人脸属性信息包括以下至少一种维度的信息:性别、年龄段、人种、脸部饰品、脸型。In some embodiments, the face attribute information includes information in at least one of the following dimensions: gender, age group, race, facial accessories, and face shape.
在一些实施例中,识别换脸前人脸样本集的人脸属性信息,包括:将换脸前人脸样本集输入至预先训练的第一分类模型,得到换脸前人脸样本集的性别、年龄段、人种、脸部饰品中的至少一种维度的信息,其中,第一分类模型是基于卷积神经网络的分类模型。In some embodiments, identifying the face attribute information of the face sample set before the face change includes: inputting the face sample set before the face change into a pre-trained first classification model to obtain the gender of the face sample set before the face change , Age, race, and facial accessories, where the first classification model is a classification model based on a convolutional neural network.
在一些实施例中,识别换脸前人脸样本集的人脸属性信息,包括:提取换脸前人脸样本集的人脸脸型分类特征;将所提取的人脸脸型分类特征输入至预先训练的第二分类模型,得到换脸前人脸样本集的脸型,其中,第二分类模型是基于支持向量机的分类模型。In some embodiments, identifying the face attribute information of the face sample set before the face change includes: extracting the face classification features of the face sample set before the face change; inputting the extracted face classification features to the pre-training The second classification model is to obtain the face shape of the face sample set before the face change, where the second classification model is a classification model based on a support vector machine.
在一些实施例中,提取换脸前人脸样本集的人脸脸型分类特征,包括:提取换脸前人脸样本集的人脸特征点信息;基于所提取的人脸特征点信息,计算换脸前人脸样本集的人脸测量参数;将所提取的人脸特征点信息和所计算的人脸测量参数合并为换脸前人脸样本集的人脸脸型分类特征。In some embodiments, extracting the facial classification features of the face sample set before the face change includes: extracting the face feature point information of the face sample set before the face change; calculating the face feature point information based on the extracted face feature point information The face measurement parameters of the face sample set before the face; the extracted face feature point information and the calculated face measurement parameters are combined into the face classification features of the face sample set before the face change.
在一些实施例中,基于所识别的人脸属性信息,从预训练模型集中确定预训练模型,包括:从预训练模型集中确定与所识别的人脸属性信息匹配的预训练模型子集;计算换脸前人脸样本集与预训练模型子集中的预训练模型对应的目标人脸样本集的相似度;基于所计算的相似度,从预训练模型子集中确定预训练模型。In some embodiments, determining a pre-training model from the pre-training model set based on the recognized face attribute information includes: determining a pre-training model subset matching the recognized face attribute information from the pre-training model set; computing; The similarity between the face sample set before the face change and the target face sample set corresponding to the pre-training model in the pre-training model subset; based on the calculated similarity, the pre-training model is determined from the pre-training model subset.
在一些实施例中,计算换脸前人脸样本集与预训练模型子集中的预训练模型对应的目标人脸样本集的相似度,包括:提取换脸前人脸样本集的平均人脸特征向量;计算所提取的平均人脸特征向量与预训练模型子集中的预训练模型对应的目标人脸样本集的平均人脸特征向量的余弦相似度。In some embodiments, calculating the similarity between the face sample set before the face change and the target face sample set corresponding to the pre-trained model in the pre-training model subset includes: extracting the average facial features of the face sample set before the face change Vector; Calculate the cosine similarity between the extracted average face feature vector and the average face feature vector of the target face sample set corresponding to the pre-training model in the pre-training model subset.
在一些实施例中,从模板人脸样本集组中确定与换脸前人脸样本集匹配的模板人脸样本集,包括:提取换脸前人脸样本集的人脸丰富度特征;计算所提 取的人脸丰富度特征与模板人脸样本集组中的模板人脸样本集的人脸丰富度特征的匹配度;基于所计算的匹配度,从模板人脸样本集组中确定模板人脸样本集。In some embodiments, determining, from the template face sample set group, the template face sample set that matches the face sample set before the face change includes: extracting the face richness features of the face sample set before the face change; The degree of matching between the extracted face richness features and the face richness features of the template face sample set in the template face sample set group; based on the calculated matching degree, the template face is determined from the template face sample set group Sample set.
在一些实施例中,提取换脸前人脸样本集的人脸丰富度特征,包括:提取换脸前人脸样本集的人脸特征信息;对人脸特征信息进行直方图统计,得到换脸前人脸样本集的人脸丰富度特征。In some embodiments, extracting the face richness features of the face sample set before the face change includes: extracting the face feature information of the face sample set before the face change; performing histogram statistics on the face feature information to obtain the face change The face richness feature of the previous face sample set.
在一些实施例中,人脸特征信息包括以下至少一种维度的信息:人脸特征点、人脸角度和人脸表情。In some embodiments, the facial feature information includes information in at least one of the following dimensions: facial feature points, facial angles, and facial expressions.
在一些实施例中,计算所提取的人脸丰富度特征与模板人脸样本集组中的模板人脸样本集的人脸丰富度特征的匹配度,包括:利用直方图匹配方法,计算所提取的人脸丰富度特征与模板人脸样本集组中的模板人脸样本集的人脸丰富度特征的匹配度。In some embodiments, calculating the matching degree between the extracted face richness features and the face richness features of the template face sample set in the template face sample set group includes: using a histogram matching method to calculate the extracted The degree of matching between the face richness features of the template face sample set and the face richness feature of the template face sample set in the template face sample set group.
在一些实施例中,基于所计算的匹配度,从模板人脸样本集组中确定模板人脸样本集,包括:若模板人脸样本集组中存在匹配度大于预设匹配度阈值的模板人脸样本集,从模板人脸样本集组中选取匹配度最高的模板人脸样本集;若模板人脸样本集组中不存在匹配度大于预设匹配度阈值的模板人脸样本集,从模板人脸样本集组中选取通用的模板人脸样本集。In some embodiments, based on the calculated matching degree, determining the template face sample set from the template face sample set group includes: if there is a template person in the template face sample set group with a matching degree greater than a preset matching degree threshold Face sample set, select the template face sample set with the highest matching degree from the template face sample set group; if there is no template face sample set with the matching degree greater than the preset matching degree threshold in the template face sample set group, select the template face sample set from the template face sample set group. Select a universal template face sample set from the face sample set group.
在一些实施例中,预训练模型集通过如下步骤训练:获取多个目标人脸样本;按照人脸属性,将多个目标人脸样本划分为目标人脸样本集组,其中,同一目标人脸样本集中的目标人脸样本的人脸属性相似;对于目标人脸样本集组中的目标人脸样本集,基于该目标人脸样本集和与该目标人脸样本集匹配的模板人脸样本集对生成式对抗网络进行训练,得到预训练模型。In some embodiments, the pre-training model set is trained by the following steps: acquiring multiple target face samples; dividing the multiple target face samples into target face sample set groups according to face attributes, where the same target face The face attributes of the target face samples in the sample set are similar; for the target face sample set in the target face sample set group, based on the target face sample set and the template face sample set matching the target face sample set Train the generative confrontation network to get the pre-training model.
在一些实施例中,预训练模型包括生成模型和判别模型;以及利用机器学习方法,基于换脸前人脸样本集和所确定的模板人脸样本集对所确定的预训练模型进行训练,得到换脸模型,包括:将换脸前人脸样本集输入所确定的预训练模型的生成模型,得到换脸后人脸样本集;将换脸后人脸样本集和所确定的模板人脸样本集输入所确定的预训练模型的判别模型,得到判别结果,其中,判别结果用于表征换脸后人脸样本集和所确定的模板人脸样本集是真实样本集的概率;基于判别结果调整所确定的预训练模型的生成模型和判别模型的参 数。In some embodiments, the pre-training model includes a generative model and a discriminant model; and using machine learning methods, the determined pre-training model is trained based on the face sample set before the face change and the determined template face sample set, to obtain The face-changing model includes: inputting the face sample set before changing the face into the generated model of the determined pre-training model to obtain the face sample set after the face changing; the face sample set after the face changing and the determined template face sample Set input to the discriminant model of the pre-trained model determined to obtain the discriminant result, where the discriminant result is used to represent the probability that the face sample set after face change and the determined template face sample set are the real sample set; adjust based on the discriminant result The parameters of the generative model and the discriminant model of the determined pre-training model.
在一些实施例中,基于判别结果调整所确定的预训练模型的生成模型和判别模型的参数,包括:确定判别结果是否满足约束条件;若判别结果不满足约束条件,基于判别结果调整所确定的预训练模型的生成模型和判别模型的参数,以及再次基于换脸前人脸样本集和所确定的模板人脸样本集对所确定的预训练模型进行训练;若判别结果满足约束条件,确定换脸模型训练完成,以及将所确定的预训练模型的生成模型最后一次输出的换脸后人脸样本集发送给用户。In some embodiments, adjusting the parameters of the generated model and the discrimination model of the determined pre-training model based on the discrimination result includes: determining whether the discrimination result meets the constraint condition; if the discrimination result does not satisfy the constraint condition, adjusting the determined parameter based on the discrimination result The generation model of the pre-training model and the parameters of the discrimination model, and the determined pre-training model is trained again based on the face sample set before the face change and the determined template face sample set; if the discrimination result meets the constraint conditions, it is determined to change The face model training is completed, and the face sample set after the face change output last time by the generation model of the determined pre-training model is sent to the user.
第二方面,本申请实施例提供了一种用于训练换脸模型的装置,包括:接收单元,被配置成接收用户发送的换脸模型训练请求,其中,换脸模型训练请求中包括用户提供的换脸前人脸样本集和指定的模板人脸标识;第一确定单元,被配置成从模板人脸标识对应的预训练模型集中确定与换脸前人脸样本集匹配的预训练模型,其中,预训练模型集包括基于目标人脸样本集组和模板人脸标识对应的模板人脸样本集组预先训练过的模型;第二确定单元,被配置成从模板人脸样本集组中确定与换脸前人脸样本集匹配的模板人脸样本集;训练单元,被配置成利用机器学习方法,基于换脸前人脸样本集和所确定的模板人脸样本集对所确定的预训练模型进行训练,得到换脸模型。In a second aspect, an embodiment of the present application provides an apparatus for training a face-changing model, including: a receiving unit configured to receive a face-changing model training request sent by a user, wherein the face-changing model training request includes the user provided The face sample set before the face change and the designated template face identifier; the first determining unit is configured to determine the pre-training model matching the face sample set before the face change from the pre-training model set corresponding to the template face identifier, Among them, the pre-training model set includes a model pre-trained based on the target face sample set group and the template face sample set group corresponding to the template face identifier; the second determining unit is configured to determine from the template face sample set group A template face sample set that matches the face sample set before the face change; the training unit is configured to use a machine learning method, based on the pre-training determined by the face sample set before the face change and the determined template face sample set The model is trained to obtain a face-changing model.
在一些实施例中,第一确定单元包括:第一确定子单元,被配置成若用户的历史换脸记录中存在模板人脸标识对应的预训练模型,将模板人脸标识对应的预训练模型确定为与换脸前人脸样本集匹配的预训练模型。In some embodiments, the first determining unit includes: a first determining subunit configured to, if there is a pre-trained model corresponding to the template face identifier in the user’s historical face-changing record, the pre-trained model corresponding to the template face identifier Determined as a pre-trained model that matches the face sample set before the face change.
在一些实施例中,第一确定单元还包括:识别子单元,被配置成若用户的历史换脸记录中不存在模板人脸标识对应的预训练模型,识别换脸前人脸样本集的人脸属性信息;第二确定子单元,被配置成基于所识别的人脸属性信息,从预训练模型集中确定预训练模型。In some embodiments, the first determining unit further includes: a recognition sub-unit configured to recognize the person in the face sample set before the face change if there is no pre-trained model corresponding to the template face identifier in the user's historical face change record Face attribute information; the second determining subunit is configured to determine the pre-training model from the pre-training model set based on the recognized face attribute information.
在一些实施例中,人脸属性信息包括以下至少一种维度的信息:性别、年龄段、人种、脸部饰品、脸型。In some embodiments, the face attribute information includes information in at least one of the following dimensions: gender, age group, race, facial accessories, and face shape.
在一些实施例中,识别子单元包括:第一分类模块,被配置成将换脸前人脸样本集输入至预先训练的第一分类模型,得到换脸前人脸样本集的性别、年龄段、人种、脸部饰品中的至少一种维度的信息,其中,第一分类模型是基于 卷积神经网络的分类模型。In some embodiments, the recognition subunit includes: a first classification module configured to input the face sample set before the face change into the pre-trained first classification model to obtain the gender and age group of the face sample set before the face change , Race, and facial accessories, where the first classification model is a classification model based on a convolutional neural network.
在一些实施例中,识别子单元包括:提取模块,被配置成提取换脸前人脸样本集的人脸脸型分类特征;第二分类模块,被配置成将所提取的人脸脸型分类特征输入至预先训练的第二分类模型,得到换脸前人脸样本集的脸型,其中,第二分类模型是基于支持向量机的分类模型。In some embodiments, the recognition subunit includes: an extraction module configured to extract facial facial classification features of a face sample set before the face change; a second classification module configured to input the extracted facial facial classification features To the pre-trained second classification model, the face shape of the face sample set before the face change is obtained, where the second classification model is a classification model based on a support vector machine.
在一些实施例中,提取模块进一步被配置成:提取换脸前人脸样本集的人脸特征点信息;基于所提取的人脸特征点信息,计算换脸前人脸样本集的人脸测量参数;将所提取的人脸特征点信息和所计算的人脸测量参数合并为换脸前人脸样本集的人脸脸型分类特征。In some embodiments, the extraction module is further configured to: extract face feature point information of the face sample set before the face change; based on the extracted face feature point information, calculate the face measurement of the face sample set before the face change Parameters: Combine the extracted facial feature point information and the calculated facial measurement parameters into the facial classification features of the face sample set before the face change.
在一些实施例中,第二确定子单元包括:第一确定模块,被配置成从预训练模型集中确定与所识别的人脸属性信息匹配的预训练模型子集;计算模块,被配置成计算换脸前人脸样本集与预训练模型子集中的预训练模型对应的目标人脸样本集的相似度;第二确定模块,被配置成基于所计算的相似度,从预训练模型子集中确定预训练模型。In some embodiments, the second determining subunit includes: a first determining module configured to determine a subset of pre-trained models matching the recognized face attribute information from a set of pre-training models; a calculation module configured to calculate The similarity between the face sample set before the face change and the target face sample set corresponding to the pre-training model in the pre-training model subset; the second determining module is configured to determine from the pre-training model subset based on the calculated similarity Pre-trained model.
在一些实施例中,计算模块进一步被配置成:提取换脸前人脸样本集的平均人脸特征向量;计算所提取的平均人脸特征向量与预训练模型子集中的预训练模型对应的目标人脸样本集的平均人脸特征向量的余弦相似度。In some embodiments, the calculation module is further configured to: extract the average face feature vector of the face sample set before the face change; calculate the extracted average face feature vector and the target corresponding to the pre-trained model in the pre-trained model subset The cosine similarity of the average face feature vector of the face sample set.
在一些实施例中,第二确定单元包括:提取子单元,被配置成提取换脸前人脸样本集的人脸丰富度特征;计算子单元,被配置成计算所提取的人脸丰富度特征与模板人脸样本集组中的模板人脸样本集的人脸丰富度特征的匹配度;第三确定子单元,被配置成基于所计算的匹配度,从模板人脸样本集组中确定模板人脸样本集。In some embodiments, the second determining unit includes: an extraction subunit configured to extract face richness features of a face sample set before the face change; a calculation subunit configured to calculate the extracted face richness features The matching degree with the face richness feature of the template face sample set in the template face sample set group; the third determining subunit is configured to determine the template from the template face sample set group based on the calculated matching degree Set of human face samples.
在一些实施例中,提取子单元进一步被配置成:提取换脸前人脸样本集的人脸特征信息;对人脸特征信息进行直方图统计,得到换脸前人脸样本集的人脸丰富度特征。In some embodiments, the extraction subunit is further configured to: extract the face feature information of the face sample set before the face change; perform histogram statistics on the face feature information to obtain the face richness of the face sample set before the face change Degree characteristics.
在一些实施例中,人脸特征信息包括以下至少一种维度的信息:人脸特征点、人脸角度和人脸表情。In some embodiments, the facial feature information includes information in at least one of the following dimensions: facial feature points, facial angles, and facial expressions.
在一些实施例中,计算子单元进一步被配置成:利用直方图匹配方法,计算所提取的人脸丰富度特征与模板人脸样本集组中的模板人脸样本集的人脸 丰富度特征的匹配度。In some embodiments, the calculation subunit is further configured to: use a histogram matching method to calculate the difference between the extracted face richness feature and the face richness feature of the template face sample set in the template face sample set group. suitability.
在一些实施例中,第三确定子单元进一步被配置成:若模板人脸样本集组中存在匹配度大于预设匹配度阈值的模板人脸样本集,从模板人脸样本集组中选取匹配度最高的模板人脸样本集;若模板人脸样本集组中不存在匹配度大于预设匹配度阈值的模板人脸样本集,从模板人脸样本集组中选取通用的模板人脸样本集。In some embodiments, the third determining subunit is further configured to: if there is a template face sample set with a matching degree greater than a preset matching degree threshold in the template face sample set group, select the matching from the template face sample set group The template face sample set with the highest degree; if there is no template face sample set with a matching degree greater than the preset matching degree threshold in the template face sample set group, select a general template face sample set from the template face sample set group .
在一些实施例中,预训练模型集通过如下步骤训练:获取多个目标人脸样本;按照人脸属性,将多个目标人脸样本划分为目标人脸样本集组,其中,同一目标人脸样本集中的目标人脸样本的人脸属性相似;对于目标人脸样本集组中的目标人脸样本集,基于该目标人脸样本集和与该目标人脸样本集匹配的模板人脸样本集对生成式对抗网络进行训练,得到预训练模型。In some embodiments, the pre-training model set is trained by the following steps: acquiring multiple target face samples; dividing the multiple target face samples into target face sample set groups according to face attributes, where the same target face The face attributes of the target face samples in the sample set are similar; for the target face sample set in the target face sample set group, based on the target face sample set and the template face sample set matching the target face sample set Train the generative confrontation network to get the pre-training model.
在一些实施例中,预训练模型包括生成模型和判别模型;以及训练单元包括:生成子单元,被配置成将换脸前人脸样本集输入所确定的预训练模型的生成模型,得到换脸后人脸样本集;判别子单元,被配置成将换脸后人脸样本集和所确定的模板人脸样本集输入所确定的预训练模型的判别模型,得到判别结果,其中,判别结果用于表征换脸后人脸样本集和所确定的模板人脸样本集是真实样本集的概率;调整子单元,被配置成基于判别结果调整所确定的预训练模型的生成模型和判别模型的参数。In some embodiments, the pre-training model includes a generative model and a discriminant model; and the training unit includes: a generating subunit configured to input the set of face samples before the face change into the generative model of the determined pre-training model to obtain the face change The posterior face sample set; the discriminant subunit is configured to input the face sample set after face change and the determined template face sample set into the discriminant model of the determined pre-training model to obtain the discriminant result, where the discriminant result is used To characterize the probability that the face sample set and the determined template face sample set are the real sample set after the face change; the adjustment subunit is configured to adjust the parameters of the determined pre-training model generation model and the discrimination model based on the discrimination result .
在一些实施例中,调整子单元进一步被配置成:确定判别结果是否满足约束条件;若判别结果不满足约束条件,基于判别结果调整所确定的预训练模型的生成模型和判别模型的参数,以及再次基于换脸前人脸样本集和所确定的模板人脸样本集对所确定的预训练模型进行训练;若判别结果满足约束条件,确定换脸模型训练完成,以及将所确定的预训练模型的生成模型最后一次输出的换脸后人脸样本集发送给用户。In some embodiments, the adjustment subunit is further configured to: determine whether the discrimination result meets the constraint condition; if the discrimination result does not satisfy the constraint condition, adjust the parameters of the determined pre-training model generation model and the discrimination model based on the discrimination result, and Train the determined pre-training model again based on the face sample set before the face change and the determined template face sample set; if the discrimination result meets the constraint conditions, it is determined that the face change model training is completed, and the determined pre-training model The face sample set after the face change last time output by the generative model is sent to the user.
第三方面,本申请实施例提供了一种计算机设备,该计算机设备包括:一个或多个处理器;存储装置,其上存储有一个或多个程序;当一个或多个程序被一个或多个处理器执行,使得一个或多个处理器实现如第一方面中任一实现方式描述的方法。In a third aspect, the embodiments of the present application provide a computer device, which includes: one or more processors; a storage device on which one or more programs are stored; when one or more programs are stored by one or more Execution by two processors, so that one or more processors implement the method described in any implementation manner of the first aspect.
第四方面,本申请实施例提供了一种计算机可读介质,其上存储有计算机 程序,该计算机程序被处理器执行时实现如第一方面中任一实现方式描述的方法。In the fourth aspect, an embodiment of the present application provides a computer-readable medium on which a computer program is stored, and when the computer program is executed by a processor, the method as described in any implementation manner in the first aspect is implemented.
本申请实施例提供的用于训练换脸模型的方法和设备,首先接收用户发送的换脸模型训练请求;之后从换脸模型训练请求中的模板人脸标识对应的预训练模型集中确定与换脸模型训练请求中的换脸前人脸样本集匹配的预训练模型;然后从模板人脸标识对应的模板人脸样本集组中确定与换脸模型训练请求中换脸前人脸样本集匹配的模板人脸样本集;最后利用机器学习方法,基于换脸前人脸样本集和所确定的模板人脸样本集对所确定的预训练模型进行训练,得到换脸模型。利用预训练模型训练换脸模型,避免了“零起点”训练,节省了换脸模型的训练耗时,提高了换脸模型的训练效率。进而为深度换脸技术在实际应用和体验效果上起到积极作用。The method and device for training a face-changing model provided by the embodiments of the application firstly receive a face-changing model training request sent by a user; then, determine and change the set of pre-training models corresponding to the template face identifier in the face-changing model training request. The pre-training model that matches the face sample set before the face change in the face model training request; then, from the template face sample set corresponding to the template face identifier, it is determined to match the face sample set before the face change in the face change model training request Finally, the machine learning method is used to train the determined pre-training model based on the face sample set before the face change and the determined template face sample set to obtain the face change model. Using the pre-training model to train the face-changing model avoids "zero-start" training, saves the time-consuming training of the face-changing model, and improves the training efficiency of the face-changing model. In turn, the in-depth face-changing technology plays a positive role in practical applications and experience effects.
附图说明Description of the drawings
通过阅读参照以下附图所作的对非限制性实施例所作的详细描述,本申请的其它特征、目的和优点将会变得更明显:By reading the detailed description of the non-limiting embodiments with reference to the following drawings, other features, purposes, and advantages of the present application will become more apparent:
图1是本申请一些实施例可以应用于其中的示例性系统架构;Fig. 1 is an exemplary system architecture in which some embodiments of the present application can be applied;
图2是根据本申请的用于训练换脸模型的方法的一个实施例的流程图;Fig. 2 is a flowchart of an embodiment of a method for training a face-changing model according to the present application;
图3是根据本申请的用于训练换脸模型的方法的又一个实施例的流程图;Fig. 3 is a flowchart of another embodiment of the method for training a face-changing model according to the present application;
图4是适于用来实现本申请一些实施例的计算机设备的计算机系统的结构示意图。Fig. 4 is a schematic structural diagram of a computer system suitable for implementing computer equipment of some embodiments of the present application.
具体实施方式Detailed ways
下面结合附图和实施例对本申请作进一步的详细说明。可以理解的是,此处所描述的具体实施例仅仅用于解释相关发明,而非对该发明的限定。另外还需要说明的是,为了便于描述,附图中仅示出了与有关发明相关的部分。The application will be further described in detail below with reference to the drawings and embodiments. It can be understood that the specific embodiments described here are only used to explain the related invention, but not to limit the invention. In addition, it should be noted that, for ease of description, only the parts related to the relevant invention are shown in the drawings.
需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互组合。下面将参考附图并结合实施例来详细说明本申请。It should be noted that the embodiments in this application and the features in the embodiments can be combined with each other if there is no conflict. Hereinafter, the application will be described in detail with reference to the drawings and in conjunction with the embodiments.
图1示出了可以应用本申请的用于训练换脸模型的方法的实施例的示例性系统架构100。Fig. 1 shows an exemplary system architecture 100 to which an embodiment of the method for training a face-changing model of the present application can be applied.
如图1所示,系统架构100中可以包括设备101、102和网络103。网络103用以在设备101、102之间提供通信链路的介质。网络103可以包括各种连接类型,例如有线、无线目标通信链路或者光纤电缆等等。As shown in FIG. 1, the system architecture 100 may include devices 101 and 102 and a network 103. The network 103 is a medium used to provide a communication link between the devices 101 and 102. The network 103 may include various connection types, such as wired, wireless target communication links, or fiber optic cables, and so on.
设备101、102可以是支持网络连接从而提供各种网络服务的硬件设备或软件。当设备为硬件时,其可以是各种电子设备,包括但不限于智能手机、平板电脑、膝上型便携计算机、台式计算机和服务器等等。这时,作为硬件设备,其可以实现成多个设备组成的分布式设备群,也可以实现成单个设备。当设备为软件时,可以安装在上述所列举的电子设备中。这时,作为软件,其可以实现成例如用来提供分布式服务的多个软件或软件模块,也可以实现成单个软件或软件模块。在此不做具体限定。The devices 101 and 102 may be hardware devices or software that support network connections to provide various network services. When the device is hardware, it can be various electronic devices, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, servers, and so on. At this time, as a hardware device, it can be implemented as a distributed device group composed of multiple devices, or as a single device. When the device is software, it can be installed in the electronic devices listed above. At this time, as software, it can be implemented as multiple software or software modules for providing distributed services, or as a single software or software module. There is no specific limitation here.
在实践中,设备可以通过安装相应的客户端应用或服务端应用来提供相应的网络服务。设备在安装了客户端应用之后,其可以在网络通信中体现为客户端。相应地,在安装了服务端应用之后,其可以在网络通信中体现为服务端。In practice, devices can provide corresponding network services by installing corresponding client applications or server applications. After the device has installed the client application, it can be embodied as a client in network communication. Correspondingly, after the server application is installed, it can be embodied as a server in network communication.
作为示例,在图1中,设备101体现为客户端,而设备102体现为服务端。具体地,设备101可以是安装有图像处理软件的客户端,设备102可以是图像处理软件的服务端。As an example, in FIG. 1, the device 101 is embodied as a client, and the device 102 is embodied as a server. Specifically, the device 101 may be a client with image processing software installed, and the device 102 may be a server of the image processing software.
需要说明的是,本申请实施例所提供的用于训练换脸模型的方法可以由设备102执行。It should be noted that the method for training a face-changing model provided in the embodiment of the present application may be executed by the device 102.
应该理解,图1中的网络和设备的数目仅仅是示意性的。根据实现需要,可以具有任意数目的网络和设备。It should be understood that the number of networks and devices in FIG. 1 is merely illustrative. According to implementation needs, there can be any number of networks and devices.
继续参考图2,其示出了根据本申请的用于训练换脸模型的方法的一个实施例的流程200。该用于训练换脸模型的方法可以包括以下步骤:Continuing to refer to FIG. 2, it shows a process 200 of an embodiment of the method for training a face-changing model according to the present application. The method for training a face-changing model may include the following steps:
步骤201,接收用户发送的换脸模型训练请求。Step 201: Receive a face-changing model training request sent by a user.
在本实施例中,用于训练换脸模型的方法的执行主体(例如图1所示的设备102)可以接收用户发送的换脸模型训练请求。其中,换脸模型训练请求中可以包括用户提供的换脸前人脸样本集和指定的模板人脸标识。换脸前人脸样本集可以是用户想要替换掉人脸的样本集。换脸前人脸样本集可以是一张或多张换脸前人脸图像,也可以是换脸前人脸视频的多帧视频帧。模板人脸可以是用户想要替换成的人脸。模板人脸标识可以由字母、数字、符号等组成,是模 板人脸的唯一标识。In this embodiment, the execution subject of the method for training a face-changing model (for example, the device 102 shown in FIG. 1) may receive a face-changing model training request sent by a user. Wherein, the face-changing model training request may include the face sample set before the face-changing provided by the user and the designated template face identifier. The face sample set before the face change may be a sample set of which the user wants to replace the face. The face sample set before the face change may be one or more face images before the face change, or it may be a multi-frame video frame of the face video before the face change. The template face may be the face that the user wants to replace. The template face identification can be composed of letters, numbers, symbols, etc., and is the only identification of the template face.
通常,用户的终端设备(例如图1所示的设备101)上可以安装有图像处理软件。用户可以打开图像处理软件,进入主页面。主页面上可以设置有编辑按键。当用户点击编辑按键时,可以显示本地存储的图像列表和/或视频列表,以供用户选择。当用户从图像列表中选定一张或多张图像时,可以将用户选定的一张或多张图像确定为用户提供的换脸前人脸样本集。当用户从视频列表中选定视频时,可以将用户选定的视频的多帧视频帧确定为用户提供的换脸前人脸样本集。此外,在用户选定换脸前人脸样本集之后,会进入图像处理页面。换脸前人脸样本集可以展示在图像处理页面上。图像处理页面上还可以设置有换脸按键。当用户点击换脸按键时,可以显示可供替换的模板人脸列表。当用户从模板人脸列表中选定模板人脸时,可以将用户选定的模板人脸确定为用户指定的模板人脸,其标识就是用户指定的模板人脸标识。此外,在用户选定模板人脸之后,终端设备就可以向上述执行主体发送包括用户提供的换脸前人脸样本集和指定的模板人脸标识的换脸模型训练请求。Generally, image processing software may be installed on the user's terminal device (for example, the device 101 shown in FIG. 1). The user can open the image processing software and enter the main page. Edit buttons can be set on the main page. When the user clicks the edit button, the locally stored image list and/or video list can be displayed for the user to select. When the user selects one or more images from the image list, the one or more images selected by the user can be determined as the face sample set provided by the user before the face change. When the user selects a video from the video list, the multi-frame video frame of the video selected by the user can be determined as the face sample set provided by the user before the face change. In addition, after the user selects the face sample set before the face change, the user will enter the image processing page. The face sample set before the face change can be displayed on the image processing page. A face-changing button can also be set on the image processing page. When the user clicks the face-changing button, a list of template faces that can be replaced can be displayed. When the user selects a template face from the template face list, the template face selected by the user can be determined as the user-specified template face, and its identifier is the user-specified template face identifier. In addition, after the user selects the template face, the terminal device can send a face-changing model training request including the face sample set before the face-changing provided by the user and the designated template face identifier to the above-mentioned execution subject.
步骤202,从模板人脸标识对应的预训练模型集中确定与换脸前人脸样本集匹配的预训练模型。Step 202: Determine a pre-training model matching the set of face samples before the face change from the pre-training model set corresponding to the template face identifier.
在本实施例中,上述执行主体可以从用户指定的模板人脸标识对应的预训练模型集中确定与换脸前人脸样本集匹配的预训练模型。例如,上述执行主体可以从用户指定的模板人脸标识对应的预训练模型集中随机选取预训练模型。In this embodiment, the above-mentioned execution subject may determine a pre-training model matching the set of face samples before the face change from the set of pre-training models corresponding to the template face identifier designated by the user. For example, the above-mentioned execution subject may randomly select a pre-training model from a set of pre-training models corresponding to a template face identifier designated by the user.
在本实施例的一些可选的实现方式中,若用户的历史换脸记录中存在模板人脸标识对应的预训练模型,上述执行主体可以将模板人脸标识对应的预训练模型确定为与换脸前人脸样本集匹配的预训练模型。通常,在用户使用预训练模型训练换脸模型进行换脸之后,会生成一条历史换脸记录。其中,历史换脸记录中可以记录历史换脸过程中所指定的模板人脸标识和所使用的预训练模型标识。可见,若用户的历史换脸记录中存在用户指定的模板人脸标识对应的预训练模型标识,说明用户曾经使用过该模板人脸标识对应的预训练模型训练过换脸模型。此时,上述执行主体可以直接将该模板人脸标识对应的预训练模型确定为本次需要使用的预训练模型。In some optional implementations of this embodiment, if there is a pre-trained model corresponding to the template face identifier in the user’s historical face-changing record, the execution subject may determine the pre-training model corresponding to the template face identifier as the A pre-trained model for matching the face sample set in front of the face. Generally, after a user uses a pre-trained model to train a face-changing model for face-changing, a historical face-changing record is generated. Among them, the historical face change record may record the template face identifier and the pre-training model identifier used during the historical face change process. It can be seen that if there is a pre-training model identifier corresponding to the template face identifier specified by the user in the user's historical face changing record, it means that the user has used the pre-training model corresponding to the template face identifier to train the face changing model. At this time, the above-mentioned execution subject may directly determine the pre-training model corresponding to the template face identifier as the pre-training model to be used this time.
通常,一个模板人脸标识对应一个预训练模型集。同一预训练模型集可以 用于训练同一模板人脸的不同人脸属性信息的换脸模型。同一模板人脸的预训练模型集可以包括基于同一目标人脸的目标人脸样本集组和同一模板人脸的模板人脸样本集组预先训练过的模型。一对目标人脸样本集和模板人脸样本集可以用于训练同一人脸属性信息的预训练模型。可见,同一目标人脸样本集中的目标人脸样本的人脸属性信息相似,同一模板人脸的样本集中的模板人脸样本的人脸属性相似。并且,用于训练同一预训练模型的目标人脸样本集和模板人脸的样本集的人脸属性信息也相似。Generally, a template face identifier corresponds to a pre-training model set. The same pre-training model set can be used to train face-changing models of different face attribute information of the same template face. The pre-trained model set of the same template face may include a pre-trained model based on the target face sample set group of the same target face and the template face sample set group of the same template face. A pair of target face sample set and template face sample set can be used to train a pre-training model of the same face attribute information. It can be seen that the face attribute information of the target face samples in the same target face sample set is similar, and the face attributes of the template face samples in the sample set of the same template face are similar. In addition, the face attribute information of the target face sample set and the template face sample set used to train the same pre-training model are also similar.
通常,人脸属性信息可以包括多个维度的信息,例如,人脸属性信息可以包括但不限于以下至少一种维度的信息:性别(如男、女)、年龄段(如青少年、中年、老年)、人种(如白种人、黄种人、黑种人)、脸部饰品(如是否佩戴脸部饰品)、脸型(如圆形脸型、三角形脸型、椭圆形脸型、方形脸型)等等。Generally, face attribute information may include information of multiple dimensions. For example, face attribute information may include, but is not limited to, information of at least one of the following dimensions: gender (such as male, female), age group (such as teenagers, middle-aged, Old age), race (such as white, yellow, black), facial accessories (such as whether to wear facial accessories), face shape (such as round face, triangle face, oval face, square face), etc. .
在本实施例的一些可选的实现方式中,预训练模型集通过如下步骤训练:In some optional implementations of this embodiment, the pre-training model set is trained through the following steps:
首先,获取多个目标人脸样本。First, obtain multiple target face samples.
这里,多个目标人脸样本可以是同一目标人脸的一批目标人脸样本。Here, the multiple target face samples may be a batch of target face samples of the same target face.
然后,按照人脸属性,将多个目标人脸样本划分为目标人脸样本集组。Then, according to the face attributes, the multiple target face samples are divided into target face sample set groups.
其中,同一目标人脸样本集中的目标人脸样本的人脸属性信息相似。例如,人脸属性信息为{男性,中年,黄种人,不戴眼镜,圆形脸型}的目标人脸样本属于一个目标人脸样本集。人脸属性信息为{男性,中年,黄种人,戴眼镜,圆形脸型}的目标人脸样本属于另一个目标人脸样本集。此外,每个目标人脸样本集上都会打上相应的标签,用于记录对应的人脸属性信息。Among them, the face attribute information of the target face samples in the same target face sample set is similar. For example, the target face sample whose face attribute information is {male, middle-aged, yellow, no glasses, round face} belongs to a target face sample set. The target face sample whose face attribute information is {male, middle-aged, yellow, wearing glasses, round face} belongs to another target face sample set. In addition, each target face sample set will be marked with a corresponding label to record the corresponding face attribute information.
最后,对于目标人脸样本集组中的目标人脸样本集,基于该目标人脸样本集和与该目标人脸样本集匹配的模板人脸样本集对生成式对抗网络进行训练,得到预训练模型。Finally, for the target face sample set in the target face sample set group, the generative confrontation network is trained based on the target face sample set and the template face sample set matching the target face sample set to obtain pre-training model.
其中,同一模板人脸样本集中的模板人脸样本的人脸属性信息相似。并且,与该目标人脸样本集匹配的模板人脸样本集的人脸属性信息与该目标人脸样本集的人脸属性信息相似。例如,目标人脸样本集的人脸属性信息为{男性,中年,黄种人,不戴眼镜,圆形脸型},那么与该目标人脸样本集匹配的模板人脸样本集的人脸属性信息有很大的概率也为{男性,中年,黄种人,不戴眼镜,圆 形脸型}。Among them, the face attribute information of the template face samples in the same template face sample set is similar. In addition, the face attribute information of the template face sample set matching the target face sample set is similar to the face attribute information of the target face sample set. For example, if the face attribute information of the target face sample set is {male, middle-aged, yellow, no glasses, round face}, then the face attributes of the template face sample set that matches the target face sample set The information has a high probability of {male, middle-aged, yellow race, no glasses, round face}.
步骤203,从模板人脸样本集组中确定与换脸前人脸样本集匹配的模板人脸样本集。Step 203: Determine a template face sample set matching the face sample set before the face change from the template face sample set group.
在本实施例中,上述执行主体可以从模板人脸样本集组中确定与换脸前人脸样本集匹配的模板人脸样本集。例如,上述执行主体可以从模板人脸样本集组中选取与换脸前人脸样本集的人脸属性信息相似的模板人脸样本集,并确定为与换脸前人脸样本集匹配的模板人脸样本集。In this embodiment, the above-mentioned execution subject may determine a template face sample set that matches the face sample set before the face change from the template face sample set group. For example, the above-mentioned execution subject can select a template face sample set similar to the face attribute information of the face sample set before the face change from the template face sample set group, and determine it as a template matching the face sample set before the face change Set of human face samples.
步骤204,利用机器学习方法,基于换脸前人脸样本集和所确定的模板人脸样本集对所确定的预训练模型进行训练,得到换脸模型。Step 204: Using a machine learning method, train the determined pre-training model based on the face sample set before the face change and the determined template face sample set to obtain the face change model.
在本实施例中,上述执行主体可以利用机器学习方法,基于换脸前人脸样本集和所确定的模板人脸样本集对所确定的预训练模型进行训练,得到换脸模型。具体地,上述执行主体可以将换脸前人脸样本集和所确定的模板人脸样本集作为输入,经过所确定的预训练模型的处理,得到相应的输出。若输出满足不约束条件,则调整所确定的预训练模型的参数,并再次输入换脸前人脸样本集和所确定的模板人脸样本集继续进行训练。若输出满足预设条件,则模型训练完成。In this embodiment, the above-mentioned execution subject may use a machine learning method to train the determined pre-training model based on the face sample set before the face change and the determined template face sample set to obtain the face change model. Specifically, the above-mentioned execution subject may take the face sample set before the face change and the determined template face sample set as input, and obtain the corresponding output through the processing of the determined pre-training model. If the output satisfies the unconstrained condition, the parameters of the determined pre-training model are adjusted, and the face sample set before the face change and the determined template face sample set are input again to continue training. If the output meets the preset conditions, the model training is completed.
实践中,由于预训练模型是训练过的生成式对抗网络,因此预训练模型可以包括训练过的生成模型和训练过的判别模型。其中,生成模型主要用来学习真实图像分布从而让自身生成的图像更加真实,以骗过判别模型。判别模型则需要对接收到的图像进行真假判别。在整个过程中,生成模型努力地让生成的图像更加真实,而判别模型则努力地去识别出图像的真假,这个过程相当于一个二人博弈,随着时间的推移,生成模型和判别模型在不断地进行对抗,最终两个网络达到了一个动态均衡:生成模型生成的图像接近于真实图像分布,而判别模型识别不出真假图像。In practice, since the pre-training model is a trained generative confrontation network, the pre-training model may include a trained generative model and a trained discriminant model. Among them, the generative model is mainly used to learn the distribution of real images to make the images generated by itself more realistic, so as to fool the discriminant model. The discriminant model needs to judge the authenticity of the received image. In the whole process, the generative model strives to make the generated image more realistic, while the discriminative model strives to identify the true and false of the image. This process is equivalent to a two-person game. As time goes by, the generative model and the discriminant model In constant confrontation, the two networks finally reached a dynamic equilibrium: the images generated by the generative model were close to the distribution of real images, and the discriminant model could not identify true and false images.
在本实施例的一些可选的实现方式中,上述执行主体可以通过如下步骤训练换脸模型:In some optional implementations of this embodiment, the above-mentioned execution subject may train the face-changing model through the following steps:
首先,将换脸前人脸样本集输入所确定的预训练模型的生成模型,得到换脸后人脸样本集。First, the face sample set before the face change is input into the determined generation model of the pre-training model to obtain the face sample set after the face change.
然后,将换脸后人脸样本集和所确定的模板人脸样本集输入所确定的预训 练模型的判别模型,得到判别结果。Then, the face sample set after the face change and the determined template face sample set are input into the determined discriminant model of the pre-training model, and the discriminant result is obtained.
其中,判别结果可以用于表征换脸后人脸样本集和所确定的模板人脸样本集是真实样本集的概率。Among them, the discrimination result can be used to characterize the probability that the face sample set after the face change and the determined template face sample set are the real sample set.
最后,基于判别结果调整所确定的预训练模型的生成模型和判别模型的参数。Finally, the parameters of the determined pre-training model generation model and the discrimination model are adjusted based on the discrimination result.
这里,每得到一次判别结果,上述执行主体都会确定判别结果是否满足约束条件。若判别结果不满足约束条件,上述执行主体可以基于判别结果调整所确定的预训练模型的生成模型和判别模型的参数。随后,再次基于换脸前人脸样本集和所确定的模板人脸样本集对所确定的预训练模型进行训练。若判别结果满足约束条件,上述执行主体可以确定换脸模型训练完成,以及将所确定的预训练模型的生成模型最后一次输出的换脸后人脸样本集发送给用户。其中,生成模型最后一次输出的换脸后人脸样本集就是将换脸前人脸替换成模板人脸的样本集。Here, every time a judgment result is obtained, the above-mentioned execution subject will determine whether the judgment result meets the constraint conditions. If the discrimination result does not satisfy the constraint condition, the above-mentioned execution subject may adjust the parameters of the determined pre-training model generation model and discrimination model based on the discrimination result. Subsequently, the determined pre-training model is trained again based on the face sample set before the face change and the determined template face sample set. If the result of the discrimination satisfies the constraint condition, the above-mentioned execution subject may determine that the face-changing model training is completed, and send the face sample set after the face-changing output of the determined generation model of the pre-training model to the user. Among them, the face sample set after the face change last output by the generative model is the sample set where the face before the face change is replaced with the template face.
本申请实施例提供的用于训练换脸模型的方法,首先接收用户发送的换脸模型训练请求;之后从换脸模型训练请求中的模板人脸标识对应的预训练模型集中确定与换脸模型训练请求中的换脸前人脸样本集匹配的预训练模型;然后从模板人脸标识对应的模板人脸样本集组中确定与换脸模型训练请求中换脸前人脸样本集匹配的模板人脸样本集;最后利用机器学习方法,基于换脸前人脸样本集和所确定的模板人脸样本集对所确定的预训练模型进行训练,得到换脸模型。利用预训练模型训练换脸模型,避免了“零起点”训练,节省了换脸模型的训练耗时,提高了换脸模型的训练效率。进而为深度换脸技术在实际应用和体验效果上起到积极作用。In the method for training a face-changing model provided by an embodiment of the application, firstly, a face-changing model training request sent by a user is received; then, the pre-training model set corresponding to the template face identifier in the face-changing model training request is determined and the face-changing model is determined The pre-training model that matches the face sample set before the face change in the training request; then, from the template face sample set group corresponding to the template face identifier, determine the template that matches the face sample set before the face change in the face change model training request Face sample set; Finally, a machine learning method is used to train the determined pre-training model based on the face sample set before the face change and the determined template face sample set to obtain the face change model. Using the pre-training model to train the face-changing model avoids "zero-start" training, saves the time-consuming training of the face-changing model, and improves the training efficiency of the face-changing model. In turn, the in-depth face-changing technology plays a positive role in practical applications and experience effects.
进一步参考图3,其示出了是根据本申请的用于训练换脸模型的方法的又一个实施例的流程300。该用于训练换脸模型的方法可以包括以下步骤:With further reference to FIG. 3, it shows a process 300 of another embodiment of the method for training a face-changing model according to the present application. The method for training a face-changing model may include the following steps:
步骤301,接收用户发送的换脸模型训练请求。Step 301: Receive a face-changing model training request sent by the user.
在本实施例中,步骤301的具体操作已在图2所示的实施例中步骤201中进行了详细的介绍,在此不再赘述。In this embodiment, the specific operation of step 301 has been described in detail in step 201 in the embodiment shown in FIG. 2, and will not be repeated here.
步骤302,若用户的历史换脸记录中不存在模板人脸标识对应的预训练模型,识别换脸前人脸样本集的人脸属性信息。Step 302: If there is no pre-training model corresponding to the template face identifier in the user's historical face change record, identify the face attribute information of the face sample set before the face change.
在本实施例中,若用户的历史换脸记录中不存在模板人脸标识对应的预训练模型,用于训练换脸模型的方法的执行主体(例如图1所示的设备102)可以识别换脸前人脸样本集的人脸属性信息。通常,人脸属性信息可以包括多个维度的信息,例如,人脸属性信息可以包括但不限于以下至少一种维度的信息:性别(如男、女)、年龄段(如青少年、中年、老年)、人种(如白种人、黄种人、黑种人)、脸部饰品(如是否佩戴脸部饰品)、脸型(如圆形脸型、三角形脸型、椭圆形脸型、方形脸型)等等。In this embodiment, if the pre-trained model corresponding to the template face identifier does not exist in the user’s historical face-changing record, the execution subject of the method for training the face-changing model (for example, the device 102 shown in FIG. 1) can identify the change The face attribute information of the face sample set in front of the face. Generally, face attribute information may include information of multiple dimensions. For example, face attribute information may include, but is not limited to, information of at least one of the following dimensions: gender (such as male, female), age group (such as teenagers, middle-aged, Old age), race (such as white, yellow, black), facial accessories (such as whether to wear facial accessories), face shape (such as round face, triangle face, oval face, square face), etc. .
在本实施例的一些可选的实现方式中,上述执行主体可以将换脸前人脸样本集输入至预先训练的第一分类模型,得到换脸前人脸样本集的性别、年龄段、人种、脸部饰品中的至少一种维度的信息。由于性别、年龄段、人种、脸部饰品都属于分类问题,因此第一分类模型可以是采用基于卷积神经网络(Convolutional Neural Networks,CNN)的分类模型(如AlexNet,GoogleNet,ResNet等)进行训练得到的。In some optional implementations of this embodiment, the above-mentioned execution subject may input the face sample set before the face change into the pre-trained first classification model to obtain the gender, age group, and person of the face sample set before the face change. Information of at least one dimension in species and facial accessories. Since gender, age group, race, and facial accessories are all classification problems, the first classification model can be a classification model based on Convolutional Neural Networks (CNN) (such as AlexNet, GoogleNet, ResNet, etc.). Get it through training.
在本实施例的一些可选的实现方式中,上述执行主体可以首先提取换脸前人脸样本集的人脸脸型分类特征;然后将所提取的人脸脸型分类特征输入至预先训练的第二分类模型,得到换脸前人脸样本集的脸型。其中,第二分类模型可以是利用基于支持向量机(Support Vector Machine,SVM)的分类模型训练得到的。In some optional implementations of this embodiment, the above-mentioned execution subject may first extract the facial classification features of the face sample set before the face change; and then input the extracted facial facial classification features into the pre-trained second The classification model obtains the face shape of the face sample set before the face change. The second classification model may be obtained by training a classification model based on Support Vector Machine (SVM).
在本实施例的一些可选的实现方式中,人脸脸型分类特征可以包括人脸特征点信息和人脸测量参数。此时,上述执行主体可以首先提取换脸前人脸样本集的人脸特征点信息;然后基于所提取的人脸特征点信息,计算换脸前人脸样本集的人脸测量参数;最后将所提取的人脸特征点信息和所计算的人脸测量参数合并为换脸前人脸样本集的人脸脸型分类特征。其中,提取人脸特征点信息的算法可以包括但不限于dlib、LBF等等。基于人脸特征点信息计算的人脸测量参数可以包括但不限于面宽(Wshape)、下颌宽(Wmandible)、形态面高(Hshape)等等。面宽可以等于左右颧点的欧氏距离。下颌宽可以等于左右下颌角点欧氏距离。形态面高可以等于鼻根点与颏下点间欧氏距离。In some optional implementations of this embodiment, the facial feature classification feature may include facial feature point information and facial measurement parameters. At this time, the above-mentioned execution subject can first extract the face feature point information of the face sample set before the face change; then, based on the extracted face feature point information, calculate the face measurement parameters of the face sample set before the face change; The extracted face feature point information and the calculated face measurement parameters are combined into the face classification feature of the face sample set before the face change. Among them, the algorithm for extracting facial feature point information may include, but is not limited to, dlib, LBF, and so on. The face measurement parameters calculated based on the facial feature point information may include, but are not limited to, face width (Wshape), jaw width (Wmandible), shape face height (Hshape), and so on. The face width can be equal to the Euclidean distance between the left and right zygomatic points. The width of the mandible can be equal to the Euclidean distance between the left and right mandibular corner points. The height of the morphological surface can be equal to the Euclidean distance between the nasion point and the submental point.
步骤303,基于所识别的人脸属性信息,从预训练模型集中确定预训练模型。Step 303: Based on the recognized face attribute information, a pre-training model is determined from the pre-training model set.
在本实施例中,上述执行主体可以基于所识别的人脸属性信息,从预训练模型集中确定预训练模型。例如,上述执行主体可以从预训练模型集中选取出与所识别的人脸属性信息最匹配的预训练模型。In this embodiment, the above-mentioned execution subject may determine the pre-training model from the pre-training model set based on the recognized face attribute information. For example, the above-mentioned execution subject may select a pre-training model that best matches the recognized face attribute information from a set of pre-training models.
在本实施例的一些可选的实现方式中,上述执行主体可以首先从预训练模型集中确定与所识别的人脸属性信息匹配的预训练模型子集;然后计算换脸前人脸样本集与预训练模型子集中的预训练模型对应的目标人脸样本集的相似度;最后基于所计算的相似度,从预训练模型子集中确定预训练模型。通常,上述执行主体可以首先提取换脸前人脸样本集的平均人脸特征向量;然后计算所提取的平均人脸特征向量与预训练模型子集中的预训练模型对应的目标人脸样本集的平均人脸特征向量的余弦相似度。其中,提取平均人脸特征向量的算法可以例如是人脸识别算法(如VggFace)。预训练模型对应的目标人脸样本集就是预先训练该预训练模型时使用的目标人脸样本集。In some optional implementations of this embodiment, the above-mentioned execution subject may first determine from the pre-training model set a subset of the pre-training model that matches the recognized face attribute information; and then calculate the face sample set before the face change and The similarity of the target face sample set corresponding to the pre-training model in the pre-training model subset; finally, based on the calculated similarity, the pre-training model is determined from the pre-training model subset. Generally, the above-mentioned execution subject can first extract the average face feature vector of the face sample set before the face change; then calculate the extracted average face feature vector and the target face sample set corresponding to the pre-training model in the pre-training model subset. The cosine similarity of the average face feature vector. Among them, the algorithm for extracting the average face feature vector may be, for example, a face recognition algorithm (such as VggFace). The target face sample set corresponding to the pre-training model is the target face sample set used when the pre-training model is pre-trained.
步骤304,提取换脸前人脸样本集的人脸丰富度特征。Step 304: Extract the face richness features of the face sample set before the face change.
在本实施例中,上述执行主体可以提取换脸前人脸样本集的人脸丰富度特征。In this embodiment, the above-mentioned execution subject may extract the face richness features of the face sample set before the face change.
在本实施例的一些可选的实现方式中,上述执行主体可以首先提取换脸前人脸样本集的人脸特征信息;然后对人脸特征信息进行直方图统计,得到换脸前人脸样本集的人脸丰富度特征。其中,人脸特征信息可以包括但不限于以下至少一种维度的信息:人脸特征点、人脸角度和人脸表情等等。提取人脸特征信息的方法可以包括但不限于人脸检测、人脸特征点提取、人脸角度识别、人脸表情识别等等。In some optional implementations of this embodiment, the above-mentioned execution subject may first extract the face feature information of the face sample set before the face change; then perform histogram statistics on the face feature information to obtain the face sample before the face change Set of face richness characteristics. Wherein, the facial feature information may include, but is not limited to, information in at least one of the following dimensions: facial feature points, facial angles, facial expressions, and so on. Methods for extracting facial feature information may include, but are not limited to, face detection, facial feature point extraction, facial angle recognition, facial expression recognition, and so on.
步骤305,计算所提取的人脸丰富度特征与模板人脸样本集组中的模板人脸样本集的人脸丰富度特征的匹配度。Step 305: Calculate the matching degree between the extracted face richness feature and the face richness feature of the template face sample set in the template face sample set group.
在本实施例中,上述执行主体可以计算所提取的人脸丰富度特征与模板人脸样本集组中的模板人脸样本集的人脸丰富度特征的匹配度。其中,匹配度的取值通常在0到1之间,0表示完全不匹配,1表示完全匹配。需要说明的是,模板人脸样本集的人脸丰富度特征可以被预选提取,其提取方法与换脸前人脸样本集的人脸丰富度特征的提取方法相同,这里不再赘述。In this embodiment, the above-mentioned execution subject may calculate the degree of matching between the extracted face richness feature and the face richness feature of the template face sample set in the template face sample set group. Among them, the value of the matching degree is usually between 0 and 1, 0 means no match at all, and 1 means complete match. It should be noted that the face richness features of the template face sample set can be pre-selected and extracted, and the extraction method is the same as the face richness feature extraction method of the face sample set before the face change, and will not be repeated here.
在本实施例的一些可选的实现方式中,上述执行主体可以利用直方图匹配 方法,计算所提取的人脸丰富度特征与模板人脸样本集组中的模板人脸样本集的人脸丰富度特征的匹配度。In some optional implementations of this embodiment, the above-mentioned execution subject may use the histogram matching method to calculate the extracted face richness features and the face richness of the template face sample set in the template face sample set group. The degree of matching of the feature.
步骤306,基于所计算的匹配度,从模板人脸样本集组中确定模板人脸样本集。Step 306: Determine a template face sample set from the template face sample set group based on the calculated matching degree.
在本实施例中,上述执行主体可以基于所计算的匹配度,从模板人脸样本集组中确定模板人脸样本集。例如,上述执行主体可以从模板人脸样本集组中选取匹配度最高的模板人脸样本集。In this embodiment, the above-mentioned execution subject may determine the template face sample set from the template face sample set group based on the calculated matching degree. For example, the above-mentioned execution subject may select the template face sample set with the highest matching degree from the template face sample set group.
在本实施例的一些可选的实现方式中,上述执行主体可以将模板人脸样本集组中的模板人脸样本集的匹配度与预设匹配度阈值(如0.7)进行比较。若模板人脸样本集组中存在匹配度大于预设匹配度阈值的模板人脸样本集,上述执行主体可以从模板人脸样本集组中选取匹配度最高的模板人脸样本集。若模板人脸样本集组中不存在匹配度大于预设匹配度阈值的模板人脸样本集,上述执行主体可以从模板人脸样本集组中选取通用的模板人脸样本集。通常,模板人脸样本集组中会预先设定一个通用的模板人脸样本集。In some optional implementations of this embodiment, the above-mentioned execution subject may compare the matching degree of the template face sample set in the template face sample set group with a preset matching degree threshold (for example, 0.7). If there is a template face sample set with a matching degree greater than a preset matching degree threshold in the template face sample set group, the above-mentioned execution subject may select the template face sample set with the highest matching degree from the template face sample set group. If there is no template face sample set with a matching degree greater than the preset matching degree threshold in the template face sample set group, the above-mentioned execution subject may select a general template face sample set from the template face sample set group. Generally, a universal template face sample set is preset in the template face sample set group.
步骤307,利用机器学习方法,基于换脸前人脸样本集和所确定的模板人脸样本集对所确定的预训练模型进行训练,得到换脸模型。Step 307: Use a machine learning method to train the determined pre-training model based on the face sample set before the face change and the determined template face sample set to obtain the face change model.
在本实施例中,步骤307的具体操作已在图2所示的实施例中步骤204中进行了详细的介绍,在此不再赘述。In this embodiment, the specific operation of step 307 has been described in detail in step 204 in the embodiment shown in FIG. 2, and will not be repeated here.
从图3中可以看出,与图2对应的实施例相比,本实施例中的用于训练换脸模型的方法的流程300突出了基于人脸属性信息确定预训练模型和基于人脸丰富度特征确定模板人脸样本集的步骤。由此,本实施例描述的方案利用人脸属性识别算法细粒度匹配预训练模型,利用人脸丰富度检测算法选取模板人脸样本集,从而实现利用人脸丰富度特征最匹配的模板人脸样本集训练人脸属性信息最相似的预训练模型,提升了训练出的换脸模型的换脸效果,使换脸模型的输出更加逼真。It can be seen from FIG. 3 that, compared with the embodiment corresponding to FIG. 2, the process 300 of the method for training a face-changing model in this embodiment highlights the determination of the pre-training model based on the face attribute information and the richness based on the face. The step of determining the template face sample set by the degree feature. Therefore, the solution described in this embodiment uses a face attribute recognition algorithm to fine-grained matching pre-training models, and uses a face richness detection algorithm to select a template face sample set, so as to realize the use of the most matching template face with facial richness features. The sample set trains the pre-trained model with the most similar face attribute information, improves the face-changing effect of the trained face-changing model, and makes the output of the face-changing model more realistic.
下面参考图4,其示出了适于用来实现本申请实施例的计算机设备(例如图1所示的设备102)的计算机系统400的结构示意图。图4示出的计算机设备仅仅是一个示例,不应对本申请实施例的功能和使用范围带来任何限制。4, which shows a schematic structural diagram of a computer system 400 suitable for implementing a computer device (for example, the device 102 shown in FIG. 1) of an embodiment of the present application. The computer device shown in FIG. 4 is only an example, and should not bring any limitation to the function and scope of use of the embodiments of the present application.
如图4所示,计算机系统400包括中央处理单元(CPU)401,其可以根据 存储在只读存储器(ROM)402中的程序或者从存储部分408加载到随机访问存储器(RAM)403中的程序而执行各种适当的动作和处理。在RAM 403中,还存储有系统400操作所需的各种程序和数据。CPU 401、ROM 402以及RAM 403通过总线404彼此相连。输入/输出(I/O)接口405也连接至总线404。As shown in FIG. 4, the computer system 400 includes a central processing unit (CPU) 401, which can be based on a program stored in a read-only memory (ROM) 402 or a program loaded from a storage part 408 into a random access memory (RAM) 403 And perform various appropriate actions and processing. In the RAM 403, various programs and data required for the operation of the system 400 are also stored. The CPU 401, the ROM 402, and the RAM 403 are connected to each other through a bus 404. An input/output (I/O) interface 405 is also connected to the bus 404.
以下部件连接至I/O接口405:包括键盘、鼠标等的输入部分406;包括诸如阴极射线管(CRT)、液晶显示器(LCD)等以及扬声器等的输出部分407;包括硬盘等的存储部分408;以及包括诸如LAN卡、调制解调器等的网络接口卡的通信部分409。通信部分409经由诸如因特网的网络执行通信处理。驱动器410也根据需要连接至I/O接口405。可拆卸介质411,诸如磁盘、光盘、磁光盘、半导体存储器等等,根据需要安装在驱动器410上,以便于从其上读出的计算机程序根据需要被安装入存储部分408。The following components are connected to the I/O interface 405: an input part 406 including a keyboard, a mouse, etc.; an output part 407 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and speakers, etc.; a storage part 408 including a hard disk, etc. ; And a communication section 409 including a network interface card such as a LAN card, a modem, and the like. The communication section 409 performs communication processing via a network such as the Internet. The driver 410 is also connected to the I/O interface 405 as needed. A removable medium 411, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 410 as required, so that the computer program read from it is installed into the storage section 408 as required.
特别地,根据本公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本公开的实施例包括一种计算机程序产品,其包括承载在计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信部分409从网络上被下载和安装,和/或从可拆卸介质411被安装。在该计算机程序被中央处理单元(CPU)401执行时,执行本申请的方法中限定的上述功能。In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program may be downloaded and installed from the network through the communication part 409, and/or installed from the removable medium 411. When the computer program is executed by the central processing unit (CPU) 401, the above-mentioned functions defined in the method of the present application are executed.
需要说明的是,本申请所述的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本申请中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本申请中,计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信 号或上述的任意合适的组合。计算机可读的信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:无线、电线、光缆、RF等等,或者上述的任意合适的组合。It should be noted that the computer-readable medium described in this application may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or a combination of any of the above. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable Programmable read only memory (EPROM or flash memory), optical fiber, portable compact disk read only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above. In this application, a computer-readable storage medium may be any tangible medium that contains or stores a program, and the program may be used by or in combination with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium may include a data signal propagated in a baseband or as a part of a carrier wave, and a computer-readable program code is carried therein. This propagated data signal can take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. The computer-readable signal medium may also be any computer-readable medium other than the computer-readable storage medium. The computer-readable medium may send, propagate, or transmit the program for use by or in combination with the instruction execution system, apparatus, or device . The program code contained on the computer-readable medium can be transmitted by any suitable medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
可以以一种或多种程序设计语言或其组合来编写用于执行本申请的操作的计算机程序代码,所述程序设计语言包括面向目标的程序设计语言-诸如Java、Smalltalk、C++,还包括常规的过程式程序设计语言-诸如”C”语言或类似的程序设计语言。程序代码可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或电子设备上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络——包括局域网(LAN)或广域网(WAN)-连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。The computer program code used to perform the operations of this application can be written in one or more programming languages or a combination thereof. The programming languages include object-oriented programming languages-such as Java, Smalltalk, C++, and also conventional The procedural programming language-such as "C" language or similar programming language. The program code can be executed entirely on the user's computer, partly on the user's computer, executed as an independent software package, partly on the user's computer and partly executed on a remote computer, or entirely executed on the remote computer or electronic device. In the case of a remote computer, the remote computer can be connected to the user's computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (for example, through an Internet service provider). Internet connection).
附图中的流程图和框图,图示了按照本申请各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,该模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation of the system architecture, functions, and operations of the system, method, and computer program product according to various embodiments of the present application. In this regard, each block in the flowchart or block diagram may represent a module, program segment, or part of code, and the module, program segment, or part of code contains one or more for realizing the specified logical function Executable instructions. It should also be noted that, in some alternative implementations, the functions marked in the block may also occur in a different order from the order marked in the drawings. For example, two blocks shown in succession can actually be executed substantially in parallel, and they can sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and/or flowchart, and the combination of the blocks in the block diagram and/or flowchart, can be implemented by a dedicated hardware-based system that performs the specified functions or operations Or it can be realized by a combination of dedicated hardware and computer instructions.
描述于本申请实施例中所涉及到的单元可以通过软件的方式实现,也可以通过硬件的方式来实现。所描述的单元也可以设置在处理器中,例如,可以描述为:一种处理器包括接收单元、第一确定单元、第二确定单元和训练单元。其中,这些单元的名称在种情况下并不构成对该单元本身的限定,例如,接收单元还可以被描述为“接收用户发送的换脸模型训练请求的单元”。The units involved in the embodiments described in the present application can be implemented in software or hardware. The described unit may also be provided in the processor. For example, it may be described as: a processor includes a receiving unit, a first determining unit, a second determining unit, and a training unit. Among them, the names of these units do not constitute a limitation on the unit itself in this case. For example, the receiving unit can also be described as "a unit that receives a face-changing model training request sent by a user".
作为另一方面,本申请还提供了一种计算机可读介质,该计算机可读介质可以是上述实施例中描述的计算机设备中所包含的;也可以是单独存在,而未装配入该计算机设备中。上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被该计算机设备执行时,使得该计算机设备:接收用户发送的换脸模型训练请求,其中,换脸模型训练请求中包括用户提供的换脸前人脸样本集和指定的模板人脸标识;从模板人脸标识对应的预训练模型集中确定与换脸前人脸样本集匹配的预训练模型,其中,预训练模型集包括基于目标人脸样本集组和模板人脸标识对应的模板人脸样本集组预先训练过的模型;从模板人脸样本集组中确定与换脸前人脸样本集匹配的模板人脸样本集;利用机器学习方法,基于换脸前人脸样本集和所确定的模板人脸样本集对所确定的预训练模型进行训练,得到换脸模型。As another aspect, this application also provides a computer-readable medium. The computer-readable medium may be included in the computer equipment described in the above-mentioned embodiments; it may also exist alone without being assembled into the computer equipment. in. The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the computer device, the computer device: receives a face-changing model training request sent by a user, wherein, in the face-changing model training request Including the face sample set before the face change and the specified template face identifier provided by the user; the pre-training model matching the face sample set before the face change is determined from the pre-training model set corresponding to the template face identifier, where the pre-training model The set includes pre-trained models based on the target face sample set group and the template face sample set group corresponding to the template face identifier; the template face that matches the face sample set before the face change is determined from the template face sample set group Sample set: Using machine learning methods, the determined pre-training model is trained based on the face sample set before the face change and the determined template face sample set to obtain the face change model.
以上描述仅为本申请的较佳实施例以及对所运用技术原理的说明。本领域技术人员应当理解,本申请中所涉及的发明范围,并不限于上述技术特征的特定组合而成的技术方案,同时也应涵盖在不脱离上述发明构思的情况下,由上述技术特征或其等同特征进行任意组合而形成的其它技术方案。例如上述特征与本申请中公开的(但不限于)具有类似功能的技术特征进行互相替换而形成的技术方案。The above description is only a preferred embodiment of the present application and an explanation of the applied technical principles. Those skilled in the art should understand that the scope of the invention involved in this application is not limited to the technical solutions formed by the specific combination of the above technical features, and should also cover the above technical features or technical solutions without departing from the above inventive concept. Other technical solutions formed by arbitrarily combining the equivalent features. For example, the above-mentioned features and the technical features disclosed in this application (but not limited to) with similar functions are mutually replaced to form a technical solution.

Claims (19)

  1. 一种用于训练换脸模型的方法,包括:A method for training a face-changing model, including:
    接收用户发送的换脸模型训练请求,其中,所述换脸模型训练请求中包括用户提供的换脸前人脸样本集和指定的模板人脸标识;Receiving a face-changing model training request sent by a user, where the face-changing model training request includes a face sample set before the face change and a designated template face identifier provided by the user;
    从所述模板人脸标识对应的预训练模型集中确定与所述换脸前人脸样本集匹配的预训练模型,其中,所述预训练模型集包括基于目标人脸样本集组和所述模板人脸标识对应的模板人脸样本集组预先训练过的模型;From the pre-training model set corresponding to the template face identifier, a pre-training model that matches the face sample set before the face change is determined, wherein the pre-training model set includes a sample set based on the target face and the template The pre-trained model of the template face sample set corresponding to the face identifier;
    从所述模板人脸样本集组中确定与所述换脸前人脸样本集匹配的模板人脸样本集;Determining, from the template face sample set group, a template face sample set that matches the face sample set before the face change;
    利用机器学习方法,基于所述换脸前人脸样本集和所确定的模板人脸样本集对所确定的预训练模型进行训练,得到换脸模型。Using a machine learning method, the determined pre-training model is trained based on the face sample set before the face change and the determined template face sample set to obtain the face change model.
  2. 根据权利要求1所述的方法,其中,所述从所述模板人脸标识对应的预训练模型集中确定与所述换脸前人脸样本集匹配的预训练模型,包括:The method according to claim 1, wherein the determining from the pre-training model set corresponding to the template face identifier the pre-training model that matches the face sample set before the face change comprises:
    若所述用户的历史换脸记录中存在所述模板人脸标识对应的预训练模型,将所述模板人脸标识对应的预训练模型确定为与所述换脸前人脸样本集匹配的预训练模型。If there is a pre-training model corresponding to the template face identifier in the user’s historical face change record, the pre-training model corresponding to the template face identifier is determined as the pre-training model that matches the face sample set before the face change. Train the model.
  3. 根据权利要求2所述的方法,其中,所述从所述模板人脸标识对应的预训练模型集中确定与所述换脸前人脸样本集匹配的预训练模型,还包括:The method according to claim 2, wherein said determining from the set of pre-training models corresponding to the template face identifiers a pre-training model that matches the set of face samples before the face change, further comprising:
    若所述用户的历史换脸记录中不存在所述模板人脸标识对应的预训练模型,识别所述换脸前人脸样本集的人脸属性信息;If the pre-trained model corresponding to the template face identifier does not exist in the user's historical face change record, identifying the face attribute information of the face sample set before the face change;
    基于所识别的人脸属性信息,从所述预训练模型集中确定预训练模型。Based on the recognized face attribute information, a pre-training model is determined from the set of pre-training models.
  4. 根据权利要求3所述的方法,其中,所述人脸属性信息包括以下至少一种维度的信息:性别、年龄段、人种、脸部饰品、脸型。The method according to claim 3, wherein the face attribute information includes information in at least one of the following dimensions: gender, age group, race, facial accessories, and face shape.
  5. 根据权利要求4所述的方法,其中,所述识别所述换脸前人脸样本集的人 脸属性信息,包括:The method according to claim 4, wherein the identifying the face attribute information of the face sample set before the face change comprises:
    将所述换脸前人脸样本集输入至预先训练的第一分类模型,得到所述换脸前人脸样本集的性别、年龄段、人种、脸部饰品中的至少一种维度的信息,其中,所述第一分类模型是基于卷积神经网络的分类模型。Input the face sample set before the face change to the pre-trained first classification model to obtain information about at least one dimension of the gender, age group, race, and facial accessories of the face sample set before the face change , Wherein the first classification model is a classification model based on a convolutional neural network.
  6. 根据权利要求4或5所述的方法,其中,所述识别所述换脸前人脸样本集的人脸属性信息,包括:The method according to claim 4 or 5, wherein the identifying the face attribute information of the face sample set before the face change comprises:
    提取所述换脸前人脸样本集的人脸脸型分类特征;Extracting face classification features of the face sample set before the face change;
    将所提取的人脸脸型分类特征输入至预先训练的第二分类模型,得到所述换脸前人脸样本集的脸型,其中,所述第二分类模型是基于支持向量机的分类模型。The extracted facial classification features are input to a pre-trained second classification model to obtain the face shape of the face sample set before the face change, wherein the second classification model is a classification model based on a support vector machine.
  7. 根据权利要求6所述的方法,其中,所述提取所述换脸前人脸样本集的人脸脸型分类特征,包括:The method according to claim 6, wherein said extracting the facial classification features of the face sample set before the face change comprises:
    提取所述换脸前人脸样本集的人脸特征点信息;Extracting face feature point information of the face sample set before the face change;
    基于所提取的人脸特征点信息,计算所述换脸前人脸样本集的人脸测量参数;Calculating the face measurement parameters of the face sample set before the face change based on the extracted face feature point information;
    将所提取的人脸特征点信息和所计算的人脸测量参数合并为所述换脸前人脸样本集的人脸脸型分类特征。The extracted face feature point information and the calculated face measurement parameters are combined into the face classification feature of the face sample set before the face change.
  8. 根据权利要求3所述的方法,其中,所述基于所识别的人脸属性信息,从所述预训练模型集中确定预训练模型,包括:The method according to claim 3, wherein the determining a pre-training model from the set of pre-training models based on the recognized face attribute information comprises:
    从所述预训练模型集中确定与所识别的人脸属性信息匹配的预训练模型子集;Determining a subset of pre-training models matching the recognized face attribute information from the set of pre-training models;
    计算所述换脸前人脸样本集与所述预训练模型子集中的预训练模型对应的目标人脸样本集的相似度;Calculating the similarity between the face sample set before the face change and the target face sample set corresponding to the pre-training model in the pre-training model subset;
    基于所计算的相似度,从所述预训练模型子集中确定预训练模型。Based on the calculated similarity, a pre-training model is determined from the subset of pre-training models.
  9. 根据权利要求8所述的方法,其中,所述计算所述换脸前人脸样本集与所述预训练模型子集中的预训练模型对应的目标人脸样本集的相似度,包括:The method according to claim 8, wherein the calculating the similarity between the face sample set before the face change and the target face sample set corresponding to the pre-training model in the pre-training model subset comprises:
    提取所述换脸前人脸样本集的平均人脸特征向量;Extracting an average face feature vector of the face sample set before the face change;
    计算所提取的平均人脸特征向量与所述预训练模型子集中的预训练模型对应 的目标人脸样本集的平均人脸特征向量的余弦相似度。Calculate the cosine similarity between the extracted average face feature vector and the average face feature vector of the target face sample set corresponding to the pre-training model in the pre-training model subset.
  10. 根据权利要求1所述的方法,其中,所述从所述模板人脸样本集组中确定与所述换脸前人脸样本集匹配的模板人脸样本集,包括:The method according to claim 1, wherein the determining a template face sample set matching the pre-changing face sample set from the template face sample set group comprises:
    提取所述换脸前人脸样本集的人脸丰富度特征;Extracting the face richness features of the face sample set before the face change;
    计算所提取的人脸丰富度特征与所述模板人脸样本集组中的模板人脸样本集的人脸丰富度特征的匹配度;Calculating the degree of matching between the extracted face richness features and the face richness features of the template face sample set in the template face sample set group;
    基于所计算的匹配度,从所述模板人脸样本集组中确定模板人脸样本集。Based on the calculated matching degree, a template face sample set is determined from the template face sample set group.
  11. 根据权利要求10所述的方法,其中,所述提取所述换脸前人脸样本集的人脸丰富度特征,包括:The method according to claim 10, wherein said extracting the face richness features of the face sample set before the face change comprises:
    提取所述换脸前人脸样本集的人脸特征信息;Extracting face feature information of the face sample set before the face change;
    对所述人脸特征信息进行直方图统计,得到所述换脸前人脸样本集的人脸丰富度特征。Performing histogram statistics on the face feature information to obtain the face richness features of the face sample set before the face change.
  12. 根据权利要求11所述的方法,其中,所述人脸特征信息包括以下至少一种维度的信息:人脸特征点、人脸角度和人脸表情。The method according to claim 11, wherein the facial feature information includes information in at least one of the following dimensions: facial feature points, facial angles, and facial expressions.
  13. 根据权利要求11所述的方法,其中,所述计算所提取的人脸丰富度特征与所述模板人脸样本集组中的模板人脸样本集的人脸丰富度特征的匹配度,包括:The method according to claim 11, wherein the calculating the matching degree between the extracted face richness feature and the face richness feature of the template face sample set in the template face sample set group comprises:
    利用直方图匹配方法,计算所提取的人脸丰富度特征与所述模板人脸样本集组中的模板人脸样本集的人脸丰富度特征的匹配度。Using the histogram matching method, the degree of matching between the extracted face richness feature and the face richness feature of the template face sample set in the template face sample set group is calculated.
  14. 根据权利要求10所述的方法,其中,所述基于所计算的匹配度,从所述模板人脸样本集组中确定模板人脸样本集,包括:The method according to claim 10, wherein the determining a template face sample set from the template face sample set group based on the calculated matching degree comprises:
    若所述模板人脸样本集组中存在匹配度大于预设匹配度阈值的模板人脸样本集,从所述模板人脸样本集组中选取匹配度最高的模板人脸样本集;If there is a template face sample set with a matching degree greater than a preset matching degree threshold in the template face sample set group, select the template face sample set with the highest matching degree from the template face sample set group;
    若所述模板人脸样本集组中不存在匹配度大于所述预设匹配度阈值的模板人脸样本集,从所述模板人脸样本集组中选取通用的模板人脸样本集。If there is no template face sample set with a matching degree greater than the preset matching degree threshold in the template face sample set group, a universal template face sample set is selected from the template face sample set group.
  15. 根据权利要求1所述的方法,其中,所述预训练模型集通过如下步骤训练:The method according to claim 1, wherein the pre-training model set is trained through the following steps:
    获取多个目标人脸样本;Obtain multiple target face samples;
    按照人脸属性,将所述多个目标人脸样本划分为所述目标人脸样本集组,其中,同一目标人脸样本集中的目标人脸样本的人脸属性相似;Dividing the multiple target face samples into the target face sample set groups according to the face attributes, wherein the target face samples in the same target face sample set have similar face attributes;
    对于所述目标人脸样本集组中的目标人脸样本集,基于该目标人脸样本集和与该目标人脸样本集匹配的模板人脸样本集对生成式对抗网络进行训练,得到预训练模型。For the target face sample set in the target face sample set group, the generative confrontation network is trained based on the target face sample set and the template face sample set matching the target face sample set to obtain pre-training model.
  16. 根据权利要求15所述的方法,其中,预训练模型包括生成模型和判别模型;以及The method according to claim 15, wherein the pre-training model includes a generative model and a discriminant model; and
    所述利用机器学习方法,基于所述换脸前人脸样本集和所确定的模板人脸样本集对所确定的预训练模型进行训练,得到换脸模型,包括:The machine learning method is used to train the determined pre-training model based on the face sample set before the face change and the determined template face sample set to obtain the face change model, including:
    将所述换脸前人脸样本集输入所确定的预训练模型的生成模型,得到换脸后人脸样本集;Inputting the face sample set before the face change into the determined generation model of the pre-training model to obtain the face sample set after the face change;
    将所述换脸后人脸样本集和所确定的模板人脸样本集输入所确定的预训练模型的判别模型,得到判别结果,其中,所述判别结果用于表征所述换脸后人脸样本集和所确定的模板人脸样本集是真实样本集的概率;The face sample set after the face change and the determined template face sample set are input into the discriminant model of the determined pre-training model to obtain a discrimination result, wherein the discrimination result is used to characterize the face after the face change The probability that the sample set and the determined template face sample set are true sample sets;
    基于所述判别结果调整所确定的预训练模型的生成模型和判别模型的参数。The parameters of the determined generation model and the discrimination model of the pre-training model are adjusted based on the discrimination result.
  17. 根据权利要求16所述的方法,其中,所述基于所述判别结果调整所确定的预训练模型的生成模型和判别模型的参数,包括:The method according to claim 16, wherein the adjusting the parameters of the determined generation model and the discrimination model of the pre-training model based on the discrimination result comprises:
    确定所述判别结果是否满足约束条件;Determine whether the judgment result meets the constraint condition;
    若所述判别结果不满足所述约束条件,基于所述判别结果调整所确定的预训练模型的生成模型和判别模型的参数,以及再次基于所述换脸前人脸样本集和所确定的模板人脸样本集对所确定的预训练模型进行训练;If the discrimination result does not satisfy the constraint condition, adjust the parameters of the determined generation model and discrimination model of the pre-training model based on the discrimination result, and again based on the face sample set before the face change and the determined template The face sample set trains the determined pre-training model;
    若所述判别结果满足所述约束条件,确定所述换脸模型训练完成,以及将所确定的预训练模型的生成模型最后一次输出的换脸后人脸样本集发送给所述用户。If the discrimination result satisfies the constraint condition, it is determined that the training of the face-changing model is completed, and the final face-changing face sample set output by the generation model of the determined pre-training model is sent to the user.
  18. 一种计算机设备,包括:A computer device including:
    一个或多个处理器;One or more processors;
    存储装置,其上存储一个或多个程序;A storage device, on which one or more programs are stored;
    当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如权利要求1-17中任一所述的方法。When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1-17.
  19. 一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现如权利要求1-17中任一所述的方法。A computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the method according to any one of claims 1-17 is realized.
PCT/CN2020/123582 2019-10-30 2020-10-26 Method and device for training face swapping model WO2021083069A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201911043178.3 2019-10-30
CN201911043178.3A CN110796089B (en) 2019-10-30 2019-10-30 Method and apparatus for training face model

Publications (1)

Publication Number Publication Date
WO2021083069A1 true WO2021083069A1 (en) 2021-05-06

Family

ID=69442013

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/123582 WO2021083069A1 (en) 2019-10-30 2020-10-26 Method and device for training face swapping model

Country Status (2)

Country Link
CN (1) CN110796089B (en)
WO (1) WO2021083069A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113379594A (en) * 2021-06-29 2021-09-10 北京百度网讯科技有限公司 Face shape transformation model training, face shape transformation method and related device
CN113486785A (en) * 2021-07-01 2021-10-08 深圳市英威诺科技有限公司 Video face changing method, device, equipment and storage medium based on deep learning
CN115358916A (en) * 2022-07-06 2022-11-18 北京健康之家科技有限公司 Face-changed image generation method and device, computer equipment and readable storage medium

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110796089B (en) * 2019-10-30 2023-12-12 上海掌门科技有限公司 Method and apparatus for training face model
CN111353392B (en) * 2020-02-18 2022-09-30 腾讯科技(深圳)有限公司 Face change detection method, device, equipment and storage medium
CN111783603A (en) * 2020-06-24 2020-10-16 有半岛(北京)信息科技有限公司 Training method for generating confrontation network, image face changing method and video face changing method and device
CN113763232B (en) * 2020-08-10 2024-06-18 北京沃东天骏信息技术有限公司 Image processing method, device, equipment and computer readable storage medium
CN112734631A (en) * 2020-12-31 2021-04-30 北京深尚科技有限公司 Video image face changing method, device, equipment and medium based on fine adjustment model

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2012078526A (en) * 2010-09-30 2012-04-19 Xing Inc Karaoke system
CN106534757A (en) * 2016-11-22 2017-03-22 北京金山安全软件有限公司 Face exchange method and device, anchor terminal and audience terminal
CN110796089A (en) * 2019-10-30 2020-02-14 上海掌门科技有限公司 Method and apparatus for training face-changing model

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108520220B (en) * 2018-03-30 2021-07-09 百度在线网络技术(北京)有限公司 Model generation method and device
CN108509916A (en) * 2018-03-30 2018-09-07 百度在线网络技术(北京)有限公司 Method and apparatus for generating image
CN109409198B (en) * 2018-08-31 2023-09-05 平安科技(深圳)有限公司 AU detection method, AU detection device, AU detection equipment and AU detection medium
CN109214343B (en) * 2018-09-14 2021-03-09 北京字节跳动网络技术有限公司 Method and device for generating face key point detection model
CN110110611A (en) * 2019-04-16 2019-08-09 深圳壹账通智能科技有限公司 Portrait attribute model construction method, device, computer equipment and storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2012078526A (en) * 2010-09-30 2012-04-19 Xing Inc Karaoke system
CN106534757A (en) * 2016-11-22 2017-03-22 北京金山安全软件有限公司 Face exchange method and device, anchor terminal and audience terminal
CN110796089A (en) * 2019-10-30 2020-02-14 上海掌门科技有限公司 Method and apparatus for training face-changing model

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
ANONYMOUS: "Face Wwap Face Replacement Tutorial", 17 March 2018 (2018-03-17), pages 1 - 7, XP055807484, Retrieved from the Internet <URL:https://blog.csdn.net/sinat_26918145/article/details/79591717> *
XING ENXU , WU XIAOYONG , LI YAXIAN: "Double-Layer Generative Adversarial Networks Based on Transfer Learning", COMPUTER ENGINEERING AND APPLICATIONS, vol. 55, no. 15, 8 March 2019 (2019-03-08), pages 38 - 46+103, XP055807487, ISSN: 1002-8331, DOI: 10.3778/j.issn.1002-8331.1812-0225 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113379594A (en) * 2021-06-29 2021-09-10 北京百度网讯科技有限公司 Face shape transformation model training, face shape transformation method and related device
CN113486785A (en) * 2021-07-01 2021-10-08 深圳市英威诺科技有限公司 Video face changing method, device, equipment and storage medium based on deep learning
CN115358916A (en) * 2022-07-06 2022-11-18 北京健康之家科技有限公司 Face-changed image generation method and device, computer equipment and readable storage medium

Also Published As

Publication number Publication date
CN110796089B (en) 2023-12-12
CN110796089A (en) 2020-02-14

Similar Documents

Publication Publication Date Title
WO2021083069A1 (en) Method and device for training face swapping model
CN109726624B (en) Identity authentication method, terminal device and computer readable storage medium
WO2020006961A1 (en) Image extraction method and device
US11487995B2 (en) Method and apparatus for determining image quality
WO2020024484A1 (en) Method and device for outputting data
WO2021036059A1 (en) Image conversion model training method, heterogeneous face recognition method, device and apparatus
WO2020253127A1 (en) Facial feature extraction model training method and apparatus, facial feature extraction method and apparatus, device, and storage medium
CN111476871B (en) Method and device for generating video
CN108416310B (en) Method and apparatus for generating information
WO2020019591A1 (en) Method and device used for generating information
CN106682632B (en) Method and device for processing face image
CN109993150B (en) Method and device for identifying age
CN108898185A (en) Method and apparatus for generating image recognition model
CN107679466B (en) Information output method and device
WO2022105118A1 (en) Image-based health status identification method and apparatus, device and storage medium
CN109189544B (en) Method and device for generating dial plate
WO2020062493A1 (en) Image processing method and apparatus
WO2021238410A1 (en) Image processing method and apparatus, electronic device, and medium
WO2021208601A1 (en) Artificial-intelligence-based image processing method and apparatus, and device and storage medium
WO2020124993A1 (en) Liveness detection method and apparatus, electronic device, and storage medium
WO2020124994A1 (en) Liveness detection method and apparatus, electronic device, and storage medium
WO2020238321A1 (en) Method and device for age identification
US20210295016A1 (en) Living body recognition detection method, medium and electronic device
WO2023050868A1 (en) Method and apparatus for training fusion model, image fusion method and apparatus, and device and medium
WO2023197648A1 (en) Screenshot processing method and apparatus, electronic device, and computer readable medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20881794

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20881794

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 20881794

Country of ref document: EP

Kind code of ref document: A1

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 27.10.2022)

122 Ep: pct application non-entry in european phase

Ref document number: 20881794

Country of ref document: EP

Kind code of ref document: A1