Face image processing method and device, computer equipment and storage medium

By combining a dual-branch feature encoder and an attention field generator, and utilizing a diffusion model with cross-attention injection, the problem of balancing high-resolution details and semantic consistency in traditional face replacement technology is solved, generating high-quality, high-fidelity face replacement images.

CN120833416APending Publication Date: 2025-10-24PING AN TECH (SHENZHEN) CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510697571.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-27
Publication Date
2025-10-24

AI Technical Summary

Technical Problem

Traditional face replacement technology struggles to balance high-resolution details and semantic consistency when processing fine-grained features, resulting in low-quality face replacement images that cannot meet the high-fidelity requirements of fields such as finance and healthcare.

Method used

A dual-branch feature encoder is used for multi-scale feature extraction, an attention field generator is used to generate attention maps, and a diffusion model with cross-attention injection is used for image generation to ensure the consistency between global structure and local details.

Benefits of technology

It improves the generation quality and consistency of face replacement images, making the generated face replacement images more natural and realistic, meeting the high fidelity requirements of fields such as finance and medicine.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120833416A_ABST
    Figure CN120833416A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of artificial intelligence, and relates to a face image processing method and device, computer equipment and a storage medium, and the method comprises the steps: obtaining a source face image and a target face image; performing multi-scale feature extraction on the source face image and the target face image based on a double-branch feature encoder to obtain corresponding source features and target features; processing the source features and the target features based on an attention field generator to generate an attention map; performing cross-attention injection processing on a preset diffusion model based on the attention map to obtain a target diffusion model; performing image generation processing corresponding to the attention map based on a target diffusion model to obtain a face replacement image; and performing output processing on the face replacement image. In addition, the invention also relates to a block chain technology, and the face replacement image can be stored in a block chain. The method and the device can be applied to face replacement scenes in the financial field and the medical field, and the quality of the generated face replacement image is effectively improved through the method and the device.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of artificial intelligence, and can be applied to the fields of financial technology, digital medical treatment, etc., and particularly relates to a face image processing method and device, a computer device and a storage medium. BACKGROUND

[0002] In traditional image generation and editing technology, diffusion models, especially the reverse diffusion process based on the U-Net architecture, have shown excellent performance in overall image quality reconstruction, but when dealing with fine-grained features (such as the eyes and mouth of a face), they often face the challenge of being unable to balance high-resolution details and semantic consistency. Specifically, in the face replacement task in an unconstrained scenario, traditional methods are easily affected by background interference or feature misplacement, resulting in blurred, artifacted, and other problems in the generated results, making it difficult to maintain high fidelity, and thus making the generated face replacement images perform poorly in terms of realism and naturalness, with overall low quality. This technical bottleneck seriously limits the application effect of face replacement technology in many fields, such as film and television entertainment, security monitoring, social media, etc.

[0003] For example, in the remote identity verification scene in the financial field, face replacement technology is often used to protect customer privacy or simulate test scenarios. However, in the face replacement process, traditional methods cannot effectively handle fine-grained features and maintain high-resolution details, resulting in low-quality verification images that are difficult to meet the strict requirements of the financial industry for identity verification accuracy and security. This not only increases the operational risk of financial institutions, but also affects customer experience and trust.

[0004] Therefore, it is urgent to provide an improved face replacement technology to effectively deal with background interference and feature misplacement in an unconstrained scenario while maintaining high-resolution details and semantic consistency, thereby generating high-quality, high-fidelity face replacement images, meeting the stringent demands of various fields for image realism and naturalness, and improving the efficiency and reliability of related applications. SUMMARY

[0005] The purpose of the embodiments of the present application is to provide a face image processing method, device, computer device and storage medium to solve the technical problem that face replacement images generated by using existing face replacement technology perform poorly in terms of realism and naturalness and have low quality.

[0006] In a first aspect, a face image processing method is provided, comprising:

[0007] obtaining an input source face image and a target face image;

[0008] perform multi-scale feature extraction on the source face image and the target face image respectively based on a preset double-branch feature encoder, to obtain source features corresponding to the source face image and target features corresponding to the target face image;

[0009] perform processing on the source features and the target features based on a preset attention field generator, to generate a corresponding attention map;

[0010] perform cross-attention injection processing on a preset diffusion model based on the attention map, to obtain a corresponding target diffusion model;

[0011] perform image generation processing corresponding to the attention map based on the target diffusion model, to obtain an output face replacement image;

[0012] perform output processing on the face replacement image.

[0013] In a second aspect, a face image processing apparatus is provided, comprising:

[0014] a first acquisition module configured to acquire an input source face image and a target face image;

[0015] an extraction module configured to perform multi-scale feature extraction on the source face image and the target face image respectively based on a preset double-branch feature encoder, to obtain source features corresponding to the source face image and target features corresponding to the target face image;

[0016] a first processing module configured to perform processing on the source features and the target features based on a preset attention field generator, to generate a corresponding attention map;

[0017] a second processing module configured to perform cross-attention injection processing on a preset diffusion model based on the attention map, to obtain a corresponding target diffusion model;

[0018] a generation module configured to perform image generation processing corresponding to the attention map based on the target diffusion model, to obtain an output face replacement image;

[0019] an output module configured to perform output processing on the face replacement image.

[0020] In a third aspect, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the face image processing method when executing the computer program.

[0021] In a fourth aspect, a computer readable storage medium is provided, which stores a computer program, wherein the computer program is executable on a processor to implement the steps of the face image processing method.

[0022] In the scheme implemented by the face image processing method, the face image processing device, the computer device, and the storage medium, first, the input source face image and the target face image are obtained. Then, based on the preset double-branch feature encoder, multi-scale feature extraction is performed on the source face image and the target face image respectively, to obtain source features corresponding to the source face image and target features corresponding to the target face image. Subsequently, based on the preset attention field generator, the source features and the target features are processed to generate corresponding attention maps. Then, based on the attention maps, cross-attention injection processing is performed on the preset diffusion model to obtain a target diffusion model. Further, based on the target diffusion model, image generation processing corresponding to the attention maps is performed to obtain an output face replacement image. Finally, the face replacement image is output. After obtaining the input source face image and the target face image, the source face image and the target face image are processed by using the double-branch feature encoder to obtain the source features corresponding to the source face image and the target features corresponding to the target face image. Then, based on the use of the attention field generator, the source features and the target features are processed to generate corresponding attention maps. Based on the use of the attention maps, cross-attention injection processing is performed on the diffusion model to obtain the target diffusion model. Further, based on the use of the target diffusion model, image generation processing corresponding to the attention maps is performed to obtain the output face replacement image. Finally, the face replacement image is output. By using the double-branch feature encoder and the attention field generator, the source face image and the target face image are processed to generate corresponding attention maps. Then, the attention maps are injected into the diffusion model to obtain the target diffusion model, so that the model can dynamically adjust the preservation and fusion of features during image generation, ensuring the consistency from the global structure to the local details, thereby effectively improving the consistency of the generated image, making the generated face replacement image more natural and realistic, and further improving the quality of the generated face replacement image. BRIEF DESCRIPTION OF DRAWINGS

