Face-changing method, device, equipment and storage medium based on artificial intelligence

By training a generative adversarial network model and performing key point feature extraction and fusion processing, the problem of poor face-changing effect caused by the difference in face shape between the source face and the target face in the existing technology is solved, and the realism and consistency of face-changing are improved. Compatibility.

CN114387656BActive Publication Date: 2024-09-13PING AN TECH (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210044175.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-14
Publication Date
2024-09-13
Estimated Expiration
2042-01-14

AI Technical Summary

Technical Problem

When the existing face-changing technology based on artificial intelligence is too different between the source face and the target face, the realism and fit of the simulated face are poor, resulting in poor face-changing effects.

Method used

By training the first generative adversarial network model and the second generative adversarial network model, the source portrait and the target portrait are obtained, the key point feature vectors are determined, and the facial image is extracted from the target portrait, and the facial image is processed and processed using this information. Fusion to generate a face-swapping portrait that better fits the target portrait.

Benefits of technology

The realism and effect of face swapping are improved, making the shape and orientation of the generated face-swapping portrait closer to the target portrait, enhancing the degree of simulation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114387656B
    Figure CN114387656B
Patent Text Reader

Abstract

The present application relates to the field of artificial intelligence and image processing, and provides a face-changing method, device, equipment and storage medium based on artificial intelligence, the method comprising: training a first generative adversarial network model according to a first sample data set; training a second generative adversarial network model according to a second sample data set; running the first generative adversarial network model to process a source portrait and a target portrait; determining a key point feature vector of a first face image, and extracting a first target face image from the target portrait and a second target face image from the first face image; running a second generative adversarial network model, processing the first face image using the key point feature vector, the first target face image and the second target face image; fusing the second face image and the target portrait. The present application improves the authenticity of face-changing. The above storage medium can store data created according to the use of blockchain nodes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing, and in particular to an artificial intelligence-based face-changing method, device, equipment and storage medium. Background Art

[0002] With the rapid development of artificial intelligence and network technology, artificial intelligence-based face-changing technology has also emerged. Face-changing technology can replace the source face in an image or video with a target face. However, in the current face-changing technology, it is necessary to convert the source face into a simulated face, and then replace the target face in the image or video with the simulated face. If the simulated face is made closer to the source face, if the face shape of the source face and the target face is too different, there is a problem that the face shape of the simulated face does not fit the face shape of the target face, and the authenticity of the simulated face cannot be guaranteed, and the face-changing effect is poor. Summary of the invention

[0003] The embodiments of the present application provide a face-changing method, device, equipment and storage medium based on artificial intelligence, aiming to improve the realism and effect of face-changing.

[0004] In a first aspect, an embodiment of the present application provides a face-changing method based on artificial intelligence, comprising:

[0005] Acquire a first sample data set, and iteratively train a first generative adversarial network model according to the first sample data set until the first generative adversarial network model converges;

[0006] Acquire a second sample data set, and iteratively train a second generative adversarial network model according to the second sample data set until the second generative adversarial network model converges;

[0007] Obtaining a source portrait and a target portrait, and running the converged first generative adversarial network model to process the source portrait and the target portrait to obtain a first facial image;

[0008] Determine a key point feature vector of the first facial image, and extract a first target facial image from the target portrait and a second target facial image from the first facial image;

[0009] Running the converged second generative adversarial network model, processing the first facial image using the key point feature vector, the first target facial image, and the second target facial image to obtain a second facial image;

[0010] The second facial image and the target portrait are fused to obtain a target face-swapped portrait.

[0011] In a second aspect, an embodiment of the present application further provides an artificial intelligence-based face-changing device, the artificial intelligence-based face-changing device comprising:

[0012] A model training module, used to obtain a first sample data set, and iteratively train a first generative adversarial network model according to the first sample data set until the first generative adversarial network model converges;

[0013] The model training module is further used to obtain a second sample data set, and iteratively train the second generative adversarial network model according to the second sample data set until the second generative adversarial network model converges;

[0014] An acquisition module, used to acquire a source portrait and a target portrait;

[0015] A first processing module, configured to run the converged first generative adversarial network model to process the source portrait and the target portrait to obtain a first facial image;

[0016] A determination module, used to determine a key point feature vector of the first facial image, and extract a first target facial image from the target portrait and a second target facial image from the first facial image;

[0017] A second processing module is used to run the converged second generative adversarial network model, and use the key point feature vector, the first target facial image and the second target facial image to process the first facial image to obtain a second facial image;

[0018] The image fusion module is used to fuse the second facial image and the target portrait to obtain a target face-swapped portrait.

[0019] In a third aspect, an embodiment of the present application further provides a computer device, comprising a processor, a memory, and a computer program stored in the memory and executable by the processor, wherein when the computer program is executed by the processor, the steps of the artificial intelligence-based face-changing method as described above are implemented.

[0020] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, wherein when the computer program is executed by a processor, the steps of the artificial intelligence-based face-changing method as described above are implemented.

[0021] The embodiments of the present application provide a face-changing method, apparatus, device and storage medium based on artificial intelligence. A first generative adversarial network model and a second generative adversarial network model are obtained through training, and a source portrait and a target portrait are fused through the first generative adversarial network model to obtain a first face image with high simulation degree, and then a key point feature vector of the first face image is determined, and a first target face image is extracted from the target portrait and a second target face image is extracted from the first face image. Finally, the first face image is processed by the second generative adversarial network model using the key point feature vector, the first target face image and the second target face image to obtain a second face portrait whose orientation is closer to the target portrait and whose shape is more similar to the face shape of the target portrait, and the second face image and the target portrait are fused to obtain a target face-changing portrait, thereby improving the realism and face-changing effect of the face-changing. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0023] Figure 1 This is a flowchart of an artificial intelligence-based face-changing method provided in an embodiment of the present application;

