Image processing method and device, electronic equipment and storage medium

Through facial segmentation, skin tone segmentation and diffusion model optimization technology, facial skin quality is automatically improved, solving the problem of high cost of manual photo editing in the existing technology, and achieving efficient beauty special effects processing and GAN training data generation.

CN118887076APending Publication Date: 2024-11-01BEIJING DAJIA INTERNET INFORMATION TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411005225.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-25
Publication Date
2024-11-01

AI Technical Summary

Technical Problem

At this stage, the GAN-based skin grinding technology in beauty special effects requires professional art designers to manually edit pictures, resulting in high time and labor costs and low image processing efficiency.

Method used

By acquiring reference images and original images, face segmentation, skin tone segmentation and facial skin type optimization are performed, and diffusion model and attention feature fusion technology can automatically improve facial skin type and generate facial images with ideal facial skin type.

Benefits of technology

No manual photo editing is required to generate high-quality facial skin images, saving time and labor costs, improving image processing efficiency, and providing efficient face pairing data for GAN training.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118887076A_ABST
    Figure CN118887076A_ABST
Patent Text Reader

Abstract

The invention provides an image processing method and device, electronic equipment and a storage medium, and belongs to the technical field of computer vision. According to the image processing scheme provided by the invention, the face image with high-quality skin can be automatically manufactured based on the reference image. Specifically, according to the scheme, a reference image with an ideal facial skin type is used as a contrast, and the facial skin type of a human face in an original image can be remarkably improved through processing such as human face segmentation, skin color segmentation and facial skin type optimization, so that a finally obtained image processing result can completely retain structural features such as five sense organs of the human face in the original image, and the image processing accuracy is improved. And meanwhile, the facial skin is consistent with the facial skin of the human face in the reference image. According to the scheme, the face image with the ideal face skin can be obtained without manual image retouching, so that the time cost and the labor cost are saved, and the image processing efficiency is high.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer vision technology, and in particular to an image processing method, device, electronic device and storage medium. Background Art

[0002] Beauty effects are an image processing technology based on computer vision technology that can beautify and modify images. For example, beauty effects include skin resurfacing effects that can address skin blemishes, skin texture, and other issues.

[0003] In the related art, skin resurfacing is achieved based on Generative Adversarial Nets (GAN). GAN is trained by supervised training after collecting face pairing data. A set of face pairing data includes a face image of a person whose facial skin quality is to be improved and a face image of a person with an ideal facial skin quality.

[0004] Since the quality of face matching data directly determines the skin smoothing effect of GAN, in order to obtain high-quality face matching data, professional art designers are still needed to manually retouch the pictures. However, in the process of manual retouching, it is very time-consuming to create high-quality facial skin texture, which is a great test of the professionalism of art designers. There are problems such as high time and labor costs, and low image processing efficiency. Summary of the invention

[0005] The present disclosure provides an image processing method, device, electronic device and storage medium. The technical solution of the present disclosure is as follows:

[0006] According to a first aspect of an embodiment of the present disclosure, there is provided an image processing method, including:

[0007] Acquire a reference image and an original image to be processed; wherein the reference image includes a first human face, and the original image includes a second human face; and the facial skin quality of the first human face is better than the facial skin quality of the second human face;

[0008] Performing face segmentation on the first face to obtain multiple face parts of the first face;

[0009] Perform skin color segmentation on the second face to obtain a skin quality area of ​​the second face;

[0010] Fusion of the skin quality features of the plurality of facial parts to corresponding positions of the skin quality area to obtain an input image;

[0011] Based on the reference image, optimizing the facial skin quality of the input image to obtain a target image;

[0012] The target image includes a processed second face, and the facial skin quality of the processed second face is consistent with the facial skin quality of the first face.

[0013] In some embodiments, the step of optimizing the facial skin quality of the input image based on the reference image to obtain a target image includes:

[0014] Inputting the reference image and the input image into a diffusion model, using the reference image as a comparison, and optimizing the facial skin quality of the input image through the diffusion model to obtain an intermediate image;

[0015] The reference image and the intermediate image are input into the diffusion model, and the reference image is used as a comparison. The facial skin quality of the intermediate image is optimized through the diffusion model to obtain the target image.

[0016] In some other embodiments, the step of optimizing the facial skin quality of the input image by using the diffusion model with the reference image as a reference to obtain an intermediate image includes:

[0017] Input the input image into the encoder of the diffusion model for first noise addition, and obtain the attention features outputted at the first number of time steps; wherein the attention features are used for attention calculation;

[0018] Inputting the input image into the encoder for a second denoising, and fusing the attention features outputted by the first number of time steps into the second denoising process;

[0019] Inputting the noisy image into the decoder of the diffusion model for denoising; wherein the noisy image refers to the image obtained in the last time step of the second noisy process;

[0020] Inputting the reference image into the encoder for noise addition, and obtaining attention features outputted at a second number of time steps;

[0021] The attention features outputted from the second number of time steps are integrated into the denoising process, and the denoised image obtained from the last time step in the denoising process is used as the intermediate image.

[0022] In some other embodiments, obtaining the attention features outputted at the first number of time steps includes:

[0023] Starting from the TP-th time step, the attention features of each time step output are obtained until the T-th time step, and the attention features of P time steps are obtained; where T and P are both positive integers, and T is greater than P.

[0024] In some other embodiments, fusing the attention features outputted from the first number of time steps into the second noise adding process includes:

[0025] The attention feature output at the Tth time step in the first noise addition process is used to replace the attention feature output at the first time step in the second noise addition process.

[0026] The attention feature output at the T-1th time step in the first noise addition process is used to replace the attention feature output at the second time step in the second noise addition process.

[0027] And so on, until the attention features output at the TP-th time step in the first noisy process replace the attention features output at the P-th time step in the second noisy process.

