Face image processing method, device, computer equipment and storage medium
By segmenting and fusion of facial feature areas in the middle image of face exchange, a face fusion area map is generated, which solves the problem that face exchange images lack real texture in the existing face exchange technology, and achieves the effect of improving the reality and quality of face exchange images.
Patent Information
- Application Number
- CN202410247193.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-04
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2044-03-04
AI Technical Summary
The face exchange images obtained in the existing face exchange technology lack real texture, resulting in limited image reality, which makes the face exchange image quality lower.
By obtaining the source face image and the target face image, face exchange is performed to obtain the intermediate image of the face exchange, and then the intermediate image is segmented in the face feature area, fusing the appearance feature area map of the target face image, the face skin area map and the appearance feature area map of the intermediate image, and generating the face fusion area map, and finally fusing it based on the fusion area map, the intermediate image and the target face image to obtain the face exchange image.
On the basis of ensuring the similarity between the face exchange image and the source face image, the facial skin of the face exchange intermediate image and the target face image is smoothed through the face fusion area map, thereby improving the facial skin texture of the face exchange image, improving the realistic effect of the face exchange image, and improving the image quality of the face exchange image.
Smart Images

Figure CN118015142B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a facial image processing method, apparatus, computer equipment, storage medium and computer program product. Background Art
[0002] With the development of computer technology, face swapping technology based on computer vision can achieve the effect of face swapping by synthesizing the image features of one face onto another face image. Face swapping technology has been widely used in film and television production, entertainment industry, video games and other fields. For example, in video games, players can use face swapping technology to replace the face of game characters after authorization to obtain a better gaming experience.
[0003] However, the face swap images obtained by the current face swap technology lack real-life texture, resulting in limited image realism and low quality of face swap images. Summary of the invention
[0004] Based on this, it is necessary to provide a face image processing method, device, computer equipment, computer-readable storage medium and computer program product that can improve the quality of face swap images in response to the above technical problems.
[0005] In a first aspect, the present application provides a method for processing a face image. The method comprises:
[0006] A source face image and a target face image are obtained, and face parts in the target face image are swapped with face parts in the source face image to obtain a face swap intermediate image;
[0007] Performing facial feature region segmentation on the face swapping intermediate image to obtain a facial feature region map of the face swapping intermediate image;
[0008] Determine a facial feature region map and a facial skin region map of a face part in a target face image;
[0009] fusing the facial feature region map of the target face image, the facial skin region map, and the facial feature region map of the face swap intermediate image to obtain a facial fusion region map;
[0010] A face swap image is obtained according to the face fusion region map, the face swap intermediate image and the target face image.
[0011] In a second aspect, the present application also provides a facial image processing device. The device comprises:
[0012] A face exchange module is used to obtain a source face image and a target face image, and to exchange the face parts in the target face image with the face parts in the source face image to obtain a face exchange intermediate image;
[0013] A feature region segmentation module is used to segment the facial feature regions of the face swap intermediate image to obtain a facial feature region map of the face swap intermediate image;
[0014] A feature region map determination module is used to determine a facial feature region map and a facial skin region map of a face part in a target face image;
[0015] A feature region map fusion module is used to fuse the facial feature region map of the target face image, the facial skin region map and the facial feature region map of the face swap intermediate image to obtain a facial fusion region map;
[0016] The face fusion region map processing module is used to obtain the face exchange image according to the face fusion region map, the face exchange intermediate image and the target face image.
[0017] In a third aspect, the present application further provides a computer device, wherein the computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the above face image processing method are implemented.
[0018] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the above face image processing method are implemented.
[0019] In a fifth aspect, the present application further provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the above face image processing method are implemented.
[0020] The above-mentioned face image processing method, device, computer equipment, storage medium and computer program product, for a face exchange intermediate image obtained by face exchanging the face parts in the target face image with the face parts in the source face image, perform facial feature area segmentation on the face exchange intermediate image to obtain a facial feature area map, fuse the facial feature area map of the target face image, the facial skin area map and the facial feature area map of the face exchange intermediate image to obtain a facial fusion area map, and obtain a face exchange image based on the facial fusion area map, the face exchange intermediate image and the target face image. The face swapping intermediate image and the target face image are fused using a face fusion region map obtained by fusing the facial feature region map of the target face image, the facial skin region map and the facial feature region map of the face swapping intermediate image. On the basis of ensuring the similarity between the face swapping image and the source face image, the facial fusion region map can be used to smooth the facial skin of the face swapping intermediate image and the target face image, thereby improving the facial skin texture of the face swapping image, enhancing the realism effect of the face swapping image, and improving the image quality of the face swapping image. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0022] Figure 1 A diagram showing an application environment of a face image processing method in some embodiments;
[0023] Figure 2 is a flowchart of a face image processing method in some embodiments;
[0024] Figure 3 A schematic block diagram of a facial image processing flow in some embodiments;
[0025] Figure 4 A schematic diagram of a process flow of texture enhancement processing in some embodiments;
[0026] Figure 5 is a flowchart of a face image processing method in some embodiments;
[0027] Figure 6 A schematic diagram of a process of face swapping in some embodiments;
[0028] Figure 7 A schematic diagram of the Unet model structure in some embodiments;
[0029] Figure 8 A schematic diagram of the Unet model structure with embedded features added in some embodiments;
[0030] Fig. 9 A schematic diagram of a process flow of skin mask fusion processing in some embodiments;
[0031] Fig.10 A schematic diagram of a process flow of face segmentation processing in some embodiments;
[0032] Fig.11 for Fig.10 A schematic diagram of a feature fusion module in the illustrated embodiment;
[0033] Fig.12 A schematic diagram of a mask fusion process in some embodiments;
[0034] Fig.13 It is a schematic diagram of the process of fitting area fusion processing in some embodiments;
[0035] Fig.14 A schematic diagram of a process flow of texture enhancement processing in some embodiments;
[0036] Fig.15 It is a schematic diagram of the structure of a stable diffusion model in some embodiments;
[0037] Fig.16 is a structural block diagram of a face image processing device in some embodiments;
[0038] Fig.17 1 is a diagram of the internal structure of a computer device in some embodiments. DETAILED DESCRIPTION
[0039] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0040] 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. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making. Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level technology and software-level technology. The basic technologies of artificial intelligence generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, pre-trained model technology, operation / interaction system, mechatronics, etc. Among them, the pre-trained model is also called the large model or basic model. After fine-tuning, it can be widely used in downstream tasks in various major directions of artificial intelligence. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0041] Pre-training model, also known as cornerstone model or big model, refers to a deep neural network (DNN) with large parameters. It is trained on massive unlabeled data, and uses the function approximation ability of large-parameter DNN to enable PTM to extract common features from the data. After fine tuning, parameter efficient fine tuning (PEFT), prompt-tuning and other technologies, it is suitable for downstream tasks. Therefore, the pre-training model can achieve ideal results in few-shot or zero-shot scenarios. PTM can be divided into language models (ELMO, BERT, GPT), visual models (swin-transformer, ViT, V-MOE), speech models (VALL-E), multimodal models (ViBERT, CLIP, Flamingo, Gato), etc. according to the data modality processed. Among them, the multimodal model refers to a model that establishes two or more data modality feature representations. The pre-training model is an important tool for outputting artificial intelligence generated content (AIGC), and can also be used as a general interface to connect multiple specific task models.
[0042] Computer Vision (CV) is a science that studies how to make machines "see". To put it more specifically, it refers to the use of cameras and computers to replace human eyes to identify, follow and measure targets, and further perform image processing to make computer processing into images that are more suitable for human eye observation or transmission to instruments for detection. As a scientific discipline, computer vision studies related theories and technologies, and attempts to establish an artificial intelligence system that can obtain information from images or multidimensional data. Large model technology has brought important changes to the development of computer vision technology. Pre-trained models in the visual field such as swin-transformer, ViT, V-MOE, and MAE can be quickly and widely applied to downstream specific tasks after fine tuning. Computer vision technology usually includes image processing, image recognition, image semantic understanding, image retrieval, OCR, video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, 3D technology, virtual reality, augmented reality, simultaneous positioning and mapping, and other technologies, as well as common biometric recognition technologies such as face recognition and fingerprint recognition.
[0043] Machine Learning (ML) is a multi-disciplinary subject involving probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines. It specializes in studying how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning usually include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and learning by induction. The pre-trained model is the latest development of deep learning, which integrates the above technologies.
[0044] With the research and advancement of artificial intelligence technology, artificial intelligence technology has been studied and applied in many fields, such as common smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, driverless cars, autonomous driving, drones, digital twins, virtual humans, robots, artificial intelligence generated content (AIGC), conversational interaction, smart medical care, smart customer service, game AI, etc. It is believed that with the development of technology, artificial intelligence technology will be applied in more fields and play an increasingly important role.
[0045] The solutions provided in the embodiments of the present application involve artificial intelligence computer vision technology, machine learning / deep learning and other technologies, which are specifically illustrated by the following embodiments.
[0046] The face image processing method provided in the embodiment of the present application can be applied to Figure 1In the application environment shown, the terminal 102 communicates with the server 104 through a network. The data storage system can store data that the server 104 needs to process. The data storage system can be set up separately, integrated on the server 104, or placed on the cloud or other servers.
[0047] The user can obtain a source face image by photographing through the terminal 102, and send the source face image and the target face image to the server 104 based on the terminal 102, and the server 104 receives the source face image and the target face image sent by the terminal 102. The server 104 can perform face exchange with the face part in the target face image by the face part in the source face image to obtain a face exchange intermediate image; the server 104 can perform facial feature area segmentation on the face exchange intermediate image to obtain a facial feature area map of the face exchange intermediate image, and determine a facial feature area map and a facial skin area map of the facial part in the target face image. The server 104 merges the facial feature area map of the target face image, the facial skin area map and the facial feature area map of the face exchange intermediate image to obtain a facial fusion area map, and finally merges the facial fusion area map, the face exchange intermediate image and the target face image to obtain a face exchange image. The server 104 can return the obtained face exchange image to the terminal 102.
[0048] In some embodiments, the facial image processing method can also be implemented separately by the terminal 102 or the server 104. For example, the terminal 102 can perform facial image processing on the acquired source facial image and the target facial image separately. For example, the server 104 can obtain the source facial image and the target facial image from the data storage system and then perform facial image processing on them. Among them, the terminal 102 can be, but is not limited to, various desktop computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 can be implemented by an independent server or a server cluster consisting of multiple servers, or it can be a cloud server.
[0049] In an exemplary embodiment, Figure 2 As shown, a face image processing method is provided. The method is executed by a computer device, and can be executed by a computer device such as a terminal or a server alone, or by a terminal and a server together. In the embodiment of the present application, the method is applied to Figure 1 The server in the example is used to illustrate, including the following steps 202 to 210. Among them:
[0050] Step 202, obtaining a source face image and a target face image, performing face swapping on the face parts in the target face image using the face parts in the source face image, and obtaining a face swapping intermediate image.
[0051] Among them, face swapping technology is also known as AI face swapping or facial replacement technology. It is a technology that uses computer vision and deep learning algorithms to achieve real-time replacement of facial images. This technology can transfer the facial features of one person to the facial image of another person, thereby generating a highly realistic face swapping effect. The source face image and the target face image are the images that need to be processed for face swapping. Specifically, the face in the target face image needs to be replaced with the face in the source face image. For example, if the face in image A needs to be replaced with the face in image B, image A is used as the source face image in the face swapping process, and image B is used as the target face image in the face swapping process. After the face swapping process, the face in image B is replaced with the face in image A. The face swapping intermediate image is a face image obtained by performing face swapping on the target face image through the source face image.
[0052] Exemplarily, the server may obtain facial images that need to be processed for face swapping, including source facial images and target facial images. The source of facial images that need to be processed for face swapping may be implemented according to the actual application scenario, and the present application does not limit this. For example, the source facial image or the target facial image may be obtained by taking a photo by a user, or may be generated by a computer device. For example, in a video game application scenario, the source facial image may be a facial image including the player's face, which may be taken by the player, and the target facial image may be a facial image of a character operated by the player in the video game. For another example, the target facial image may also be a facial image generated based on artificial intelligence content generation technology. In addition, the source facial image or the target facial image may also be a facial image captured from various images or videos, such as a facial image captured from a film or TV series.
[0053] The server replaces the facial parts in the target facial image with the facial parts in the source facial image to achieve face swapping between the source facial image and the target facial image to obtain a face swapping intermediate image. In the face swapping intermediate image, the face in the target facial image is replaced with the face in the source facial image, while the rest of the image retains the content in the target facial image, such as the image background retaining the image background in the target facial image. In some embodiments, the server may receive the source facial image and the target facial image from the terminal, and perform face swapping processing on the source facial image and the target facial image through a pre-trained face swapping model, such as Face2Face (face to face), FaceSwap (face swapping), NeuralTextures (neural texture) and other face swapping models, and obtain the face swapping intermediate image by the output of the face swapping model.
[0054] Step 204, performing facial feature region segmentation on the face swapping intermediate image to obtain a facial feature region map of the face swapping intermediate image.
[0055] Among them, the facial feature region map is a feature map obtained after identifying and segmenting the feature region of the face of the face in the face swap intermediate image, which can be a mask map. The mask map can be a single-channel image, which can be a binary image or a grayscale image. Each pixel position in the mask map has a corresponding value, which determines whether the position works in a certain operation. In the mask map, a position with a value of 0 indicates that the operation at this position does not work, while a position with a value not 0 (usually 255) indicates that the operation at this position will work. In the face swap application scenario, by making a mask map, the area to be swapped can be specified, thereby achieving a more realistic and natural face swap effect. For example, in artificial intelligence-based face swapping technology, the mask map can be used to specify the facial feature areas to be replaced, thereby ensuring that only these areas are replaced and other areas remain unchanged. The facial feature region map can specifically include feature areas that reflect the appearance of the face, such as the facial features, and the facial features can specifically include eye feature areas, eyebrow feature areas, nose feature areas, lip feature areas, ear feature areas, and other areas. In a specific application, the facial feature region map may include at least one of the facial features, such as the eye feature region, the eyebrow feature region, the nose feature region, and the lip feature region. The facial feature region map may be used to specify the facial feature regions that need to be replaced in the source face image and the target face image.
[0056] Optionally, the server may perform facial feature region segmentation on the face swap intermediate image, specifically, may perform feature region segmentation on feature parts such as eyebrows, eyes, nose, mouth or ears of the face included in the face swap intermediate image, thereby obtaining a facial feature region map. In specific implementation, the server may perform facial feature region segmentation on the face swap intermediate image based on an image segmentation algorithm, such as a threshold-based segmentation algorithm, an edge-based segmentation algorithm, a region-based segmentation algorithm, a clustering-based segmentation algorithm or a deep learning-based segmentation algorithm. In some embodiments, the facial parts targeted by the facial feature region segmentation may be flexibly set according to actual needs, specifically including but not limited to at least one of eyebrows, eyes, nose, mouth or ears of the face.
[0057] Step 206, determining a facial feature region map and a facial skin region map of the face part in the target face image.
[0058] Among them, the facial skin area map includes the area covered by the skin of the face part in the target face image, and specifically can be the area of the skin of the face other than the facial features. Specifically, the server can obtain the facial feature area map and the facial skin area map of the target face image. The facial feature area map is a feature area map including the facial features of the face in the target face image, and specifically can include the facial features area. Based on the facial feature area map, the facial features of the face in the target face image can be reflected, such as the eyebrows, eyes, nose, mouth or ears of the face in the target face image; the facial skin area map is a feature area map including the facial skin in the target face image, and the facial skin area map can reflect the skin features of the face in the target face image. In some embodiments, the server can directly query the facial feature area map and the facial skin area map of the target face image based on the target face image, and the server can also perform facial feature area segmentation on the target face image to obtain the facial feature area map and the facial skin area map of the target face image.
[0059] Step 208, the facial feature region map of the target facial image, the facial skin region map and the facial feature region map of the face swap intermediate image are fused to obtain a facial fusion region map.
[0060] Among them, the face fusion area map is a fusion result obtained by fusing various feature area maps. Exemplarily, the server can fuse the facial feature area map of the target face image, the facial skin area map and the facial feature area map of the face swap intermediate image. Specifically, the facial feature area map of the target face image can be first fused with the facial feature area map of the face swap intermediate image, and then fused with the facial skin area map to obtain the facial fusion area map. In some embodiments, corresponding fusion weights can be set for each feature area map, so that each feature area map can be weightedly fused through its own fusion weight. Specifically, the facial feature area map of the target face image, the facial skin area map and the facial feature area map of the face swap intermediate image can be weightedly fused to obtain the facial fusion area map.
[0061] Step 210, obtaining a face swap image according to the face fusion region map, the face swap intermediate image and the target face image.
[0062] The face swap image is obtained based on the face fusion region map, the face swap intermediate image and the target face image, and specifically can be an image fusion result obtained by fusing the face fusion region map, the face swap intermediate image and the target face image. Optionally, the server can use the face fusion region map to fuse the face swap intermediate image and the target face image, and specifically can perform weighted fusion of the face swap intermediate image and the target face image to obtain the face swap image.
[0063] In a specific application, such as Figure 3 As shown, the server obtains the source face image and the target face image, and performs face swapping on the face parts in the target face image by using the face parts in the source face image to obtain the face swapping intermediate image. The server performs facial feature area segmentation on the face swapping intermediate image to obtain a facial feature area map of the face swapping intermediate image. The server determines the facial feature area map and the facial skin area map of the facial parts in the target face image. The server fuses the facial feature area map, the facial skin area map and the facial feature area map of the face swapping intermediate image to obtain a facial fusion area map. The server fuses the facial fusion area map, the face swapping intermediate image and the target face image to obtain a face swapping image, and uses the facial fusion area map to smooth the facial skin of the face swapping intermediate image and the target face image, so as to improve the facial skin texture of the face swapping image, which is beneficial to improving the image quality of the face swapping image.
[0064] In the above-mentioned face image processing method, for the face exchange intermediate image obtained by face exchange of the face parts in the target face image with the face parts in the source face image, the face feature area segmentation is performed on the face exchange intermediate image to obtain a facial feature area map, the facial feature area map of the target face image, the facial skin area map and the facial feature area map of the face exchange intermediate image are fused to obtain a facial fusion area map, and the face exchange image is obtained according to the facial fusion area map, the face exchange intermediate image and the target face image. The face exchange intermediate image and the target face image are fused by using the facial fusion area map obtained by fusion of the facial feature area map of the target face image, the facial skin area map and the facial feature area map of the face exchange intermediate image, so that the facial skin of the face exchange intermediate image and the target face image can be smoothed by using the facial fusion area map on the basis of ensuring the similarity between the face exchange image and the source face image, thereby improving the facial skin texture of the face exchange image, improving the realism effect of the face exchange image, and improving the image quality of the face exchange image.
[0065] In an exemplary embodiment, the facial feature area map of the target facial image, the facial skin area map and the facial feature area map of the face swap intermediate image are fused to obtain a facial fusion area map, including: fusing the facial feature area map of the target facial image and the facial feature area map of the face swap intermediate image to obtain a facial feature area fusion map; fusing the facial feature area fusion map with the facial skin area map to obtain a facial fusion area map.
[0066] Among them, the facial feature area fusion map is a feature area map obtained by fusing the facial feature area maps of the target face image and the face swap intermediate image. The facial feature area fusion map can cover the feature areas where the facial features of the target face image and the face swap intermediate image are located, such as the feature areas where the facial features of the target face image and the face swap intermediate image are located.
[0067] Exemplarily, the server first fuses the facial feature area map of the target facial image and the facial feature area map of the face swap intermediate image to obtain a facial feature area fusion map. In some embodiments, the various feature maps can be mask maps, and the fused facial feature area fusion map is also a mask map, which can reflect the feature area covered by the facial features of the target facial image and the face swap intermediate image after they are superimposed in the same map. The facial features targeted in the facial feature area fusion map may include facial features. The server fuses the facial feature area fusion map with the facial skin area map, and specifically deletes the covered area corresponding to the facial feature area fusion map in the facial skin area map, thereby removing the area in the facial skin area map that covers the facial features, and ensuring the accuracy of the facial skin area map.
[0068] In this embodiment, the server first fuses the facial feature area map of the target facial image and the facial feature area map of the face swap intermediate image, and then fuses them with the facial skin area map, thereby ensuring that the fusion of the facial feature area fusion map is not interfered by the facial skin area map, ensuring the accuracy of the facial skin area map, and thus ensuring the reliability of the facial fusion area map, which is beneficial to improving the image quality of the face swap image when performing face image processing based on the facial fusion area map.
[0069] In an exemplary embodiment, a facial feature area map of a target facial image and a facial feature area map of a face swap intermediate image are fused to obtain a facial feature area fusion map, including: fusing the facial feature area map of the target facial image and the facial feature area map of the face swap intermediate image to obtain an original fusion map; obtaining an eye feature area map of the face swap intermediate image and an eye feature area map of the target facial image; fusing the eye feature area map of the face swap intermediate image, the eye feature area map of the target facial image and the original fusion map to obtain a facial feature area fusion map.
[0070] The original fusion image is the original fusion result obtained by directly fusing the facial feature region map of the target face image and the facial feature region map of the face swap intermediate image. The eye feature region map is a feature region map including eye features. The eye feature region map of the face swap intermediate image may be a feature region map including the eyes of the face in the face swap intermediate image. The eye feature region map of the target face image may be a feature region map including the eyes of the face in the target face image. The eye feature region map may be obtained by performing facial feature region segmentation on the corresponding face image, that is, it may be obtained based on performing facial feature region segmentation on the corresponding face image. For example, for the face swap intermediate image, the eye feature region map of the face swap intermediate image may be obtained based on the segmentation result of performing facial feature region segmentation on the face swap intermediate image.
[0071] Optionally, the server directly fuses the facial feature area map of the target facial image and the facial feature area map of the face swap intermediate image to obtain an original fused image. The server obtains the eye feature area map of the face swap intermediate image and the eye feature area map of the target facial image. The eye feature area map of the face swap intermediate image can be extracted from the facial feature area map of the face swap intermediate image, and the eye feature area map of the target facial image can be extracted from the facial feature area map of the target facial image. In some embodiments, the eye feature area map can also be obtained by performing eye feature area segmentation processing on the corresponding facial image, and the eye feature area segmentation processing can be implemented based on an image segmentation algorithm, such as the eye feature area map of the face swap intermediate image can be obtained by performing eye feature area segmentation processing on the face swap intermediate image, and the eye feature area map of the target facial image can be obtained by performing eye feature area segmentation processing on the target facial image. The server fuses the eye feature area map of the face swap intermediate image, the eye feature area map of the target face image and the original fusion map. Specifically, the two eye feature area maps and the original fusion map can be weightedly fused to obtain the facial feature area fusion map.
[0072] In this embodiment, after the server fuses the facial feature area maps to obtain the original fused image, it further fuses the eye feature area map of the face swap intermediate image and the eye feature area map of the target face image, so that it can strengthen the focus on the eye area with rich facial features to ensure the accuracy of the facial feature area fusion map, which is conducive to improving the image quality of the face swap image when face image processing is performed based on the face fusion area map.
[0073] In an exemplary embodiment, the eye feature area map of the face swap intermediate image, the eye feature area map of the target face image and the original fusion map are fused to obtain a facial feature area fusion map, including: dilating the original fusion map, the eye feature area map of the face swap intermediate image and the eye feature area map of the target face image respectively to obtain an expanded fusion map, a first eye area expansion map and a second eye area expansion map; fusing the expanded fusion map, the first eye area expansion map and the second eye area expansion map to obtain an intermediate fusion map; dilating the intermediate fusion map to obtain a facial feature area fusion map.
[0074] Among them, dilation is used to expand the region of interest in the image to ensure that the region of interest can accurately cover the corresponding features. For example, for the original fusion image, the facial features in the original fusion image, such as the edges of the facial features region, can be enlarged, so as to expand and expand the range of the facial features region to avoid the displacement of the facial features and ensure the accuracy of the original fusion image. The dilated fusion image is a feature region map obtained by dilating the original fusion image; the first eye region dilation map is a feature region map obtained by dilating the eye feature region map of the face swap intermediate image; the second eye region dilation map is a feature region map obtained by dilating the eye feature region map of the target face image. The intermediate fusion image is a feature region map obtained by fusing the dilated fusion image obtained after dilation, the first eye region dilation map, and the second eye region dilation map.
[0075] Exemplarily, the server may expand the original fusion image, the eye feature area map of the face swap intermediate image, and the eye feature area map of the target face image, respectively, to expand the feature areas of interest in each feature map. Specifically, for the eye feature area map of the face swap intermediate image, the server may expand the edge of the eye part in the eye feature area map, thereby expanding the feature area of the eye part to obtain a first eye area expansion map. The server may fuse the expanded fusion image, the first eye area expansion map, and the second eye area expansion map, thereby fusing and superimposing the facial feature area in the expanded fusion image, the eye feature area in the first eye area expansion map, and the eye feature area in the second eye area expansion map to obtain an intermediate fusion image. The server further expands the intermediate fusion image, and specifically may expand the edge of the intermediate fusion image to expand the area to which the facial features belong in the intermediate fusion image.
[0076] In this embodiment, the server dilates the original fusion image, the eye feature area map of the face swap intermediate image, and the eye feature area map of the target face image, and then fuses them to obtain an intermediate fusion image, and dilates the intermediate fusion image to obtain a facial feature area fusion map, thereby avoiding the offset of facial features or eye parts and ensuring the accuracy of the facial feature area fusion map, which is beneficial to improving the image quality of the face swap image when face image processing is performed based on the face fusion area map.
[0077] In an exemplary embodiment, the facial feature region fusion map and the facial skin region map are fused to obtain the facial fusion region map, including: removing the area covered by the facial feature region fusion map from the facial skin region map to obtain the facial fusion region map.
[0078] The facial skin region map includes the region covered by the facial skin in the target face image, and the facial feature region fusion map includes the region covered by the facial features. By removing the region covered by the facial features in the facial skin region map, a facial fusion region map with accurate skin coverage can be obtained. Specifically, when the server fuses the facial feature region fusion map and the facial skin region map, the region covered by the facial feature region fusion map can be determined from the facial skin region map, and the region covered by the facial feature region fusion map can be removed to obtain the facial fusion region map.
[0079] In this embodiment, the server removes the area covered by the facial feature area fusion map in the facial skin area map, and can use the facial feature area fusion map to adjust the area range of the facial skin area map, thereby improving the accuracy of the facial skin area map, which is beneficial to improving the image quality of the face exchange image when facial image processing is performed based on the facial fusion area map.
[0080] In an exemplary embodiment, a face swap image is obtained based on a face fusion region map, a face swap intermediate image and a target face image, including: determining the fusion weights of the face swap intermediate image and the target face image respectively; and weightedly fusing the face fusion region map, the face swap intermediate image and the target face image according to the weighted weights to obtain the face swap image.
[0081] Among them, the fusion weight can be set for the face swap intermediate image and the target face image respectively, so as to adjust the skin texture effect of the face swap image according to actual needs. Exemplarily, the server can obtain the fusion weights set for the face swap intermediate image and the target face image respectively, and the fusion weights can be set in advance according to the actual scene needs. The server performs weighted fusion on the face fusion area map, the face swap intermediate image and the target face image according to the fusion weights to obtain the face swap image. In some embodiments, the face fusion area map can be a mask map, and the face fusion area map can be used to perform weighted fusion on the face swap intermediate image and the target face image respectively, such as first performing weighted fusion on the face fusion area map and the target face image according to the fusion weight corresponding to the target face image to obtain a fusion result, and then performing weighted fusion on the fusion result with the face swap intermediate image according to the fusion weight corresponding to the face swap intermediate image to obtain the face swap image.
[0082] In this embodiment, the server performs weighted fusion based on the fusion weights of the face swap intermediate image and the target face image in combination with the face fusion area map. The face fusion area map can be used to effectively smooth the skin of the face swap intermediate image and the target face image, thereby improving the facial skin texture of the face swap image, improving the realism effect of the face swap image, and improving the image quality of the face swap image.
[0083] In an exemplary embodiment, facial feature regions are segmented on a face swapping intermediate image to obtain a facial feature region map of the face swapping intermediate image, including: performing feature encoding on the face swapping intermediate image at least once to obtain pixel space encoding features of the face swapping intermediate image; extracting image semantic features of the face swapping intermediate image; fusing the pixel space encoding features with the image semantic features to obtain image fusion features; and performing facial feature region segmentation based on the image fusion features to obtain a facial feature region map of the face swapping intermediate image.
[0084] Among them, feature encoding can be feature processing for the face swap intermediate image based on the pixel space dimension, which can be specifically realized by performing at least one convolution operation on the face swap intermediate image. Pixel space encoding features are image features obtained by feature encoding the face swap intermediate image. Pixel space encoding features are directly obtained based on pixel space dimension encoding, and belong to the bottom-level features that carry the spatial information of the face swap intermediate image. Image semantic features are features extracted from the face swap intermediate image based on semantic feature extraction algorithms, such as convolutional neural networks (CNN), global average pooling, region-based convolutional neural networks (R-CNN), attention mechanisms, or multimodal feature fusion algorithms, and belong to high-level features that include semantic information of the face swap intermediate image. Image fusion features are obtained by fusing pixel space encoding features and image semantic features, and belong to features that fuse bottom-level features and high-level features.
[0085] Optionally, the server may perform feature encoding on the face swap intermediate image, and specifically may perform feature encoding processing at least once to obtain pixel space encoding features. In some embodiments, the server may implement feature encoding processing on the face swap intermediate image based on the convolutional layer in the convolutional neural network. When multiple convolutional layers are included, multiple feature encodings for the face swap intermediate image may be implemented to obtain low-level pixel space encoding features. The server extracts high-level image semantic features for the face swap intermediate image, such as extracting semantic features for the face swap intermediate image based on the Context Path algorithm to obtain image semantic features for the face swap intermediate image. The server may fuse pixel space encoding features and image semantic features to obtain image fusion features. The server performs facial feature region segmentation based on the image fusion features obtained by fusion, such as performing facial feature region segmentation based on the image fusion features through an image segmentation algorithm, thereby determining a facial feature region map of the face swap intermediate image. In some embodiments, when the server performs facial feature region segmentation based on the image fusion features, the part feature regions of each part of the facial features may be obtained, and the server obtains a facial feature region map based on the part feature regions of each facial feature. In addition, when performing facial feature area segmentation on the face swap intermediate image, a facial skin area map of the face swap intermediate image can also be obtained, and the facial skin area map includes the area covered by the facial skin of the face in the face swap intermediate image.
[0086] In this embodiment, the server performs low-level feature encoding and high-level semantic feature extraction on the face swap intermediate image, respectively, to obtain pixel space coding features and image semantic features, and after fusing the pixel space coding features and the image semantic features, performs facial feature region segmentation based on the fused image fusion features. The facial feature region segmentation can be performed by comprehensively considering the bottom-level and high-level image features of the face swap intermediate image, thereby ensuring the accuracy of the facial feature region map, which is beneficial to improving the image quality of the face swap image when face image processing is performed based on the face fusion region map.
[0087] In an exemplary embodiment, determining a facial feature region map and a facial skin region map of facial parts in a target facial image includes: performing facial feature region segmentation on the facial parts in the target facial image to obtain a facial feature region map and a facial skin region map of the facial parts in the target facial image.
[0088] Exemplarily, the server may directly perform facial feature region segmentation on the facial parts in the target facial image, such as by using an image segmentation algorithm or a pre-trained facial semantic segmentation model to perform facial feature region segmentation on the facial parts in the target facial image, and obtain a facial feature region map and a facial skin region map of the target facial image. In some embodiments, the server may perform facial feature region segmentation on the face swap intermediate image and the target facial image, respectively, and obtain respective feature region maps, specifically including a facial feature region map of the face swap intermediate image, and a facial feature region map and a facial skin region map of the target facial image.
[0089] In this embodiment, the server directly performs facial feature area segmentation on the target facial image to obtain a facial feature area map and a facial skin area map, and can obtain different feature areas of the target facial image for use in face swap image processing, thereby improving the image quality of the face swap image.
[0090] In an exemplary embodiment, determining a facial feature area map and a facial skin area map of facial parts in a target facial image includes: based on an image identifier of the target facial image, querying to obtain a facial feature area map and a facial skin area map of facial parts in the target facial image.
[0091] Among them, the image identifier is the identification information of the user to identify different images, which may include but is not limited to identification information such as image name and image number. Specifically, the server can determine the image identifier of the target facial image, and perform a feature area map query based on the image identifier, such as querying in the feature area library based on the image identifier to obtain the facial feature area map and facial skin area map of the target facial image identified by the image identifier. The feature area library can be pre-established according to actual needs, and specifically, facial feature area segmentation can be performed in advance for the facial parts in various facial images, and the image identifiers of various facial images and the corresponding facial feature area maps and facial skin area maps are stored in the feature area library, so that the corresponding feature area maps can be queried from the feature area library based on the image identifier, which may specifically include facial feature area maps and facial skin area maps.
[0092] In this embodiment, the server directly queries and obtains the pre-stored facial feature area map and facial skin area map of the target facial image based on the image identifier of the target facial image, which can improve the efficiency of obtaining the feature area map, thereby facilitating improving the processing efficiency of the face swap image.
[0093] In an exemplary embodiment, face swapping is performed on face parts in a target face image using face parts in a source face image to obtain a face swap intermediate image, including: extracting embedded features of the face parts of the source face image; and face swapping is performed on the face parts in the target face image based on the embedded features to obtain a face swap intermediate image.
[0094] Among them, the embedded feature is a more abstract and semantic feature representation of the facial part image in the source face image, and the embedded feature is conducive to ensuring the face similarity after face swapping. Exemplarily, the server can extract the embedded features of the facial part in the source face image, such as extracting the corresponding embedded features for the facial part of the source face image through a pre-trained embedded feature extraction model. The server embeds the features to perform face swapping on the facial part in the target face image to obtain a face swapping intermediate image. Face swapping can be achieved through a face swapping model, and the server can obtain a face swapping model pre-trained based on historical data. The face swapping model can be constructed based on at least one of various algorithms such as DeepFakes algorithm, FaceSwap algorithm, GANimation (Generative Adversarial Animation, Generative Adversarial Animation) algorithm, Convolutional Neural Network (CNN) algorithm, Recurrent Neural Network (RNN) or Unet network algorithm. The server can input the embedded features and the target face image into the face swapping model for face swapping processing, and the face swapping model outputs the face swapping intermediate image.
[0095] In this embodiment, the server uses the embedded features of the facial parts of the source facial image to perform face swapping on the facial parts in the target facial image, which can ensure the similarity of the faces after the face swapping and ensure the face-changing effect of the face swapping.
[0096] In an exemplary embodiment, the face image processing method also includes: obtaining a texture enhancement model; the texture enhancement model is trained based on an image set that meets image texture conditions; and the facial skin texture in the face swap image is processed by the texture enhancement model to obtain a face swap image with improved facial skin texture.
[0097] Among them, the texture enhancement model is used to enhance the skin texture of the image. The texture of facial skin can include elements such as granularity, texture, hair, etc. of the facial skin, thereby showing the overall realism of the facial image. The higher the skin texture of the facial image, the more realistic the corresponding facial image is visually. The texture enhancement model is pre-trained based on an image set that meets the image texture conditions. Specifically, the texture enhancement model can be obtained by training an image set composed of high-texture images. The texture enhancement model can be trained based on various neural network algorithms or deep learning algorithms, and can specifically include various network model forms such as convolutional neural networks, recurrent neural networks, generative networks, or diffusion models.
[0098] Optionally, the server can obtain a pre-trained texture enhancement model, and the texture enhancement model is trained on a set of images with high texture. The high-texture images that meet the image texture conditions included in the image set can be images of the real world captured by a camera, so that the image has a strong sense of reality. The server can enhance the texture of the face swap image through the texture enhancement model, and specifically process the facial skin texture in the face swap image to obtain a face swap image with improved facial skin texture. Compared with the face swap image, the granularity, texture, hair and other elements of the facial skin in the face swap image with improved facial skin texture are more delicate, so that the overall image is more realistic.
[0099] In this embodiment, the server improves the facial skin texture of the face swap image through the pre-trained texture enhancement model, which can improve the realism of the face swap image and improve the image quality of the face swap image.
[0100] In an exemplary embodiment, Figure 4 As shown, the texture enhancement process, that is, processing the facial skin texture in the face swap image through the texture enhancement model to obtain the face swap image with enhanced facial skin texture, includes:
[0101] Step 402: segment a facial region image from the face exchange image.
[0102] The facial region image is an image including the region to which the facial part in the face swap image belongs. Specifically, the server can perform facial region segmentation processing on the face swap image to obtain the facial region image, which includes the region to which the facial part in the face swap image belongs.
[0103] Step 404: input the facial region image into the texture enhancement model to perform facial skin texture processing to obtain a facial region image after facial skin texture enhancement.
[0104] Exemplarily, the server can improve the facial skin texture of the facial area image through a texture enhancement model. Specifically, the server can input the facial area image into the texture enhancement model, have the texture enhancement model process the facial skin texture, and output the facial area image with improved facial skin texture.
[0105] Step 406, fitting the facial region image after the facial skin texture is enhanced back into the face swap image to obtain the face swap image after the facial skin texture is enhanced.
[0106] Optionally, for the facial area image after the facial skin texture is improved, the server can fit it back into the face swap image to fill the area belonging to the facial part in the face swap image, thereby improving the skin texture of the face in the face swap image and obtaining the face swap image after the facial skin texture is improved.
[0107] In this embodiment, the server segments a facial area image from the face swap image, performs texture enhancement on it using a texture enhancement model, and then fits the facial area image with enhanced facial skin texture back into the face swap image. This can improve the facial skin texture of the face swap image, improve the quality of the face swap image, reduce the amount of texture enhancement processing data, and improve the processing efficiency of the face swap image.
[0108] In an exemplary embodiment, the facial image processing method also includes: when the face exchange image after facial skin texture enhancement does not meet the texture enhancement end judgment condition, the facial skin in the face exchange image after facial skin texture enhancement is processed by a texture enhancement model to obtain the face exchange image after repeated texture enhancement.
[0109] Among them, the texture enhancement end judgment condition is used to determine whether to end the texture enhancement processing for the face swap image. When the texture enhancement end judgment condition is not met, it is considered necessary to continue to enhance the facial skin texture of the face swap image.
[0110] Exemplarily, the server can detect whether the face swap image after the facial skin texture is improved meets the preset texture improvement end judgment condition, and when it is determined that the texture improvement end judgment condition is not met, the face skin in the face swap image after the facial skin texture is improved is continuously processed through the texture improvement model, thereby obtaining the face swap image after repeated texture improvement. In some embodiments, the server can make a judgment based on the texture difference between the face swap image after the facial skin texture is improved and the target face image, so as to determine whether the texture improvement end judgment condition is met according to the judgment result. For example, the texture difference between the face swap image after the facial skin texture is improved and the target face image can be quantified to obtain the texture difference value. When the texture difference value is less than the texture difference threshold, it is considered that the texture improvement end judgment condition is not met, and the facial skin quality processing is continued for the face swap image after the facial skin texture is improved until the image texture end condition is met, and the final face swap image is obtained.
[0111] In some embodiments, a texture determination model may be pre-trained, and the texture determination model may be used to determine the texture difference between the face swap image after the face skin texture is enhanced and the target face image, so as to determine whether the texture enhancement termination determination condition is met. In a specific application, when the texture enhancement termination determination condition is not met, the face swap image after the face skin texture is enhanced may be texture enhanced again to directly obtain the final face swap image, or the texture enhancement process may be repeated multiple times until a face swap image that meets the image texture termination condition is obtained.
[0112] In this embodiment, when the face swap image after facial skin texture enhancement does not meet the texture enhancement end judgment condition, the server can repeatedly perform texture enhancement processing to ensure the texture of the face swap image, thereby improving the image quality of the face swap image.
[0113] The present application also provides an application scenario, and the application scenario applies the above-mentioned face image processing method. Specifically, the application of the face image processing method in the application scenario is as follows:
[0114] Face swapping, also known as face-changing model in computer vision, usually refers to inputting two pictures with human faces into the system, namely the source picture and the target picture, and using the facial features in the source picture to replace the facial features of the person in the target picture, thereby changing the facial features in the target picture to be more consistent with the facial features in the source picture. For the realization of face swapping, the existing method is to convert the facial image in the target picture by manual editing. This method is to use software such as Photoshop (image processing software) to manually edit the input target picture. During the editing process, the user's own selfie will be input, so that the final edited target picture meets the user's original appearance characteristics, thereby completing the demand for face swapping of the target picture. However, the method of manually editing pictures based on the Photoshop tool is extremely slow in production efficiency for industrial applications. At the same time, due to the differences in editing methods and subjective feelings of different people, the similarity of the faces of the edited images will be greatly different, and a standardized face-changing effect cannot be formed. Face similarity is to determine the similarity distance between the facial features of the characters in two given pictures. In order to determine whether the two faces belong to the same person, it can be used for face recognition and identification. In this solution, it is mainly used to determine the similarity distance between the face in the generated personalized image and the user's own appearance features.
[0115] At present, the current user's face data and the target face data can be combined into a large number of data pairs, and then the current data pairs can be used to train a face-changing GAN (Generative Adversarial Network) model for the current user. Then this model is the user's own face-changing model. As long as the target image is input, the facial features of the characters in the target image can be replaced with the features of the user's face. However, by using a large amount of user face image data and target data to train a dedicated face-changing GAN model, although the model trained by this method can complete the task of face-changing to a certain extent. However, the model trained by this method cannot be universal, and can only be a face-changing model exclusive to the current person, and this method will rely on a large amount of user face data, but in the actual implementation process, it is impossible to provide so much data. At the same time, this learning method can easily overfit the user's face skin quality in the training data, resulting in the skin quality of the final face-changing unable to maintain the original texture of the target image. Skin quality mainly refers to the special properties and characteristics formed by the diversity of human facial skin. In this solution, it is mainly used to express the skin texture of the image character's face, including the granularity, texture, hair and other elements shown on the face. The corresponding is smooth skin quality, which means that the skin texture of the entire image face is too smooth or AI-like, without the performance of real people.
[0116] In addition, a face swap model is constructed by using a large number of open source face swap datasets to complete the training mechanism of the traditional face swap model. Specifically, a large number of convolutional networks plus Attention are used, such as the Style-GAN (Style-Based Generator Adversarial Networks, based on image style generative adversarial network) model. Then the model can form a general Face Swap model. By inputting the current user's picture and the target picture, the face in the target picture can be replaced with the user's appearance features after calculation by this model. After training with a large number of open source face swap picture datasets, there is a certain good face swap effect, but in actual use, because the quality of the pictures uploaded by the user is not necessarily very high, the model will bring the texture and clarity of the pictures uploaded by the user into the target picture when performing face swap, resulting in the Face Swap result being prone to blurred skin texture or low clarity.
[0117] For the conversion of the target image based on the Stable Diffusion model. Fine-tune a user-specific Stable Diffusion (SD) model by using a large number of photos of the user's appearance. Then, in actual use, input the target image into the Stable Diffusion model, perform Img2img (image to image) modification on the image, and let the model replace the learned user appearance representation with the target image. Using the Stable Diffusion model to learn and train the user's appearance features based on user image data can enable the SD (Stable Diffusion) model to have the ability to restore its appearance features. However, in actual applications, if the training data is not diverse enough, the texture in the user's image will be brought into the target image, thereby affecting the texture of the final result. If there are enough pictures, the model may produce AI smooth texture. This is mainly for the model to take into account various skin textures in learning and training. This will also bring AI smooth texture to the final output target result image, thereby affecting the final image quality.
[0118] Based on this, the face image processing method provided in this embodiment is based on the Face Parsing Paste mechanism to improve the face texture and similarity of Face Swap. This method is to be able to improve the skin texture of the target face and the face similarity of the result after face swapping and the source face during the Face Swap process. This embodiment first constructs an innovative Face Swap model based on a massive face swapping data set training, and then uses the Face Swap model to perform face swapping operations on the input source image and the target image. After the face swapping, the facial features in the generated target result image can be converted into the features in the source image. Then, the FaceParsing Paste model in this embodiment is used to identify and detect the facial features and skin areas of the two faces in the target image and the target result image based on the face semantic segmentation model, and then the Paste Mask is calculated according to the required area. Finally, the face texture of the target image and the target result image is fused according to the calculated Paste Mask, and the face similarity in the target result image can be maintained and improved. Finally, the image is input into the Face Aigc-I2I (Artificial Intelligence Generative Content- Image-to-Image) model to perform special face texture fusion enhancement on the face area in the target result image, so as to increase the texture of the face in the target result image, thereby improving the texture quality of the final Face Swap image. The face image processing method provided in this embodiment can solve the problems of poor texture and low similarity encountered in many traditional face swap models, and improves the texture of the result after Face Swap and the similarity of the face based on the Face Parsing Paste+Aigc-I2I method.
[0119] The face image processing method provided in this embodiment is a system flow solution for fully automated training and reasoning calculations, which does not require human intervention, can greatly improve the efficiency of the overall face-changing industrial production, and can significantly reduce costs. In addition, the face image processing method provided in this embodiment can improve the skin texture and face similarity of the Face Swap results, standardize the entire production process, and will not be affected by any subjective result differences. Specifically, the Face Swap base model in the face image processing method provided in this embodiment can use a Unet network model structure based on FaceEmbedding embedding. This structure does not require the use of a large amount of exclusive user portrait image data and target data for training. It only needs to be trained on an open source face-changing data set, which can get rid of the dependence on a large amount of user data, and is convenient for online use, improving the user experience.
[0120] The face image processing method provided in this embodiment can be deployed in many face application scenarios. First, the method can be applied in many smart cameras, helping the camera to provide a Face Swap function module with high texture and high similarity, and providing users with a self-service face-changing application scenario, which can support users to upload their own photos and target photos they want to change faces with, and then after uploading their own photos, change their own appearance features to the target photo, and generate a target result image with their own appearance.
[0121] In addition, the facial image processing method provided in this embodiment can be applied to live broadcast scenarios, especially for virtual live broadcasts. For many anchors and uploaders, a virtual person can be used to complete the need to let a virtual anchor perform live broadcasts on their behalf, thereby saving their own live broadcast costs. First, by setting up an image of a virtual person, and then using the system in this solution to replace the up owner's own appearance features with the virtual person's face, the virtual person can be used to perform live broadcasts on their behalf, thereby reducing the overall work cost and burden of live broadcasts.
[0122] The facial image processing method provided in this embodiment is based on the Face Parsing Paste mechanism to improve the texture and similarity of FaceSwap faces. In this method, Face Parsing Paste is combined with the Face-I2i mechanism to fuse the skin texture of the target result image of Face Swap. While fusing, the similarity of the faces after face swapping can be improved and maintained, thereby improving the overall texture and quality of the Face Swap results. It can be applied and deployed in multiple landing directions such as smart cameras, live broadcasts, and post-production of film and television dramas.
[0123] Specifically, the face image processing method provided in this embodiment can be divided into three stages, namely, the Face Swap model based on the FaceEmbedding multi-layer embedding, the Face Parsing Paste model, and the Face-I2I model. Figure 5 As shown in the figure, users can input the source image and the target image into the face swap model (Face Swap) respectively. The source image is the source face image that needs to replace other faces, and the target image is the target face image that needs to be replaced. For the face-swapped image, that is, the face swap intermediate image combined with the target image is input into the Face Parsing Paste model to obtain the face swap image. The face swap image is input into the face image generation model (Face-I2I) trained based on the high-quality image dataset to obtain the target result image, that is, the face swap image with improved facial skin texture.
[0124] For the Face Swap model module with multi-layer Face Embedding, in this module, by using the multi-layer embedding method of FaceEmbedding in the Unet network, the model can deeply feel the appearance characteristics of the source face, and at the same time input the portrait data of the target image, and finally calculate and generate the target result image. In the portrait in the target result image, except for the face, the rest remains the same as the previous target image, and only the facial appearance is changed to the facial appearance characteristics of the source image uploaded by the user. Then the target image and the target result image are input into the Face Parsing Paste model in the second stage. In this model, the faces of the input target image and the target result image are disassembled by building an innovative face semantic segmentation model, and then the masks of the facial features and skin are calculated and fused to generate the final mask area. Based on this mask area, the skin texture of the two images is fused while maintaining the similarity of the face. The fused image is input into the third module, which is the Face-I2I model. This model is a Stable Diffusion model trained based on a large amount of hyper-realistic data. It first locates the face in the input image, then extracts the facial box image and performs I2I to increase the texture. After enhancement, the face is pasted back to the original position to generate the final Face Swap target result image with high texture and high face similarity.
[0125] Furthermore, for the Face Swap model based on Face Embedding multi-layer embedding. The input of this model is the user's source image data and the target image that the user wants to swap faces with. The purpose of this model is to be able to convert the facial features of the person in the source image to the target image data, that is, through the Face Swap model, the face parts in the source face image are swapped with the face parts in the target face image to obtain the face swap intermediate image. Figure 6 As shown in the figure, the source face image is specifically the source image, and the target face image is specifically the target image. After the source image is subjected to the face image clipping encoding module (Clip lmage Encoder Model), the face embedding feature (Face Embedding) is obtained. The face embedding feature and the target image are input into the face swap model, specifically into the U-net model, to obtain the face swap intermediate image. Specifically, this model designs a Face Swap model method based on multi-layer embedding of Face Embedding. First, Face Embedding is extracted according to the input source image data, and then a large Face Swap model is constructed based on the Unet network. This model is constructed by embedding Face Embedding into multiple layers of network layers in Unet. In order to enable each layer in the entire model to deeply feel the appearance characteristics of the source image Face, so as to improve the face replacement effect of the entire model for the current input, the face similarity after Face Swap is greatly improved. At the same time, the input of the Unet network is the target image data. As the main calculation feature of the entire model, the image data will pass through the Downsample and Upsample branches of the Unet network, and finally calculate and generate an image of the same size.
[0126] For the Unet network, the typical feature of the Unet network is that it is a U-shaped symmetrical structure, with a convolutional layer on the left and an upsampling layer on the right. The Unet structure contains 4 Convolutional Layers and corresponding 4 Up Sampling Layers. Therefore, when implementing, you can either implement the network from scratch and initialize the weights, and then train the model; you can also borrow the convolutional layer structure of some existing networks and the corresponding trained weight files, and then add the subsequent Up Sampling Layer for training calculations, such as Resnet (Residual Network), Vgg (Visual Geometry Group), etc. In the model training of deep learning, by using the existing weight model files, the training speed can be greatly accelerated. Another feature is that the feature maps obtained by each convolutional layer of the Unet network will be concatenated to the corresponding upsampling layer, so that each layer of feature maps can be effectively used in subsequent calculations. That is, Skip-Connection. In this way, compared with some other network structures such as FCN (Fully Convolutional Network), Unet avoids direct supervision and loss calculation in high-level Feature Maps, but combines the features in low-level Feature Maps, so that the final Feature Map contains both High-Level Features and many Low-Level Features, realizing the fusion of Features at different scales and improving the accuracy of the model results.
[0127] Among them, Convolutional Neural Network (CNN) is a feedforward neural network whose artificial neurons can respond to surrounding units within a certain coverage area, and has excellent performance in large image processing. Convolutional neural network consists of one or more convolutional layers and a fully connected layer at the top (corresponding to the classic neural network), as well as associated weights and pooling layers.
[0128] like Figure 7As shown in the figure, the Unet network has four layers, which downsample and upsample the input image 4 times respectively. Starting from the leftmost, the input is a 572x572x1 image, which is then convolved with 64 3x3 convolution kernels, and then passed through the ReLU function to obtain 64 570x570x1 feature channels, and then the 570x570x64 result is convolved with 64 3x3 convolution kernels, and then passed through the ReLU function to obtain 64 568x568x1 feature extraction results, which is the processing result of the first layer. The processing result of the first layer is a 568x568x64 feature image. Through the 2x2 pooling kernel, the image is downsampled to half of its original size, that is, 284x284x64, and then 128 convolution kernels are used to further extract image features. The following downsampling process is similar. Each layer will go through two convolutions to extract image features. Each downsampling will reduce the image size by half and double the number of convolution kernels. The final result of the downsampling part is 28x28x1024, which means there are 1024 feature layers in total, and the feature size of each layer is 28x28. The right part is 4 upsampling processes from bottom to top. Starting from the bottom right corner, the 28x28x1024 feature matrix is deconvolved with 512 2x2 convolution kernels, and the matrix is expanded to 56x56x512, and then convolution is performed to extract features. Since each valid convolution will make the result smaller, the image in the left downsampling process needs to be cropped before each splicing. After the matrix is spliced, the entire new feature matrix becomes 56x56x1024, and then after 512 convolution kernels, two convolutions are performed to obtain a 52x52x512 feature matrix, which is upsampled again and the above process is repeated. Each layer will be convoluted twice to extract features. Each upsampling layer will double the image and reduce the number of convolution kernels by half. The final upsampling result is 388x388x64, which means there are 64 feature layers in total, and the feature size of each layer is 388x388. In the last step, two 1x1 convolution kernels are selected to turn the 64 feature channels into 2, which is the final 388x388x2. In fact, this is a binary classification operation, which divides the image into two categories: background and target.
[0129] like Figure 8As shown in the diagram of the modified new U-net network architecture, the basic architecture is the same as the original Unet network architecture, but in each layer of Unet, the same embedding feature (Embedding) vector is added as embedding, which is the Face Embedding vector calculated in this module. By embedding this vector into each layer of the network, the entire model can deeply perceive and learn the extracted Face (face) appearance feature information, so that each layer calculation can move closer to the appearance feature.
[0130] For the Face Parsing Paste module, the input of the entire module is the face swap intermediate image after Face Swap and the original target image, which is used to integrate the skin texture in the original target image into the current target result image, while avoiding affecting the similarity of the user's face in the target result image. This module mainly builds a facial semantic segmentation network, then segments the facial features and skin into masks, calculates the mask of the area to be fused according to the mask fusion rules in the FaceParsing Paste mechanism, and finally fuses the skin texture of the two images according to the calculated mask. The non-mask area still retains the content in the target result image, so as to maintain the similarity of the face. Fig. 9 As shown in the figure, for the target image and the face swap intermediate image, the respective facial regions are determined and face segmentation is performed to obtain the skin mask, facial features mask and eye mask of the target image, as well as the facial features mask of the face swap intermediate image. The facial features mask and eye mask of the target image are fused and dilated (Concat+Dilate) with the facial features mask of the face swap intermediate image, and the dilation result is subjected to mask selection (Mask Select) with the skin mask of the target image to obtain a skin-fitting mask. The skin-fitting mask is fused with the skin mask of the target image and then skin-pasted (Skin Paste) with the face swap intermediate image to obtain the output, i.e., the face swap image.
[0131] The Face Parsing Paste module is divided into two parts: the semantic segmentation model of the face, FaceSegment, and the skin quality Paste fused with the Parsing Mask, that is, the face fusion area map processing module.
[0132] Among them, the semantic segmentation model Face Segment is a face semantic segmentation model. Fig.10As shown in the figure, the face semantic segmentation model is divided into three parts, namely, the encoding module, the context path, and the feature fusion. The first is the encoding module of the model. In the segmentation task, it is difficult to achieve both spatial resolution and receptive field, especially in the case of real-time segmentation. Existing methods usually use small input images or lightweight backbone models to achieve acceleration. However, small images lose a lot of spatial information compared to the original images, and lightweight models damage spatial information due to cropping channels. Therefore, the feature encoding module in this model retains the spatial scale of the original input image and enriches the encoding spatial information. The entire encoding module contains a 4-layer structure. Each of the three layers above is a convolution layer + Batch Norm (Batch Normailzatoin, batch normalization) + Relu activation function, that is, conv+bn+relu in the figure. The convolution stride (step length) in each layer is equal to 2, so the feature map size calculated by the entire encoding module is 1 / 8 of the original input image size. Finally, a 1x1 convolution layer (conv) is added to consolidate the semantics of the feature.
[0133] In segmentation tasks, the receptive field is crucial to performance. To increase the receptive field, some methods use pyramid pooling modules, atrous spatial pyramid pooling (ASPP) or "large kernel", but these operations are computationally and memory intensive, resulting in slow speed. In order to achieve both a larger receptive field and higher computational efficiency, this model proposes Context Path, which makes full use of lightweight models and global average pooling to provide a large receptive field. In Context Path, global average pooling is used to capture global semantics and calculate attention vectors to guide feature learning. This design can optimize the output features of each stage in Context Path and easily integrate global semantic information without any upsampling operations. Specifically, Fig.10As shown in the figure, for the input face image, that is, for the face swap intermediate image or the target face image, the input image is downsampled by 4x down, so that the image is reduced to 1 / 4, and then downsampled by 8x down and 16x down in sequence, so that the image is reduced to 1 / 8 and 1 / 16 of the original input image respectively; further, in one branch, pooling is performed in sequence through the pooling layer (pooling), convolution operation is performed through the convolution layer (1x1 conv), normalization is performed through the batch normalization layer (bn), normalization is performed through the activation function layer (sigmoid), and matrix multiplication (mul) is performed to obtain the output of the first branch; in another branch, downsampling is performed in sequence through the downsampling layer (32x down), pooling is performed through the pooling layer (pooling), and convolution operation is performed through the convolution layer (1x1 The first branch is convolved with the first branch through a convolution operation (conv), normalized by a batch normalization layer (bn), normalized by an activation function layer (sigmoid), processed by a matrix multiplication layer (mul), and the output of the second branch is obtained. The outputs of the first branch and the second branch are fused through a fusion layer (merge) to obtain the output of the context path.
[0134] The calculated features of the semantic segmentation model Face Segment and the skin texture Paste fused by the Parsing Mask are input into the feature concat module for the final high-level feature fusion. Specifically, Fig.11As shown in the figure, in the feature fusion module, the outputs of the encoding module and the context path module are connected through the connection layer (concat) and processed through the layer structure (conv+bn+relu). On the one hand, the outputs are processed through the pooling layer (pooling), the convolution layer (1x1 conv), the activation function layer (relu), the convolution layer (1x1 conv) and the activation function layer (sigmoid), and the feature fusion result is obtained through the matrix multiplication layer (mul) and the fusion layer (add). At the level of feature representation, the features of the two networks are not the same, so these features cannot be simply weighted. Because the output of the semantic segmentation model contains a lot of spatial information, especially for detail information. Semantic information is encoded in the Context Path, which can be understood as the features of the first module are low-level, while the features of the skin texture Paste fused by the Parsing Mask are high-level. More accurate feature information extraction is performed by fusing the features of the high and low levels. After the features are calculated, they are input into the activation function for segmentation judgment. The judgment is calculated at each point in the fused feature map. After calculation, the boundary between different objects can be located on the small feature map, and then restored to the input image size after the same 3-layer Upsample. Finally, the required segmentation boundary in the original image can be obtained, which is the boundary of the facial features and skin of the input training image in this solution.
[0135] For the skin texture paste fused by Parsing Mask, that is, the facial fusion area map processing module, such as Fig.12 As shown in the figure, for the fusion of face parsing mask. After the calculation of the face semantic segmentation model in the previous node, the facial features and skin areas of the two faces can be detected and identified, and the mask image is calculated based on the detection results, where the focus area is white in the figure and the non-focus area is black. For the target image, the facial feature area Mask of the target result face image (target) is obtained, where the facial feature areas include the left and right eyes (L-eye, R-eye), left and right eyebrows (L-eyebrow, R-eyebrow), nose (nose), upper and lower lips (U-lip, D-lip) and other parts, which are specifically mask maps; for the face swap intermediate image output by the previous module, the same method is used to extract the facial feature Mask of the target face image (Source), and specifically obtain the left eye (L-eye), right eye (R-eye), left eyebrow (L-eyebrow), right eyebrow (R-eyebrow), nose (nose), upper lip (U-lip) and lower lip (D-lip) and other parts, which are specifically mask maps.
[0136] The masks calculated from the two images are fused. At the same time, in order to avoid displacement of the facial features after Face Swap, the fused mask needs to be expanded, that is, the edges of the white areas in the mask image are expanded. The eye area, which is the focus of attention, needs to be processed separately. Therefore, the masks of the left and right eye areas in the two images are calculated and then expanded and expanded, and then fused again with the fused mask above. Finally, the Skin Mask of the original target portrait image is subtracted from the fused Mask result above, which is the area that needs to be fused with skin texture, that is, the Paste Mask fitting mask area. Fig.13 As shown in the figure, after calculating the Paste Mask area, the weighted sum of the two face images in the white area of the Mask is performed, and specifically the image area of the target image and the face swap intermediate image in the pasting area (Paste Mask) are weightedly fused. Then, the skin texture of the target face image can be integrated into the final image, that is, the pasting result image is obtained. At the same time, the facial features fusion Mask area is removed, so that the face image can maintain the similarity to the user's face.
[0137] For the Face-I2I fusion module, it is a model that improves the skin quality of the target result image after the previous module is pasted. This model is trained based on the traditional Stable Diffusion model and the high-quality image dataset. Fig.14 As shown in the figure, a large number of high-quality image data sets are used to train the Face-I2I model in the training phase. The key is to enable the model to learn the skin texture of the face in the image and obtain a face generation model based on stable diffusion (Face-I2I Stable Diffusion). Then, in the prediction phase, the target result image calculated by the second module is input to improve the skin texture, and the image is input into the trained model, that is, into the pre-trained face generation model based on stable diffusion (trained Face-I2I Stable Diffusion), and the output result image is calculated. The image can improve the final skin texture without affecting the similarity of the face in the image. The Face-I2I fusion module uses a large number of high-quality image images based on Stable Diffusion to train a model to improve the texture. After the skin texture is extracted, a texture judgment module can be added to calculate the texture difference between the result image and the target image. If it is lower than a certain texture difference threshold, a secondary model processing is required to improve the final effect.
[0138] Stable Diffusion (SD) is a variation of the diffusion model called the latent diffusion model (LDM). The diffusion model was introduced in 2015 and aims to eliminate the successive application of Gaussian noise to the training images, which can be viewed as a series of denoising autoencoders. StableDiffusion consists of 3 parts: a variational auto-encoder (VAE), a U-Net (a convolution-based image segmentation network), and a text encoder. Instead of learning to denoise image data, the VAE is trained to transform the image into a low-dimensional latent space. The process of adding and removing Gaussian noise is applied to this latent representation, and then the final denoised output is decoded into pixel space. During the forward diffusion process, Gaussian noise is iteratively applied to the compressed latent representation. Each denoising step is done by a U-Net architecture containing a residual neural network, which obtains the latent representation by denoising in the reverse direction from the forward diffusion. Finally, the VAE decoder generates the output image by transforming the representation back into pixel space.
[0139] like Fig.15 As shown in the figure, for the Stable Diffusion model, we first need to train an autoencoder model (AutoEncoder, including an encoder and a decoder). In this way, we can use the encoder to compress the image, then perform the Diffusion operation in the latent space, and finally use the decoder to restore it to the original pixel space. This method is called perceptual compression in the model. This method of compressing high-dimensional features to low dimensions and then operating in the low-dimensional space is universal. Specifically in the pixel space, for the input , encoded to obtain the feature map , based on the feature map The diffusion process is realized in the latent space, specifically from the feature map To feature map Diffusion process; in the decoding process, the conditional mechanism is introduced, including various conditions such as semantic map, text, representations and images. Decode and recover. Specifically, when decoding, To feature map In the process, the Unet network is combined with the attention mechanism to achieve the feature map Combined with the previous restored image Get feature map , and obtain the feature map of pixel space , and finally generate the output graph .
[0140] The main process of the Diffusion operation on the latent representation space is not much different from the standard diffusion model. The specific implementation of the diffusion model used is time-conditional UNet. However, an important point is that the model introduces conditional mechanisms for the Diffusion operation, and implements multimodal training through Cross-Attention, so that conditional image generation tasks can also be achieved. The Diffusion model as a whole has three main components:
[0141] VAE: VAE consists of two main parts: encoder and decoder. The encoder will convert the image into a low-dimensional latent representation which will be the input to the next component U-Net. The decoder will do the opposite, it will convert the latent representation back to an image. During Diffusion training, the encoder is used to obtain the latent representation of the input image during forward diffusion. While during inference, the VAE decoder will convert the latent signal back to an image.
[0142] Unet: UNet also consists of two parts, encoder and decoder, both of which are composed of ResNet blocks. The encoder compresses the image representation into a low-resolution image, and the decoder decodes the low-resolution back to a high-resolution image. In order to prevent U-Net from losing important information when downsampling, a shortcut connection is usually added between the downsampled ResNet of the encoder and the upsampled ResNet of the decoder. A cross-attention layer is added to the diffusion U-Net to adjust the output of the text embedding. The cross-attention layer is added between the encoder and decoder ResNet blocks of U-Net.
[0143] Text encoder: The text encoder converts the input text prompt into an embedding space that U-Net can understand. It is a simple Transformer-based encoder that maps a sequence of tokens to a sequence of potential text embeddings. In order to be able to use good text prompts to get better expected outputs. Stable Diffusion uses the MSE (Mean Squared Error) loss function as the update function mechanism for the entire system during training.
[0144] The face image processing method provided in this embodiment improves the face texture of FaceSwap and maintains the similarity based on the Face Parsing Paste mechanism. The method integrates the innovative Face Parsing Paste mechanism and the AIGC (Artificial lntelligence Generative Content) face image texture fusion mechanism, and can respectively perform subtle semantic segmentation on facial features, skin and other areas, and then calculate the difference between the source and the target to select the fusion area, and then use the texture fusion mechanism based on Aigc-Img2img to smooth the patches. The method can respectively improve the skin texture of the target image face and the face similarity and quality after the face swap, and can also improve the similarity with the source face after the swap, thereby improving the overall quality and effect of the Face Swap system results.
[0145] The face image processing method provided in this embodiment uses the constructed innovative face parsing semantic segmentation model to detect and segment the facial features and skin areas of the input face image, and then performs mask calculation according to the required areas. After multiple rounds of mask fusion processing, the face area in the Face Swap result is matched with the face of the original target image in the form of mask area, so as to improve the skin texture of the whole model face swap. At the same time, because the Face Swap result is used for fusion, the Mask can be used to maintain the face similarity of the Face Swap result.
[0146] The face image processing method provided in this embodiment uses a Face Aigc-I2I (Image-to-Image)-based method to perform texture fusion on the target face after Face Parsing Paste, thereby improving the patch phenomenon that may be caused by Paste fusion. At the same time, the AIGC model trained with a large amount of high-quality face image data is used as the base model of I2I for fusion, which can ensure the face texture after Face Swap and avoid AI smoothness, thereby improving the skin texture of the final Face Swap result image.
[0147] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0148] Based on the same inventive concept, the embodiment of the present application also provides a face image processing device for implementing the face image processing method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more face image processing device embodiments provided below can refer to the limitations on the face image processing method above, and will not be repeated here.
[0149] In an exemplary embodiment, Fig.16 As shown, a face image processing device 1600 is provided, comprising: a face exchange module 1602, a feature region segmentation module 1604, a feature region map determination module 1606, a feature region map fusion module 1608 and a face fusion region map processing module 1610, wherein:
[0150] The face exchange module 1602 is used to obtain a source face image and a target face image, and perform face exchange on the face parts in the target face image using the face parts in the source face image to obtain a face exchange intermediate image;
[0151] The feature region segmentation module 1604 is used to segment the face feature region of the face swap intermediate image to obtain a facial feature region map of the face swap intermediate image;
[0152] The feature region map determining module 1606 is used to determine the facial feature region map and the facial skin region map of the face part in the target face image;
[0153] The feature region map fusion module 1608 is used to fuse the facial feature region map of the target face image, the facial skin region map and the facial feature region map of the face swap intermediate image to obtain a facial fusion region map;
[0154] The face fusion region map processing module 1610 is used to obtain a face swap image according to the face fusion region map, the face swap intermediate image and the target face image.
[0155] In one embodiment, the feature area map fusion module 1608 is also used to fuse the facial feature area map of the target facial image and the facial feature area map of the face swap intermediate image to obtain a facial feature area fusion map; and to fuse the facial feature area fusion map with the facial skin area map to obtain a facial fusion area map.
[0156] In one embodiment, the feature area map fusion module 1608 is also used to fuse the facial feature area map of the target facial image and the facial feature area map of the face swap intermediate image to obtain an original fused image; obtain the eye feature area map of the face swap intermediate image and the eye feature area map of the target facial image; fuse the eye feature area map of the face swap intermediate image, the eye feature area map of the target facial image and the original fused image to obtain a facial feature area fused image.
[0157] In one embodiment, the feature area map fusion module 1608 is also used to dilate the original fusion map, the eye feature area map of the face swap intermediate image and the eye feature area map of the target face image respectively to obtain an expanded fusion map, a first eye area expansion map and a second eye area expansion map; fuse the expanded fusion map, the first eye area expansion map and the second eye area expansion map to obtain an intermediate fusion map; and dilate the intermediate fusion map to obtain a facial feature area fusion map.
[0158] In one embodiment, the feature region map fusion module 1608 is further used to remove the area covered by the facial feature region fusion map from the facial skin region map to obtain a facial fusion region map.
[0159] In one embodiment, the face fusion region map processing module 1610 is further used to determine the fusion weights of the face swap intermediate image and the target face image respectively; the face fusion region map, the face swap intermediate image and the target face image are weightedly fused according to the fusion weights to obtain the face swap image.
[0160] In one embodiment, the feature region segmentation module 1604 is further used to perform feature encoding on the face swap intermediate image at least once to obtain pixel space encoding features of the face swap intermediate image; extract image semantic features of the face swap intermediate image; fuse the pixel space encoding features and the image semantic features to obtain image fusion features; perform facial feature region segmentation based on the image fusion features to obtain a facial feature region map of the face swap intermediate image.
[0161] In one embodiment, the feature region map determining module 1606 may also be used to perform facial feature region segmentation on the face parts in the target face image to obtain a facial feature region map and a facial skin region map of the face parts in the target face image.
[0162] In one embodiment, the feature region map determining module 1606 is further used to query and obtain a facial feature region map and a facial skin region map of a facial part in the target facial image based on the image identification of the target facial image.
[0163] In one embodiment, the face swap module 1602 is further used to extract embedded features of facial parts of the source facial image; perform face swap on the facial parts in the target facial image based on the embedded features to obtain a face swap intermediate image.
[0164] In one embodiment, it also includes a texture enhancement module for obtaining a texture enhancement model; the texture enhancement model is obtained by training an image set that meets image texture conditions; the facial skin texture in the face swap image is processed by the texture enhancement model to obtain a face swap image with enhanced facial skin texture.
[0165] In one embodiment, the texture enhancement module is also used to segment a facial area image from a face swap image; input the facial area image into a texture enhancement model to perform facial skin texture processing to obtain a facial area image with improved facial skin texture; and fit the facial area image with improved facial skin texture back into the face swap image to obtain a face swap image with improved facial skin texture.
[0166] In one embodiment, it also includes a texture end judgment module, which is used to process the facial skin texture in the face swap image after the facial skin texture is improved through the texture improvement model when the face swap image after the facial skin texture is improved does not meet the texture improvement end judgment condition, so as to obtain the face swap image after repeated texture improvement.
[0167] Each module in the above-mentioned face image processing device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module above.
[0168] In an exemplary embodiment, a computer device is provided. The computer device may be a server or a terminal. The internal structure diagram thereof may be as follows: Fig.17As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store facial image data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a facial image processing method is implemented.
[0169] Those skilled in the art will understand that Fig.17 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.
[0170] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.
[0171] In one embodiment, a computer-readable storage medium is provided, storing a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0172] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0173] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0174] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0175] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0176] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A facial image processing method, characterized in that: The method comprises: Acquire a source face image and a target face image, and perform face swapping on the face parts in the target face image using the face parts in the source face image to obtain a face swapping intermediate image; Performing facial feature area segmentation on the face swap intermediate image to obtain a facial feature area map of the face swap intermediate image; Determine a facial feature area map and a facial skin area map of a facial part in the target facial image; Fusing the facial feature region map of the target facial image and the facial feature region map of the face swap intermediate image to obtain a facial feature region fusion map; Fusing the facial feature region fusion map and the facial skin region map to obtain a facial fusion region map; A face swap image is obtained according to the face fusion region map, the face swap intermediate image and the target face image.
2. The method according to claim 1, characterized in that: The step of fusing the facial feature region map of the target facial image and the facial feature region map of the face swap intermediate image to obtain a facial feature region fusion map includes: Fusing the facial feature region map of the target facial image with the facial feature region map of the face swap intermediate image to obtain an original fused image; Acquire an eye feature region map of the face swap intermediate image and an eye feature region map of the target face image; The eye feature area map of the face swap intermediate image, the eye feature area map of the target face image and the original fusion map are fused to obtain a facial feature area fusion map.
3. The method according to claim 2, characterized in that The step of fusing the eye feature region map of the face swap intermediate image, the eye feature region map of the target face image and the original fusion map to obtain a facial feature region fusion map comprises: The original fusion image, the eye feature area map of the face swap intermediate image, and the eye feature area map of the target face image are respectively expanded to obtain an expanded fusion image, a first eye area expansion image, and a second eye area expansion image; fusing the dilated fusion image, the first eye region dilation image, and the second eye region dilation image to obtain an intermediate fusion image; The intermediate fusion image is expanded to obtain a fusion image of the facial feature area.
4. The method according to claim 1, characterized in that The step of fusing the facial feature region fusion map with the facial skin region map to obtain a facial fusion region map includes: The area covered by the facial feature area fusion map is removed from the facial skin area map to obtain a facial fusion area map.
5. The method according to claim 1, characterized in that The step of obtaining the face swap image according to the face fusion region map, the face swap intermediate image and the target face image comprises: Determining respective fusion weights of the face swap intermediate image and the target face image; The face fusion region map, the face swap intermediate image and the target face image are weighted fused according to the fusion weight to obtain a face swap image.
6. The method according to claim 1, characterized in that The step of segmenting the face feature area of the face swap intermediate image to obtain a facial feature area map of the face swap intermediate image includes: Performing feature encoding on the face swapping intermediate image at least once to obtain pixel space encoding features of the face swapping intermediate image; Extracting image semantic features of the face swap intermediate image; Fusing the pixel space coding feature and the image semantic feature to obtain an image fusion feature; The facial feature region is segmented based on the image fusion features to obtain a facial feature region map of the face swap intermediate image.
7. The method according to claim 1, characterized in that The step of determining a facial feature area map and a facial skin area map of a facial part in the target facial image includes at least one of the following: Performing facial feature region segmentation on the facial part in the target facial image to obtain a facial feature region map and a facial skin region map of the facial part in the target facial image; Based on the image identifier of the target facial image, a facial feature area map and a facial skin area map of the facial part in the target facial image are obtained by querying.
8. The method according to claim 1, characterized in that The step of performing face swapping on the face parts in the target face image using the face parts in the source face image to obtain a face swapping intermediate image comprises: Extracting embedded features of facial parts of the source facial image; Based on the embedded features, face swapping is performed on the face parts in the target face image to obtain a face swapping intermediate image.
9. The method according to any one of claims 1 to 8, characterized in that: The method further comprises: Acquire a texture enhancement model; the texture enhancement model is trained based on an image set that meets image texture conditions; The facial skin texture in the face swap image is processed by the texture enhancement model to obtain a face swap image with enhanced facial skin texture.
10. The method according to claim 9, characterized in that The step of processing the facial skin texture in the face swap image by using the texture enhancement model to obtain the face swap image after the facial skin texture is enhanced includes: Segmenting a facial region image from the face swap image; Inputting the facial region image into the texture enhancement model to perform facial skin texture processing to obtain a facial region image after facial skin texture enhancement; The facial region image after the facial skin texture is enhanced is fitted back into the face exchange image to obtain the face exchange image after the facial skin texture is enhanced.
11. The method according to claim 9, characterized in that The method further comprises: When the face swap image after the facial skin texture is improved does not meet the texture improvement end judgment condition, the facial skin in the face swap image after the facial skin texture is improved is processed by the texture improvement model to obtain the face swap image after repeated texture improvement.
12. A facial image processing device, characterized in that: The device comprises: A face exchange module, used to obtain a source face image and a target face image, and perform face exchange on the face parts in the target face image using the face parts in the source face image to obtain a face exchange intermediate image; A feature region segmentation module is used to segment the face feature regions of the face swap intermediate image to obtain a facial feature region map of the face swap intermediate image; A feature region map determination module, used to determine a facial feature region map and a facial skin region map of a face part in the target face image; A feature region map fusion module is used to fuse the facial feature region map of the target face image and the facial feature region map of the face exchange intermediate image to obtain a facial feature region fusion map; and fuse the facial feature region fusion map with the facial skin region map to obtain a facial fusion region map; The face fusion region map processing module is used to obtain the face exchange image according to the face fusion region map, the face exchange intermediate image and the target face image.
13. The device according to claim 12, characterized in that The feature area map fusion module is also used to fuse the facial feature area map of the target facial image and the facial feature area map of the face swap intermediate image to obtain an original fused image; obtain the eye feature area map of the face swap intermediate image and the eye feature area map of the target facial image; fuse the eye feature area map of the face swap intermediate image, the eye feature area map of the target facial image and the original fused image to obtain a facial feature area fused image.
14. The device according to claim 13, characterized in that The feature area map fusion module is also used to expand the original fusion map, the eye feature area map of the face exchange intermediate image and the eye feature area map of the target face image respectively to obtain an expanded fusion map, a first eye area expansion map and a second eye area expansion map; fuse the expanded fusion map, the first eye area expansion map and the second eye area expansion map to obtain an intermediate fusion map; and expand the intermediate fusion map to obtain a facial feature area fusion map.
15. The device according to claim 12, characterized in that The feature region map fusion module is also used to remove the area covered by the facial feature region fusion map from the facial skin region map to obtain a facial fusion region map.
16. The device according to claim 12, characterized in that The face fusion region map processing module is also used to determine the respective fusion weights of the face swap intermediate image and the target face image; the face fusion region map, the face swap intermediate image and the target face image are weightedly fused according to the fusion weights to obtain a face swap image.
17. The device according to claim 12, characterized in that The feature region segmentation module is further used to perform feature encoding on the face swap intermediate image at least once to obtain pixel space encoding features of the face swap intermediate image; extract image semantic features of the face swap intermediate image; fuse the pixel space encoding features with the image semantic features to obtain image fusion features; perform facial feature region segmentation based on the image fusion features to obtain a facial feature region map of the face swap intermediate image.
18. The device according to claim 12, characterized in that The feature region map determination module is further used for at least one of the following: Performing facial feature region segmentation on the facial part in the target facial image to obtain a facial feature region map and a facial skin region map of the facial part in the target facial image; Based on the image identifier of the target facial image, a facial feature area map and a facial skin area map of the facial part in the target facial image are obtained by querying.
19. The device according to claim 12, characterized in that The face exchange module is further used to extract embedded features of the face parts of the source face image; perform face exchange on the face parts in the target face image based on the embedded features to obtain a face exchange intermediate image.
20. The device according to any one of claims 12 to 19, characterized in that The device also includes: The texture enhancement module is used to obtain a texture enhancement model; the texture enhancement model is trained based on an image set that meets the image texture conditions; the facial skin texture in the face swap image is processed by the texture enhancement model to obtain a face swap image with improved facial skin texture.
21. The device according to claim 20, characterized in that The texture enhancement module is also used to segment a facial area image from the face exchange image; input the facial area image into the texture enhancement model to perform facial skin texture processing to obtain a facial area image with improved facial skin texture; and fit the facial area image with improved facial skin texture back into the face exchange image to obtain a face exchange image with improved facial skin texture.
22. The device according to claim 20, characterized in that The device also includes: The texture end judgment module is used to process the facial skin texture in the face swap image after the facial skin texture is improved through the texture improvement model when the face swap image after the facial skin texture is improved does not meet the texture improvement end judgment condition, so as to obtain the face swap image after repeated texture improvement.
23. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 11 are implemented.
24. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 11 are implemented.
25. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 11 are implemented.
Citation Information
Patent Citations
Face image processing method and device, electronic equipment and storage medium
CN111368796A
Image face changing processing method and device, electronic equipment and storage medium
CN115423677A