[0024] Figure 2 Schematic diagram of the hierarchical structure of the first generative adversarial network model in the embodiment of the present application;

[0025] Figure 3 is a schematic block diagram of an artificial intelligence-based face-changing device provided in an embodiment of the present application;

[0026] Figure 4 yes Figure 3 A schematic block diagram of submodules of an artificial intelligence-based face-changing device;

[0027] Figure 5 It is a schematic block diagram of the structure of a computer device provided in an embodiment of the present application.

[0028] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

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

[0030] The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may also be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.

[0031] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0032] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0033] The embodiments of the present application provide a face-changing method, device, equipment and computer-readable storage medium based on artificial intelligence. Among them, the face-changing method based on artificial intelligence can be applied to a server, which can be an independent server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.

[0034] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.

[0035] See also Figure 1 , Figure 1 It is a flowchart of an artificial intelligence-based face-changing method provided in an embodiment of the present application.

[0036] like Figure 1As shown, the artificial intelligence-based face-changing method includes steps S101 to S106.

[0037] Step S101: Obtain a first sample data set, and iteratively train a first generative adversarial network model according to the first sample data set until the first generative adversarial network model converges.

[0038] The first sample data set includes a plurality of portrait pairs, wherein the portrait pair includes a first source portrait and a second target portrait. Figure 2 As shown, the first generative adversarial network (GAN) model includes a facial feature extraction network 110, an attribute feature extraction network 120 and a first GAN network 130. The facial feature extraction network 110 is connected in parallel with the attribute feature extraction network 120 and then connected in series with the first GAN network 130. The facial feature extraction network 110 is used to extract facial features of a portrait, and the attribute feature extraction network 120 is used to extract attribute features of a portrait. The attribute features include but are not limited to lighting, expression, and hairstyle. The facial feature extraction network includes an Arcface network, and the attribute feature extraction network includes an 8-layer u-net network structure.

[0039] In one embodiment, a portrait pair is selected from a first sample data set as a target portrait pair; a first source portrait in the target portrait pair is input into a facial feature extraction network for facial feature extraction to obtain a first facial feature vector; the first target portrait in the target portrait pair is input into an attribute feature network for attribute feature extraction to obtain a first attribute feature vector; the first facial feature vector and the first attribute feature vector are input into a first generative adversarial network for processing to obtain a first predicted face image; a second facial feature vector of the first predicted face image and a second attribute feature vector of the first predicted face image are determined; a first model loss value is calculated based on the first facial feature vector, the first attribute feature vector, the second facial feature vector, the second attribute feature vector, the first source portrait and the first predicted face image; whether the first generative adversarial network model has converged is determined based on the first model loss value; if the first generative adversarial network model has not converged, the model parameters of the first generative adversarial network model are updated; and the step of selecting a portrait pair from the first sample data set as the target portrait pair is returned to be executed until the first generative adversarial network model converges.

[0040] Exemplarily, a portrait pair is randomly selected from the first sample data set as the target portrait pair. Alternatively, an identification ID is assigned to each portrait pair from the first sample data set, and based on the identification ID, a portrait pair is selected from the first sample data set in ascending order as the target portrait pair. The portrait pairs selected each time are not repeated.

[0041] Exemplarily, a first similarity between a first facial feature vector and a second facial feature vector is determined; a second similarity between a first attribute feature vector and a second attribute feature vector is determined; a third similarity between a first source portrait and a first predicted face image is determined; and a first model loss value is calculated based on the first similarity, the second similarity, and the third similarity. The first similarity, the second similarity, and the third similarity can be calculated based on a cosine similarity formula.