[0023] In order to more clearly illustrate the schemes in the present application, the drawings needed in the embodiments of the present application will be briefly introduced as follows. Obviously, the drawings in the following description are some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without creative labor.

[0024] Figure 1 is an exemplary system architecture diagram to which the present application can be applied;

[0025] Figure 2 is a flowchart of one embodiment of the face image processing method according to the present application;

[0026] Figure 3 is a structural schematic diagram of one embodiment of a face image processing device according to the present application;

[0027] Figure 4 is a structural schematic diagram of one embodiment of a computer device according to the present application. DETAILED DESCRIPTION

[0028] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs; the terminology used in the description herein is for describing particular embodiments only and is not intended to be limiting of the application; the description herein and the claims of the application and the above description of the drawings herein, the terms "comprising", "having" and "including" and any variations thereof are intended to cover without limitation the inclusion of the stated features, elements, components or steps. The terms "first", "second", and the like, as used herein do not have their ordinary meaning, but are used only to distinguish one element from another.

[0029] Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase "in an embodiment" in various places in the specification are not necessarily all referring to the same embodiment, nor are they necessarily all directed to the same embodiment, or to a single alternative embodiment. It is explicitly contemplated that embodiments described herein can be combined with each other.

[0030] In order to make the technical personnel in the art better understand the scheme of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings.

[0031] As shown in Figure 1 The system architecture 100 can include a terminal device 101, a network 102 and a server 103, and the terminal device 101 can be a notebook computer 1011, a tablet computer 1012 or a mobile phone 1013. The network 102 is a medium for providing a communication link between the terminal device 101 and the server 103. The network 102 can include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0032] A user can use the terminal device 101 to interact with the server 103 through the network 102 to receive or send messages, etc. Various communication client applications can be installed on the terminal device 101, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0033] The terminal device 101 can be various electronic devices with a display screen and supporting web browsing, in addition to the notebook computer 1011, the tablet computer 1012 or the mobile phone 1013, the terminal device 101 can also be an electronic book reader, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 player (Moving Picture Experts Group Audio Layer IV), a laptop computer and a desktop computer, etc.

[0034] The server 103 can be a server providing various services, for example, a background server providing support for a page displayed on the terminal device 101.

[0035] It should be noted that the face image processing method provided by the embodiments of the present application is generally executed by a server / terminal device, and accordingly, the face image processing apparatus is generally arranged in a server / terminal device.

[0036] It should be understood that Figure 1 The number of terminal devices, networks and servers in

[0037] With reference to Figure 2 , a flow chart of one embodiment of the face image processing method according to the present application is shown. The order of the steps in the flow chart can be changed according to different needs, and some steps can be omitted. The face image processing method provided by the embodiments of the present application can be applied to any scene requiring face image processing, and then the face image processing method can be applied to products in these scenes, for example, face replacement scenes in the financial field and the medical field. The face image processing method comprises the following steps:

[0038] In step S201, an input source face image and a target face image are acquired.

[0039] In the present embodiment, the electronic device (for example Figure 1The server / terminal device shown) can obtain the input source face image and target face image through wired connection or wireless connection. It should be noted that the wireless connection can include but is not limited to 3G / 4G / 5G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection, and other now known or future developed wireless connection methods. The execution subject of the present application is a face processing system, which can be referred to as a system. The core of the system is to combine dynamic attention mechanism with diffusion model, and to realize high-fidelity face synthesis through attention-guided feature modulation. This method breaks through the limitations of traditional face replacement technology in detail preservation and semantic consistency, and is particularly suitable for high-resolution image processing in unconstrained scenarios. The system architecture includes three main modules: 1. Double-branch feature encoder: adopt Vision Transformer (ViT) structure, respectively process source face image and target face image, extract multi-scale feature representation. The two branches share part of the network parameters to improve the calculation efficiency. 2. Attention field generator: receive features from double encoder as input, generate spatial adaptive attention map through lightweight convolutional network. These attention maps can dynamically identify and emphasize the facial feature areas that need to be preserved. 3. Attention-modulated diffusion model: diffusion model based on U-Net architecture, integrates attention map information in the process of reverse denoising, realizes selective preservation and fusion of features through cross-attention mechanism. The three modules work together to form a complete processing flow: first extract features through double encoder, then generate attention map, and finally realize attention-guided face synthesis in the diffusion process. The system supports end-to-end training and inference, and can handle high-resolution face replacement tasks in various complex scenarios.

[0040] The present application can be applied to face replacement scenarios in the financial field and the medical field. The goal of the present application is to replace the face in the source face image on the face of the corresponding character in the target face image. For example, in the financial field, the face replacement scenario can be privacy protection in the insurance claim process. The source face image includes: scene description: when processing insurance claims, the insurance company may need to verify the identity of the insured person or the photos of the accident scene. For example, after a car accident, the owner takes a photo of the scene containing his own face and the damaged vehicle. Image content: the photo contains the face of the owner and the damage of the accident vehicle. The target face image includes: scene description: in order to protect the privacy of the owner, the insurance company hopes to replace the face of the owner with an anonymized face when processing internally or displaying externally. Image content: replace the owner's face in the original photo with an anonymized face image (such as a virtual character or a general face model). Application purpose: protect the privacy of the owner and avoid the leakage of personal information. Ensure the anonymity of the image when auditing internally or displaying externally.