[0028] In some other embodiments, obtaining the attention features outputted at the second number of time steps includes:

[0029] The attention features of each time step output are obtained starting from the first time step until the TS-th time step, and the attention features of TS time steps are obtained; where T and S are both positive integers, and T is greater than S.

[0030] In some other embodiments, fusing the attention features outputted by the second number of time steps into the denoising process includes:

[0031] The attention features output at the TSth time step in the denoising process are used to replace the attention features output at the Sth time step in the denoising process.

[0032] The attention features output at the TS-1th time step during the noise addition process are used to replace the attention features output at the S+1th time step during the denoising process.

[0033] And so on, until the attention features output in the first time step of the noise addition process replace the attention features output in the last time step of the denoising process.

[0034] In other embodiments, the attention features refer to key features and value features in the attention mechanism.

[0035] In some other embodiments, fusing the skin quality features of the multiple facial parts to corresponding positions of the skin quality area to obtain an input image includes:

[0036] adding noise to the skin texture area to obtain a processed skin texture area;

[0037] For any one of the multiple facial parts, the pixel values ​​at each position of the facial part are merged to the corresponding position of the processed skin quality area until the multiple facial parts are traversed to obtain the input image.

[0038] In some other embodiments, the method further comprises:

[0039] Performing image degradation processing on the target image to obtain a degraded image;

[0040] The target image and the degraded image constitute a set of face pairing data; the face pairing data is used to train a machine learning model, and the machine learning model is used to add a skin smoothing effect to the face.

[0041] According to a second aspect of an embodiment of the present disclosure, there is provided an image processing apparatus, including:

[0042] An acquisition module is configured to acquire a reference image and an original image to be processed; wherein the reference image includes a first human face, and the original image includes a second human face; and the facial skin quality of the first human face is better than the facial skin quality of the second human face;

[0043] A first processing module is configured to perform face segmentation on the first face to obtain multiple face parts of the first face;

[0044] The first processing module is further configured to perform skin color segmentation on the second face to obtain a skin quality area of ​​the second face;

[0045] The first processing module is further configured to fuse the skin quality features of the plurality of facial parts to corresponding positions of the skin quality area to obtain an input image;

[0046] A second processing module is configured to perform facial skin quality optimization on the input image based on the reference image to obtain a target image;

[0047] The target image includes a processed second face, and the facial skin quality of the processed second face is consistent with the facial skin quality of the first face.

[0048] In some embodiments, the second processing module is configured to:

[0049] Inputting the reference image and the input image into a diffusion model, using the reference image as a comparison, and optimizing the facial skin quality of the input image through the diffusion model to obtain an intermediate image;

[0050] The reference image and the intermediate image are input into the diffusion model, and the reference image is used as a comparison. The facial skin quality of the intermediate image is optimized through the diffusion model to obtain the target image.

[0051] In some other embodiments, the second processing module is configured to:

[0052] Inputting the input image into the encoder of the diffusion model for first noise addition, and obtaining attention features outputted at a first number of time steps; wherein the attention features are used for attention calculation;

[0053] Inputting the input image into the encoder for a second denoising, and fusing the attention features outputted by the first number of time steps into the second denoising process;

[0054] Inputting the noisy image into the decoder of the diffusion model for denoising; wherein the noisy image refers to the image obtained in the last time step of the second noisy process;

[0055] Inputting the reference image into the encoder for noise addition, and obtaining attention features outputted at a second number of time steps;

[0056] The attention features outputted from the second number of time steps are integrated into the denoising process, and the denoised image obtained from the last time step in the denoising process is used as the intermediate image.

[0057] In some other embodiments, the second processing module is configured to:

[0058] Starting from the TP-th time step, the attention features of each time step output are obtained until the T-th time step, and the attention features of P time steps are obtained; where T and P are both positive integers, and T is greater than P.

[0059] In some other embodiments, the second processing module is configured to:

[0060] The attention feature output at the Tth time step in the first noise addition process is used to replace the attention feature output at the first time step in the second noise addition process.

[0061] The attention feature output at the T-1th time step in the first noise addition process is used to replace the attention feature output at the second time step in the second noise addition process.

[0062] And so on, until the attention features output at the TP-th time step in the first noisy process replace the attention features output at the P-th time step in the second noisy process.

[0063] In some other embodiments, the second processing module is configured to:

[0064] The attention features of each time step output are obtained starting from the first time step until the TS-th time step, and the attention features of TS time steps are obtained; where T and S are both positive integers, and T is greater than S.

[0065] In some other embodiments, the second processing module is configured to:

[0066] The attention features output at the TSth time step in the denoising process are used to replace the attention features output at the Sth time step in the denoising process.

[0067] The attention features output at the TS-1th time step during the noise addition process are used to replace the attention features output at the S+1th time step during the denoising process.

[0068] And so on, until the attention features output in the first time step of the noise addition process replace the attention features output in the last time step of the denoising process.

[0069] In other embodiments, the attention features refer to key features and value features in the attention mechanism.

[0070] In some other embodiments, the first processing module is further configured to:

[0071] adding noise to the skin texture area to obtain a processed skin texture area;

[0072] For any one of the multiple facial parts, the pixel values ​​at each position of the facial part are merged to the corresponding position of the processed skin quality area until the multiple facial parts are traversed to obtain the input image.

[0073] In some other embodiments, the device further comprises:

[0074] a third processing module, configured to perform image degradation processing on the target image to obtain a degraded image;

[0075] The target image and the degraded image constitute a set of face pairing data; the face pairing data is used to train a machine learning model, and the machine learning model is used to add a skin smoothing effect to the face.

[0076] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, the electronic device comprising:

[0077] one or more processors;

[0078] A memory for storing program codes executable by the processor;

[0079] The processor is configured to execute the program code to implement the above-mentioned image processing method.