[0042] Exemplarily, the first weighting coefficient, the second weighting coefficient and the third weighting coefficient are obtained; the product between the first similarity and the first weighting coefficient is calculated to obtain the first loss value; the product between the second similarity and the second weighting coefficient is calculated to obtain the second loss value; the product between the third similarity and the third weighting coefficient is calculated to obtain the third loss value; the first loss value, the second loss value and the third loss value are summed to obtain the first model loss value. Among them, the first weighting coefficient, the second weighting coefficient and the third weighting coefficient can be set based on actual conditions, and this embodiment does not specifically limit this.

[0043] Exemplarily, a method for determining whether the first generative adversarial network model has converged based on the first model loss value can be: determining whether the first model loss value is less than or equal to a preset first loss value; if the first model loss value is less than or equal to the preset first loss value, determining that the first generative adversarial network model has converged; if the first model loss value is greater than the first loss value, determining that the first generative adversarial network model has not converged.

[0044] Step S102: Obtain a second sample data set, and iteratively train the second generative adversarial network model according to the second sample data set until the second generative adversarial network model converges.

[0045] Among them, the second sample data set includes multiple sample data, the sample data includes sample face images, sample portraits and annotated face images, and the sample face images are face images generated by the first generative adversarial network model.

[0046] In one embodiment, a sample data is selected from a second sample data set as target sample data; a sample face image in the target sample data is input into a key point detection network for key point detection to obtain a key point feature vector of the sample face image; a first face image is segmented from the sample face image, and a second face image is segmented from a sample face image in the target sample data; the sample face image, the key point feature vector of the sample face image, the first face image, and the second face image are input into a second generative adversarial network for processing to obtain a second predicted face image; a second model loss value is calculated based on the second predicted face image and the labeled face image in the target sample data; whether the second generative adversarial network converges is determined based on the second model loss value; if the second generative adversarial network does not converge, the model parameters of the second generative adversarial network are updated; and the step of selecting a sample data from the second sample data set as the target sample data is returned to be executed until the second generative adversarial network converges.

[0047] Exemplarily, the similarity between the second predicted face image and the annotated face image is determined, and the reciprocal of the similarity is determined as the second model loss value. If the second model loss value is less than or equal to the preset second loss value, it is determined that the second generative adversarial network model has converged; if the second model loss value is greater than the preset second loss value, it is determined that the second generative adversarial network model has not converged.

[0048] Step S103: Obtain a source portrait and a target portrait, and run the converged first generative adversarial network model to process the source portrait and the target portrait to obtain a first face image.

[0049] Exemplarily, the source portrait is input into the facial feature extraction network in the converged first generative adversarial network model to extract facial features, and obtain the facial feature vector of the source portrait; the target portrait is input into the attribute feature network in the converged first generative adversarial network model to extract attribute features, and obtain the attribute feature vector of the target portrait; the facial feature vector of the source portrait and the attribute feature vector of the target portrait are input into the first generative adversarial network in the converged first generative adversarial network model to perform image generation processing, and obtain the first face image. By fusing the facial feature vector of the source portrait and the attribute feature vector of the target portrait, a face image with high simulation can be generated.

[0050] Step S104: determine the key point feature vector of the first facial image, and extract the first target facial image from the target portrait and the second target facial image from the first facial image.

[0051] Exemplarily, the first face image is input into a key point detection network to extract key point features, and obtain a key point feature vector of the first face image; the target portrait is input into a facial segmentation network to perform facial segmentation, and obtain a first facial image; and the first face image is subjected to facial segmentation to obtain a second facial image. The key point detection network is a pre-trained neural network, and the facial segmentation network can be a pre-trained deep convolutional neural network.

[0052] Step S105, running the converged second generative adversarial network model, using the key point feature vector, the first target facial image and the second target facial image to process the first facial image to obtain the second facial image.

[0053] Exemplarily, a second generative adversarial network model is run after convergence, and the first facial image is subjected to orientation correction and edge supplementation processing using the key point feature vector, the first target facial image, and the second target facial image to obtain a second facial image having a facial orientation that is more consistent with the target portrait and a facial contour that is closer.

[0054] Step S106: Fusing the second facial image and the target portrait to obtain a target face-swapped portrait.

[0055] Exemplarily, the face mask of the second target facial image is subjected to edge feathering processing to obtain the target face mask; the second face image and the target portrait are fused using the target face mask to obtain the target face-swapped portrait. By fusing the second face image and the target portrait with the target face mask having a natural edge transition, an overall face-swapped portrait with a natural facial edge transition can be obtained.