[0041] In the medical field, the face replacement scenario can be privacy protection in medical education or surgical simulation. The source face image includes: scene description: in medical education, teachers may want to use real surgical videos or patient photos to demonstrate surgical procedures or disease symptoms. However, these images may contain patient facial information and need to protect privacy. Image content: the surgical video or photo contains the patient's face and the surgical site. The target face image includes: scene description: in order to protect the privacy of patients in medical education, teachers hope to replace the patient's face with an anonymized face. Image content: replace the patient's face in the original video or photo with an anonymized face image (such as a virtual character or a general face model). Application purpose: protect the privacy of patients and avoid the leakage of personal information in medical education. Use anonymized images for demonstration and training without affecting teaching effectiveness.

[0042] Step S202, based on a preset double-branch feature encoder, multi-scale feature extraction is performed on the source face image and the target face image respectively, to obtain source features corresponding to the source face image and target features corresponding to the target face image.

[0043] In the present embodiment, the above-mentioned double-branch feature encoder adopts a hierarchical ViT architecture to process the source face image I s and the target face image I t respectively. For each input image, the encoder outputs L levels of feature maps:

[0044]

[0045] wherein l∈{1,...,L} represents the feature level. is the feature map of the first layer, H l , W l , C l respectively represent the height, width and channel number of the feature map of the layer. The two encoders share low layer parameters to extract general features, and high layer parameters are independent to retain respective identity features.

[0046] In addition, the specific construction process of the above-mentioned double-branch feature encoder will be further described in detail in subsequent specific embodiments, and will not be described too much here.

[0047] Step S203, the source feature and the target feature are processed based on the preset attention field generator to generate a corresponding attention map.

[0048] In the embodiment, the specific implementation process of the above-mentioned processing of the source feature and the target feature based on the preset attention field generator to generate a corresponding attention map will be further described in detail in subsequent specific embodiments, and will not be described too much here.

[0049] Step S204, the preset diffusion model is processed based on the attention map to obtain a corresponding target diffusion model.

[0050] In the embodiment, the specific implementation process of the above-mentioned processing of the preset diffusion model based on the attention map to obtain a corresponding target diffusion model will be further described in detail in subsequent specific embodiments, and will not be described too much here.

[0051] Step S205, the image corresponding to the attention map is generated based on the target diffusion model to obtain an output face replacement image.

[0052] In the embodiment, the specific implementation process of the above-mentioned processing of the image corresponding to the attention map based on the target diffusion model to obtain an output face replacement image will be further described in detail in subsequent specific embodiments, and will not be described too much here.

[0053] Step S206, the face replacement image is output.

[0054] In the embodiment, the specific implementation process of the above-mentioned output processing of the face replacement image will be further described in detail in subsequent specific embodiments, and will not be described too much here.

[0055] The application first acquires an input source face image and a target face image; then performs multi-scale feature extraction on the source face image and the target face image based on a preset double-branch feature encoder respectively, to obtain source features corresponding to the source face image and target features corresponding to the target face image; then processes the source features and the target features based on a preset attention field generator to generate corresponding attention maps; subsequently performs cross-attention injection processing on a preset diffusion model based on the attention maps to obtain a corresponding target diffusion model; further performs image generation processing corresponding to the attention maps based on the target diffusion model to obtain an output face replacement image; and finally performs output processing on the face replacement image. After acquiring the input source face image and the target face image, the application uses the double-branch feature encoder to perform multi-scale feature extraction on the source face image and the target face image respectively to obtain the source features corresponding to the source face image and the target features corresponding to the target face image, then uses the attention field generator to process the source features and the target features to generate corresponding attention maps, and uses the attention maps to perform cross-attention injection processing on the diffusion model to obtain the target diffusion model, and then uses the target diffusion model to perform image generation processing corresponding to the attention maps to obtain the output face replacement image, and finally performs output processing on the face replacement image. By using the double-branch feature encoder and the attention field generator to process the source face image and the target face image to generate corresponding attention maps, and then injecting the attention maps into the diffusion model to obtain the target diffusion model, the model can dynamically adjust the preservation and fusion of features during image generation, ensuring the consistency from the global structure to the local details, effectively improving the consistency of the generated image, making the generated face replacement image more natural and realistic, and thus improving the quality of the generated face replacement image.

[0056] In some optional implementations, step S203 includes the following steps:

[0057] Based on the attention field generator, performing corresponding concatenation operation on the source features and the target features to obtain concatenated features.

[0058] In this embodiment, the attention field generator receives the features (source features and target features) from the double-branch feature encoder as input, and generates the attention map through the following steps:

[0059] Feature concatenation and projection:

[0060]

[0061] wherein Concat represents the concatenation operation along the channel dimension, and Linear is a linear projection layer that maps the concatenated features to a unified dimension.

[0062] Attention map generation:

[0063]

[0064] where, here, ConvBlock consists of two 3x3 convolutional layers and ReLU activation functions, and σ represents a Sigmoid function that normalizes the output to the range [0, 1]. The generated attention map is the same size as the feature map of the corresponding level.

[0065] Specifically, at each level, the corresponding level features of the source image and the target image are spliced along the channel dimension to obtain spliced features, i.e., spliced features.

[0066] The spliced features are projected based on a preset linear projection layer to obtain corresponding first features.

[0067] In this embodiment, the spliced features (i.e., spliced features) can be mapped to a unified dimension by a linear projection layer to obtain projected features, i.e., the above-mentioned first features.

[0068] The first features are spatial feature extracted based on a preset convolutional block to obtain corresponding second features.

[0069] In this embodiment, the above-mentioned convolutional block refers to a convolutional block consisting of two 3x3 convolutional layers and ReLU activation functions. The spatial features can be extracted by inputting the projected features, i.e., the first features, into the above-mentioned convolutional block to obtain the corresponding second features.

[0070] The second features are normalized based on a preset target function to obtain corresponding feature data.

[0071] In this embodiment, the above-mentioned target function is specifically a Sigmoid function. The output of the above-mentioned convolutional block (i.e., the second features) can be normalized to the range [0, 1] by using the Sigmoid function to generate an attention map A l . For example, for the eye region, the attention map gives a higher weight, indicating that these regions are features that need to be highlighted and fused.

[0072] The feature data is taken as an attention map corresponding to the source features and the target features.