[0080] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, and when a program code in the computer-readable storage medium is executed by a processor of an electronic device, the electronic device is enabled to perform the above-mentioned image processing method.

[0081] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, including a computer program, which implements the above-mentioned image processing method when executed by a processor of an electronic device.

[0082] The image processing scheme provided by the disclosed embodiment can automatically produce a facial image with high-quality skin quality based on a reference image. In detail, the scheme uses a reference image with ideal facial skin quality as a comparison, and through processes such as face segmentation, skin color segmentation, and facial skin quality optimization, it can significantly improve the facial skin quality of the face in the original image, so that the final image processing result can completely retain the structural features such as the facial features of the face in the original image, and at the same time, its facial skin quality is consistent with the facial skin quality of the face in the reference image. Since the scheme can obtain a facial image with ideal facial skin quality without manual retouching, it saves time and labor costs, and has high image processing efficiency.

[0083] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0084] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.

[0085] Figure 1 It is a schematic diagram of an implementation environment of an image processing method according to an exemplary embodiment.

[0086] Figure 2 The figure is a flowchart of an image processing method according to an exemplary embodiment.

[0087] Figure 3 is a schematic diagram showing a comparison of skin texture according to an exemplary embodiment.

[0088] Figure 4 is a flowchart of another image processing method according to an exemplary embodiment.

[0089] Figure 5 The figure is an overall flow chart of image processing according to an exemplary embodiment.

[0090] Figure 6 is a schematic diagram of facial skin quality optimization according to an exemplary embodiment.

[0091] Figure 7 is a block diagram of an image processing apparatus according to an exemplary embodiment.

[0092] Figure 8 It is a block diagram of a server according to an exemplary embodiment. DETAILED DESCRIPTION

[0093] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.

[0094] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0095] The information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in this disclosure are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.

[0096] Figure 1 It is a schematic diagram of an implementation environment of an image processing method according to an exemplary embodiment.

[0097] See also Figure 1 , the implementation environment includes: a terminal 101 and a server 102. The terminal 101 is an electronic device used by a user. In the embodiment of the present disclosure, a target application is installed on the terminal 101. The target application can be an instant messaging application, such as a short video application, an image editing application or a video editing application, or an application dedicated to live broadcasting, which is not limited in the present disclosure.

[0098] In some embodiments, the terminal 101 is a device such as a smart phone, a desktop computer, or a laptop computer. Figure 1The terminal 101 is only used as a smartphone for illustration. In addition, those skilled in the art will appreciate that the number of the above terminals may be more or less. For example, the above terminals may be only a few, or the above devices may be dozens or hundreds, or more. The embodiments of the present disclosure do not limit the number and type of terminals.

[0099] In other embodiments, the server 102 provides background services for the target application. In addition, the server 102 is connected to the terminal 101 via a wireless network or a wired network. In addition, the server involved in the embodiment of the present disclosure may also include other functional servers to provide more comprehensive and diversified services.

[0100] In other embodiments, the server 102 is responsible for executing the image processing method provided by the embodiment of the present disclosure. This method can be used to obtain face pairing data with high-quality facial skin in batches, and these face pairing data can be used for the supervised training task of GAN. In addition, after the GAN is trained, the face can be smoothed based on the network. Among them, the skin smoothing effect is a beauty effect provided by the target application installed on the terminal 101. Under this premise, the terminal 101 combines with the GAN located on the server to realize the skin smoothing of the face image to be processed.

[0101] The image processing solution provided by the embodiment of the present disclosure is described in detail through the following embodiments.

[0102] Figure 2 is a flowchart of an image processing method according to an exemplary embodiment. Figure 2 As shown, the image processing method is applied to electronic devices, such as Figure 1 In the server 102 shown. The image processing method comprises the following steps:

[0103] In 201, the electronic device obtains a reference image and an original image to be processed; wherein the reference image includes a first face, and the original image includes a second face; and the facial skin quality of the first face is better than the facial skin quality of the second face.

[0104] The reference image in this article refers to a face image with an ideal facial skin quality, and the original image in this article refers to a face image of a face whose facial skin quality is to be improved. In addition, the first face and the second face can be the same face or different faces, which is not limited in this disclosure.

[0105] In some embodiments, facial skin quality herein refers to skin texture. Figure 3 is a schematic diagram showing a comparison of skin texture according to an exemplary embodiment. Figure 3In the figure, the left side is a face image with skin texture to be improved, and the right side is a face image with high-quality skin texture after image processing.

[0106] In 202, the electronic device performs face segmentation on the first face to obtain multiple face parts of the first face.

[0107] In the disclosed embodiments, face segmentation is also referred to as face parsing, which is a special case of semantic image segmentation and is used to decompose the human head including the facial features and determine the pixel-level label mapping of different semantic components in the face image (such as hair, facial skin, eyes, eyebrows, nose, mouth, ears, etc.). In other words, given a face image, face parsing will assign a pixel-level label to each semantic component in the face image.

[0108] The above-mentioned multiple facial parts correspond to different semantic components of the first face. That is, after performing face recognition on the reference image to obtain the first face, high-quality texture blocks at different positions of the face are obtained by performing face analysis on the first face.

[0109] In 203, the electronic device performs skin color segmentation on the second face to obtain a skin quality area of ​​the second face.

[0110] Among them, skin color segmentation is used to separate the skin color area of ​​the face from other areas in the image.

[0111] In some embodiments, taking the original image as an RGB image as an example, the skin color segmentation of the second face can be performed in the following manner:

[0112] First, convert the RGB image to YCbCr color space using the rgb2ycbcr function.

[0113] Afterwards, a skin color range threshold is set, that is, the approximate range of skin color in the YCbCr color space is determined.