[0056] In one embodiment, a target super-resolution processing model is obtained; and the target super-resolution processing model is run to perform super-resolution processing on the target face-changing portrait. The target super-resolution processing model is obtained by iteratively training a neural network model according to a training image set in advance, and the training image set includes multiple image groups, each image group includes a first image and a second image corresponding to the first image, and the resolution of the first image is lower than the resolution of the second image. The neural network model includes but is not limited to an enhanced deep super-resolution network (Enhanced Deep Super-Resolution Network, EDSR), an end-to-end super-resolution network based on deep learning (Super-Resolution Convolutional Neural Network, SRCNN), an efficient sub-pixel convolutional neural network (Efficient Sub-Pixel Convolutional Neural Network, ESPCN), a super-resolution network based on a deep Laplacian pyramid network (Deep Laplacian Pyramid Networks for Fast and Accurate Super-Resolution, LapSRN), etc. By performing super-resolution processing on the fused target face-changing portrait, a face-changing portrait with higher definition can be obtained.

[0057] The artificial intelligence-based face-changing method provided in the above embodiment obtains the first generative adversarial network model and the second generative adversarial network model through training, and fuses the source portrait and the target portrait through the first generative adversarial network model to obtain a first face image with high simulation degree, and then determines the key point feature vector of the first face image, and extracts the first target facial image from the target portrait and the second target facial image from the first face image, and finally processes the first face image through the second generative adversarial network model using the key point feature vector, the first target facial image and the second target facial image to obtain a second face portrait whose orientation is closer to the target portrait and whose shape is more similar to the face shape of the target portrait, and fuses the second face image and the target portrait to obtain the target face-changing portrait, thereby improving the authenticity and face-changing effect of the face-changing.

[0058] See also Figure 3 , Figure 3 It is a schematic block diagram of an artificial intelligence-based face-changing device provided in an embodiment of the present application.

[0059] like Figure 3 As shown, the artificial intelligence-based face-changing device 200 includes:

[0060] A model training module 210 is used to obtain a first sample data set, and iteratively train a first generative adversarial network model according to the first sample data set until the first generative adversarial network model converges;

[0061] The model training module 210 is further used to obtain a second sample data set, and iteratively train the second generative adversarial network model according to the second sample data set until the second generative adversarial network model converges;

[0062] An acquisition module 220, used to acquire a source portrait and a target portrait;

[0063] A first processing module 230 is used to run the converged first generative adversarial network model to process the source portrait and the target portrait to obtain a first face image;

[0064] A determination module 240, configured to determine a key point feature vector of the first facial image, and extract a first target facial image from the target portrait and a second target facial image from the first facial image;

[0065] A second processing module 250 is used to run the converged second generative adversarial network model, and use the key point feature vector, the first target facial image and the second target facial image to process the first facial image to obtain a second facial image;

[0066] The image fusion module 260 is used to fuse the second facial image and the target portrait to obtain a target face-swapped portrait.

[0067] In one embodiment, the first generative adversarial network model includes a facial feature extraction network, an attribute feature extraction network, and a first generative adversarial network, the first sample data set includes a plurality of portrait pairs, the portrait pairs include a first source portrait and a second target portrait, and the model training module 210 is further used to:

[0068] Selecting a person-portrait pair from the first sample data set as a target person-portrait pair;

[0069] Inputting a first source portrait in the target portrait pair into the facial feature extraction network to extract facial features, thereby obtaining a first facial feature vector;

[0070] Inputting the first target person image in the target person image pair into the attribute feature network to extract attribute features, thereby obtaining a first attribute feature vector;

[0071] Inputting the first facial feature vector and the first attribute feature vector into a first generative adversarial network for processing to obtain a first predicted face image;

[0072] Determining a second facial feature vector of the first predicted facial image and a second attribute feature vector of the first predicted facial image;

[0073] Calculating a first model loss value according to the first facial feature vector, the first attribute feature vector, the second facial feature vector, the second attribute feature vector, the first source portrait, and the first predicted face image;

[0074] Determining whether the first generative adversarial network model converges according to the first model loss value;

[0075] If the first generative adversarial network model does not converge, updating the model parameters of the first generative adversarial network model;

[0076] Return to the step of selecting a person-portrait pair from the first sample data set as a target person-portrait pair until the first generative adversarial network model converges.

[0077] In one embodiment, the model training module 210 is further used to:

[0078] determining a first similarity between the first facial feature vector and the second facial feature vector;

[0079] determining a second similarity between the first attribute feature vector and the second attribute feature vector;