[0073] The source feature and the target feature are spliced based on the attention field generator to obtain spliced features; then the spliced features are projected based on a preset linear projection layer to obtain corresponding first features; then spatial feature extraction is performed on the first features based on a preset convolution block to obtain corresponding second features; subsequently, the second features are normalized based on a preset target function to obtain corresponding feature data; finally, the feature data is taken as an attention map corresponding to the source feature and the target feature. Through the use of the attention field generator, the source feature and the target feature are spliced to obtain spliced features, then the spliced features are projected based on the use of the linear projection layer to obtain first features, then the first features are spatially feature-extracted based on the use of the convolution block to obtain second features, and subsequently, the second features are normalized based on the use of the target function, so that an attention map corresponding to the source feature and the target feature can be efficiently and accurately generated, and the accuracy of the generated attention map is ensured.

[0074] In some optional implementations of the embodiment, step S204 includes the following steps:

[0075] A preset diffusion model is called.

[0076] In the embodiment, the diffusion model can be specifically a diffusion model based on a U-Net architecture, such as DDPM, DDIM, Stable Diffusion, etc. The U-Net is a classic convolutional neural network architecture, which is widely used in diffusion models as the core network for noise prediction. The basic structure of the U-Net includes a contraction path and a symmetric expansion path. The contraction path captures context information through multiple downsampling operations, while the expansion path combines low-level features and high-level features through upsampling operations to achieve accurate pixel-level segmentation. This U-shaped structure design enables efficient use of limited labeled samples and fast execution on modern GPUs.

[0077] A preset injection strategy is obtained.

[0078] In the embodiment, the strategy content of the injection strategy includes: at each resolution level l of the U-Net, the attention map A l is injected into the skip connection and the intermediate feature:

[0079]

[0080] wherein, is the intermediate feature of the lth layer of the U-Net, is the skip connection feature of the corresponding level, and represents element-wise multiplication.

[0081] Based on the injection strategy, the attention map is injected into the skip connection features and intermediate features of the corresponding level of the diffusion model to obtain a processed diffusion model.

[0082] In this embodiment, based on the policy content of the injection strategy, the attention map is injected into the skip connection features and intermediate features of the corresponding level of the diffusion model, and the obtained processed diffusion model is taken as the required target diffusion model to complete the process of introducing the attention modulation mechanism into the diffusion model.

[0083] The processed diffusion model is taken as the target diffusion model.

[0084] In this embodiment, by introducing the attention modulation mechanism into the diffusion model, the target diffusion model obtained can dynamically adjust the retention degree of different region features and enhance the performance of key regions. For example, in the region that needs to retain the features of the source image (such as expression and posture), the value of the attention map is higher, and the model will emphasize the features of the source image more; and in the region that needs to fuse the features of the target image (such as clear facial details), the value of the attention map is lower, and the model will emphasize the features of the target image more.

[0085] The present application calls a preset diffusion model, then acquires a preset injection strategy, and then based on the injection strategy, the attention map is injected into the skip connection features and intermediate features of the corresponding level of the diffusion model to obtain a processed diffusion model. The present application takes the processed diffusion model as the target diffusion model. By using the injection strategy, the present application injects the attention map into the skip connection features and intermediate features of the corresponding level of the diffusion model, thereby efficiently and accurately completing the cross-attention injection process of the diffusion model, and further enabling the target diffusion model to dynamically adjust the retention and fusion of features in the image generation process, thereby retaining the expressions and postures of the characters in the source image while fusing the clear facial details in the target image. This attention modulation mechanism effectively improves the quality and consistency of the generated image, making the generated face replacement image more natural and realistic.

[0086] In some optional implementations, step S205 includes the following steps:

[0087] Based on the target diffusion model, an initialization process is performed to obtain a corresponding initial image.

[0088] In this embodiment, after the attention modulation mechanism is introduced into the diffusion model, the attention map is injected into the target diffusion model to guide the selective retention and fusion of features. Next, the target diffusion model will complete the accurate face replacement process matching the source face image and the target face image according to the reverse diffusion process and generate a high-quality face replacement image.

[0089] The reverse diffusion process includes: the reverse diffusion process is a step-by-step denoising process, starting from a completely random noise image, gradually removing noise to generate a target image. This process is divided into multiple time steps t, from T to 1, and the image is gradually optimized. The specific process is as follows:

[0090] 1. Initialization. Initially, the initial image is a completely random noise image x t , which contains a large amount of noise and almost no identifiable features.

[0091] 2. Step-by-step denoising. At each time step t, the target diffusion model (which can be referred to as the model) predicts noise ∈ θ (x t ,t,a) according to the current noise image x t and the set of attention maps. θ After predicting the noise, the model updates the image using the following formula:

[0092]

[0093] where ∈ θ is a noise prediction network that includes an attention modulation mechanism, a represents the set of attention maps of all levels, α t and are diffusion scheduling parameters, σ t is a noise scale, and z is a standard Gaussian noise.

[0094] 3. Role of the attention modulation mechanism. When predicting noise ∈ θ (x t ,t,A), the model uses the set of attention maps A of all levels to guide the prediction of noise. The attention map guides the model to selectively adjust the noise in different spatial regions. For example: in regions where source image features need to be preserved (such as expressions and poses), the attention map has a higher value, and the model will reduce the prediction of noise in these regions, thereby preserving more source image features. In regions where target image features need to be fused (such as clear facial details), the attention map has a lower value, and the model will increase the prediction of noise in these regions, thereby fusing more target image features.

[0095] 4. Iterative optimization. Repeat the above process to gradually remove noise and generate an image. After multiple iterations, the model will generate a high-quality face replacement image that preserves the expressions and poses of the source face image and fuses clear facial details from the target face image.

[0096] Obtain a preset update formula.

[0097] In this embodiment, the above update formula can refer to the formula described above.

[0098] Based on the attention map and the initial image, corresponding denoising processing is performed using the update formula to obtain a processing image meeting preset requirements.

[0099] In the embodiment, the processing procedure of obtaining the processing image meeting the preset requirements based on the attention map and the initial image using the update formula can refer to the processing procedure of the reverse diffusion process, which will not be described in detail here.

[0100] The processing image is taken as the face replacement image.