[0114] Next, the pixels in the image are traversed for skin color segmentation, that is, each pixel in the converted YCbCr image is judged. If the Cb value and Cr value of the pixel are within the set skin color range, the pixel is marked as a skin color area; otherwise, the pixel is marked as a non-skin color area.

[0115] Finally, the segmentation results are displayed, such as generating a binary image based on the labeling results or highlighting the skin texture area on the original image.

[0116] It should be noted that the skin color segmentation effect will be affected by many factors, such as lighting conditions, image quality, and skin color differences between different individuals. Therefore, in practical applications, the size of the skin color range threshold needs to be adjusted according to the specific situation.

[0117] In other embodiments, deep learning technology may also be used to perform skin color segmentation, such as training a skin color segmentation model (deep learning model) to perform skin color segmentation, which is not limited in the present disclosure.

[0118] In 204, the electronic device fuses the skin quality features of the multiple facial parts of the first face to the corresponding positions of the skin quality area of ​​the second face to obtain an input image.

[0119] In some embodiments, the disclosed embodiments fuse the skin quality features of each facial part in the first face to the corresponding position of the skin quality area of ​​the second face in the following manner:

[0120] First, noise is added to the skin texture area of ​​the second face, that is, the skin texture area of ​​the second face is noise-filled to obtain a processed skin texture area. In image processing, noise filling is used to fill in missing or damaged parts in an image to make it look more complete or natural.

[0121] Next, for any facial part, the pixel values ​​at each position of the facial part are merged into the corresponding position of the processed skin quality area, until all facial parts of the first face are traversed to obtain the input image. For example, taking the skin quality feature as the skin texture feature, the pixel values ​​at each position refer to the skin texture information.

[0122] It should be noted that fusing the pixel values ​​at various positions of the face part to the corresponding positions of the processed skin area means fusing the pixel values ​​at various positions of the face part with the pixel values ​​at the corresponding positions in the processed skin area.

[0123] In other embodiments, the fusion here refers to the addition of pixel values. For example, according to a set weighting coefficient, the pixel values ​​at various positions of the face part and the pixel values ​​at corresponding positions of the processed skin quality area are weighted averaged, which is not limited in the present disclosure.

[0124] In other embodiments, face warping mapping technology is used to determine the corresponding positions of various positions of the face parts in the processed skin texture area. Face warping mapping refers to performing some transformation or mapping on the face to improve the image processing effect, making the processed effect more realistic, lifelike and natural.

[0125] In 205, the electronic device optimizes the facial skin quality of the input image based on the reference image to obtain a target image; wherein the target image includes a processed second face, and the facial skin quality of the processed second face is consistent with the facial skin quality of the first face.

[0126] Regarding facial skin quality optimization, the disclosed embodiment proposes a structure-preserving inversion based on a diffusion model, wherein the structure-preserving inversion based on a diffusion model is an image processing technology that aims to preserve the structural features of the input image by inverting it and matching it with the facial skin quality of a reference image. In this process, the quality of the final image processing result can be improved by improving attention interaction. The final image processing result can completely preserve the structural features such as the facial features of the second face, while the facial skin quality is processed to be consistent with the facial skin quality of the reference image. That is, the facial non-skin quality area of ​​the target image is consistent with the input image, but the facial skin quality of the skin quality area is consistent with the reference image. In addition, the attention mechanism can also help the model better focus on important areas in the image, thereby preserving structural features such as the facial features of the input image.

[0127] In summary, the image processing scheme provided by the embodiments of the present disclosure can automatically produce a facial image with high-quality skin quality based on a reference image. In detail, the scheme uses a reference image with ideal facial skin quality as a comparison, and through processes such as face segmentation, skin color segmentation, and facial skin quality optimization, it can significantly improve the facial skin quality of the face in the original image, so that the final image processing result can completely retain the structural features such as the facial features of the face in the original image, and at the same time, its facial skin quality is consistent with the facial skin quality of the face in the reference image. Since the scheme can obtain a facial image with ideal facial skin quality without manual retouching, it saves time and labor costs, and has high image processing efficiency.

[0128] It should be noted that by repeatedly performing the above steps 201 to 205 and replacing at least one of the reference image and the input image, facial images with ideal facial skin quality can be obtained in batches.

[0129] In other embodiments, for the facial images with ideal facial skin quality obtained in batches, low-quality facial images (with poor facial skin quality) to be paired with these high-quality facial images can be obtained through image degradation processing. That is, the method provided by the embodiment of the present disclosure also includes: performing image degradation processing on the target image to obtain a degraded image.

[0130] Exemplarily, image degradation processing includes, but is not limited to: generating facial dirt, facial blemishes, adding dark circles or nasolabial folds, etc., which is not limited in the present disclosure.

[0131] In addition, the target image and the degraded image constitute a set of face pairing data. In the disclosed embodiment, the constructed face pairing data is used to train a machine learning model, and the machine learning model is used to add a skin smoothing effect to a face.

[0132] Exemplarily, the machine learning model is GAN. GAN is a deep generative model based on adversarial learning, which consists of a generator and a discriminator. The generator is used to receive a random noise vector as input and generate fake image data. The discriminator is used to distinguish true from false image data. During the training process, the generator and the discriminator compete with each other, thereby promoting the performance of both parties. In the beautification task, the trained GAN is used to achieve skin resurfacing, that is, to generate real and natural skin texture.

[0133] In summary, the disclosed embodiments can obtain a face image with ideal facial skin quality without manual retouching, and thus a large amount of face pairing data can be constructed through image degradation processing, which can be used for supervised training tasks of models such as GAN. In other words, the disclosed embodiments can efficiently generate face pairing data for training models such as GAN. This provides basic support for face resurfacing in live broadcast, short video, image editing or video editing scenarios.