[0080] Determining a third similarity between the first source human portrait and the first predicted human face image;

[0081] A first model loss value is calculated according to the first similarity, the second similarity and the third similarity.

[0082] In one embodiment, the model training module 210 is further used to:

[0083] Obtaining a first weighting coefficient, a second weighting coefficient, and a third weighting coefficient;

[0084] Calculating the product of the first similarity and the first weighting coefficient to obtain a first loss value;

[0085] Calculate the product of the second similarity and the second weighting coefficient to obtain a second loss value;

[0086] Calculating the product of the third similarity and the third weighting coefficient to obtain a third loss value;

[0087] The first loss value, the second loss value, and the third loss value are summed to obtain the first model loss value.

[0088] In one embodiment, the second generative adversarial network model includes a second generative adversarial network, the second sample data set includes a plurality of sample data, and the model training module 210 is further used to:

[0089] Selecting a sample data from the second sample data set as target sample data;

[0090] Inputting the sample face image in the target sample data into the key point detection network to perform key point detection, and obtaining the key point feature vector of the sample face image;

[0091] Segmenting the sample face image to obtain a first face image, and segmenting the sample face image in the target sample data to obtain a second face image;

[0092] Inputting the sample facial image, the key point feature vector of the sample facial image, the first facial image and the second facial image into the second generative adversarial network for processing to obtain a second predicted facial image;

[0093] Calculating a second model loss value according to the second predicted face image and the labeled face image in the target sample data;

[0094] Determining whether the second generative adversarial network converges according to the second model loss value;

[0095] If the second generative adversarial network has not converged, updating the model parameters of the second generative adversarial network;

[0096] Return to the step of selecting a sample data from the second sample data set as target sample data until the second generative adversarial network converges.

[0097] In one embodiment, if Figure 4 As shown, the image fusion module 260 includes:

[0098] An edge feathering processing submodule 261 is used to perform edge feathering processing on the face mask of the second target facial image to obtain a target face mask;

[0099] The image fusion submodule 262 is used to fuse the second face image and the target portrait using the target face mask to obtain a target face-swapped portrait.

[0100] In one embodiment, the second processing module 250 is further configured to:

[0101] Acquire a target super-resolution processing model, wherein the super-resolution processing model is obtained by iteratively training a neural network model according to a training image set in advance, the training image set includes a plurality of image groups, the image groups include a first image and a second image corresponding to the first image, and the resolution of the first image is lower than the resolution of the second image;

[0102] The target super-resolution processing model is run to perform super-resolution processing on the target face-swapped portrait.

[0103] It should be noted that technical personnel in the relevant field can clearly understand that, for the convenience and conciseness of description, the specific working process of the above-described device and each module and unit can refer to the corresponding process in the aforementioned embodiment of the artificial intelligence-based face-changing method, and will not be repeated here.

[0104] The apparatus provided in the above embodiment may be implemented in the form of a computer program. The computer program may be Figure 5 Runs on the computer device shown.

[0105] See also Figure 5 , Figure 5 1 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device may be a server or a terminal device.

[0106] like Figure 5 As shown, the computer device includes a processor, a memory, and a network interface connected via a system bus, wherein the memory may include a storage medium and an internal memory.

[0107] The storage medium can store an operating system and a computer program. The computer program includes program instructions, and when the program instructions are executed, the processor can execute any one of the face-changing methods based on artificial intelligence.

[0108] The processor is used to provide computing and control capabilities and support the operation of the entire computer equipment.

[0109] The network interface is used for network communication, such as sending assigned tasks, etc. Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0110] It should be understood that the processor may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0111] In one embodiment, the processor is used to run a computer program stored in the memory to implement the following steps:

[0112] Acquire a first sample data set, and iteratively train a first generative adversarial network model according to the first sample data set until the first generative adversarial network model converges;

[0113] Acquire a second sample data set, and iteratively train a second generative adversarial network model according to the second sample data set until the second generative adversarial network model converges;

[0114] Obtaining a source portrait and a target portrait, and running the converged first generative adversarial network model to process the source portrait and the target portrait to obtain a first facial image;

[0115] Determine a key point feature vector of the first facial image, and extract a first target facial image from the target portrait and a second target facial image from the first facial image;

[0116] Running the converged second generative adversarial network model, processing the first facial image using the key point feature vector, the first target facial image, and the second target facial image to obtain a second facial image;

[0117] The second facial image and the target portrait are fused to obtain a target face-swapped portrait.

[0118] In one embodiment, the first generative adversarial network model includes a facial feature extraction network, an attribute feature extraction network, and a first generative adversarial network, the first sample data set includes a plurality of portrait pairs, the portrait pairs include a first source portrait and a second target portrait, and the processor, when implementing iterative training of the first generative adversarial network model according to the first sample data set until the first generative adversarial network model converges, is used to implement:

[0119] Selecting a person-portrait pair from the first sample data set as a target person-portrait pair;

[0120] Inputting a first source portrait in the target portrait pair into the facial feature extraction network to extract facial features, thereby obtaining a first facial feature vector;

[0121] Inputting the first target person image in the target person image pair into the attribute feature network to extract attribute features, thereby obtaining a first attribute feature vector;

[0122] Inputting the first facial feature vector and the first attribute feature vector into a first generative adversarial network for processing to obtain a first predicted face image;

[0123] Determining a second facial feature vector of the first predicted facial image and a second attribute feature vector of the first predicted facial image;

[0124] Calculating a first model loss value according to the first facial feature vector, the first attribute feature vector, the second facial feature vector, the second attribute feature vector, the first source portrait, and the first predicted face image;

[0125] Determining whether the first generative adversarial network model converges according to the first model loss value;

[0126] If the first generative adversarial network model does not converge, updating the model parameters of the first generative adversarial network model;

[0127] Return to the step of selecting a person-portrait pair from the first sample data set as a target person-portrait pair until the first generative adversarial network model converges.

[0128] In one embodiment, when the processor calculates the first model loss value according to the first facial feature vector, the first attribute feature vector, the second facial feature vector, the second attribute feature vector, the first source portrait, and the first predicted face image, it is used to implement:

[0129] determining a first similarity between the first facial feature vector and the second facial feature vector;

[0130] determining a second similarity between the first attribute feature vector and the second attribute feature vector;

[0131] Determining a third similarity between the first source human portrait and the first predicted human face image;

[0132] A first model loss value is calculated according to the first similarity, the second similarity and the third similarity.

[0133] In one embodiment, when the processor calculates the first model loss value according to the first similarity, the second similarity and the third similarity, it is used to implement:

[0134] Obtaining a first weighting coefficient, a second weighting coefficient, and a third weighting coefficient;

[0135] Calculating the product of the first similarity and the first weighting coefficient to obtain a first loss value;

[0136] Calculate the product of the second similarity and the second weighting coefficient to obtain a second loss value;

[0137] Calculating the product of the third similarity and the third weighting coefficient to obtain a third loss value;

[0138] The first loss value, the second loss value, and the third loss value are summed to obtain the first model loss value.

[0139] In one embodiment, the second generative adversarial network model includes a second generative adversarial network, the second sample data set includes a plurality of sample data, and the processor, when implementing iterative training of the second generative adversarial network model according to the second sample data set until the second generative adversarial network model converges, is used to implement:

[0140] Selecting a sample data from the second sample data set as target sample data;

[0141] Inputting the sample face image in the target sample data into the key point detection network to perform key point detection, and obtaining the key point feature vector of the sample face image;

[0142] Segmenting the sample face image to obtain a first face image, and segmenting the sample face image in the target sample data to obtain a second face image;

[0143] Inputting the sample facial image, the key point feature vector of the sample facial image, the first facial image and the second facial image into the second generative adversarial network for processing to obtain a second predicted facial image;

[0144] Calculating a second model loss value according to the second predicted face image and the labeled face image in the target sample data;

[0145] Determining whether the second generative adversarial network converges according to the second model loss value;

[0146] If the second generative adversarial network has not converged, updating the model parameters of the second generative adversarial network;

[0147] Return to the step of selecting a sample data from the second sample data set as target sample data until the second generative adversarial network converges.

[0148] In one embodiment, when the processor realizes fusing the second facial image with the target portrait to obtain the target face-swapped portrait, it is used to realize:

[0149] Performing edge feathering processing on the face mask of the second target facial image to obtain a target face mask;

[0150] The second face image and the target portrait are fused using the target face mask to obtain a target face-swapped portrait.

[0151] In one embodiment, the processor is further configured to implement the following steps:

[0152] Acquire a target super-resolution processing model, wherein the super-resolution processing model is obtained by iteratively training a neural network model according to a training image set in advance, the training image set includes a plurality of image groups, the image groups include a first image and a second image corresponding to the first image, and the resolution of the first image is lower than the resolution of the second image;

[0153] The target super-resolution processing model is run to perform super-resolution processing on the target face-swapped portrait.

[0154] It should be noted that those skilled in the art can clearly understand that, for the sake of convenience and brevity of description, the specific working process of the computer device described above can refer to the corresponding process in the aforementioned embodiment of the artificial intelligence-based face-changing method, and will not be repeated here.