[0101] The application obtains an initial image by performing initialization processing based on the target diffusion model, then obtains a preset update formula, then performs corresponding denoising processing based on the attention map and the initial image using the update formula to obtain a processing image meeting preset requirements, and finally takes the processing image as the face replacement image. The application obtains an initial image by performing initialization processing based on the target diffusion model, then performs corresponding denoising processing based on the attention map and the initial image using the update formula to obtain a processing image meeting preset requirements and taking the processing image as the final face replacement image. Through the image generation processing corresponding to the attention map realized by the target diffusion model that has undergone cross-attention injection processing, the model starts from a completely random noise image, gradually removes noise, and generates a target image. At each time step, the attention modulation mechanism guides the model to selectively adjust the noise in different spatial regions, thereby realizing accurate face replacement. The finally generated image not only retains the features of the source image but also fuses the details of the target image, achieving a high-quality face replacement effect, effectively improving the realism and naturalness of the generated face replacement image.

[0102] In some optional implementations, step S206 includes the following steps:

[0103] Based on a preset image optimization strategy, the face replacement image is optimized to obtain a corresponding target face replacement image.

[0104] In the embodiment, the specific implementation process of obtaining the target face replacement image based on the preset image optimization strategy will be further described in detail in subsequent specific embodiments, and will not be described in detail here.

[0105] The target face replacement image is quality evaluated to obtain a corresponding quality evaluation result.

[0106] In the embodiment, a suitable image quality evaluation index can be selected according to actual evaluation requirements, such as using PSNR (peak signal-to-noise ratio), SSIM (structural similarity index), and the like for objective evaluation. Then the generated target face replacement image is input into the selected evaluation index to calculate a quality score, and a quality evaluation result of the target face replacement image is generated based on the obtained quality score. If the quality score is detected to be greater than or equal to a preset score threshold, it is determined that the target face replacement image passes the quality evaluation, and a quality evaluation result that passes the quality evaluation is generated. If the quality score is detected to be less than the score threshold, it is determined that the target face replacement image fails the quality evaluation, and a quality evaluation result that fails the quality evaluation is generated. The value of the score threshold is not specifically limited, and can be determined according to actual business requirements.

[0107] If the quality evaluation result passes the quality evaluation, a preset image output mode is obtained.

[0108] In the embodiment, the selection of the image output mode is not specifically limited, and can be determined according to actual requirements of a user. For example, any one of the following modes can be used: email sending, interface display, message sending, and the like. The user is a specified person who inputs the source face image and the target face image.

[0109] Based on the image output mode, the target face replacement image is output processed.

[0110] In the embodiment, the target face replacement image can be sent to the user according to the selected image output mode, so as to complete the output processing of the target face replacement image.

[0111] In the embodiment, the target face replacement image is obtained by optimizing the face replacement image based on a preset image optimization strategy. Then the target face replacement image is quality evaluated to obtain a corresponding quality evaluation result. If the quality evaluation result passes the quality evaluation, a preset image output mode is obtained. Subsequently, the target face replacement image is output processed based on the image output mode. After the face replacement image is generated based on the use of the target diffusion model, the face replacement image is also automatically optimized based on the use of the image optimization strategy, so as to improve the quality and naturalness of the generated target face replacement image. Then the target face replacement image is intelligently quality evaluated, and when it is detected that the obtained quality evaluation result passes the quality evaluation, the target face replacement image is output processed based on the obtained image output mode, so as to effectively ensure the accuracy and quality of the output target face replacement image, and further improve the user experience.

[0112] In some optional implementations of the embodiment, step S203 includes the following steps:

[0113] The face replacement image is subjected to detail enhancement processing to obtain a corresponding first face image.

[0114] In the embodiment, the target of the above-mentioned detail enhancement processing is to enhance facial details such as texture and micro-expression. The processing method includes: using a local contrast enhancement technique such as adaptive histogram equalization (CLAHE) to enhance the contrast in local regions of the image to highlight details. Using a model such as ESRGAN (Enhanced Super-Resolution Generative Adversarial Networks), learn the mapping from low resolution to high resolution by training the model to enhance the details and texture of the image. The specific implementation process includes: selecting a suitable detail enhancement algorithm or pre-trained deep learning model; input the generated face replacement image into the algorithm or model; adjust the parameters (such as enhancement intensity) of the algorithm or model to achieve the desired detail enhancement effect; output the enhanced image, observe and evaluate whether the details are clear and natural.

[0115] The first face image is subjected to edge enhancement processing to obtain a corresponding second face image.

[0116] In the embodiment, the target of the above-mentioned edge enhancement processing is to make the facial contour and edge clearer. The processing method includes: using an algorithm such as Canny edge detection to detect the edges in the image. Improve the clarity of the image by enhancing the detected edges, for example, using an image sharpening filter. The specific implementation process includes: using the Canny edge detection algorithm to perform edge detection on the image to obtain an edge map; performing enhancement processing on the edge map, such as enhancing the contrast of the edges through a filter; combining the enhanced edge map with the original image to adjust the intensity and clarity of the edges; output the edge-enhanced image to ensure that the facial contour and details are clearer.

[0117] The second face image is subjected to image inpainting processing to obtain a corresponding third face image.

[0118] In this embodiment, the target of the above image inpainting processing is to repair the artifacts or unnatural regions that may exist in the generated image. The processing method includes: a deep learning-based image inpainting model: using a GAN-based inpainting model such as Context Encoders or EdgeConnect, learning how to repair missing or damaged image regions by training the model. The specific implementation process includes: identifying the regions in the image that need to be repaired (such as artifacts or unnatural parts); using a pre-trained image inpainting model to repair the identified regions; adjusting the parameters of the model to ensure that the repaired regions are naturally integrated with the surrounding image; outputting the repaired image and checking whether the repair effect meets the expectations.

[0119] Performing style adjustment processing on the third face image to obtain a corresponding fourth face image.

[0120] In this embodiment, the target of the above style adjustment processing is to make the style of the generated image consistent with that of the target image. The processing method includes: using techniques such as AdaIN (Adaptive Instance Normalization) or CycleGAN (Cycle-Consistent Adversarial Networks) to transfer the style of the target image to the generated image. The specific implementation process includes: extracting the style features (such as color, texture, etc.) of the target image; using a style transfer model (such as AdaIN or CycleGAN) to apply the extracted style features to the generated image; adjusting the model parameters to ensure that the style-transferred image is visually consistent with the target image; outputting the style-transferred image and evaluating whether the style is consistent.

[0121] Replacing the fourth face image as the target face replacement image.