[0134] Above Figure 2 The following is only a basic process of the present disclosure. The solution provided by the present disclosure is further described based on a specific implementation method. Figure 4 is a flowchart of another image processing method according to an exemplary embodiment. Figure 4 As shown, the image processing method is applied to electronic devices, such as Figure 1 In the server 102 shown. The image processing method comprises the following steps:

[0135] In 401, the electronic device obtains a reference image and an original image to be processed; wherein the reference image includes a first face, and the original image includes a second face; and the facial skin quality of the first face is better than the facial skin quality of the second face.

[0136] Figure 5 FIG. 1 is an overall flow chart of image processing according to an exemplary embodiment. Figure 5 As shown, the first face included in the reference image and the second face included in the original image are different faces, wherein the first face has ideal high-quality skin quality, while the second face needs to improve its facial skin quality.

[0137] In 402, the electronic device performs face segmentation on the first face to obtain multiple face parts of the first face.

[0138] This step may refer to the above step 202 and will not be described again here.

[0139] In 403, the electronic device performs skin color segmentation on the second face to obtain a skin quality area of ​​the second face.

[0140] This step may refer to the above step 203 and will not be described again here.

[0141] In 404, the electronic device fuses the skin quality features of the multiple facial parts of the first face to the corresponding positions of the skin quality area of ​​the second face to obtain an input image.

[0142] like Figure 5 As shown, taking the improvement of skin texture as an example, after the texture features of the high-quality texture block obtained in step 402 are fused to the corresponding position of the skin quality area obtained in step 402, an input image for inputting the diffusion model is obtained.

[0143] Regarding facial skin quality optimization, the disclosed embodiment proposes a structure-preserving inversion based on a diffusion model. The structure-preserving inversion based on a diffusion model is introduced below through the following steps 405 and 406.

[0144] It should be noted that the image processing method proposed in the embodiment of the present disclosure does not need to collect sample data for model training, and can directly perform image processing based on the diffusion model, which can greatly save computing resources. In other words, the embodiment of the present disclosure does not need to collect sample data in advance and train a machine learning model dedicated to the image processing task shown in this article.

[0145] In 405, the electronic device inputs the reference image and the input image into the diffusion model, uses the reference image as a comparison, and optimizes the facial skin quality of the input image through the diffusion model to obtain an intermediate image.

[0146] The diffusion model usually includes two processes, namely, the forward diffusion process (also called the forward noise addition process, the noise addition process or the forward process) and the reverse diffusion process (also called the reverse denoising process, the denoising process, the sampling process or the reverse process). The noise addition process and the denoising process both include T time steps, that is, the noise addition process lasts T times, and the denoising process also lasts T times. The value of T is a positive integer, such as 1000, which is not limited in the present disclosure.

[0147] The facial skin optimization in this step is not as refined as that in step 406, so this step is also called "rough processing of the facial skin texture of the input image based on the reference image".

[0148] In some embodiments, the diffusion model includes a retention inversion process and a sampling process, wherein the following steps 4051 and 4052 correspond to the retention inversion process, and the following steps 4053 and 4055 correspond to the sampling process.

[0149] In some other embodiments, the reference image is used as a reference, and the facial skin quality of the input image is optimized by a diffusion model to obtain an intermediate image, including the following steps:

[0150] 4051. Input the input image into the encoder of the diffusion model for first noise addition, and obtain the attention features outputted for the first number of time steps.

[0151] like Figure 6 As shown, in the first noise addition process, given an image For images Add Gaussian noise gradually, for example, adding a small amount of Gaussian noise each time. The noise adding process lasts T times, also known as T time steps. This process will produce a series of noisy images. To achieve the purpose of destroying the image.

[0152] In the embodiment of the present disclosure, the attention feature is used for attention calculation. Exemplarily, the attention feature refers to the key (K) feature and the value (V) feature in the attention mechanism, which is not limited in the present disclosure.

[0153] In other embodiments, Figure 6 As shown, the embodiment of the present disclosure obtains the attention features outputted by the first number of time steps in the following manner:

[0154] The attention features of each time step are obtained starting from the TPth time step until the Tth time step, and the attention features of P time steps are obtained. Where T and P are both positive integers, and T is greater than P.

[0155] 4052. The input image is input into the encoder of the diffusion model for second denoising, and the attention features outputted in the first number of time steps are fused into the second denoising process.

[0156] like Figure 6 As shown, in the second noise addition process, given the image For images Add Gaussian noise gradually, for example, adding a small amount of Gaussian noise each time. The noise adding process lasts T times, also known as T time steps. This process will produce a series of noisy images. To achieve the purpose of destroying the image.

[0157] It should be noted that the image and images The two images are the same and refer to the input image. The two different symbols are used in this article to distinguish the first noise addition from the second noise addition and do not constitute any other limitation.

[0158] In other embodiments, Figure 6 As shown, the embodiment of the present disclosure fuses the attention features outputted in the first number of time steps into the second noise addition process in the following manner:

[0159] The attention feature output at the Tth time step in the first noise addition process is used to replace the attention feature output at the first time step in the second noise addition process.

[0160] The attention feature output at the T-1th time step in the first noise addition process is used to replace the attention feature output at the second time step in the second noise addition process.

[0161] And so on, until the attention features output at the TP-th time step in the first noisy process replace the attention features output at the P-th time step in the second noisy process.

[0162] 4053. Input the noisy image into the decoder of the diffusion model for denoising.

[0163] Here, the noisy image refers to the image obtained at the last time step in the second noisy process. For example, the noisy image obtained at the last time step in the second noisy process refers to Figure 6 The image output by the encoder in This image will be used as the input of the decoder, that is, the image With image refers to the same image.

[0164] 4054. Input the reference image into the encoder of the diffusion model to add noise, and obtain the attention features outputted by the second number of time steps.