[0155] It can be known from the description of the above implementation methods that those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the present application can be essentially or partly contributed to the prior art in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present application or certain parts of the embodiments.

[0156] An embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. The computer program includes program instructions. The method implemented when the program instructions are executed can refer to the various embodiments of the artificial intelligence-based face-changing method of the present application.

[0157] The computer-readable storage medium may be volatile or non-volatile. The computer-readable storage medium may be an internal storage unit of the computer device described in the foregoing embodiment, such as a hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc., equipped on the computer device.

[0158] Furthermore, the computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.

[0159] The blockchain referred to in this application is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.

[0160] It should be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0161] It should also be understood that the term "and / or" used in the specification of this application and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, including these combinations. It should be noted that, in this article, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "including a..." does not exclude the presence of other identical elements in the process, method, article or system including the element.

[0162] The serial numbers of the embodiments of the present application are for description only and do not represent the advantages and disadvantages of the embodiments. The above description is only a specific implementation mode of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. A face-changing method based on artificial intelligence, characterized in that: include: Acquire a first sample data set, and iteratively train a first generative adversarial network model according to the first sample data set until the first generative adversarial network model converges; Acquire a second sample data set, and iteratively train a second generative adversarial network model according to the second sample data set until the second generative adversarial network model converges; Obtaining a source portrait and a target portrait, and running the converged first generative adversarial network model to process the source portrait and the target portrait to obtain a first facial image; Determine a key point feature vector of the first facial image, and extract a first target facial image from the target portrait and a second target facial image from the first facial image; Running the converged second generative adversarial network model, using the key point feature vector, the first target facial image and the second target facial image to perform orientation correction and edge supplementation processing on the first facial image, so as to obtain a second facial image that is more closely aligned with the facial orientation of the target portrait and has a facial contour closer to that of the target portrait; fusing the second facial image and the target portrait to obtain a target face-swapped portrait; The first generative adversarial network model includes a facial feature extraction network, an attribute feature extraction network and a first generative adversarial network, the first sample data set includes a plurality of portrait pairs, the portrait pairs include a first source portrait and a second target portrait, and the iterative training of the first generative adversarial network model according to the first sample data set until the first generative adversarial network model converges includes: Select a portrait pair from the first sample data set as a target portrait pair; input the first source portrait in the target portrait pair into the facial feature extraction network for facial feature extraction to obtain a first facial feature vector; input the first target portrait in the target portrait pair into the attribute feature network for attribute feature extraction to obtain a first attribute feature vector; input the first facial feature vector and the first attribute feature vector into the first generative adversarial network for processing to obtain a first predicted face image; determine the second facial feature vector of the first predicted face image and the second attribute feature vector of the first predicted face image; calculate the first model loss value according to the first facial feature vector, the first attribute feature vector, the second facial feature vector, the second attribute feature vector, the first source portrait and the first predicted face image; determine whether the first generative adversarial network model converges according to the first model loss value; if the first generative adversarial network model does not converge, update the model parameters of the first generative adversarial network model; return to execute the step of selecting a portrait pair from the first sample data set as the target portrait pair until the first generative adversarial network model converges; The second generative adversarial network model includes a second generative adversarial network, the second sample data set includes a plurality of sample data, and the iterative training of the second generative adversarial network model according to the second sample data set until the second generative adversarial network model converges includes: Select one sample data from the second sample data set as target sample data; input the sample face image in the target sample data into the key point detection network for key point detection to obtain the key point feature vector of the sample face image; segment the first face image from the sample face image, and segment the second face image from the sample image in the target sample data; input the sample face image, the key point feature vector of the sample face image, the first face image, and the second face image into the second generative adversarial network for processing to obtain a second predicted face image; calculate the second model loss value based on the second predicted face image and the labeled face image in the target sample data; determine whether the second generative adversarial network converges based on the second model loss value; if the second generative adversarial network does not converge, update the model parameters of the second generative adversarial network; return to the step of selecting one sample data from the second sample data set as target sample data until the second generative adversarial network converges.

2. The face-changing method based on artificial intelligence according to claim 1, characterized in that: The step of calculating a first model loss value according to the first facial feature vector, the first attribute feature vector, the second facial feature vector, the second attribute feature vector, the first source portrait, and the first predicted face image includes: determining a first similarity between the first facial feature vector and the second facial feature vector; determining a second similarity between the first attribute feature vector and the second attribute feature vector; Determining a third similarity between the first source human portrait and the first predicted human face image; A first model loss value is calculated according to the first similarity, the second similarity and the third similarity.