[0122] The present application obtains a corresponding first face image by performing detail enhancement processing on the face replacement image; then performs edge enhancement processing on the first face image to obtain a corresponding second face image; then performs image inpainting processing on the second face image to obtain a corresponding third face image; subsequently performs style adjustment processing on the third face image to obtain a corresponding fourth face image; finally replaces the fourth face image as the target face replacement image. The present application performs detail enhancement processing, edge enhancement processing, image inpainting processing, and style adjustment processing on the face replacement image, thereby automatically and intelligently completing the optimization processing of the face replacement image, and further significantly improving the quality and naturalness of the generated target face replacement image, making it more suitable for actual application scenarios.

[0123] In some optional implementations of the embodiment, before step S202, the electronic device can further perform the following steps:

[0124] The preset first initial encoder and the second initial encoder are called.

[0125] In the embodiment, the first initial encoder and the second initial encoder can specifically be two independent Vision Transformer (ViT) encoders.

[0126] A preset parameter setting strategy is obtained.

[0127] In the embodiment, the parameter setting strategy includes setting low-layer parameters of the two encoders to extract common features and setting high-layer parameters to be independent to retain respective identity features. That is, the low-layer parameters of the two encoders are shared to extract common features, such as the basic outline of a face, the approximate positions of facial features, and the like. The high-layer parameters of the two encoders are independent to retain unique identity features of the person in the respective images, such as hairstyle, eye shape, and the like.

[0128] Based on the parameter setting strategy, the first initial encoder and the second initial encoder are subjected to shared processing of low-layer parameters and independent configuration processing of high-layer parameters to obtain corresponding first generated encoders and second generated encoders.

[0129] In the embodiment, the first initial encoder and the second initial encoder can be subjected to shared processing of low-layer parameters and independent configuration processing of high-layer parameters based on the parameter setting strategy to obtain corresponding first generated encoders and second generated encoders.

[0130] Based on the first generated encoders and the second generated encoders, the dual-branch feature encoder is constructed.

[0131] In the embodiment, the first generated encoders and the second generated encoders can be integrated to obtain a dual-branch feature encoder that shares network parameters of two branches.

[0132] The application calls preset first and second initial encoders, then acquires a preset parameter setting strategy, and then performs low-layer parameter sharing processing and high-layer parameter independent configuration processing on the first and second initial encoders based on the parameter setting strategy, to obtain corresponding first and second generated encoders, and subsequently constructs the double-branch feature encoder based on the first and second generated encoders. The application calls preset first and second initial encoders, and then performs low-layer parameter sharing processing and high-layer parameter independent configuration processing on the first and second initial encoders based on the use of the parameter setting strategy, and further automatically constructs the corresponding double-branch feature encoder based on the obtained first and second generated encoders. Since the two encoders of the double-branch feature encoder share part of the network parameters, the calculation efficiency can be effectively improved when the double-branch feature encoder is used for feature extraction processing subsequently.

[0133] In some optional implementations, the acquired user information seeks user consent and complies with relevant laws and relevant policies.

[0134] In addition, the non-company software tools or components appearing in the embodiments of the application are only examples and do not represent actual use.

[0135] In addition, the core value of the application is embodied in three aspects: 1. Dynamic attention regulation: the attention field generated by autonomous learning realizes precise control of key facial regions without relying on manual annotation or fixed prior knowledge; 2. Multi-scale feature fusion: attention modulation is introduced at multiple levels of the diffusion model to ensure consistency from global structure to local details; 3. End-to-end optimization: the entire system uses a unified training framework to realize full-process optimization from feature extraction to final synthesis.

[0136] The face replacement method of the application has wide application prospects in the fields of film special effects, virtual reality, digital entertainment, etc., in addition to the fields of finance and medicine, and can significantly improve the realism and naturalness of face replacement.

[0137] It should be understood that the size of the serial number of each step in the above embodiments does not mean the order of execution, and the execution order of each process should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the application.

[0138] It should be emphasized that, in order to further ensure the privacy and security of the above face replacement image, the above face replacement image can also be stored in a node of a blockchain.

[0139] The blockchain referred to in the present application is a new application mode of distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm and other computer technologies. The blockchain is essentially a decentralized database, which is a series of data blocks associated using cryptographic methods, each data block containing information of a batch of network transactions, used to verify the validity (anti-fake) of the information and generate the next block. The blockchain can include a blockchain underlying platform, a platform product service layer, and an application service layer.

[0140] Embodiments of the present application can acquire and process related data based on artificial intelligence technology. Artificial intelligence (AI) is the use of digital computers or computer-controlled machines to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0141] Artificial intelligence basic technologies generally include technologies such as sensors, special artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction system, mechatronics, etc. Artificial intelligence software technology mainly includes computer vision technology, robot technology, biometric technology, speech processing technology, natural language processing technology, and machine learning / deep learning, etc.

[0142] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by computer readable instructions instructing related hardware, and the computer readable instructions can be stored in a computer readable storage medium. The program can include the processes of the above-mentioned embodiments when executed, wherein the storage medium can be a non-volatile storage medium such as a magnetic disc, an optical disc, a read-only memory (ROM), or a random access memory (RAM).

[0143] It should be understood that although each step in the flowchart of the accompanying drawings is shown in sequence according to the direction of the arrow, these steps are not necessarily executed in sequence according to the direction of the arrow. Unless otherwise specified herein, the execution of these steps is not strictly limited in sequence, and they can be executed in other orders. Moreover, at least part of the steps in the flowchart of the accompanying drawings can include multiple sub-steps or multiple stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution sequence is not necessarily sequential, but can be executed in rotation or alternation with at least part of other steps or sub-steps or stages of other steps.

[0144] Further reference is made to Figure 3As an implementation of the method shown in the above Figure 2 The present application provides an embodiment of a face image processing device, which corresponds to the method embodiment shown in the above Figure 2 The device can be applied to various electronic devices.

[0145] As shown in the above Figure 3 The face image processing device 300 of the present embodiment comprises a first acquisition module 301, an extraction module 302, a first processing module 303, a second processing module 304, a generation module 305, and an output module 306. Among them:

[0146] The first acquisition module 301 is configured to acquire an input source face image and a target face image.