[0165] like Figure 6 As shown, in the process of adding noise to the reference image, given the image For images Add Gaussian noise gradually, for example, adding a small amount of Gaussian noise each time. The noise adding process lasts T times, also known as T time steps. This process will produce a series of noisy images. To achieve the purpose of destroying the image.

[0166] In other embodiments, Figure 6 As shown, the embodiment of the present disclosure obtains the attention features outputted by the second number of time steps in the following manner, including:

[0167] The attention features of each time step output are obtained starting from the first time step until the TS-th time step, and the attention features of TS time steps are obtained; where T and S are both positive integers, and T is greater than S.

[0168] 4055. The attention features outputted in the second number of time steps are integrated into the denoising process, and the denoised image obtained in the last time step of the denoising process is used as the intermediate image.

[0169] In other embodiments, Figure 6As shown, the embodiment of the present disclosure integrates the attention features outputted by the second number of time steps into the denoising process in the following manner:

[0170] The attention features output at the TSth time step in the denoising process are used to replace the attention features output at the Sth time step in the denoising process.

[0171] The attention features output at the TS-1th time step during the noise addition process are used to replace the attention features output at the S+1th time step during the denoising process.

[0172] And so on, until the attention features output in the first time step of the noise addition process replace the attention features output in the last time step of the denoising process.

[0173] Among them, the denoised image obtained in the last time step during the denoising process refers to Figure 6 Images in That is, the intermediate image refers to the image

[0174] In the denoising process, Figure 6 As shown, for the image By gradually denoising it, we can get

[0175] The second point to be explained is that the It is referred to as sampled output in this article. The sampled output of each time step is obtained by sampling the data distribution (probability distribution of the image) of each time step during the denoising process.

[0176] In 406, the electronic device inputs the reference image and the intermediate image into the diffusion model, uses the reference image as a comparison, and optimizes the facial skin quality of the intermediate image through the diffusion model to obtain a target image.

[0177] The facial skin optimization in this step is more refined than the facial skin optimization in step 405, so this step is also called "fine processing of the facial skin quality of the input image based on the reference image".

[0178] The facial skin quality optimization process of this step is similar to step 405, and the difference between the two is that the model input is different. The model input of step 405 is the reference image and the input image, while the model input of this step is the reference image and the intermediate image output by step 405.

[0179] In some embodiments, the reference image is used as a reference, and the facial skin quality of the intermediate image is optimized by a diffusion model to obtain a target image, including the following steps:

[0180] 4061. Input the intermediate image into the encoder of the diffusion model for first noise addition, and obtain the attention features outputted for the first number of time steps.

[0181] In other embodiments, the embodiments of the present disclosure obtain the attention features outputted from the first number of time steps in the following manner: obtaining the attention features outputted from each time step starting from the TP-th time step until the T-th time step, and obtaining the attention features of P time steps.

[0182] 4062. Input the intermediate image into the encoder of the diffusion model for second denoising, and fuse the attention features outputted by the first number of time steps into the second denoising process.

[0183] In some other embodiments, the disclosed embodiments fuse the attention features outputted from the first number of time steps into the second noise addition process in the following manner:

[0184] The attention feature output at the Tth time step in the first noise addition process is used to replace the attention feature output at the first time step in the second noise addition process.

[0185] The attention feature output at the T-1th time step in the first noise addition process is used to replace the attention feature output at the second time step in the second noise addition process.

[0186] And so on, until the attention features output at the TP-th time step in the first noisy process replace the attention features output at the P-th time step in the second noisy process.

[0187] 4063. Input the noisy image into the decoder of the diffusion model for denoising. The noisy image here refers to the image obtained in the last time step of the second noisy process.

[0188] 4064. Input the reference image into the encoder of the diffusion model for noise addition, and obtain the attention features outputted for a second number of time steps.

[0189] In other embodiments, the embodiments of the present disclosure obtain the attention features outputted by the second number of time steps in the following manner: obtain the attention features outputted by each time step starting from the first time step until the TS-th time step, and obtain the attention features of TS time steps.

[0190] 4065. The attention features outputted in the second number of time steps are integrated into the denoising process, and the denoised image obtained in the last time step of the denoising process is used as the target image.

[0191] In some other embodiments, the disclosed embodiments fuse the attention features outputted at the second number of time steps into the denoising process in the following manner:

[0192] The attention features output at the TSth time step in the denoising process are used to replace the attention features output at the Sth time step in the denoising process.

[0193] The attention features output at the TS-1th time step during the noise addition process are used to replace the attention features output at the S+1th time step during the denoising process.

[0194] And so on, until the attention features output in the first time step of the noise addition process replace the attention features output in the last time step of the denoising process.

[0195] In summary, the image processing scheme provided by the embodiments of the present disclosure can automatically produce a facial image with high-quality skin quality based on a reference image. In detail, the scheme uses a reference image with ideal facial skin quality as a comparison, and through processes such as face segmentation, skin color segmentation, and facial skin quality optimization, it can significantly improve the facial skin quality of the face in the original image, so that the final image processing result can completely retain the structural features such as the facial features of the face in the original image, and at the same time, its facial skin quality is consistent with the facial skin quality of the face in the reference image. Since the scheme can obtain a facial image with ideal facial skin quality without manual retouching, it saves time and labor costs, and has high image processing efficiency.

[0196] In addition, since the embodiment of the present disclosure can obtain face images with ideal facial skin quality without manual retouching, a large amount of face pairing data can be constructed by performing image degradation processing on these face images, and these face pairing data can be used for supervised training tasks of models such as GAN. In other words, the embodiment of the present disclosure can efficiently generate face pairing data for training models such as GAN. This provides basic support for face resurfacing in live broadcast, short video, image editing or video editing scenarios.

[0197] Figure 7 is a block diagram of an image processing device according to an exemplary embodiment. Figure 7 , the device comprises:

[0198] The acquisition module 701 is configured to acquire a reference image and an original image to be processed; wherein the reference image includes a first face, and the original image includes a second face; and the facial skin quality of the first face is better than the facial skin quality of the second face;

[0199] A first processing module 702 is configured to perform face segmentation on the first face to obtain multiple face parts of the first face;

[0200] The first processing module 702 is further configured to perform skin color segmentation on the second face to obtain a skin quality area of ​​the second face;

[0201] The first processing module 702 is further configured to fuse the skin quality features of the plurality of facial parts to corresponding positions of the skin quality area to obtain an input image;

[0202] The second processing module 703 is configured to perform facial skin quality optimization on the input image based on the reference image to obtain a target image;

[0203] The target image includes a processed second face, and the facial skin quality of the processed second face is consistent with the facial skin quality of the first face.

[0204] The image processing scheme provided by the disclosed embodiment can automatically produce a facial image with high-quality skin quality based on a reference image. In detail, the scheme uses a reference image with ideal facial skin quality as a comparison, and through processes such as face segmentation, skin color segmentation, and facial skin quality optimization, it can significantly improve the facial skin quality of the face in the original image, so that the final image processing result can completely retain the structural features such as the facial features of the face in the original image, and at the same time, its facial skin quality is consistent with the facial skin quality of the face in the reference image. Since the scheme can obtain a facial image with ideal facial skin quality without manual retouching, it saves time and labor costs, and has high image processing efficiency.

[0205] In some embodiments, the second processing module is configured to:

[0206] Inputting the reference image and the input image into a diffusion model, using the reference image as a comparison, and optimizing the facial skin quality of the input image through the diffusion model to obtain an intermediate image;

[0207] The reference image and the intermediate image are input into the diffusion model, and the reference image is used as a comparison. The facial skin quality of the intermediate image is optimized through the diffusion model to obtain the target image.

[0208] In some other embodiments, the second processing module is configured to:

[0209] Inputting the input image into the encoder of the diffusion model for first noise addition, and obtaining attention features outputted at a first number of time steps; wherein the attention features are used for attention calculation;

[0210] Inputting the input image into the encoder for a second denoising, and fusing the attention features outputted by the first number of time steps into the second denoising process;

[0211] Inputting the noisy image into the decoder of the diffusion model for denoising; wherein the noisy image refers to the image obtained in the last time step of the second noisy process;

[0212] Inputting the reference image into the encoder for noise addition, and obtaining attention features outputted at a second number of time steps;

[0213] The attention features outputted from the second number of time steps are integrated into the denoising process, and the denoised image obtained from the last time step in the denoising process is used as the intermediate image.

[0214] In some other embodiments, the second processing module is configured to:

[0215] Starting from the TP-th time step, the attention features of each time step output are obtained until the T-th time step, and the attention features of P time steps are obtained; where T and P are both positive integers, and T is greater than P.

[0216] In some other embodiments, the second processing module is configured to:

[0217] The attention feature output at the Tth time step in the first noise addition process is used to replace the attention feature output at the first time step in the second noise addition process.

[0218] The attention feature output at the T-1th time step in the first noise addition process is used to replace the attention feature output at the second time step in the second noise addition process.

[0219] And so on, until the attention features output at the TP-th time step in the first noisy process replace the attention features output at the P-th time step in the second noisy process.

[0220] In some other embodiments, the second processing module is configured to:

[0221] The attention features of each time step output are obtained starting from the first time step until the TS-th time step, and the attention features of TS time steps are obtained; where T and S are both positive integers, and T is greater than S.

[0222] In some other embodiments, the second processing module is configured to:

[0223] The attention features output at the TSth time step in the denoising process are used to replace the attention features output at the Sth time step in the denoising process.

[0224] The attention features output at the TS-1th time step during the noise addition process are used to replace the attention features output at the S+1th time step during the denoising process.

[0225] And so on, until the attention features output in the first time step of the noise addition process replace the attention features output in the last time step of the denoising process.

[0226] In other embodiments, the attention features refer to key features and value features in the attention mechanism.

[0227] In some other embodiments, the first processing module is further configured to:

[0228] adding noise to the skin texture area to obtain a processed skin texture area;

[0229] For any one of the multiple facial parts, the pixel values ​​at each position of the facial part are merged to the corresponding position of the processed skin quality area until the multiple facial parts are traversed to obtain the input image.

[0230] In some other embodiments, the device further comprises:

[0231] a third processing module, configured to perform image degradation processing on the target image to obtain a degraded image;

[0232] The target image and the degraded image constitute a set of face pairing data; the face pairing data is used to train a machine learning model, and the machine learning model is used to add a skin smoothing effect to the face.

[0233] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present disclosure, which will not be described in detail here.

[0234] It should be noted that the image processing device provided in the above embodiment only uses the division of the above functional units as an example when performing image processing. In actual applications, the above functions can be assigned to different functional units as needed, that is, the internal structure of the electronic device is divided into different functional units to complete all or part of the functions described above. In addition, the image processing device provided in the above embodiment and the image processing method embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0235] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0236] In some embodiments, when the electronic device is provided as a server, Figure 8800 is a block diagram of a server 800 according to an exemplary embodiment. The server 800 may have relatively large differences due to different configurations or performances, and includes one or more processors (Central Processing Units, CPU) 801 and one or more memories 802, wherein the memory 802 stores at least one program code, and the at least one program code is loaded and executed by the processor 801 to implement the image processing methods provided by the above-mentioned various method embodiments. Of course, the server also has components such as a wired or wireless network interface, a keyboard, and an input and output interface for input and output. The server 800 also includes other components for implementing device functions, which will not be repeated here.

[0237] In some embodiments, a computer-readable storage medium including instructions is also provided, such as a memory including instructions, and the instructions are executed by a processor of an electronic device to implement the above-mentioned image processing method. In other embodiments, the computer-readable storage medium is a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0238] In some embodiments, a computer program product is also provided, including a computer program, which is executed by a processor of an electronic device to implement the above-mentioned image processing method.