3. The face-changing method based on artificial intelligence according to claim 2, characterized in that: The calculating a first model loss value according to the first similarity, the second similarity and the third similarity includes: Obtaining a first weighting coefficient, a second weighting coefficient, and a third weighting coefficient; Calculating the product of the first similarity and the first weighting coefficient to obtain a first loss value; Calculate the product of the second similarity and the second weighting coefficient to obtain a second loss value; Calculating the product of the third similarity and the third weighting coefficient to obtain a third loss value; The first loss value, the second loss value, and the third loss value are summed to obtain the first model loss value.

4. The artificial intelligence-based face-changing method according to any one of claims 1 to 3, characterized in that: The step of fusing the second facial image with the target portrait to obtain a target face-swapped portrait includes: Performing edge feathering processing on the face mask of the second target facial image to obtain a target face mask; The second face image and the target portrait are fused using the target face mask to obtain a target face-swapped portrait.

5. The face-changing method based on artificial intelligence according to claim 4, characterized in that: The method further comprises: Acquire a target super-resolution processing model, wherein the super-resolution processing model is obtained by iteratively training a neural network model according to a training image set in advance, the training image set includes a plurality of image groups, the image groups include a first image and a second image corresponding to the first image, and the resolution of the first image is lower than the resolution of the second image; The target super-resolution processing model is run to perform super-resolution processing on the target face-swapped portrait.

6. A face-changing device based on artificial intelligence, characterized in that: The face-changing device based on artificial intelligence comprises: A model training module, used to obtain a first sample data set, and iteratively train a first generative adversarial network model according to the first sample data set until the first generative adversarial network model converges; The model training module is further used to obtain a second sample data set, and iteratively train the second generative adversarial network model according to the second sample data set until the second generative adversarial network model converges; An acquisition module, used to acquire a source portrait and a target portrait; A first image generation module, configured to input the source portrait and the target portrait into the converged first generative adversarial network model for processing to obtain a first face image; A determination module, used to determine a key point feature vector of the first facial image, and extract a first target facial image from the target portrait and a second target facial image from the first facial image; A second image generation module is used to input the first facial image, the key point feature vector, the first target facial image and the second target facial image into the converged second generative adversarial network model to perform orientation correction and edge supplementation processing to obtain a second facial image that is more closely aligned with the facial orientation of the target portrait and has a facial contour closer to the target portrait; An image fusion module, used for fusing the second face image with the target portrait to obtain a target face-swapped portrait; The first generative adversarial network model includes a facial feature extraction network, an attribute feature extraction network and a first generative adversarial network, the first sample data set includes a plurality of portrait pairs, the portrait pairs include a first source portrait and a second target portrait, and the model training module is further used to: Select a portrait pair from the first sample data set as a target portrait pair; input the first source portrait in the target portrait pair into the facial feature extraction network for facial feature extraction to obtain a first facial feature vector; input the first target portrait in the target portrait pair into the attribute feature network for attribute feature extraction to obtain a first attribute feature vector; input the first facial feature vector and the first attribute feature vector into the first generative adversarial network for processing to obtain a first predicted face image; determine the second facial feature vector of the first predicted face image and the second attribute feature vector of the first predicted face image; calculate the first model loss value according to the first facial feature vector, the first attribute feature vector, the second facial feature vector, the second attribute feature vector, the first source portrait and the first predicted face image; determine whether the first generative adversarial network model converges according to the first model loss value; if the first generative adversarial network model does not converge, update the model parameters of the first generative adversarial network model; return to execute the step of selecting a portrait pair from the first sample data set as the target portrait pair until the first generative adversarial network model converges; The second generative adversarial network model includes a second generative adversarial network, the second sample data set includes a plurality of sample data, and the model training module is further used for: Select one sample data from the second sample data set as target sample data; input the sample face image in the target sample data into the key point detection network for key point detection to obtain the key point feature vector of the sample face image; segment the first face image from the sample face image, and segment the second face image from the sample image in the target sample data; input the sample face image, the key point feature vector of the sample face image, the first face image, and the second face image into the second generative adversarial network for processing to obtain a second predicted face image; calculate the second model loss value based on the second predicted face image and the labeled face image in the target sample data; determine whether the second generative adversarial network converges based on the second model loss value; if the second generative adversarial network does not converge, update the model parameters of the second generative adversarial network; return to the step of selecting one sample data from the second sample data set as target sample data until the second generative adversarial network converges.

7. A computer device, characterized in that: The computer device includes a processor, a memory, and a computer program stored in the memory and executable by the processor, wherein when the computer program is executed by the processor, the steps of the artificial intelligence-based face-changing method as described in any one of claims 1 to 5 are implemented.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the steps of the artificial intelligence-based face-changing method as described in any one of claims 1 to 5 are implemented.