[0147] The extraction module 302 is configured to perform multi-scale feature extraction on the source face image and the target face image based on a preset double-branch feature encoder, to obtain source features corresponding to the source face image and target features corresponding to the target face image.

[0148] The first processing module 303 is configured to process the source features and the target features based on a preset attention field generator, to generate corresponding attention maps.

[0149] The second processing module 304 is configured to perform cross-attention injection processing on a preset diffusion model based on the attention maps, to obtain a corresponding target diffusion model.

[0150] The generation module 305 is configured to perform image generation processing corresponding to the attention maps based on the target diffusion model, to obtain an output face replacement image.

[0151] The output module 306 is configured to perform output processing on the face replacement image.

[0152] In the present embodiment, the above modules or units are respectively used to perform operations corresponding to the steps of the face image processing method of the foregoing embodiments, which will not be described here.

[0153] In some optional implementations of the present embodiment, the first processing module 303 comprises:

[0154] The splicing sub-module is configured to perform corresponding splicing operations on the source features and the target features based on the attention field generator, to obtain splicing features.

[0155] The projection sub-module is configured to perform projection processing on the splicing features based on a preset linear projection layer, to obtain corresponding first features.

[0156] The extraction submodule is configured to perform spatial feature extraction on the first feature based on a preset convolution block to obtain corresponding second feature.

[0157] The normalization submodule is configured to perform normalization processing on the second feature based on a preset target function to obtain corresponding feature data.

[0158] The first determination submodule is configured to take the feature data as an attention map corresponding to the source feature and the target feature.

[0159] In some optional implementation manners of the embodiment, the second processing module 304 includes:

[0160] The calling submodule is configured to call a preset diffusion model.

[0161] The first acquisition submodule is configured to acquire a preset injection strategy.

[0162] The first processing submodule is configured to inject the attention map into a corresponding level of a skip connection feature and an intermediate feature in the diffusion model based on the injection strategy to obtain a processed diffusion model.

[0163] The second determination submodule is configured to take the processed diffusion model as the target diffusion model.

[0164] In some optional implementation manners of the embodiment, the generation module 305 includes:

[0165] The second processing submodule is configured to perform initialization processing based on the target diffusion model to obtain a corresponding initial image.

[0166] The second acquisition submodule is configured to acquire a preset update formula.

[0167] The third processing submodule is configured to perform corresponding denoising processing on the initial image based on the attention map and the update formula to obtain a processed image meeting a preset requirement.

[0168] The third determination submodule is configured to take the processed image as the face replacement image.

[0169] In some optional implementation manners of the embodiment, the output module 306 includes:

[0170] The optimization submodule is configured to perform optimization processing on the face replacement image based on a preset image optimization strategy to obtain a corresponding target face replacement image.

[0171] The evaluation submodule is configured to perform quality evaluation on the target face replacement image to obtain a corresponding quality evaluation result.

[0172] The third obtaining sub-module is configured to obtain a preset image output mode if the quality evaluation result is passed.

[0173] The output sub-module is configured to perform output processing on the target face replacement image based on the image output mode.

[0174] In some optional implementations of the embodiment, the optimization sub-module includes:

[0175] The first processing unit is configured to perform detail enhancement processing on the face replacement image to obtain a corresponding first face image.

[0176] The second processing unit is configured to perform edge enhancement processing on the first face image to obtain a corresponding second face image.

[0177] The third processing unit is configured to perform image inpainting processing on the second face image to obtain a corresponding third face image.

[0178] The fourth processing unit is configured to perform style adjustment processing on the third face image to obtain a corresponding fourth face image.

[0179] The determination unit is configured to determine the fourth face image as the target face replacement image.

[0180] In some optional implementations of the embodiment, the face image processing apparatus further includes:

[0181] The calling module is configured to call a preset first initial encoder and a second initial encoder.

[0182] The second obtaining module is configured to obtain a preset parameter setting strategy.

[0183] The third processing module is configured to perform sharing processing of low-level parameters and independent configuration processing of high-level parameters on the first initial encoder and the second initial encoder based on the parameter setting strategy to obtain a corresponding first generated encoder and a second generated encoder.

[0184] The construction module is configured to construct the double-branch feature encoder based on the first generated encoder and the second generated encoder.

[0185] To solve the above technical problems, the embodiment of the present application further provides a computer device. For details, please refer to Figure 4 , Figure 4 The basic structure block diagram of the computer device of the embodiment is shown in FIG. 1.

[0186] The computer device 4 includes a memory 41, a processor 42, and a network interface 43, which are communicatively connected via a system bus. It should be noted that only the computer device 4 with components 41-43 is shown in the figure, but it should be understood that not all of the shown components are required to be implemented, and more or fewer components can be alternatively implemented. Among them, those skilled in the art can understand that the computer device herein is a device capable of automatically performing numerical calculation and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (ASICs), field programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.

[0187] The computer device can be a desktop computer, a notebook computer, a palm computer, a cloud server, and the like. The computer device can interact with the user through a keyboard, a mouse, a remote controller, a touchpad, a voice control device, and the like.

[0188] The memory 41 includes at least one type of readable storage medium, including a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., an SD or DX memory, etc.), a random access memory (RAM), a static random access memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, and the like. In some embodiments, the memory 41 can be an internal storage unit of the computer device 4, such as a hard disk or a memory of the computer device 4. In other embodiments, the memory 41 can also be an external storage device of the computer device 4, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, and the like. Of course, the memory 41 can also include both the internal storage unit and the external storage device of the computer device 4. In this embodiment, the memory 41 is generally used to store an operating system and various application software installed in the computer device 4, such as computer readable instructions of the face image processing method, and the like. In addition, the memory 41 can also be used to temporarily store various data that have been output or will be output.

[0189] The processor 42 may be a Central Processing Unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip in some embodiments. The processor 42 is generally used to control the overall operation of the computer device 4. In the present embodiment, the processor 42 is configured to run computer program instructions stored in the memory 41 or process data, for example, computer program instructions of the face image processing method.

[0190] The network interface 43 may include a wireless network interface or a wired network interface, and is generally used to establish a communication connection between the computer device 4 and other electronic devices.

[0191] Compared with the prior art, the present embodiment has the following beneficial effects:

[0192] In the present embodiment, the source face image and the target face image are processed by using the double-branch feature encoder and the attention field generator to generate the corresponding attention map, and then the attention map is injected into the diffusion model to obtain the target diffusion model, so that the model can dynamically adjust the retention and fusion of features during image generation, ensuring the consistency from the global structure to the local details, thereby effectively improving the consistency of the generated image, making the generated face replacement image more natural and realistic, and further improving the quality of the generated face replacement image.

[0193] The present application also provides another implementation, that is, a computer readable storage medium storing computer readable instructions, which can be executed by at least one processor to make the at least one processor execute the steps of the face image processing method as described above.

[0194] Compared with the prior art, the present embodiment has the following beneficial effects:

[0195] In the present embodiment, the source face image and the target face image are processed by using the double-branch feature encoder and the attention field generator to generate the corresponding attention map, and then the attention map is injected into the diffusion model to obtain the target diffusion model, so that the model can dynamically adjust the retention and fusion of features during image generation, ensuring the consistency from the global structure to the local details, thereby effectively improving the consistency of the generated image, making the generated face replacement image more natural and realistic, and further improving the quality of the generated face replacement image.

[0196] Those skilled in the art can clearly understand the above-mentioned embodiment method can be realized by means of software and the necessary general hardware platform, of course, it can also be realized by hardware, but in many cases, the former is a better embodiment. Based on such understanding, the technical solutions of the present application can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes a plurality of instructions for making a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) execute the method described in each embodiment of the present application.

[0197] Obviously, the above-described embodiments are only some of the embodiments of the present application, not all the embodiments, and the drawings show the preferred embodiments of the present application, but do not limit the patent scope of the present application. The present application can be implemented in many different forms, and conversely, the purpose of providing these embodiments is to make the disclosure of the present application more thorough and comprehensive. Although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions recorded in the foregoing specific embodiments, or make equivalent replacements to some of the technical features. Any equivalent structure made by using the content of the specification and drawings, directly or indirectly applied to other related technical fields, is also within the scope of the patent protection of the present application.

Claims

1. A method for processing a face image, characterized by, The method comprises the following steps: obtaining an input source face image and a target face image; performing multi-scale feature extraction on the source face image and the target face image based on a preset double-branch feature encoder to obtain source features corresponding to the source face image and target features corresponding to the target face image; processing the source features and the target features based on a preset attention field generator to generate corresponding attention maps; performing cross-attention injection processing on a preset diffusion model based on the attention maps to obtain a corresponding target diffusion model; performing image generation processing corresponding to the attention maps based on the target diffusion model to obtain an output face replacement image; outputting the face replacement image.

2. The method of claim 1, wherein, The step of processing the source features and the target features based on the preset attention field generator to generate corresponding attention maps specifically comprises: performing corresponding splicing operations on the source features and the target features based on the attention field generator to obtain spliced features; performing projection processing on the spliced features based on a preset linear projection layer to obtain corresponding first features; performing spatial feature extraction on the first features based on a preset convolution block to obtain corresponding second features; performing normalization processing on the second features based on a preset objective function to obtain corresponding feature data; using the feature data as the attention maps corresponding to the source features and the target features.

3. The method of claim 1, wherein, The step of performing cross-attention injection processing on a preset diffusion model based on the attention maps to obtain a corresponding target diffusion model specifically comprises: calling a preset diffusion model; obtaining a preset injection strategy; injecting the attention maps into the skip-connection features and intermediate features of the corresponding levels of the diffusion model based on the injection strategy to obtain a processed diffusion model; using the processed diffusion model as the target diffusion model.

4. The method of claim 1, wherein, The step of performing image generation processing corresponding to the attention maps based on the target diffusion model to obtain an output face replacement image specifically comprises: performing initialization processing based on the target diffusion model to obtain a corresponding initial image; obtaining a preset update formula; performing corresponding denoising processing using the update formula based on the attention maps and the initial image to obtain a processed image meeting preset requirements; using the processed image as the face replacement image.

5. The method of claim 1, wherein, The step of outputting the face replacement image specifically comprises: performing optimization processing on the face replacement image based on a preset image optimization strategy to obtain a corresponding target face replacement image; performing quality assessment on the target face replacement image to obtain a corresponding quality assessment result; if the quality assessment result passes the quality assessment, obtaining a preset image output mode; performing output processing on the target face replacement image based on the image output mode.

6. The method of claim 5, wherein, The step of performing optimization processing on the face replacement image based on a preset image optimization strategy to obtain a corresponding target face replacement image specifically comprises: Performing detail enhancement processing on the face replacement image to obtain a corresponding first face image; Performing edge enhancement processing on the first facial image to obtain a corresponding second facial image; performing image restoration processing on the second facial image to obtain a corresponding third facial image; performing style adjustment processing on the third facial image to obtain a corresponding fourth facial image; The fourth face image is used as the target face replacement image.

7. The method of claim 1, wherein, Before the step of performing multi-scale feature extraction on the source face image and the target face image based on the preset dual-branch feature encoder to obtain source features corresponding to the source face image and target features corresponding to the target face image, the method further includes: Calling the preset first initial encoder and second initial encoder; Get the preset parameter setting strategy; performing a sharing process of low-layer parameters and an independent configuration process of high-layer parameters on the first initial encoder and the second initial encoder based on the parameter setting strategy to obtain a corresponding first generated encoder and a corresponding second generated encoder; The dual-branch feature encoder is constructed based on the first generative encoder and the second generative encoder.

8. An apparatus for processing a face image, characterized by comprising: include: A first acquisition module is used to acquire an input source face image and a target face image; an extraction module, configured to perform multi-scale feature extraction on the source face image and the target face image based on a preset dual-branch feature encoder, to obtain source features corresponding to the source face image and target features corresponding to the target face image; A first processing module is configured to process the source features and the target features based on a preset attention field generator to generate a corresponding attention map; A second processing module is configured to perform cross-attention injection processing on a preset diffusion model based on the attention map to obtain a corresponding target diffusion model; A generation module, configured to perform image generation processing corresponding to the attention map based on the target diffusion model to obtain an output face replacement image; An output module is used to output the face replacement image.

9. A computer device, comprising: The method comprises a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the facial image processing method according to any one of claims 1 to 7 when executing the computer-readable instructions.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the facial image processing method according to any one of claims 1 to 7.

Citation Information

Cited By

  • Video person changing method and device and storage medium

    CN121194004A