[0239] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.

[0240] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. An image processing method, It is characterized in that The method comprises: Acquire a reference image and an original image to be processed; wherein the reference image includes a first human face, and the original image includes a second human face; and the facial skin quality of the first human face is better than the facial skin quality of the second human face; Performing face segmentation on the first face to obtain multiple face parts of the first face; Perform skin color segmentation on the second face to obtain a skin quality area of ​​the second face; Fusion of the skin quality features of the plurality of facial parts to corresponding positions of the skin quality area to obtain an input image; Based on the reference image, optimizing the facial skin quality of the input image to obtain a target image; The target image includes a processed second face, and the facial skin quality of the processed second face is consistent with the facial skin quality of the first face.

2. The image processing method according to claim 1, It is characterized in that The step of optimizing the facial skin quality of the input image based on the reference image to obtain a target image includes: Inputting the reference image and the input image into a diffusion model, using the reference image as a comparison, and optimizing the facial skin quality of the input image through the diffusion model to obtain an intermediate image; The reference image and the intermediate image are input into the diffusion model, and the reference image is used as a comparison. The facial skin quality of the intermediate image is optimized through the diffusion model to obtain the target image.

3. The image processing method according to claim 2, It is characterized in that The step of optimizing the facial skin quality of the input image by using the diffusion model and taking the reference image as a reference to obtain an intermediate image comprises: Input the input image into the encoder of the diffusion model for first noise addition, and obtain the attention features outputted at the first number of time steps; wherein the attention features are used for attention calculation; Inputting the input image into the encoder for a second denoising, and fusing the attention features outputted by the first number of time steps into the second denoising process; Inputting the noisy image into the decoder of the diffusion model for denoising; wherein the noisy image refers to the image obtained in the last time step of the second noisy process; Inputting the reference image into the encoder for noise addition, and obtaining attention features outputted at a second number of time steps; The attention features outputted from the second number of time steps are integrated into the denoising process, and the denoised image obtained from the last time step in the denoising process is used as the intermediate image.

4. The image processing method according to claim 3, It is characterized in that The obtaining of the attention features outputted at the first number of time steps includes: Starting from the TP-th time step, the attention features of each time step output are obtained until the T-th time step, and the attention features of P time steps are obtained; where T and P are both positive integers, and T is greater than P.

5. The image processing method according to claim 3, It is characterized in that The step of fusing the attention features outputted from the first number of time steps into the second noise adding process includes: The attention feature output at the Tth time step in the first noise addition process is used to replace the attention feature output at the first time step in the second noise addition process. The attention feature output at the T-1th time step in the first noise addition process is used to replace the attention feature output at the second time step in the second noise addition process. And so on, until the attention features output at the TP-th time step in the first noisy process replace the attention features output at the P-th time step in the second noisy process.

6. The image processing method according to claim 3, It is characterized in that The obtaining of the attention features outputted at the second number of time steps includes: The attention features of each time step output are obtained starting from the first time step until the TS-th time step, and the attention features of TS time steps are obtained; where T and S are both positive integers, and T is greater than S.

7. The image processing method according to claim 3, It is characterized in that The step of fusing the attention features outputted by the second number of time steps into the denoising process includes: The attention features output at the TSth time step in the denoising process are used to replace the attention features output at the Sth time step in the denoising process. The attention features output at the TS-1th time step during the noise addition process are used to replace the attention features output at the S+1th time step during the denoising process. And so on, until the attention features output in the first time step of the noise addition process replace the attention features output in the last time step of the denoising process.

8. The image processing method according to claim 3, It is characterized in that The attention features refer to the key features and value features in the attention mechanism.

9. The image processing method according to claim 3, It is characterized in that The step of fusing the skin quality features of the plurality of facial parts to corresponding positions of the skin quality area to obtain an input image includes: adding noise to the skin texture area to obtain a processed skin texture area; For any one of the multiple facial parts, the pixel values ​​at each position of the facial part are merged to the corresponding position of the processed skin quality area until the multiple facial parts are traversed to obtain the input image.

10. The image processing method according to any one of claims 1 to 9, It is characterized in that The method further comprises: Performing image degradation processing on the target image to obtain a degraded image; The target image and the degraded image constitute a set of face pairing data; the face pairing data is used to train a machine learning model, and the machine learning model is used to add a skin smoothing effect to the face.

11. An image processing device, It is characterized in that The device comprises: An acquisition module is configured to acquire a reference image and an original image to be processed; wherein the reference image includes a first human face, and the original image includes a second human face; and the facial skin quality of the first human face is better than the facial skin quality of the second human face; A first processing module is configured to perform face segmentation on the first face to obtain multiple face parts of the first face; The first processing module is further configured to perform skin color segmentation on the second face to obtain a skin quality area of ​​the second face; The first processing module is further configured to fuse the skin quality features of the plurality of facial parts to corresponding positions of the skin quality area to obtain an input image; A second processing module is configured to perform facial skin quality optimization on the input image based on the reference image to obtain a target image; The target image includes a processed second face, and the facial skin quality of the processed second face is consistent with the facial skin quality of the first face.

12. An electronic device, It is characterized in that The electronic device comprises: one or more processors; a memory for storing program code executable by the processor; The processor is configured to execute the program code to implement the image processing method according to any one of claims 1 to 10.

13. A computer-readable storage medium, It is characterized in that When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the image processing method according to any one of claims 1 to 10.

14. A computer program product, It is characterized in that The invention comprises a computer program, which implements the image processing method according to any one of claims 1 to 10 when being executed by a processor of an electronic device.

Citation Information

Cited By

  • Image generation method

    CN119850408A

  • Image generation method

    CN119850408B