Image processing method, device, electronic device and storage medium
By training the target facial processing model, using multiple reference facial images and a sample set of processing reference images, the problem of detail loss and high operational complexity in facial image processing in the existing technology is solved, and automatic processing and efficient effects of facial images are achieved. .
Patent Information
- Application Number
- CN202210114114.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-30
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2042-01-30
AI Technical Summary
Existing technology cannot effectively perform automatic refinement processing on each local area in a facial image, resulting in loss of facial image details and high operational complexity.
By acquiring multiple reference facial images to be processed and facial processing reference images, a sample set is constructed, and the target facial processing model is trained to realize automatic processing of facial images.
It improves the facial image processing effect, reduces the complexity of facial processing, and achieves refined processing of local areas of the face without the need for manual adjustment by the user.
Smart Images

Figure CN114445301B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present disclosure relate to the field of image technology, and in particular to an image processing method, device, electronic device, and storage medium. Background Art
[0002] Existing face processing technologies are mostly based on traditional image processing technologies, which directly smooth the skin of facial images to improve the overall brightness and smoothness of the face through one-click beautification. However, this method will cause a large loss of resolution of facial images, lose facial image details, and have a poor beautification effect. In addition, it is impossible to optimize local areas of facial images, such as removing wrinkles and filling facial depressions.
[0003] In order to optimize each local area of the facial image, the existing technology usually requires users to manually adjust each local area on the image processing software, such as adjusting the face shape, modifying the eye size, etc. During the adjustment process, the user needs to constantly interact with the image processing software, and the operation steps are complicated.
[0004] Therefore, the prior art has the technical problem of being unable to achieve automatic refinement processing of each local area in a facial image. Summary of the invention
[0005] The embodiments of the present disclosure provide an image processing method, an apparatus, an electronic device, and a storage medium to realize automatic processing of local areas in a facial image, improve the processing effect of the facial image, and reduce the complexity of facial processing.
[0006] In a first aspect, an embodiment of the present disclosure provides an image processing method, including:
[0007] Acquire a target facial image to be processed of a target object;
[0008] Inputting the target facial image to be processed into a pre-trained target facial processing model to obtain a facial processing target image of a target facial effect;
[0009] The target face processing model is trained based on the following method:
[0010] Acquire multiple reference facial images to be processed to construct a preliminary sample set to be processed, and acquire multiple facial processing reference images with target facial effects to construct a preliminary processing effect set;
[0011] Determine a sample facial image to be processed and a sample facial image to be processed corresponding to the sample facial image to be processed according to the reference facial image to be processed in the preliminary sample set to be processed and the facial processing reference image in the preliminary processing effect set;
[0012] The initial facial processing model is trained according to the sample facial image to be processed and the facial processing sample image corresponding to the sample facial image to be processed to obtain a target facial processing model.
[0013] In a second aspect, the present disclosure also provides an image processing device, including:
[0014] An acquisition module is used to acquire a target facial image to be processed of a target object;
[0015] A processing module, used for inputting the target facial image to be processed into a pre-trained target facial processing model to obtain a facial processing target image with a target facial effect;
[0016] The target face processing model is trained based on the following method:
[0017] Acquire multiple reference facial images to be processed to construct a preliminary sample set to be processed, and acquire multiple facial processing reference images with target facial effects to construct a preliminary processing effect set;
[0018] Determine a sample facial image to be processed and a sample facial image to be processed corresponding to the sample facial image to be processed according to the reference facial image to be processed in the preliminary sample set to be processed and the facial processing reference image in the preliminary processing effect set;
[0019] The initial facial processing model is trained according to the sample facial image to be processed and the facial processing sample image corresponding to the sample facial image to be processed to obtain a target facial processing model.
[0020] In a third aspect, an embodiment of the present disclosure further provides an electronic device, the electronic device comprising:
[0021] one or more processors;
[0022] a storage device for storing one or more programs,
[0023] When the one or more programs are executed by the one or more processors, the one or more processors implement the image processing method provided by any embodiment of the present disclosure.
[0024] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the image processing method provided by any embodiment of the present disclosure is implemented.
[0025] The technical solution of the disclosed embodiment obtains a target facial image to be processed of a target object, inputs the target facial image to be processed into a pre-trained target facial processing model, and obtains a facial processing target image with a target facial effect. Specifically, the sample facial image to be processed and the facial processing sample image corresponding to the sample facial image to be processed can be determined through the reference facial image to be processed in a preliminary sample set and the facial processing reference image in a preliminary processing effect set, and then the target facial processing model is trained through each sample facial image to be processed and the facial processing sample image corresponding thereto, so that the trained target facial processing model can automatically process local facial areas, thereby solving the technical problems of the related technology such as the large loss of facial details, frequent interactions, and time-consuming image processing when performing image processing, thereby improving the processing effect of facial images, and reducing the processing complexity of facial images without the need for manual adjustment by users. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the technical solutions of the exemplary embodiments of the present disclosure, the following briefly introduces the drawings required to describe the embodiments. Obviously, the drawings introduced are only drawings of a part of the embodiments to be described in the present invention, rather than all the drawings. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0027] Figure 1 A flowchart of an image processing method provided in the first embodiment of the present disclosure;
[0028] Figure 2 A schematic diagram of a flow chart of training a target face processing model in an image processing method provided in Embodiment 2 of the present disclosure;
[0029] Figure 3A A schematic diagram of a flow chart of training a target face processing model in an image processing method provided in Embodiment 3 of the present disclosure;
[0030] Figure 3B A schematic diagram of a process for generating paired facial images provided in Embodiment 3 of the present disclosure;
[0031] Figure 4 A schematic diagram of a flow chart of training a target face processing model in an image processing method provided in Embodiment 4 of the present disclosure;
[0032] Figure 5 A flowchart of an image processing method provided in Embodiment 5 of the present disclosure;
[0033] Fig. 6A A flowchart of a preferred image processing method provided in Embodiment 6 of the present disclosure;
[0034] Figure 6B A schematic diagram of a model training based on a preliminary sample set to be processed and a preliminary processing effect set provided in Embodiment 6 of the present disclosure;
[0035] Figure 7 A structural diagram of an image processing device provided in Embodiment 7 of the present disclosure;
[0036] Figure 8 This is a schematic diagram of the structure of an electronic device provided in Embodiment 8 of the present disclosure. DETAILED DESCRIPTION
[0037] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0038] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0039] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0040] It should be noted that the concepts of "first", "second", etc. mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units. It should be noted that the modifications of "one" and "multiple" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, they should be understood as "one or more".
[0041] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0042] Embodiment 1
[0043] Figure 1 This is a flow chart of an image processing method provided in the first embodiment of the present disclosure. This embodiment can be applied to the case where a facial image currently taken by a user or a selected historical facial image is processed to obtain a processed image containing a target facial effect, such as filling a facial sunken area in a facial image, enhancing facial firmness in a facial image, reducing facial firmness, correcting facial skin color in a facial image, etc. The method can be executed by an image processing device, which can be implemented by software and / or hardware and can be configured in a terminal and / or server to implement the image processing method in the embodiment of the present disclosure.
[0044] like Figure 1 As shown, the method of this embodiment may specifically include:
[0045] S110, obtaining a target facial image to be processed of the target object.
[0046] The target object may be an object that needs facial processing, such as a person, an animal, and a model thereof. The target facial image to be processed may be an image containing the facial region of the target object. There are many ways to obtain the target facial image to be processed, such as a facial image currently shot by a user, an image frame in a video clip currently shot by a user, or a historical facial image selected by a user.
[0047] Exemplarily, obtaining the target facial image to be processed of the target object may include: in response to a processing trigger operation of a received facial processing target image for generating a target facial effect, photographing the target facial image to be processed of the target object based on an image capturing device, or receiving the target facial image to be processed of the target object uploaded based on an image upload control.
[0048] The processing trigger operation may be a processing control displayed on the user triggering interface to generate a facial processing target image of the target facial effect. Specifically, after the processing trigger operation is detected, an image shooting control and an image upload control may be displayed on the interface. If a shooting trigger operation for the image shooting control is detected, the target facial image to be processed of the target object may be shot based on the image shooting device. If an upload trigger operation for triggering the image upload control is detected, the target facial image to be processed of the target object uploaded by the user may be received.
[0049] Of course, obtaining the target facial image to be processed of the target object may also be: in response to the received processing trigger operation of the facial processing target image for generating the target facial effect, based on the image shooting device shooting the target facial video to be processed of the target object, determining the target facial image to be processed based on the target facial video to be processed. In this example, the target facial image to be processed shot or uploaded by the user is obtained through the image shooting device or the image upload control, thereby realizing the diversification of the target facial image to be processed and improving the user's experience.
[0050] In an optional embodiment, considering that the acquired target facial image to be processed may contain redundant areas other than the facial area, such as a large number of background areas or areas other than the face, after acquiring the target facial image to be processed of the target object, the method may further include: cutting the target facial image to be processed based on a pre-trained facial detection model so that the cut target facial image to be processed only includes the facial area.
[0051] Specifically, the facial detection model can locate the facial region in the target facial image to be processed, and remove the remaining regions except the facial region in the target facial image to be processed; or, cut and retain a set size region containing the facial region in the target facial image to be processed, such as a 512*512 size region containing the facial region. In this way, the redundant regions in the target facial image to be processed can be removed, the influence of the redundant regions on the processing process can be reduced, and the processing efficiency and processing accuracy of the facial image can be improved.
[0052] S120, inputting the target facial image to be processed into a pre-trained target facial processing model to obtain a facial processing target image with a target facial effect.
[0053] Among them, the target facial effect is a pre-set facial processing effect. In this embodiment, the target facial effect can be an effect of beautifying or uglifying the target facial image to be processed. Exemplarily, the target facial effect of the beautification type can be facial plumping, facial brightening, facial lifting and firming, face shape correction, spot removal, dark circle reduction, eye light addition, facial feature proportion adjustment or facial feature color correction; the target facial effect of the uglification type can be increasing skin age, reducing eye size, reducing facial firmness or facial dullness, etc. Specifically, the target facial effect can include at least one of the above effects.
[0054] Specifically, the pre-trained target facial processing model can output a processed image with a target facial effect. After obtaining the target facial image to be processed, it is input into the target facial processing model to obtain the facial processing target image output by the target facial processing model.
[0055] In this embodiment, the target face processing model is trained based on the following steps:
[0056] Step 1, obtaining multiple reference facial images to be processed to construct a preliminary sample set to be processed, and obtaining multiple facial processing reference images with target facial effects to construct a preliminary processing effect set;
[0057] Step 2, determining a sample facial image to be processed and a facial processing sample image corresponding to the sample facial image to be processed according to the reference facial image to be processed in the preliminary sample set to be processed and the facial processing reference image in the preliminary processing effect set;
[0058] Step 3: training an initial facial processing model according to the sample facial image to be processed and the facial processing sample image corresponding to the sample facial image to be processed to obtain a target facial processing model.
[0059] The reference facial image to be processed may be an unprocessed real facial image; and the facial processing reference image may be a facial image with a target facial effect. Specifically, a certain number of reference facial images to be processed may be collected to form a preliminary sample set to be processed, and a certain number of facial processing reference images may be collected to form a preliminary processing effect set. In order to improve the accuracy of the target facial processing model, reference facial images to be processed and facial processing reference images may be collected at various angles, various skin colors or various age groups.
[0060] During the acquisition process, the structural features of the image can be extracted to determine whether the image can be used as a reference image for facial processing, that is, whether it has the target facial effect. For example, if the target facial effect is a full face, that is, the face has a three-dimensional sense and there is no concave part, the corner points of each image can be extracted. If the number of corner points is less than a preset number threshold, it can be determined that the image has a full face effect and the image is determined as a reference image for facial processing. Alternatively, it is also possible to determine whether the image is a full face image by extracting the line features of the image. For example, the cheek concave area, the chin concave area and the forehead concave area in the facial image can be divided by an edge detection algorithm. If the proportion of the cheek concave area to the cheek exceeds the preset cheek concave ratio threshold, it can be determined that the image does not have the target facial effect; or, if the proportion of the chin concave area exceeds the preset chin concave ratio threshold, it can be determined that the image does not have the target facial effect; or, if the proportion of the forehead concave area exceeds the preset forehead concave ratio threshold, it can be determined that the image does not have the target facial effect.
[0061] For another example, if the target facial effect is to remove spots, the facial area other than the facial features in the image can be determined, and based on the pixel values of each pixel point in the facial area other than the facial features, it can be determined whether there are spots in the facial area. If not, the image can be determined to be a facial processing reference image. If the target facial effect is to reduce dark circles, the associated area of the eyes can be determined in the image, and based on the difference between the pixel mean of the associated area of the eyes and the pixel mean of the rest of the facial area, it can be determined whether the image has the target facial effect. For example, if the difference between the pixel mean of the associated area of the eyes in the image and the pixel mean of the rest of the facial area is less than a preset difference threshold, it can be determined that the image has the target facial effect.
[0062] Furthermore, based on the reference facial images to be processed in the constructed preliminary sample set to be processed and the facial processing reference images in the constructed preliminary processing effect set, paired sample facial images to be processed and facial processing sample images can be generated.
[0063] The sample facial images to be processed may be reference facial images to be processed in the preliminary sample set to be processed, or may be newly generated unprocessed facial images. Exemplarily, a style-based generative adversarial network may be trained by the preliminary sample set to be processed, and new unprocessed facial images may be generated based on the trained generative adversarial network. For example, the preliminary sample set to be processed includes 500 reference facial images to be processed, an image generation network is trained by the 500 reference facial images to be processed, and 2000 new facial images to be processed are generated by the trained image generation network. Then, the sample facial images to be processed used to train the target facial processing model may be all or part of the 2500 images.
[0064] The facial processing sample image corresponding to the sample facial image to be processed may be a newly generated facial image with a target facial effect. For example, another image generation network may be trained using the preliminary processing effect set, and the vector corresponding to the sample facial image to be processed may be input into the trained image generation network to obtain a facial processing sample image paired with the sample facial image to be processed. It should be noted that the sample facial image to be processed and the facial processing sample image corresponding to the sample facial image to be processed may be two facial images of the same target object, or may be facial images of two similar but different target objects. The image generation networks trained respectively using the preliminary sample set to be processed and the preliminary processing effect set may be the same network or different networks. For example, the image generation network may be a style-based generative adversarial network, a pixel recursive neural network, a variational autoencoder, and the like.
[0065] It should be noted that the purpose of determining the sample facial images to be processed and the facial processing sample images corresponding to the sample facial images to be processed in the present embodiment is: considering that it is difficult to obtain a large number of reference images when collecting data, and it is difficult to obtain paired images to be processed and facial images with target facial effects; therefore, the present embodiment can generate paired sample facial images to be processed and facial processing sample images by collecting a small number of reference facial images to be processed and facial processing reference images, which solves the technical problem that the prior art cannot obtain a large number of paired facial images, provides data support for the training of the target facial processing model, and thereby ensures the prediction accuracy of the trained target facial processing model.
[0066] In this embodiment, further, after determining each sample facial image to be processed and the facial processing sample image corresponding to each sample facial image to be processed, the constructed initial facial processing model can be trained according to the paired sample facial images to be processed and the facial processing sample images, the loss is calculated according to the prediction results of the initial facial processing model, and the network parameters in the initial facial processing model are adjusted in reverse. If the loss function reaches the convergence condition, the trained initial facial processing model is used as the target facial processing model.
[0067] Among them, the target facial processing model can be a convolutional neural network model such as a residual network, a fully convolutional network, etc., or it can also be a generative model trained in a generative adversarial network model.
[0068] In an optional implementation, the initial facial processing model includes a processing effect generation model and a processing effect discrimination model; the training of the initial facial processing model according to the sample facial image to be processed and the facial processing sample image corresponding to the sample facial image to be processed to obtain the target facial processing model may include the following steps:
[0069] Step 1, input the sample facial image to be processed into the processing effect generation model to obtain the processing effect generation image; Step 2, adjust the processing effect generation model according to the sample facial image to be processed, the processing effect generation image and the facial processing sample image corresponding to the sample facial image to be processed; Step 3, determine whether to end the adjustment of the processing effect generation model according to the discrimination result of the processing effect discrimination model on the processing effect generation image, and use the processing effect generation model obtained at the end of the adjustment as the target facial processing model.
[0070] The processing effect generation model may be a generator in the initial facial processing model, and the processing effect discrimination model may be a discriminator in the initial facial processing model. Specifically, the processing effect generation model may generate a facial image with a target facial effect added to the sample facial image to be processed, i.e., a processing effect generation image.
[0071] In this optional implementation, the loss function can be calculated based on the processing effect generation image output by the processing effect generation model, the input sample facial image to be processed, and the facial processing sample image corresponding to the sample facial image to be processed, and the internal parameters of the processing effect generation model can be adjusted based on the calculation result of the loss function.
[0072] The processing effect generated image output by the processing effect generation model can also be input into the processing effect discrimination model. The processing effect discrimination model can discriminate the processing effect generated image based on the facial processing sample image corresponding to the sample facial image to be processed, and output the probability that the processing effect generated image and the facial processing sample image belong to the same category, that is, output the discrimination result of the processing effect generated image; determine whether to continue adjusting the processing effect generation model based on the discrimination result.
[0073] The value of the discrimination result can be [0,1], where 0 means that the processing effect generated image and the facial processing sample image do not belong to the same category, that is, the processing effect generated image is "false" and the processing effect is poor; 1 means that the processing effect generated image and the facial processing sample image belong to the same category, that is, the processing effect generated image is "true" and the processing effect is good. Exemplarily, if the discrimination result is greater than a preset discrimination threshold, the parameter adjustment of the processing effect generation model can be terminated; or, if the number of times the discrimination result is greater than the preset discrimination threshold exceeds a preset number of times, the parameter adjustment of the processing effect generation model can be terminated.
[0074] In this optional implementation, the processing effect generation model is reversely adjusted based on the processing effect generation image output by the processing effect generation model and the discrimination result of the processing effect discrimination model on the processing effect generation image, thereby achieving accurate training of the target facial processing model. Compared with the convolutional neural network, the generative adversarial target facial processing model can improve the processing accuracy of facial images.
[0075] In the above steps, the processing effect generation model is adjusted through the sample facial image to be processed, the processing effect generation image and the facial processing sample image, and the facial high-dimensional semantic feature correction and the facial low-dimensional texture feature correction can also be performed.
[0076] That is, the processing effect generation model is adjusted according to the sample facial image to be processed, the processing effect generated image, and the facial processing sample image corresponding to the sample facial image to be processed. Specifically, it can be: determining a first facial feature loss between the sample facial image to be processed and the processing effect generated image, and determining a second facial feature loss between the processing effect generated image and the facial processing sample image corresponding to the sample facial image to be processed; adjusting the processing effect generation model according to the first facial feature loss and the second facial feature loss.
[0077] The first facial feature loss can be understood as the loss between the input and output of the processing effect generation model; the second facial feature loss can be understood as the loss between the label corresponding to the input of the processing effect generation model and the output. Specifically, the processing effect generation model is adjusted according to the first facial feature loss and the second facial feature loss, which can be: the first facial feature loss is less than a preset first loss threshold, and the second facial feature loss is less than a preset second loss threshold as the adjustment termination conditions, and the processing effect generation model is adjusted.
[0078] It should be noted that the purpose of using the first facial feature loss being less than the preset first loss threshold and the second facial feature loss being less than the preset second loss threshold as the adjustment termination conditions is to: while ensuring the processing effect of the processing effect generation model, reduce the gap between the input and output of the processing effect generation model, and ensure that the processed facial image retains the original facial information as much as possible.
[0079] In another embodiment, the processing effect generation model is adjusted according to the first facial feature loss and the second facial feature loss. It can also be that the total damage is calculated based on the first facial feature loss, the weight corresponding to the first facial feature loss, the second facial feature loss and the weight corresponding to the second facial feature loss, and the processing effect generation model is adjusted based on the total damage.
[0080] In this optional implementation, the processing effect generation model is adjusted by calculating the first facial feature loss and the second facial feature loss, thereby achieving high-dimensional semantic feature correction and low-dimensional texture feature correction of the face. While improving the processing accuracy of the processing effect generation model, it ensures that the processed facial image retains as much initial facial information as possible, thereby avoiding severe distortion of the facial image after processing.
[0081] The technical solution of this embodiment obtains a target facial image to be processed of the target object, inputs the target facial image to be processed into a pre-trained target facial processing model, and obtains a facial processing target image with a target facial effect. Specifically, the sample facial image to be processed and the facial processing sample image corresponding to the sample facial image to be processed can be determined through the reference facial image to be processed in the preliminary sample set and the facial processing reference image in the preliminary processing effect set, and then the target facial processing model is trained through each sample facial image to be processed and the facial processing sample image corresponding thereto, so that the trained target facial processing model can realize automatic processing of local facial areas, thereby improving the processing effect of facial images and reducing the processing complexity of facial images.
[0082] Embodiment 2
[0083] Figure 2 A flow chart of training a target facial processing model in an image processing method provided in the second embodiment of the present disclosure, wherein the present embodiment is based on any optional technical solution in the embodiments of the present disclosure, and optionally, the sample facial image to be processed and the facial processing sample image corresponding to the sample facial image to be processed are determined according to the reference facial image to be processed in the preliminary sample set to be processed and the facial processing reference image in the preliminary processing effect set, including: training a pre-established first initial image generation model according to the reference facial image to be processed in the preliminary sample set to be processed to obtain a sample effect image generation model; training a pre-established second initial image generation model according to the facial processing reference image in the preliminary processing effect set to obtain a sample effect image generation model; generating a sample facial image to be processed and a facial processing sample image corresponding to the sample facial image to be processed according to the sample image generation model and the sample effect image generation model; wherein the first initial image generation model and the second initial image generation model are style-based generative adversarial networks.
[0084] like Figure 2 As shown, the training method of the target face processing model provided in this embodiment includes the following steps:
[0085] S210, obtaining a plurality of reference facial images to be processed to construct a preliminary sample set to be processed, and obtaining a plurality of facial processing reference images having target facial effects to construct a preliminary processing effect set.
[0086] S220. A first initial image generation model established in advance is trained according to the reference facial images to be processed in the preliminary sample set to be processed to obtain an image generation model to be processed; and a second initial image generation model established in advance is trained according to the facial processing reference images in the preliminary processing effect set to obtain a sample effect image generation model.
[0087] Wherein, the first initial image generation model and the second initial image generation model are style-based generative adversarial networks. Exemplarily, the style-based generative adversarial network can be a style-based generator (StyleGAN). Of course, the first initial image generation model and the second initial image generation model can also adopt unsupervised neural networks.
[0088] Specifically, the first initial image generation model may include a generation network and a discriminant network. Exemplarily, the training process of the image generation model to be processed may be: first, a plurality of simulated facial images to be processed for training the discriminator are generated through the generation network; a label set for each simulated facial image to be processed (such as 0, indicating false) and a label set for each reference facial image to be processed (such as 1, indicating true); based on the simulated facial image to be processed, the reference facial image to be processed, the label corresponding to the simulated facial image to be processed and the label corresponding to the reference facial image to be processed, a training set for training the discriminant network is constructed, and the discriminant network is trained. In the training process of the discriminant network, the discriminant network can determine the probability that the simulated facial image to be processed and the reference facial image to be processed belong to the same category based on the input simulated facial image to be processed and the reference facial image to be processed, that is, the probability that the simulated facial image to be processed is true; or, the probability that the two reference facial images to be processed belong to the same category can be determined based on the input two reference facial images to be processed.
[0089] Furthermore, after completing the training of the discriminant network, the training purpose of the generative network is to enable the generative network to generate facial images to be processed that are as realistic as possible. Specifically, a plurality of simulated facial images to be processed can be generated again by the generative network, and the newly generated simulated facial images to be processed are input into the discriminant network. Based on the discrimination result of the discriminant network on the simulated facial images to be processed, the generative network is reversely adjusted until the discrimination result of the discriminant network on the simulated facial images to be processed generated by the generative network is true, thereby obtaining a generation model of the image to be processed.
[0090] In this embodiment, the second initial image generation model may also include a generation network and a discriminant network. Specifically, the training process of the second initial image generation model may be: generating multiple simulated processed facial images for training the discriminator through the generation network, training the discriminant network based on the simulated processed facial images, facial processing reference images, labels corresponding to the simulated processed facial images, and labels corresponding to the facial processing reference images, and then generating multiple simulated processed facial images again through the generation network, inputting the newly generated simulated processed facial images into the discriminant network, adjusting the generation network based on the discriminant network's discrimination results of the simulated processed facial images, and obtaining a sample effect image generation model.
[0091] S230. Generate a sample facial image to be processed and a facial processing sample image corresponding to the sample facial image to be processed according to the sample facial image generation model and the sample effect image generation model.
[0092] Specifically, after training the image generation model to be processed and the sample effect image generation model, the image generation model to be processed can be used to generate a sample facial image to be processed, and the sample effect image generation model can be used to generate a facial processing sample image corresponding to the sample facial image to be processed.
[0093] Exemplarily, random noise (i.e., random vector) can be introduced into the image generation model to be processed to obtain a sample facial image to be processed corresponding to the random noise output by the image generation model to be processed, and the same random noise can be introduced into the sample effect image generation model to obtain a facial processing sample image corresponding to the random noise. At this time, the sample facial image to be processed output by the image generation model to be processed is paired with the facial processing sample image output by the sample effect image generation model.
[0094] In other words, by inputting the same vector into the image generation model to be processed and the sample effect image generation model respectively, a sample facial image to be processed and a facial processing sample image corresponding to the sample facial image to be processed can be obtained. In this way, a large number of sample facial images to be processed and facial processing sample images paired therewith can be determined, thereby expanding the sample set used to train the target facial processing model.
[0095] It should be noted that, since the sample facial image to be processed can also be the reference facial image to be processed in the preliminary sample set to be processed, the reference facial image to be processed in the preliminary sample set to be processed can also be directly determined as the sample facial image to be processed, and the vector corresponding to the reference facial image to be processed can be input into the sample effect image generation model.
[0096] S240, training an initial facial processing model according to the sample facial image to be processed and the facial processing sample image corresponding to the sample facial image to be processed to obtain a target facial processing model.
[0097] The technical solution of this embodiment is to train a style-based generative adversarial network using the reference facial images to be processed in the preliminary sample set to be processed to obtain a generation model for the images to be processed, and to train a style-based generative adversarial network using the facial processing reference images in the preliminary processing effect set to obtain a sample effect image generation model, and then generate a sample facial image to be processed and a facial processing sample image corresponding to the sample facial image to be processed according to the generation model for the image to be processed and the sample effect image generation model, thereby achieving the expansion of the training data of the target facial processing model, solving the technical problem that the prior art cannot obtain a large number of paired images to be processed and facial processing images, and improving the processing accuracy of the target facial processing model.
[0098] Embodiment 3
[0099] Figure 3A This is a flow chart of training a target facial processing model in an image processing method provided in the third embodiment of the present disclosure. This embodiment is based on any optional technical solution in the embodiments of the present disclosure. Optionally, the generation of a sample facial image to be processed and a facial processing sample image corresponding to the sample facial image to be processed according to the image generation model to be processed and the sample effect image generation model includes: determining a target image conversion model according to the reference facial image to be processed in the preliminary sample set to be processed and the image generation model to be processed, wherein the target image conversion model is used to convert an image input into the target image conversion model into a target image vector; generating a sample facial image to be processed according to the image generation model to be processed, and generating a facial processing sample image corresponding to the sample facial image to be processed according to the sample facial image to be processed, the target image encoding model and the sample effect image generation model. Figure 3A As shown, the training method of the target face processing model provided in this embodiment includes the following steps:
[0100] S310, obtaining a plurality of reference facial images to be processed to construct a preliminary sample set to be processed, and obtaining a plurality of facial processing reference images having target facial effects to construct a preliminary processing effect set.
[0101] S320, training a pre-established first initial image generation model according to the reference facial images to be processed in the preliminary sample set to be processed to obtain a model for generating an image to be processed, and training a pre-established second initial image generation model according to the facial processing reference images in the preliminary processing effect set to obtain a sample effect image generation model.
[0102] The first initial image generation model and the second initial image generation model are style-based generative adversarial networks.
[0103] S330, determining a target image conversion model according to the reference facial image to be processed in the preliminary sample set to be processed and the image generation model to be processed, wherein the target image conversion model is used to convert the image input into the target image conversion model into a target image vector.
[0104] In this embodiment, the purpose of converting an image into a target image vector by using a target image conversion model is to obtain a vector corresponding to the image to be paired, so as to input the vector corresponding to the image into a processing image generation model and a sample effect image generation model, and obtain a paired processing sample facial image and a facial processing sample image. The image to be paired can be a processing reference facial image in a preliminary processing sample set, or an image generated based on the processing image generation model.
[0105] Specifically, the target image conversion model can be trained by using the preliminary sample set to be processed and the image generation model to be processed. Exemplarily, the target image conversion model is determined based on the reference facial image to be processed in the preliminary sample set to be processed and the image generation model to be processed, which may include the following steps:
[0106] Step 1: inputting the reference facial image to be processed in the preliminary sample set to be processed into the initial image conversion model to obtain a model conversion vector;
[0107] Step 2: input the model conversion vector into the image generation model to be processed to obtain a model generated image corresponding to the model conversion vector;
[0108] Step 3: Adjust the parameters of the initial image conversion model according to the loss between the model-generated image and the input reference facial image to be processed corresponding to the model-generated image to obtain a target image conversion model.
[0109] In the above exemplary steps, by inputting the reference facial image to be processed into the constructed initial image conversion model, a model conversion vector corresponding to the reference facial image to be processed output by the initial image conversion model can be obtained; further, the model conversion vector is input into the trained image generation model to be processed to obtain a model generated image corresponding to the model conversion vector; finally, the loss function is calculated through the reference facial image to be processed and the model generated image, and the parameters of the initial image conversion model are adjusted according to the calculation result of the loss function until the training cutoff condition is reached. Among them, the training cutoff condition can be that the loss between the reference facial image to be processed and the model generated image converges and approaches zero, that is, the model generated image output by the image generation model to be processed is infinitely close to the reference facial image to be processed in the initial sample set to be processed.
[0110] In the above steps, by inputting the reference facial image to be processed into the initial image conversion model, and inputting the model conversion vector output by the initial image conversion model into the image generation model to be processed, the parameters of the initial image conversion model are adjusted according to the loss between the reference facial image to be processed and the model generated image output by the image generation model to be processed, thereby achieving accurate training of the target image conversion model, improving the accuracy of the image vector output by the target image conversion model, and thereby improving the accuracy of the paired sample facial images to be processed and the facial processing sample images.
[0111] S340, generating a sample facial image to be processed according to the image generation model to be processed, and generating a facial processing sample image corresponding to the sample facial image to be processed according to the sample facial image to be processed, the target image encoding model and the sample effect image generation model.
[0112] Specifically, a sample facial image to be processed may be generated by a model for generating an image to be processed, the sample facial image to be processed may be input into a target image encoding model to obtain a target image vector corresponding to the sample facial image to be processed, and further, the target image vector may be input into a sample effect image generation model to generate a facial processing sample image corresponding to the sample facial image to be processed.
[0113] In another optional embodiment, the step of generating a sample facial image to be processed according to the image generation model to be processed, and generating a facial processing sample image corresponding to the sample facial image to be processed according to the sample facial image to be processed, the target image encoding model and the sample effect image generation model, may also be: inputting the reference facial image to be processed into the target image encoding model to obtain a target image vector corresponding to the reference facial image to be processed; inputting the target image vector into the image generation model to obtain the sample facial image to be processed; and inputting the target image vector into the sample effect image generation model to obtain a facial processing sample image corresponding to the sample facial image to be processed.
[0114] That is, Figure 3B As shown, a schematic diagram of the process of generating paired facial images is shown. The reference facial image to be processed in the preliminary sample set to be processed is input into the target image encoding model to obtain the target image vector corresponding to the reference facial image to be processed; and the target image vector is input into the image generation model to be processed and the sample effect image generation model respectively to obtain the sample facial image to be processed and the facial processing sample image corresponding to the sample facial image to be processed.
[0115] Through this optional implementation, the paired facial images are accurately constructed, and then the training data of the target facial processing model is determined, which solves the technical problem that the prior art cannot obtain paired facial images.
[0116] S350, training an initial facial processing model according to the sample facial image to be processed and the facial processing sample image corresponding to the sample facial image to be processed to obtain a target facial processing model.
[0117] The technical solution of this embodiment determines a target image conversion model that can convert an image into a vector through a reference facial image to be processed in a preliminary sample set to be processed and a generation model of the image to be processed, and generates a sample facial image to be processed and a facial processing sample image corresponding to the sample facial image to be processed through the target image conversion model, the generation model of the image to be processed and the sample effect image generation model, thereby realizing automatic acquisition of paired facial images, solving the technical problem that the prior art cannot acquire a large amount of paired data, and eliminating the need to manually screen out facial images that can be paired, thereby reducing development costs.
[0118] Embodiment 4
[0119] Figure 4 This is a flowchart of training a target facial processing model in an image processing method provided in the fourth embodiment of the present disclosure. This embodiment is based on any optional technical solution in the embodiments of the present disclosure. Optionally, before the initial facial processing model is trained according to the sample facial images to be processed and the facial processing sample images corresponding to the sample facial images to be processed, it also includes: performing image correction processing on the facial processing sample images corresponding to the sample facial images to be processed according to the sample facial images to be processed, wherein the image correction processing includes at least one of facial color correction processing, facial deformation correction processing, and facial makeup restoration processing. Figure 4 As shown, the training method of the target face processing model provided in this embodiment includes the following steps:
[0120] S410, obtaining a plurality of reference facial images to be processed to construct a preliminary sample set to be processed, and obtaining a plurality of facial processing reference images having a target facial effect to construct a preliminary processing effect set.
[0121] S420, training a pre-established first initial image generation model according to the reference facial images to be processed in the preliminary sample set to be processed to obtain an image generation model to be processed, and training a pre-established second initial image generation model according to the facial processing reference images in the preliminary processing effect set to obtain a sample effect image generation model.
[0122] S430. Generate a sample facial image to be processed and a facial processing sample image corresponding to the sample facial image to be processed according to the sample facial image generation model and the sample effect image generation model.
[0123] S440, performing image correction processing on the sample facial image to be processed or the facial processing sample image corresponding to the sample facial image to be processed, wherein the image correction processing includes at least one of facial color correction processing, facial deformation correction processing and facial makeup restoration processing.
[0124] Specifically, in order to enable the trained target facial processing model to retain as much initial facial information as possible while realizing local processing of facial images, reduce the gap between the processed facial images and the initial facial images, and improve the user experience, the present embodiment can also adjust the facial processing sample images corresponding to the sample facial images to be processed required for training the target facial processing model before training the target facial processing model, so that the facial processing sample images include more features of the sample facial images to be processed, thereby making the processing effect of the trained target facial processing model more realistic.
[0125] In this embodiment, at least one of facial color correction, facial deformation correction, and facial makeup restoration can be performed on the facial processing sample image corresponding to the sample facial image to be processed. Among them, the facial color correction can be performed by correcting the colors of each area in the facial processing sample image so that the colors of each area in the corrected facial processing sample image are close to the colors of the same area in the sample facial image to be processed. The facial deformation correction can be performed by correcting the facial features and / or facial angle in the facial processing sample image so that the facial features and / or facial angle between the corrected facial processing sample image and the sample facial image to be processed are consistent. The facial makeup restoration can be performed by determining the makeup information in the facial processing sample image and adding the makeup information to the sample facial image to be processed corresponding to the facial processing sample image so that the makeup information between the added sample facial image to be processed and the facial processing sample image is consistent.
[0126] Exemplarily, when the image correction processing includes facial color correction processing, the image correction processing performed on the sample facial image to be processed or the facial processing sample image corresponding to the sample facial image to be processed may include: determining the facial skin area to be processed in the sample facial image to be processed, and determining a reference color average value corresponding to each pixel in the facial skin area to be processed; determining the facial skin area to be adjusted in the facial processing sample image corresponding to the sample facial image to be processed, and determining a color average value to be adjusted corresponding to each pixel in the facial skin area to be adjusted; adjusting the color values corresponding to each pixel in the facial skin area to be adjusted according to the reference color average value and the color average value to be adjusted.
[0127] Among them, the facial skin area to be processed may be an area that needs to be color corrected, such as a cheek area, a forehead area, a jaw area, etc. Optionally, the cheek area, the forehead area and the jaw area may be directly divided in the sample facial image to be processed according to a preset facial division template, and the divided areas are determined as the facial skin areas to be processed. Alternatively, the facial skin area to be processed may be divided according to the facial features in the sample facial image to be processed. For example, determining the facial skin area to be processed in the sample facial image to be processed may be: determining the locations of the facial features in the sample facial image to be processed, dividing the sample facial image to be processed according to the locations of the facial features, and obtaining the facial skin areas to be processed.
[0128] Furthermore, the reference color average value corresponding to each pixel point in the facial skin area to be processed is determined. The reference color average value may be the color average value of the pixel points in other areas of the facial skin area to be processed except the facial features, or it may be the color average value of the pixel points in the central area of the facial skin area to be processed except the facial features. At the same time, the area corresponding to the facial skin area to be processed in the facial processing sample image, that is, the facial skin area to be adjusted, may also be determined, and the color average value to be adjusted corresponding to each pixel point in the facial skin area to be adjusted is determined. The color average value to be adjusted may be the color average value of the pixel points in other areas of the facial skin area to be adjusted except the facial features, or it may be the color average value of the pixel points in the central area of the facial skin area to be adjusted except the facial features.
[0129] Adjusting the color values corresponding to each pixel point in the facial skin area to be adjusted according to the reference color average value and the color average value to be adjusted can be: determining the color deviation amount corresponding to the color average value to be adjusted compared with the reference color average value, adding the color values corresponding to each pixel point in the facial skin area to be adjusted to the color deviation amount, so as to update the color values corresponding to each pixel point in the facial skin area to be adjusted. The color deviation amount can be calculated by subtracting the reference color average value from the color average value to be adjusted, and the color deviation amount can be a positive value, that is, the color average value to be adjusted is less than the reference color average value, or a negative value, that is, the color average value to be adjusted is greater than the reference color average value.
[0130] In this example, by determining the facial skin area to be processed in the sample facial image to be processed, the reference color average corresponding to each pixel in the facial skin area to be processed, the facial skin area to be adjusted in the facial processing sample image, and the color average to be adjusted corresponding to each pixel in the facial skin area to be adjusted, the color values corresponding to each pixel in the facial skin area to be adjusted are adjusted by the reference color average and the color average to be adjusted, thereby realizing facial color correction processing for the facial processing sample image, so that the facial color in the paired facial processing sample image is closer to the facial color in the sample facial image to be processed, and then the trained target facial processing model can maintain the original facial color as much as possible while realizing facial processing, thereby improving the user experience.
[0131] In another example, when the image correction processing includes facial makeup restoration processing, the image correction processing on the sample facial image to be processed or the facial processing sample image corresponding to the sample facial image to be processed may include: if the facial area in the facial processing sample image includes makeup information, then performing makeup processing on the sample facial image to be processed corresponding to the facial processing sample image according to the makeup information.
[0132] Wherein, it can be determined whether the facial area in the facial processing sample image includes makeup information in the following manner, namely: based on a preset facial makeup area division template, each facial area to be determined is divided in the sample facial image to be processed, and each facial area to be compared is divided in the facial processing sample image, and based on the color mean of the facial area to be compared and the color mean of the facial area to be determined corresponding to the facial area to be compared, it is determined whether the facial area to be determined includes makeup information; wherein the facial makeup area division template may include a lip-related area, a nose bridge-related area, and an eye-related area. Alternatively, it can also be determined whether the facial area to be determined includes makeup information based on the contour information of the facial area to be compared and the contour information of the facial area to be determined corresponding to the facial area to be compared; wherein the facial makeup area division template also includes an eyebrow-related area and an eye extension area.
[0133] After determining that the facial area in the facial processing sample image includes makeup information, a makeup information migration strategy can be adopted to copy the makeup information to the sample facial image to be processed; or the makeup position included in the makeup information and the operation information corresponding to the makeup position are analyzed, and makeup processing is performed on the sample facial image to be processed based on the makeup position and the operation information corresponding to the makeup position.
[0134] In this example, makeup processing can be performed on the sample facial image to be processed corresponding to the facial processing sample image through the makeup information in the facial area in the facial processing sample image, so that the makeup information in the sample facial image to be processed is consistent with the makeup information in the paired facial processing sample image, thereby enabling the trained target facial processing model to maintain the original facial makeup as much as possible while realizing facial processing, thereby improving the user experience.
[0135] In another example, when the image correction processing includes facial deformation correction processing, the image correction processing on the sample facial image to be processed or the facial processing sample image corresponding to the sample facial image to be processed may include: respectively determining correction key points of the facial area in the sample facial image to be processed and the facial processing sample image corresponding to the sample facial image to be processed; adjusting the shape of the facial area in the facial processing sample image according to the positions of the correction key points in the sample facial image to be processed.
[0136] Among them, the correction key points can be facial key points located in the sample facial image to be processed and the facial processing sample image. For example, the facial features and facial contours of the sample facial image to be processed and the facial processing sample image can be obtained, and each correction key point can be determined in the facial features and facial contours; or, the correction key points can be determined in the sample facial image to be processed and the facial processing sample image based on methods such as ASM (Active Shape Model), AAM (Active Appearance Model), CPR (Cascaded Pose Regression), etc.
[0137] It should be noted that the number of the correction key points determined in the sample facial image to be processed and the facial processing sample image should be consistent, and the correction key points in the sample facial image to be processed can correspond one-to-one to the correction key points in the facial processing sample image.
[0138] Furthermore, based on the position of the correction key point in the sample facial image to be processed, the position of the correction key point corresponding to the correction key point in the facial processing sample image can be adjusted to adjust the shape of the facial area in the facial processing sample image, so that the shape of the facial area in the adjusted facial processing sample image is close to the shape of the facial area in the sample facial image to be processed, including the shape of the facial features and the facial angle.
[0139] In this example, by respectively determining the correction key points of the facial area in the sample facial image to be processed and the paired facial processing sample image, the shape of the facial area in the facial processing sample image is adjusted according to the positions of the correction key points, so that the facial shape of the sample facial image to be processed and the corresponding facial processing sample image are kept as consistent as possible, thereby enabling the trained target facial processing model to maintain the original facial shape as much as possible while realizing facial processing, thereby improving the user experience.
[0140] S450, training an initial facial processing model according to the sample facial image to be processed and the facial processing sample image corresponding to the sample facial image to be processed to obtain a target facial processing model.
[0141] The technical solution of this embodiment performs at least one of facial color correction processing, facial deformation correction processing, and facial makeup restoration processing on the sample facial image to be processed or the facial processing sample image corresponding to the sample facial image to be processed before training the initial facial processing model based on the sample facial image to be processed and the facial processing sample image corresponding to the sample facial image to be processed, thereby reducing the facial color difference, facial deformation difference, or facial makeup difference between the sample facial image to be processed and the facial processing sample image, thereby enabling the trained target facial processing model to output a processed image that retains more initial facial information, thereby improving the user experience.
[0142] Embodiment 5
[0143] Figure 5 This is a flowchart of an image processing method provided by Embodiment 5 of the present disclosure. Based on any optional technical solution in the embodiments of the present disclosure, this embodiment optionally further comprises, after obtaining a target facial effect facial processing target image, displaying the target facial processing image in a target display area. Figure 5 As shown, the image processing method provided in this embodiment includes the following steps:
[0144] S510, obtaining a target facial image to be processed of a target object, and inputting the target facial image to be processed into a pre-trained target facial processing model to obtain a facial processing target image of a target facial effect.
[0145] S520: Display the facial processing target image in the target display area.
[0146] The target display area may be a pre-set area for displaying the target image of the face processing. For example, the target display area may be the entire area of the display interface. Alternatively, the target display area may also be a partial area of the display interface.
[0147] Specifically, the display interface can be divided into two local areas, such as two local areas of the same size, located at the upper and lower parts of the display interface; or two local areas of the same size, located at the left and right parts of the display interface; or two independent areas of different sizes, located at different positions in the display interface.
[0148] The advantage of setting a local area as the target display area in the display interface is that it is convenient to simultaneously display the facial processing target image and the target facial image to be processed, so that the user can compare the facial processing target image and the target facial image to be processed, that is, compare the facial images before and after processing, thereby improving the user experience.
[0149] In this embodiment, the facial processing target image can be directly displayed in the target display area, and the facial processing target images with different processing degrees can also be directly displayed in the target display area respectively; or, according to the user's operation, the facial processing target image with the processing degree corresponding to the operation can also be displayed.
[0150] That is, optionally, after the facial processing target image of the target facial effect is obtained, it also includes: displaying an effect adjustment control for adjusting the degree of image processing in the target display area; when receiving a processing degree adjustment operation input to the effect adjustment control, displaying the facial processing target image corresponding to the processing degree adjustment operation in the target display area.
[0151] The effect adjustment control may be in the form of multiple selection boxes or a progress bar. The user may select the processing degree by triggering the selection box in the effect adjustment control, or may select the processing degree by dragging the progress bar in the effect adjustment control.
[0152] Specifically, after obtaining the processing degree adjustment operation input by the user for the effect adjustment control, that is, the selected selection box or the position of the dragged progress bar, the facial processing target image corresponding to the processing degree adjustment operation can be displayed in the target display area. Among them, different processing degree adjustment operations correspond to different degrees of target facial effects in the facial processing target image. For example, the processing degree can be determined according to the processing degree adjustment operation, and the facial processing target image corresponding to the processing degree adjustment operation is determined based on the processing degree.
[0153] In this optional embodiment, by displaying an effect adjustment control for adjusting the degree of image processing, and after receiving a processing degree adjustment operation input to the effect adjustment control, displaying a facial processing target image corresponding to the processing degree adjustment operation, the display of facial processing target images with different processing degrees is achieved, the user is provided with a choice of processing degrees, and the diversity of processed images is improved, thereby greatly improving the user experience.
[0154] In a specific embodiment, displaying the facial processing target image corresponding to the adjustment operation in the target display area includes: determining a target weight value corresponding to the processing degree adjustment operation, determining the facial processing target image corresponding to the processing degree adjustment operation based on the target facial image to be processed, the facial processing target image, the target weight value and a preset facial mask image, and displaying the adjusted facial processing target image in the target display area.
[0155] The pixel value of the facial skin area in the preset facial mask image is 1, and the pixel value of the area other than the facial skin area is 0. Specifically, the pixel value interval [0,255] can be mapped to the interval [0,1], where 0 represents black and 1 represents white. That is, the facial skin area in the preset facial mask image can be white; the area other than the facial skin area, such as the facial features area, is black.
[0156] By presetting the facial mask image, it is possible to adjust the processing degree of only the facial skin area, and avoid adjusting the processing degree of areas other than the facial skin area. Specifically, the facial skin area in the facial processing target image and the target facial image to be processed can be determined by presetting the facial mask image, and further, the pixel values of the facial skin area in the facial processing target image and the target facial image to be processed can be weighted by the target weight value to obtain the facial processing target image corresponding to the processing degree adjustment operation.
[0157] It should be noted that in the process of weighted calculation of the pixel values of the facial skin area in the face processing target image and the target facial image to be processed by using the target weight value, if the processing degree is smaller, the weight calculation value of the pixel values of the facial skin area in the target facial image to be processed will be larger; if the processing degree is larger, the weight calculation value of the pixel values of the facial skin area in the face processing target image will be larger.
[0158] In this embodiment, by presetting a facial mask image, a target weight value corresponding to a processing degree adjustment operation, a target facial image to be processed, and a facial processing target image, a facial processing target image corresponding to the processing degree adjustment operation is determined, thereby achieving adjustment of the processing degree for the facial skin area, avoiding adjustment of areas other than the facial skin area, and thereby avoiding distortion of areas other than the facial skin area, thereby improving the user experience.
[0159] In the above process, optionally, determining the facial processing target image corresponding to the processing degree adjustment operation according to the target facial image to be processed, the facial processing target image, the target weight value and the preset facial mask image may also be: performing weighted processing on the pixel values of each pixel in the preset facial mask image according to the target weight value to obtain the target adjustment weight corresponding to each pixel; for each pixel to be adjusted in the facial area of the facial processing target image, calculating the target pixel value of the pixel to be adjusted according to the original pixel value of the pixel to be adjusted in the target facial image to be processed, the current pixel value in the facial processing target image and the target adjustment weight corresponding to the pixel to be adjusted, so as to obtain the facial processing target image corresponding to the processing degree adjustment operation.
[0160] That is, the pixel values in the preset facial mask image can also be weighted by the target weight value to obtain the target adjustment weight of each pixel. Further, for each pixel to be adjusted in the facial area of the facial processing target image, a weighted calculation can be performed according to the original pixel value of the pixel to be adjusted in the facial image to be processed, the current pixel value in the facial processing target image, and the target adjustment weight corresponding to the pixel to be adjusted to obtain the target pixel value of the pixel to be adjusted. In this way, the processing degree of each pixel to be adjusted in the facial area of the facial processing target image can be adjusted to obtain the facial processing target image corresponding to the processing degree adjustment operation.
[0161] Exemplarily, the above optional implementation can be expressed by the following formula:
[0162] output=a×(1-t×mask)+b×(t×mask)
[0163] Among them, output represents the facial processing target image corresponding to the processing degree adjustment operation, a represents the original pixel value of the pixel to be adjusted in the target facial image to be processed, b represents the current pixel value of the pixel to be adjusted in the facial processing target image, t represents the target weight value corresponding to the processing degree adjustment operation, and t×mask represents the target adjustment weight value corresponding to the pixel to be adjusted.
[0164] In this optional implementation, the target adjustment weight corresponding to each pixel can be obtained through the target weight value and the preset facial mask image, and then for each pixel to be adjusted in the facial area of the facial processing target image, the target pixel value is calculated through the target adjustment weight corresponding to the pixel to be adjusted, the original pixel value of the pixel to be adjusted in the target facial image to be processed, and the current pixel value of the pixel to be adjusted in the facial processing target image, thereby realizing pixel value adjustment of the facial processing target image based on the processing degree adjustment operation, thereby realizing precise adjustment of the processing degree of the facial processing target image, and improving the user experience.
[0165] The technical solution of this embodiment obtains a target facial image to be processed of the target object, inputs the target facial image to be processed into a pre-trained target facial processing model to obtain a facial processing target image of the target facial effect, and displays the facial processing target image in a target display area, thereby realizing interaction with the user, facilitating the user to view the processed facial image, and improving the user experience.
[0166] Embodiment 6
[0167] Fig. 6A A flowchart of a preferred image processing method provided by Embodiment 6 of the present disclosure is shown as follows: Fig. 6AAs shown, the method comprises the following steps:
[0168] S610: Acquire multiple reference facial images to be processed to construct a preliminary sample set to be processed, and acquire multiple facial processing reference images with target facial effects to construct a preliminary processing effect set.
[0169] S620. A pre-established first initial image generation model is trained according to the reference facial images to be processed in the preliminary sample set to be processed to obtain a sample image generation model. A pre-established second initial image generation model is trained according to the facial processing reference images in the preliminary processing effect set to obtain a sample effect image generation model.
[0170] S630: Determine a target image conversion model according to the reference facial image to be processed in the preliminary sample set to be processed and the image generation model to be processed.
[0171] For example, Figure 6B As shown, a schematic diagram of model training based on a preliminary sample set to be processed and a preliminary processing effect set is shown. First, a model for generating images to be processed is obtained by training the preliminary sample set to be processed, and a model for generating sample effect images is obtained by training the preliminary processing effect set; then, a target image conversion model is obtained by training the image generation model to be processed and the preliminary sample set to be processed.
[0172] S640: Input the reference facial image to be processed into the target image coding model to obtain a target image vector corresponding to the reference facial image to be processed.
[0173] S650, input the target image vector into the image generation model to be processed to obtain a sample facial image to be processed, and input the target image vector into the sample effect image generation model to obtain a facial processing sample image corresponding to the sample facial image to be processed.
[0174] S660: Perform image correction processing on the sample facial image to be processed or the facial processing sample image corresponding to the sample facial image to be processed.
[0175] S670: Train an initial facial processing model according to the sample facial image to be processed and the facial processing sample image corresponding to the sample facial image to be processed to obtain a target facial processing model.
[0176] S680, obtaining a target facial image to be processed of the target object, and inputting the target facial image to be processed into a pre-trained target facial processing model to obtain a facial processing target image of a target facial effect.
[0177] S690, displaying an effect adjustment control for adjusting the degree of image processing in the target display area, and when receiving a processing degree adjustment operation input to the effect adjustment control, displaying a facial processing target image corresponding to the processing degree adjustment operation in the target display area.
[0178] The technical solution of this embodiment realizes the determination of a large number of paired sample facial images to be processed and facial processing sample images, provides data support for the training of the target facial processing model, ensures the output accuracy of the target facial processing model, enables the target facial processing model to automatically perform fine processing on each local area in the facial image, improves the processing effect of the facial image, and does not require manual adjustment by the user, thereby reducing the processing complexity of the facial image. The target facial processing model can also retain more original facial image information while processing the local area, thereby improving the user experience.
[0179] Embodiment 7
[0180] Figure 7 This is a structural diagram of an image processing device provided in Embodiment 7 of the present disclosure. The image processing device provided in this embodiment can be implemented by software and / or hardware, and can be configured in a terminal and / or a server to implement the image processing method in the embodiment of the present disclosure. The device may specifically include:
[0181] An acquisition module 710 is used to acquire a target facial image to be processed of a target object;
[0182] The processing module 720 is used to input the target facial image to be processed into a pre-trained target facial processing model to obtain a facial processing target image with a target facial effect;
[0183] The target face processing model is trained based on the following method:
[0184] Acquire multiple reference facial images to be processed to construct a preliminary sample set to be processed, and acquire multiple facial processing reference images with target facial effects to construct a preliminary processing effect set;
[0185] Determine a sample facial image to be processed and a sample facial image to be processed corresponding to the sample facial image to be processed according to the reference facial image to be processed in the preliminary sample set to be processed and the facial processing reference image in the preliminary processing effect set;
[0186] The initial facial processing model is trained according to the sample facial image to be processed and the facial processing sample image corresponding to the sample facial image to be processed to obtain a target facial processing model.
[0187] On the basis of any optional technical solution in the embodiments of the present disclosure, optionally, the device also includes a first model training module, a second model training module and an image pairing module; the first model training module is used to train a pre-established first initial image generation model according to the reference facial image to be processed in the preliminary sample set to be processed, so as to obtain a generation model for the image to be processed; the second model training module is used to train a pre-established second initial image generation model according to the facial processing reference image in the preliminary processing effect set, so as to obtain a sample effect image generation model; the image pairing module is used to generate a sample facial image to be processed and a facial processing sample image corresponding to the sample facial image to be processed according to the image generation model to be processed and the sample effect image generation model; wherein the first initial image generation model and the second initial image generation model are style-based generative adversarial networks.
[0188] On the basis of any optional technical solution in the embodiments of the present disclosure, optionally, the image pairing module includes a conversion model training unit and an image generation unit, wherein the conversion model training unit is used to determine a target image conversion model based on the reference facial image to be processed in the preliminary sample set to be processed and the image generation model to be processed, wherein the target image conversion model is used to convert the image input into the target image conversion model into a target image vector; the image generation unit is used to generate a sample facial image to be processed according to the image generation model to be processed, and generate a facial processing sample image corresponding to the sample facial image to be processed according to the sample facial image to be processed, the target image encoding model and the sample effect image generation model.
[0189] Based on any optional technical solution in the embodiments of the present disclosure, optionally, the conversion model training unit is specifically used to:
[0190] Input the reference facial image to be processed in the preliminary sample set to be processed into the initial image conversion model to obtain a model conversion vector; input the model conversion vector into the image generation model to be processed to obtain a model generated image corresponding to the model conversion vector; adjust the parameters of the initial image conversion model according to the loss between the model generated image and the input reference facial image to be processed corresponding to the model generated image to obtain a target image conversion model.
[0191] Based on any optional technical solution in the embodiments of the present disclosure, optionally, the image generating unit is specifically used to:
[0192] The reference facial image to be processed is input into the target image encoding model to obtain a target image vector corresponding to the reference facial image to be processed; the target image vector is input into the image generation model to obtain a sample facial image to be processed; the target image vector is input into the sample effect image generation model to obtain a facial processing sample image corresponding to the sample facial image to be processed.
[0193] On the basis of any optional technical solution in the embodiments of the present disclosure, optionally, the device further includes a training preprocessing module, wherein the training preprocessing module is used to perform image correction processing on the sample facial image to be processed or the facial processing sample image corresponding to the sample facial image to be processed before training the initial facial processing model according to the sample facial image to be processed and the facial processing sample image corresponding to the sample facial image to be processed, wherein the image correction processing includes at least one of facial color correction processing, facial deformation correction processing and facial makeup restoration processing.
[0194] On the basis of any optional technical solution in the embodiments of the present disclosure, optionally, the training preprocessing module includes a color correction unit, and the color correction unit is used to determine the facial skin area to be processed in the sample facial image to be processed, and determine the reference color average value corresponding to each pixel in the facial skin area to be processed when the image correction processing includes facial color correction processing; determine the facial skin area to be adjusted in the facial processing sample image corresponding to the sample facial image to be processed, and determine the color average value to be adjusted corresponding to each pixel in the facial skin area to be adjusted; adjust the color values corresponding to each pixel in the facial skin area to be adjusted according to the reference color average value and the color average value to be adjusted.
[0195] On the basis of any optional technical solution in the embodiments of the present disclosure, optionally, the training preprocessing module includes a makeup restoration unit, and the makeup restoration unit is used to perform makeup processing on the sample facial image to be processed corresponding to the facial processing sample image according to the makeup information when the image correction processing includes facial makeup restoration processing, if the facial area in the facial processing sample image includes makeup information.
[0196] On the basis of any optional technical solution in the embodiments of the present disclosure, optionally, the training preprocessing module includes a deformation correction unit, and the deformation correction unit is used to determine the correction key points of the facial area in the sample facial image to be processed and the facial processing sample image corresponding to the sample facial image to be processed respectively when the image correction processing includes facial deformation correction processing; and adjust the shape of the facial area in the facial processing sample image according to the positions of the correction key points in the sample facial image to be processed and the positions of the correction key points in the facial processing sample image.
[0197] Based on any optional technical solution in the embodiments of the present disclosure, optionally, the initial face processing model includes a processing effect generation model and a processing effect discrimination model; the device also includes a target model training module, and the target model training module includes an effect generation unit, a first adjustment unit and a second adjustment unit; wherein,
[0198] The effect generation unit is used to input the sample facial image to be processed into the processing effect generation model to obtain a processing effect generation image;
[0199] The first adjustment unit is used to adjust the processing effect generation model according to the sample facial image to be processed, the processing effect generation image and the facial processing sample image corresponding to the sample facial image to be processed;
[0200] The second adjustment unit is used to determine whether to end the adjustment of the processing effect generation model according to the discrimination result of the processing effect discrimination model on the processing effect generation image, and use the processing effect generation model obtained when the adjustment is ended as the target facial processing model.
[0201] Based on any optional technical solution in the embodiments of the present disclosure, optionally, the first adjustment unit is specifically configured to:
[0202] Determine a first facial feature loss between the sample facial image to be processed and the processing effect generated image, and determine a second facial feature loss between the processing effect generated image and a facial processing sample image corresponding to the sample facial image to be processed; and adjust the processing effect generation model according to the first facial feature loss and the second facial feature loss.
[0203] Based on any optional technical solution in the embodiments of the present disclosure, optionally, the acquisition module 710 is specifically used to:
[0204] In response to a received processing trigger operation of a facial processing target image for generating a target facial effect, a target facial image to be processed of a target object is captured by an image capturing device, or a target facial image to be processed of a target object is received by uploading the image based on an image upload control.
[0205] On the basis of any optional technical solution in the embodiments of the present disclosure, optionally, the device further includes an image display module, and the image display module is used to display the facial processing target image in a target display area.
[0206] On the basis of any optional technical solution in the embodiments of the present disclosure, optionally, the image display module includes a control display unit and an effect adjustment unit; the control display unit is used to display an effect adjustment control for adjusting the degree of image processing in the target display area; the effect adjustment unit is used to display a facial processing target image corresponding to the processing degree adjustment operation in the target display area when receiving a processing degree adjustment operation input to the effect adjustment control.
[0207] On the basis of any optional technical solution in the embodiments of the present disclosure, optionally, the effect adjustment unit includes an effect display subunit, and the effect display subunit is used to determine a target weight value corresponding to the processing degree adjustment operation, determine the facial processing target image corresponding to the processing degree adjustment operation according to the target facial image to be processed, the facial processing target image, the target weight value and a preset facial mask image, and display the adjusted facial processing target image in the target display area, wherein the pixel value of the facial skin area in the preset facial mask image is 1, and the pixel value of the area other than the facial skin area is 0.
[0208] Based on any optional technical solution in the embodiments of the present disclosure, optionally, the effect display subunit is specifically used for:
[0209] Determine a target weight value corresponding to the processing degree adjustment operation, perform weighted processing on the pixel values of each pixel in the preset facial mask image according to the target weight value, and obtain a target adjustment weight value corresponding to each pixel; for each pixel to be adjusted in the facial area of the facial processing target image, calculate the target pixel value of the pixel to be adjusted according to the original pixel value of the pixel to be adjusted in the facial processing target image, the current pixel value in the facial processing target image, and the target adjustment weight value corresponding to the pixel to be adjusted, so as to obtain the facial processing target image corresponding to the processing degree adjustment operation; and display the adjusted facial processing target image in the target display area.
[0210] The above-mentioned image processing device can execute the image processing method provided by any embodiment of the present disclosure, and has the corresponding functional modules and beneficial effects of the execution method.
[0211] It is worth noting that the various units and modules included in the above-mentioned device are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of the present disclosure.
[0212] Embodiment 8
[0213] Figure 8 FIG8 is a schematic diagram of the structure of an electronic device provided by Embodiment 8 of the present disclosure. Referring to FIG8 below, it shows an electronic device (eg, Figure 8 The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 8 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0214] like Figure 8 As shown, the electronic device 800 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage device 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the electronic device 800 are also stored. The processing device 801, the ROM 802, and the RAM 803 are connected to each other via a bus 805. An edit / output (I / O) interface 804 is also connected to the bus 805.
[0215] Typically, the following devices may be connected to the I / O interface 804: input devices 806 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 807 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 808 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 809. The communication devices 809 may allow the electronic device 800 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 8The electronic device 800 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0216] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 809, or installed from a storage device 808, or installed from a ROM 802. When the computer program is executed by the processing device 801, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0217] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0218] The electronic device provided by the embodiment of the present disclosure and the image processing method provided by the above embodiment belong to the same inventive concept. The technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.
[0219] Embodiment 9
[0220] The embodiments of the present disclosure provide a computer storage medium on which a computer program is stored. When the program is executed by a processor, the image processing method provided by the above embodiments is implemented.
[0221] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0222] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0223] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0224] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device:
[0225] Acquire a target facial image to be processed of a target object;
[0226] Inputting the target facial image to be processed into a pre-trained target facial processing model to obtain a facial processing target image of a target facial effect;
[0227] The target face processing model is trained based on the following method:
[0228] Acquire multiple reference facial images to be processed to construct a preliminary sample set to be processed, and acquire multiple facial processing reference images with target facial effects to construct a preliminary processing effect set;
[0229] Determine a sample facial image to be processed and a sample facial image to be processed corresponding to the sample facial image to be processed according to the reference facial image to be processed in the preliminary sample set to be processed and the facial processing reference image in the preliminary processing effect set;
[0230] The initial facial processing model is trained according to the sample facial image to be processed and the facial processing sample image corresponding to the sample facial image to be processed to obtain a target facial processing model.
[0231] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0232] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0233] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of a unit does not limit the unit itself in some cases. For example, the first acquisition unit may also be described as a "unit for acquiring at least two Internet Protocol addresses".
[0234] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0235] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0236] According to one or more embodiments of the present disclosure, [Example 1] provides an image processing method, the method comprising:
[0237] Acquire a target facial image to be processed of a target object;
[0238] Inputting the target facial image to be processed into a pre-trained target facial processing model to obtain a facial processing target image of a target facial effect;
[0239] The target face processing model is trained based on the following method:
[0240] Acquire multiple reference facial images to be processed to construct a preliminary sample set to be processed, and acquire multiple facial processing reference images with target facial effects to construct a preliminary processing effect set;
[0241] Determine a sample facial image to be processed and a sample facial image to be processed corresponding to the sample facial image to be processed according to the reference facial image to be processed in the preliminary sample set to be processed and the facial processing reference image in the preliminary processing effect set;
[0242] The initial facial processing model is trained according to the sample facial image to be processed and the facial processing sample image corresponding to the sample facial image to be processed to obtain a target facial processing model.
[0243] According to one or more embodiments of the present disclosure, [Example 2] provides an image processing method, the method further comprising:
[0244] Optionally, determining the sample facial image to be processed and the facial processing sample image corresponding to the sample facial image to be processed according to the reference facial image to be processed in the preliminary sample set to be processed and the facial processing reference image in the preliminary processing effect set includes:
[0245] Training a pre-established first initial image generation model according to the reference facial image to be processed in the preliminary sample set to be processed to obtain an image generation model to be processed;
[0246] Training a pre-established second initial image generation model according to the facial processing reference image in the preliminary processing effect set to obtain a sample effect image generation model;
[0247] Generate a sample facial image to be processed and a facial processing sample image corresponding to the sample facial image to be processed according to the to-be-processed image generation model and the sample effect image generation model;
[0248] The first initial image generation model and the second initial image generation model are style-based generative adversarial networks.
[0249] According to one or more embodiments of the present disclosure, [Example 3] provides an image processing method, the method further comprising:
[0250] Optionally, generating a sample facial image to be processed and a facial processing sample image corresponding to the sample facial image to be processed according to the sample facial image generation model to be processed and the sample effect image generation model includes:
[0251] Determining a target image conversion model according to the reference facial image to be processed in the preliminary sample set to be processed and the image generation model to be processed, wherein the target image conversion model is used to convert an image input into the target image conversion model into a target image vector;
[0252] A sample facial image to be processed is generated according to the image generation model to be processed, and a facial processing sample image corresponding to the sample facial image to be processed is generated according to the sample facial image to be processed, the target image encoding model and the sample effect image generation model.
[0253] According to one or more embodiments of the present disclosure, [Example 4] provides an image processing method, the method further comprising:
[0254] Optionally, determining the target image conversion model according to the reference facial image to be processed in the preliminary sample set to be processed and the image generation model to be processed includes:
[0255] Inputting the reference facial image to be processed in the preliminary sample set to be processed into the initial image conversion model to obtain a model conversion vector;
[0256] Inputting the model conversion vector into the image generation model to be processed to obtain a model generated image corresponding to the model conversion vector;
[0257] The parameters of the initial image conversion model are adjusted according to the loss between the model-generated image and the input reference facial image to be processed corresponding to the model-generated image to obtain a target image conversion model.
[0258] According to one or more embodiments of the present disclosure, [Example 5] provides an image processing method, the method further comprising:
[0259] Optionally, generating a sample facial image to be processed according to the image generation model to be processed, and generating a facial processing sample image corresponding to the sample facial image to be processed according to the sample facial image to be processed, the target image encoding model and the sample effect image generation model, comprises:
[0260] Inputting the reference facial image to be processed into the target image coding model to obtain a target image vector corresponding to the reference facial image to be processed;
[0261] Inputting the target image vector into the to-be-processed image generation model to obtain a to-be-processed sample facial image;
[0262] The target image vector is input into the sample effect image generation model to obtain a facial processing sample image corresponding to the sample facial image to be processed.
[0263] According to one or more embodiments of the present disclosure, [Example 6] provides an image processing method, the method further comprising:
[0264] Optionally, before training the initial facial processing model according to the sample facial image to be processed and the facial processing sample image corresponding to the sample facial image to be processed, the method further includes:
[0265] Perform image correction processing on the sample facial image to be processed or the facial processing sample image corresponding to the sample facial image to be processed, wherein the image correction processing includes at least one of facial color correction processing, facial deformation correction processing and facial makeup restoration processing.
[0266] According to one or more embodiments of the present disclosure, [Example 7] provides an image processing method, the method further comprising:
[0267] Optionally, when the image correction processing includes facial color correction processing, performing image correction processing on the sample facial image to be processed or the facial processing sample image corresponding to the sample facial image to be processed includes:
[0268] Determine a facial skin area to be processed in the sample facial image to be processed, and determine a reference color average value corresponding to each pixel point in the facial skin area to be processed;
[0269] Determine a facial skin area to be adjusted in a facial processing sample image corresponding to the sample facial image to be processed, and determine an average value of colors to be adjusted corresponding to each pixel point in the facial skin area to be adjusted;
[0270] The color values corresponding to the pixels in the facial skin area to be adjusted are adjusted according to the reference color average value and the color average value to be adjusted.
[0271] According to one or more embodiments of the present disclosure, [Example 8] provides an image processing method, the method further comprising:
[0272] Optionally, when the image correction processing includes facial makeup restoration processing, performing image correction processing on the sample facial image to be processed or the facial processing sample image corresponding to the sample facial image to be processed includes:
[0273] If the facial region in the facial processing sample image includes makeup information, makeup processing is performed on the sample facial image to be processed corresponding to the facial processing sample image according to the makeup information.
[0274] According to one or more embodiments of the present disclosure, [Example 9] provides an image processing method, the method further comprising:
[0275] Optionally, when the image correction processing includes facial deformation correction processing, performing image correction processing on the sample facial image to be processed or the facial processing sample image corresponding to the sample facial image to be processed includes:
[0276] Respectively determining correction key points of the facial region in the sample facial image to be processed and the facial processing sample image corresponding to the sample facial image to be processed;
[0277] The position of the corrected key point in the facial processing sample image is adjusted according to the position of the corrected key point in the sample facial image to be processed, and the shape of the facial area in the facial processing sample image is adjusted.
[0278] According to one or more embodiments of the present disclosure, [Example 10] provides an image processing method, the method further comprising:
[0279] Optionally, the initial facial processing model includes a processing effect generation model and a processing effect discrimination model; the initial facial processing model is trained according to the sample facial image to be processed and the facial processing sample image corresponding to the sample facial image to be processed to obtain a target facial processing model, including:
[0280] Inputting the sample facial image to be processed into the processing effect generation model to obtain a processing effect generation image;
[0281] adjusting the processing effect generation model according to the sample facial image to be processed, the processing effect generation image, and the facial processing sample image corresponding to the sample facial image to be processed;
[0282] Whether the adjustment of the processing effect generation model is to be completed is determined according to the result of the processing effect discrimination model on the processing effect generation image, and the processing effect generation model obtained when the adjustment is completed is used as the target facial processing model.
[0283] According to one or more embodiments of the present disclosure, [Example 11] provides an image processing method, the method further comprising:
[0284] Optionally, adjusting the processing effect generation model according to the sample facial image to be processed, the processing effect generation image, and a facial processing sample image corresponding to the sample facial image to be processed includes:
[0285] Determine a first facial feature loss between the sample facial image to be processed and the processing effect generated image, and determine a second facial feature loss between the processing effect generated image and a facial processing sample image corresponding to the sample facial image to be processed;
[0286] The processing effect generation model is adjusted according to the first facial feature loss and the second facial feature loss.
[0287] According to one or more embodiments of the present disclosure, [Example 12] provides an image processing method, the method further comprising:
[0288] Optionally, obtaining a target facial image to be processed of a target object includes:
[0289] In response to a received processing trigger operation of a facial processing target image for generating a target facial effect, a target facial image to be processed of a target object is captured by an image capturing device, or a target facial image to be processed of a target object is received by uploading the image based on an image upload control.
[0290] According to one or more embodiments of the present disclosure, [Example 13] provides an image processing method, the method further comprising:
[0291] Optionally, after obtaining the target facial effect of the facial processing target image, the method further includes:
[0292] The face processing target image is displayed in the target display area.
[0293] According to one or more embodiments of the present disclosure, [Example 14] provides an image processing method, the method further comprising:
[0294] Optionally, after obtaining the target facial effect of the facial processing target image, the method further includes:
[0295] Displaying an effect adjustment control for adjusting the degree of image processing in the target display area;
[0296] When a processing degree adjustment operation input to the effect adjustment control is received, a facial processing target image corresponding to the processing degree adjustment operation is displayed in the target display area.
[0297] According to one or more embodiments of the present disclosure, [Example 15] provides an image processing method, the method further comprising:
[0298] Optionally, displaying the facial processing target image corresponding to the adjustment operation in the target display area includes:
[0299] Determine a target weight value corresponding to the processing degree adjustment operation, determine a facial processing target image corresponding to the processing degree adjustment operation based on the target facial image to be processed, the facial processing target image, the target weight value and a preset facial mask image, and display the adjusted facial processing target image in the target display area, wherein the pixel value of the facial skin area in the preset facial mask image is 1, and the pixel value of the area other than the facial skin area is 0.
[0300] According to one or more embodiments of the present disclosure, [Example 16] provides an image processing method, the method further comprising:
[0301] Optionally, determining the facial processing target image corresponding to the processing degree adjustment operation according to the target facial image to be processed, the facial processing target image, the target weight value and a preset facial mask image includes:
[0302] Performing weighted processing on the pixel values of each pixel point in the preset facial mask image according to the target weight value to obtain a target adjustment weight value corresponding to each pixel point;
[0303] For each pixel to be adjusted in the facial area of the facial processing target image, a target pixel value of the pixel to be adjusted is calculated according to an original pixel value of the pixel to be adjusted in the facial processing target image, a current pixel value in the facial processing target image, and a target adjustment weight corresponding to the pixel to be adjusted, so as to obtain a facial processing target image corresponding to the processing degree adjustment operation.
[0304] According to one or more embodiments of the present disclosure, [Example 17] provides an image processing device, the device comprising:
[0305] An acquisition module is used to acquire a target facial image to be processed of a target object;
[0306] A processing module, used for inputting the target facial image to be processed into a pre-trained target facial processing model to obtain a facial processing target image with a target facial effect;
[0307] The target face processing model is trained based on the following method:
[0308] Acquire multiple reference facial images to be processed to construct a preliminary sample set to be processed, and acquire multiple facial processing reference images with target facial effects to construct a preliminary processing effect set;
[0309] Determine a sample facial image to be processed and a sample facial image to be processed corresponding to the sample facial image to be processed according to the reference facial image to be processed in the preliminary sample set to be processed and the facial processing reference image in the preliminary processing effect set;
[0310] The initial facial processing model is trained according to the sample facial image to be processed and the facial processing sample image corresponding to the sample facial image to be processed to obtain a target facial processing model.
[0311] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0312] In addition, although each operation is described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or to be performed in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0313] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
Claims
1. An image processing method, It is characterized in that include: Acquire a target facial image to be processed of a target object; Inputting the target facial image to be processed into a pre-trained target facial processing model to obtain a facial processing target image with a target facial effect, wherein the target facial effect is an effect of processing a local facial area of the target facial image to be processed; the target facial effect includes at least one of the following effects: facial plumping, facial brightening, facial lifting and firming, face shape correction, spot removal, dark circle reduction, eye light addition, facial feature proportion adjustment, facial feature color correction, facial firmness reduction or facial dullness reduction, skin age increase, and eye size reduction; The target face processing model is trained based on the following method: Acquire multiple reference facial images to be processed to construct a preliminary sample set to be processed, and acquire multiple facial processing reference images with target facial effects to construct a preliminary processing effect set; Determine a sample facial image to be processed and a sample facial image to be processed corresponding to the sample facial image to be processed according to the reference facial image to be processed in the preliminary sample set to be processed and the facial processing reference image in the preliminary processing effect set; Training an initial facial processing model according to the sample facial image to be processed and a facial processing sample image corresponding to the sample facial image to be processed to obtain a target facial processing model; After obtaining the target facial image to be processed of the target object, the method further includes: locating a facial region in the target facial image to be processed based on a pre-trained facial detection model, and removing the remaining regions except the facial region in the target facial image to be processed.
2. The method according to claim 1, It is characterized in that The step of determining a sample facial image to be processed and a facial processing sample image corresponding to the sample facial image to be processed according to the reference facial image to be processed in the preliminary sample set to be processed and the facial processing reference image in the preliminary processing effect set comprises: Training a pre-established first initial image generation model according to the reference facial image to be processed in the preliminary sample set to be processed to obtain an image generation model to be processed; Training a pre-established second initial image generation model according to the facial processing reference image in the preliminary processing effect set to obtain a sample effect image generation model; Generate a sample facial image to be processed and a facial processing sample image corresponding to the sample facial image to be processed according to the to-be-processed image generation model and the sample effect image generation model; The first initial image generation model and the second initial image generation model are style-based generative adversarial networks.
3. The method according to claim 2, It is characterized in that The step of generating a sample facial image to be processed and a facial processing sample image corresponding to the sample facial image to be processed according to the sample facial image generation model to be processed and the sample effect image generation model comprises: Determining a target image conversion model according to the reference facial image to be processed in the preliminary sample set to be processed and the image generation model to be processed, wherein the target image conversion model is used to convert an image input into the target image conversion model into a target image vector; A sample facial image to be processed is generated according to the image generation model to be processed, and a facial processing sample image corresponding to the sample facial image to be processed is generated according to the sample facial image to be processed, the target image encoding model and the sample effect image generation model.
4. The method according to claim 3, It is characterized in that The step of determining the target image conversion model according to the reference facial image to be processed in the preliminary sample set to be processed and the image generation model to be processed comprises: Inputting the reference facial image to be processed in the preliminary sample set to be processed into the initial image conversion model to obtain a model conversion vector; Inputting the model conversion vector into the image generation model to be processed to obtain a model generated image corresponding to the model conversion vector; The parameters of the initial image conversion model are adjusted according to the loss between the model-generated image and the input reference facial image to be processed corresponding to the model-generated image to obtain a target image conversion model.
5. The method according to claim 3, It is characterized in that The step of generating a sample facial image to be processed according to the image generation model to be processed, and generating a facial processing sample image corresponding to the sample facial image to be processed according to the sample facial image to be processed, the target image encoding model and the sample effect image generation model, comprises: Inputting the reference facial image to be processed into a target image coding model to obtain a target image vector corresponding to the reference facial image to be processed; Inputting the target image vector into the to-be-processed image generation model to obtain a to-be-processed sample facial image; The target image vector is input into the sample effect image generation model to obtain a facial processing sample image corresponding to the sample facial image to be processed.
6. The method according to claim 2, It is characterized in that Before the initial facial processing model is trained according to the sample facial image to be processed and the facial processing sample image corresponding to the sample facial image to be processed, the method further includes: Perform image correction processing on the sample facial image to be processed or the facial processing sample image corresponding to the sample facial image to be processed, wherein the image correction processing includes at least one of facial color correction processing, facial deformation correction processing and facial makeup restoration processing.
7. The method according to claim 6, It is characterized in that When the image correction process includes facial color correction process, the image correction process is performed on the sample facial image to be processed or the facial processing sample image corresponding to the sample facial image to be processed, including: Determine a facial skin area to be processed in the sample facial image to be processed, and determine a reference color average value corresponding to each pixel point in the facial skin area to be processed; Determine a facial skin area to be adjusted in a facial processing sample image corresponding to the sample facial image to be processed, and determine an average value of colors to be adjusted corresponding to each pixel point in the facial skin area to be adjusted; The color values corresponding to the pixels in the facial skin area to be adjusted are adjusted according to the reference color average value and the color average value to be adjusted.
8. The method according to claim 6, It is characterized in that When the image correction processing includes facial makeup restoration processing, the image correction processing of the sample facial image to be processed or the facial processing sample image corresponding to the sample facial image to be processed includes: If the facial region in the facial processing sample image includes makeup information, makeup processing is performed on the sample facial image to be processed corresponding to the facial processing sample image according to the makeup information.
9. The method according to claim 6, It is characterized in that When the image correction process includes facial deformation correction process, the image correction process is performed on the sample facial image to be processed or the facial processing sample image corresponding to the sample facial image to be processed, including: Respectively determining correction key points of the facial region in the sample facial image to be processed and the facial processing sample image corresponding to the sample facial image to be processed; The position of the corrected key point in the facial processing sample image is adjusted according to the position of the corrected key point in the sample facial image to be processed, and the shape of the facial area in the facial processing sample image is adjusted.
10. The method according to claim 1, It is characterized in that The initial facial processing model includes a processing effect generation model and a processing effect discrimination model; the initial facial processing model is trained according to the sample facial image to be processed and the facial processing sample image corresponding to the sample facial image to be processed to obtain a target facial processing model, including: Inputting the sample facial image to be processed into the processing effect generation model to obtain a processing effect generation image; adjusting the processing effect generation model according to the sample facial image to be processed, the processing effect generation image, and the facial processing sample image corresponding to the sample facial image to be processed; Whether the adjustment of the processing effect generation model is to be completed is determined according to the result of the processing effect discrimination model on the processing effect generation image, and the processing effect generation model obtained when the adjustment is completed is used as the target facial processing model.
11. The method according to claim 10, It is characterized in that The step of adjusting the processing effect generation model according to the sample facial image to be processed, the processing effect generation image, and the facial processing sample image corresponding to the sample facial image to be processed comprises: Determine a first facial feature loss between the sample facial image to be processed and the processing effect generated image, and determine a second facial feature loss between the processing effect generated image and a facial processing sample image corresponding to the sample facial image to be processed; The processing effect generation model is adjusted according to the first facial feature loss and the second facial feature loss.
12. The method according to claim 1, It is characterized in that The step of obtaining a target facial image to be processed of a target object comprises: In response to a received processing trigger operation of a facial processing target image for generating a target facial effect, a target facial image to be processed of a target object is captured by an image capturing device, or a target facial image to be processed of a target object is received by uploading the image based on an image upload control.
13. The method according to claim 1, It is characterized in that After obtaining the target facial effect of the facial processing target image, the method further includes: The face processing target image is displayed in the target display area.
14. The method according to claim 13, It is characterized in that After obtaining the target facial effect of the facial processing target image, the method further includes: Displaying an effect adjustment control for adjusting the degree of image processing in the target display area; When a processing degree adjustment operation input to the effect adjustment control is received, a facial processing target image corresponding to the processing degree adjustment operation is displayed in the target display area.
15. The method according to claim 14, It is characterized in that The displaying of the facial processing target image corresponding to the processing degree adjustment operation in the target display area includes: Determine a target weight value corresponding to the processing degree adjustment operation, determine a facial processing target image corresponding to the processing degree adjustment operation based on the target facial image to be processed, the facial processing target image, the target weight value and a preset facial mask image, and display the adjusted facial processing target image in the target display area, wherein the pixel value of the facial skin area in the preset facial mask image is 1, and the pixel value of the area other than the facial skin area is 0.
16. The method according to claim 15, It is characterized in that The step of determining the facial processing target image corresponding to the processing degree adjustment operation according to the target facial image to be processed, the facial processing target image, the target weight value, and the preset facial mask image comprises: Performing weighted processing on the pixel values of each pixel point in the preset facial mask image according to the target weight value to obtain a target adjustment weight value corresponding to each pixel point; For each pixel to be adjusted in the facial area of the facial processing target image, a target pixel value of the pixel to be adjusted is calculated according to an original pixel value of the pixel to be adjusted in the facial processing target image, a current pixel value in the facial processing target image, and a target adjustment weight corresponding to the pixel to be adjusted, so as to obtain a facial processing target image corresponding to the processing degree adjustment operation.
17. An image processing device, It is characterized in that include: An acquisition module, used for acquiring a target facial image to be processed of a target object; A processing module, for inputting the target facial image to be processed into a pre-trained target facial processing model to obtain a facial processing target image with a target facial effect, wherein the target facial effect is an effect of processing a local facial area of the target facial image to be processed; the target facial effect includes at least one of the following effects: facial plumping, facial brightening, facial lifting and firming, face shape correction, spot removal, dark circle reduction, eye light addition, facial feature proportion adjustment, facial feature color correction, facial firmness reduction or facial dullness reduction, skin age increase, and eye size reduction; The target face processing model is trained based on the following method: Acquire multiple reference facial images to be processed to construct a preliminary sample set to be processed, and acquire multiple facial processing reference images with target facial effects to construct a preliminary processing effect set; Determine a sample facial image to be processed and a sample facial image to be processed corresponding to the sample facial image to be processed according to the reference facial image to be processed in the preliminary sample set to be processed and the facial processing reference image in the preliminary processing effect set; Training an initial facial processing model according to the sample facial image to be processed and a facial processing sample image corresponding to the sample facial image to be processed to obtain a target facial processing model; After obtaining the target facial image to be processed of the target object, the method further includes: locating a facial region in the target facial image to be processed based on a pre-trained facial detection model, and removing the remaining regions except the facial region in the target facial image to be processed.
18. An electronic device, It is characterized in that The electronic device comprises: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the image processing method as described in any one of claims 1-16.
19. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, the image processing method as described in any one of claims 1 to 16 is implemented.
