Image processing model training method, image processing method, device and electronic equipment
By training the image processing model, the shape and attribute feature vectors are fused to generate deformation results close to the reference image, which solves the problem of single deformation results in the existing technology and achieves diversified beauty effects.
Patent Information
- Application Number
- CN202210764492.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-30
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2042-06-30
AI Technical Summary
Existing beautification technology is difficult to ensure reasonable and continuous deformation when processing the side of a character, and relies on the inherent three-dimensional template designed by the 3D designer, resulting in a relatively single deformation result.
By obtaining the shape feature vector and attribute feature vector of the reference image and sample image, train the image processing model for fusion processing, generate the target shape feature vector and render the output image, train the model according to the loss value, and ensure that the shape feature of the output image is close to the reference image and retain object properties.
It achieves the generation of diversified deformation results without relying on 3D designer templates, ensuring that the shape characteristics of the output image are close to the reference image, and maintaining object attributes, solving the problem of single deformation results.
Smart Images

Figure CN115115909B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to an image processing method, device, electronic device and storage medium. Background Art
[0002] Since beauty technology can improve the appearance of people in images, it has been widely used in image processing. With the popularization of aesthetics such as bone makeup and facial folds, facial structure reshaping has gradually become one of the difficulties that the beauty field is committed to overcoming.
[0003] In related technologies, beautification methods usually use image deformation methods such as liquefaction to achieve functions such as nose augmentation and chin augmentation. However, it is difficult to ensure reasonable and continuous deformation when processing the side view of a person.
[0004] For this reason, face reconstruction has been introduced in related technologies. During face reconstruction, the initial face reconstruction result is obtained through a 3D reconstruction network and a three-dimensional deformation model, and then part of the initial face reconstruction result is directly replaced with a three-dimensional template designed by a 3D designer. This method can ensure reasonable deformation at 360 degrees. However, since the face deformation process relies on the inherent three-dimensional template designed by the 3D designer, the deformation of the reconstructed face is relatively fixed, and different faces have the same local deformation result, resulting in a relatively single deformation result. Summary of the invention
[0005] In order to solve the above technical problems existing in the related art, the present disclosure provides an image processing model training method, an image processing method, a device and an electronic device. The technical solution of the present disclosure is as follows:
[0006] According to a first aspect of an embodiment of the present disclosure, there is provided an image processing model training method, comprising:
[0007] Acquire a first shape feature vector of a first object included in a reference image, and a second shape feature vector and an attribute feature vector of a second object included in a sample image; the first shape feature vector is used to characterize a shape feature of the first object; the second shape feature vector is used to characterize a shape feature of the second object, and the attribute feature vector is a feature vector of the second object other than the second shape feature vector; the shape feature of the second object is different from the shape feature of the first object;
[0008] Inputting the first shape feature vector and the second shape feature vector into the image processing model to be trained to obtain a target shape feature vector of the second object; the target shape feature vector is obtained by fusing the first shape feature vector and the second shape feature vector through the image processing model to be trained;
[0009] Rendering the target shape feature vector and the attribute feature vector to obtain an output image corresponding to the sample image;
[0010] The image processing model to be trained is trained according to a first loss value between the reference image and the output image, and a second loss value between the sample image and the output image to obtain a trained image processing model; the first loss value is used to characterize the loss size of the shape feature of the object in the output image relative to the shape feature of the first object, and the second loss value is used to characterize the loss size of the attribute feature of the object in the output image relative to the attribute feature of the second object. The attribute feature of an object is the feature of the object other than the shape feature.
[0011] Optionally, acquiring a first shape feature vector of a first object included in the reference image includes:
[0012] Inputting a reference image into a pre-trained shape feature extraction model, extracting a plurality of first shape feature maps of a first object included in the reference image through the shape feature extraction model, and outputting the plurality of first shape feature maps; different first shape feature maps are used to characterize shape features of different dimensions of the first object;
[0013] The multiple first shape feature maps are respectively subjected to global pooling to obtain multiple first sub-shape feature vectors;
[0014] The multiple first sub-shape feature vectors are concatenated to obtain a first shape feature vector of the first object included in the reference image.
[0015] Optionally, the training process of the shape feature extraction model includes:
[0016] Acquire a first training image including different types of third objects; the different types of third objects have different shape features, and the first training image is annotated with a classification label, and the classification label is used to characterize the shape features of the third objects;
[0017] Inputting the first training image into a shape feature extraction model to be trained to obtain an output result; the output result is used to characterize the shape features of the object included in the image output from the shape feature extraction model to be trained;
[0018] Based on the classification label and the output result, calculating the loss function value of the shape feature extraction model to be trained;
[0019] When the calculated loss function value is less than the first preset loss value, the model parameters of the shape feature extraction model to be trained are determined to obtain the trained shape feature extraction model.
[0020] Optionally, inputting the first shape feature vector and the second shape feature vector into an image processing model to be trained to obtain a target shape feature vector of the second object includes:
[0021] Inputting the second shape feature vector into the first fully connected layer of the image processing model to be trained to obtain a deformed second shape feature vector;
[0022] The deformed second shape feature vector and the first shape feature vector with a weight coefficient are input into a second fully connected layer of the image processing model to be trained to obtain a target shape feature vector of the second object; the weight coefficient is preset.
[0023] Optionally, the training the image processing model to be trained according to a first loss value between the reference image and the output image, and a second loss value between the sample image and the output image, to obtain a trained image processing model includes:
[0024] Calculating a first loss value between the reference image and the output image, and a second loss value between the sample image and the output image;
[0025] When the sum of the first loss value and the second loss value is less than a second preset loss value, the model parameters of the image processing model to be trained are determined to obtain the trained image processing model.
[0026] Optionally, calculating a first loss value between the reference image and the output image, and a second loss value between the sample image and the output image, includes:
[0027] Calculating an adversarial loss value between the reference image and the output image as a first loss value between the reference image and the output image;
[0028] Calculating a loss value between an object feature vector obtained by object recognition of the sample image and the output image, and a loss value between a feature map obtained by downsampling the sample image and the output image;
[0029] The sum of the loss value between the object feature vectors and the loss value between the feature maps obtained by downsampling is used as the second loss value.
[0030] Optionally, acquiring a second shape feature vector and an attribute feature vector of a second object included in the sample image includes:
[0031] The sample image is input into a pre-trained three-dimensional reconstruction model, and a second shape feature vector and an attribute feature vector of a second object included in the sample image are extracted through the three-dimensional reconstruction model.
[0032] Optionally, the training process of the three-dimensional reconstruction model includes:
[0033] Acquire a second training image including a fourth object, input the second training image into a 3D reconstruction model to be trained, and extract a shape feature vector, a first attribute feature vector, and a second attribute feature vector of the fourth object through the 3D reconstruction model to be trained; the first attribute feature vector is used to characterize the features of the fourth object itself, and the second attribute feature vector is used to characterize the environmental features of the fourth object in the second training image;
[0034] Inputting the shape feature vector of the fourth object and the first attribute feature vector into a three-dimensional deformation model to obtain a three-dimensional mesh corresponding to the fourth object;
[0035] Rendering to obtain an output image based on the second attribute feature vector and the three-dimensional grid;
[0036] When the sum of the pixel-level loss value between the second training image and the output image, the loss value between the object feature vectors obtained by object recognition of the second training image and the output image, and the loss value between the key points obtained by object key point detection of the second training image and the output image is less than a preset loss value, a trained three-dimensional reconstruction model is obtained.
[0037] In a second aspect, the present disclosure provides an image processing method, including:
[0038] Acquire a shape feature vector of a reference object included in a target reference image, and a shape feature vector and a target attribute feature vector of a target object included in a target input image; the shape feature vector of the reference object is used to characterize the shape feature of the reference object, the shape feature vector of the target object is used to characterize the shape feature of the target object, the target attribute feature vector is a feature vector of the target object other than the shape feature vector, and the shape feature of the target object is different from the shape feature of the reference object;
[0039] Inputting the shape feature vector of the reference object and the shape feature vector of the target object into a trained image processing model to obtain a deformed shape feature vector of the target object; the trained image processing model is trained by the method according to the first aspect;
[0040] The deformed shape feature vector and the target attribute feature vector are rendered to obtain a target output image corresponding to the target input image.
[0041] Optionally, acquiring a shape feature vector of a reference object included in the target reference image includes:
[0042] Inputting the target reference image into a pre-trained shape feature extraction model, extracting multiple reference shape feature maps of the reference object included in the target reference image through the shape feature extraction model, and outputting the multiple reference shape feature maps; different reference shape feature maps are used to characterize shape features of different dimensions of the reference object;
[0043] The multiple reference shape feature maps are respectively subjected to global pooling to obtain multiple reference sub-shape feature vectors;
[0044] The multiple reference sub-shape feature vectors are concatenated to obtain a shape feature vector of the reference object included in the target reference image.
[0045] Optionally, inputting the shape feature vector of the reference object and the shape feature vector of the target object into a trained image processing model to obtain the deformed shape feature vector of the target object includes:
[0046] Inputting the shape feature vector of the target object into the first fully connected layer of the trained image processing model to obtain a deformed shape feature sub-vector of the target object;
[0047] The deformed shape feature subvector of the target object and the shape feature vector of the reference object with a weight coefficient are input into the second fully connected layer of the trained image processing model to obtain the deformed shape feature vector of the target object; the weight coefficient is preset.
[0048] According to a third aspect of an embodiment of the present disclosure, there is provided an image processing model training device, comprising:
[0049] a feature vector acquisition module, configured to acquire a first shape feature vector of a first object included in a reference image, and a second shape feature vector and an attribute feature vector of a second object included in a sample image; the first shape feature vector is used to characterize a shape feature of the first object; the second shape feature vector is used to characterize a shape feature of the second object, and the attribute feature vector is a feature vector of the second object other than the second shape feature vector; the shape feature of the second object is different from the shape feature of the first object;
[0050] a feature vector fusion module, configured to input the first shape feature vector and the second shape feature vector into the image processing model to be trained to obtain a target shape feature vector of the second object; the target shape feature vector is obtained by fusing the first shape feature vector and the second shape feature vector through the image processing model to be trained;
[0051] An output image acquisition module is configured to render the target shape feature vector and the attribute feature vector to obtain an output image corresponding to the sample image;
[0052] The image processing model determination module is configured to execute training of the image processing model to be trained according to a first loss value between the reference image and the output image, and a second loss value between the sample image and the output image, to obtain a trained image processing model; the first loss value is used to characterize the loss size of the shape feature of the object in the output image relative to the shape feature of the first object, and the second loss value is used to characterize the loss size of the attribute feature of the object in the output image relative to the attribute feature of the second object, and the attribute feature of an object is the feature of the object other than the shape feature.
[0053] Optionally, the feature vector acquisition module is specifically configured to execute:
[0054] Inputting a reference image into a pre-trained shape feature extraction model, extracting a plurality of first shape feature maps of a first object included in the reference image through the shape feature extraction model, and outputting the plurality of first shape feature maps; different first shape feature maps are used to characterize shape features of different dimensions of the first object;
[0055] The multiple first shape feature maps are respectively subjected to global pooling to obtain multiple first sub-shape feature vectors;
[0056] The multiple first sub-shape feature vectors are concatenated to obtain a first shape feature vector of the first object included in the reference image.
[0057] Optionally, the device further comprises a shape feature extraction model training module, configured to execute:
[0058] Acquire a first training image including different types of third objects; the different types of third objects have different shape features, and the first training image is annotated with a classification label, and the classification label is used to characterize the shape features of the third objects;
[0059] Inputting the first training image into a shape feature extraction model to be trained to obtain an output result; the output result is used to characterize the shape features of the object included in the image output from the shape feature extraction model to be trained;
[0060] Based on the classification label and the output result, calculating the loss function value of the shape feature extraction model to be trained;
[0061] When the calculated loss function value is less than the first preset loss value, the model parameters of the shape feature extraction model to be trained are determined to obtain the trained shape feature extraction model.
[0062] Optionally, a feature vector fusion module is specifically configured to perform:
[0063] Inputting the second shape feature vector into the first fully connected layer of the image processing model to be trained to obtain a deformed second shape feature vector;
[0064] The deformed second shape feature vector and the first shape feature vector with a weight coefficient are input into a second fully connected layer of the image processing model to be trained to obtain a target shape feature vector of the second object; the weight coefficient is preset.
[0065] Optionally, the image processing model determination module includes:
[0066] A loss value calculation module, configured to calculate a first loss value between the reference image and the output image, and a second loss value between the sample image and the output image;
[0067] The image processing model determination unit is configured to determine the model parameters of the image processing model to be trained when the sum of the first loss value and the second loss value is less than a second preset loss value, so as to obtain the trained image processing model.
[0068] Optionally, the loss value calculation module is specifically configured to perform:
[0069] Calculating an adversarial loss value between the reference image and the output image as a first loss value between the reference image and the output image;
[0070] Calculating a loss value between an object feature vector obtained by object recognition of the sample image and the output image, and a loss value between a feature map obtained by downsampling the sample image and the output image;
[0071] The sum of the loss value between the object feature vectors and the loss value between the feature maps obtained by downsampling is used as the second loss value.
[0072] Optionally, the feature vector acquisition module is further specifically configured to execute:
[0073] The sample image is input into a pre-trained three-dimensional reconstruction model, and a second shape feature vector and an attribute feature vector of a second object included in the sample image are extracted through the three-dimensional reconstruction model.
[0074] The device also includes a three-dimensional reconstruction model training module, which is specifically configured to execute:
[0075] Acquire a second training image including a fourth object, input the second training image into a 3D reconstruction model to be trained, and extract a shape feature vector, a first attribute feature vector, and a second attribute feature vector of the fourth object through the 3D reconstruction model to be trained; the first attribute feature vector is used to characterize the features of the fourth object itself, and the second attribute feature vector is used to characterize the environmental features of the fourth object in the second training image;
[0076] Inputting the shape feature vector of the fourth object and the first attribute feature vector into a three-dimensional deformation model to obtain a three-dimensional mesh corresponding to the fourth object;
[0077] Based on the second attribute feature vector and the three-dimensional grid, an output image is rendered; when the sum of the pixel-level loss value between the second training image and the output image, the loss value between the object feature vectors obtained by object recognition of the second training image and the output image, and the loss value between the key points obtained by object key point detection of the second training image and the output image is less than a preset loss value, a trained three-dimensional reconstruction model is obtained.
[0078] According to a fourth aspect of an embodiment of the present disclosure, there is provided an image processing apparatus, including:
[0079] a feature vector acquisition module, configured to acquire a shape feature vector of a reference object included in a target reference image, and a shape feature vector and a target attribute feature vector of a target object included in a target input image; the shape feature vector of the reference object is used to characterize a shape feature of the reference object, the shape feature vector of the target object is used to characterize a shape feature of the target object, the target attribute feature vector is a feature vector of the target object other than the shape feature vector, and the shape feature of the target object is different from the shape feature of the reference object;
[0080] a deformed shape feature vector acquisition module, configured to input the shape feature vector of the reference object and the shape feature vector of the target object into a trained image processing model to obtain a deformed shape feature vector of the target object; the trained image processing model is trained by the method according to the first aspect;
[0081] The target output image acquisition module is configured to render the deformed shape feature vector and the target attribute feature vector to obtain a target output image corresponding to the target input image.
[0082] Optionally, the feature vector acquisition module is specifically configured to execute:
[0083] Inputting the target reference image into a pre-trained shape feature extraction model, extracting multiple reference shape feature maps of the reference object included in the target reference image through the shape feature extraction model, and outputting the multiple reference shape feature maps; different reference shape feature maps are used to characterize shape features of different dimensions of the reference object;
[0084] The multiple reference shape feature maps are respectively subjected to global pooling to obtain multiple reference sub-shape feature vectors;
[0085] The multiple reference sub-shape feature vectors are concatenated to obtain a shape feature vector of the reference object included in the target reference image.
[0086] Optionally, the deformation shape feature vector acquisition module is specifically configured to execute:
[0087] Inputting the shape feature vector of the target object into the first fully connected layer of the trained image processing model to obtain a deformed shape feature sub-vector of the target object;
[0088] The deformed shape feature subvector of the target object and the shape feature vector of the reference object with a weight coefficient are input into the second fully connected layer of the trained image processing model to obtain the deformed shape feature vector of the target object; the weight coefficient is preset.
[0089] According to a fifth aspect of an embodiment of the present disclosure, there is provided an electronic device, including:
[0090] processor;
[0091] a memory for storing instructions executable by the processor;
[0092] Wherein, the processor is configured to execute the instructions to implement the image processing model training method described in the first aspect, or the image processing method described in the second aspect.
[0093] According to the sixth aspect of an embodiment of the present disclosure, a storage medium is provided. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the image processing model training method described in the first aspect, or the image processing method described in the second aspect.
[0094] According to the seventh aspect of the embodiments of the present disclosure, a computer program product is provided, which, when executed on a computer, enables the computer to implement the image processing model training method described in the first aspect, or the image processing method described in the second aspect.
[0095] The technical solution provided by the embodiment of the present disclosure obtains a first shape feature vector of a first object included in a reference image, and a second shape feature vector and an attribute feature vector of a second object included in a sample image; the first shape feature vector and the second shape feature vector are input into an image processing model to be trained, and the image processing model fuses the first shape feature vector and the second shape feature vector to obtain a target shape feature vector of the second object; the target shape feature vector and the attribute feature vector are rendered to obtain an output image corresponding to the sample image; and the image processing model to be trained is trained according to a first loss value between the reference image and the output image, and a second loss value between the sample image and the output image to obtain a trained image processing model.
[0096] It can be seen that, through the technical solution provided by the embodiment of the present disclosure, when training the image processing model, the loss size of the shape feature of the object in the output image relative to the shape feature of the first object is used as the first loss value, and the loss size of the attribute feature of the object in the output image relative to the attribute feature of the second object is used as the second loss value. The image processing model to be trained is trained by the first loss value and the second loss value, so that the shape feature of the output image can be closer to the shape feature of the reference image, and the closer the attribute feature of the object in the output image is to the attribute feature of the second object in the sample image, that is, the object in the output image is still the second object in the sample image, so that the trained image processing model can make the shape of the object in the sample image deform to a shape close to the first object in the reference image. Instead of relying on the inherent three-dimensional template designed by the 3D designer to achieve deformation like the related art, for different input images, by selecting different reference images, the object in the output image output by the trained image processing model has different deformation results, thereby solving the problem of relatively single deformation results in the related art. BRIEF DESCRIPTION OF THE DRAWINGS
[0097] Figure 1 is a flowchart of an image processing model training method according to an exemplary embodiment;
[0098] Figure 2 yes Figure 1 A flowchart of an implementation of step S110 in the illustrated embodiment;
[0099] Figure 3 is a flow chart of a training process of a shape feature extraction model according to an exemplary embodiment;
[0100] Figure 4 yes Figure 1 A flowchart of an implementation of step S140 in the illustrated embodiment;
[0101] Figure 5 yes Figure 4 A flowchart of an implementation of step S141 in the illustrated embodiment;
[0102] Figure 6 is a schematic diagram of a training process of a three-dimensional reconstruction model according to an exemplary embodiment;
[0103] Figure 7 is a schematic diagram of a training process of an image processing model, taking a face stereo as an example, according to an exemplary embodiment;
[0104] Figure 8 is a flowchart of an image processing method according to an exemplary embodiment;
[0105] Fig. 9 is a block diagram of an image processing model training device according to an exemplary embodiment;
[0106] Fig.10 is a block diagram of an image processing device according to an exemplary embodiment;
[0107] Fig.11 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0108] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.
[0109] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0110] With the popularity of aesthetics such as bone makeup and facial folds, facial structure reshaping has gradually become one of the difficulties that the beauty field is committed to overcoming. Traditional beauty methods usually use image deformation methods such as liquefaction to achieve functions such as rhinoplasty and chin augmentation. However, it is difficult to ensure reasonable and continuous deformation when viewed from the side. For this reason, related technologies have introduced face reconstruction, which directly replaces part of the original reconstruction result with a three-dimensional template designed by the designer in 3D space. This method can ensure reasonable deformation in 360 degrees. However, since the face deformation process relies on the inherent three-dimensional template designed by the 3D designer, the deformation of the reconstructed face is relatively fixed, and different faces have the same local deformation result, resulting in a relatively single deformation result. .
[0111] Specifically, taking rhinoplasty as an example, in the relevant technology, the process of rhinoplasty is roughly divided into the following four steps:
[0112] The first step: The 3D designer manually raises the nose bridge based on the 3D face template, and then calculates the coordinate offset between the original nose bridge height and the manually raised nose bridge height.
[0113] The second step: input the image to be rhinoplasty into the trained 3D reconstruction network, and obtain the initial 3D face mesh a aligned with the image to be rhinoplasty through the 3DMM face base (three-dimensional deformation model);
[0114] The third step: add the offset obtained in the first step to the mesh a obtained in the second step to obtain the 3D face mesh b after nose correction;
[0115] The fourth step: project the 3D face network a and 3D face network b to the image space to obtain a' and b', that is, project the 3D coordinates of the 3D face network a to obtain the 2D coordinates, and the 2D coordinates obtained by the projection constitute a'; project the 3D coordinates of the 3D face network b to obtain the 2D coordinates, and the 2D coordinates obtained by the projection constitute b'. And deform a' to b' through the deformation algorithm to obtain the final rhinoplasty effect.
[0116] From the above description, it can be seen that in the related art, the rhinoplasty effect depends on the designer's design and aesthetic level, and because 3D designers rely on the inherent 3D face template, the rhinoplasty effects of different faces are the same, and the rhinoplasty effect is relatively single. In addition, in the related art, usually only partial deformation of the face can be performed, and full face deformation cannot be achieved.
[0117] In order to solve the above-mentioned technical problems existing in the related art, the embodiments of the present disclosure provide an image processing model training method, an image processing method, a device and an electronic device.
[0118] First, an image processing model training method provided by an embodiment of the present disclosure will be introduced in detail.
[0119] like Figure 1 As shown, an image processing model training method provided by an embodiment of the present disclosure may include the following steps:
[0120] S110, acquiring a first shape feature vector of a first object included in a reference image, and a second shape feature vector and an attribute feature vector of a second object included in a sample image.
[0121] The first shape feature vector is used to characterize the shape feature of the first object, the second shape feature vector is used to characterize the shape feature of the second object, and the attribute feature vector is the feature vector of the second object except the second shape feature vector; the shape feature of the second object is different from the shape feature of the first object.
[0122] Specifically, in practical applications, a reference image can be selected according to the purpose of image deformation. Different reference images are selected for different image deformation purposes. The reference image may include a face or other object to be deformed. The disclosed embodiment does not specifically limit this. For the sake of clarity in describing the solution, the object included in the reference image is referred to as the first object.
[0123] For example, if the first object is a human face and the image deformation purpose is to make the face three-dimensional, the reference image may be an image including a human face with a relatively three-dimensional face. For example, since the faces of Europeans or celebrities are generally relatively three-dimensional, the reference image may be an image including the faces of Europeans; or, it may be an image including the faces of celebrities.
[0124] In the reference image, a shape feature vector of a first object in the reference image can be extracted. For the sake of clarity in describing the solution, the shape feature vector of the first object is referred to as a first shape feature vector. The first shape feature vector can be used to characterize a shape feature of the first object. The shape feature can be a facial shape feature, such as a human face shape feature.
[0125] For example, still taking the image deformation purpose as a face stereoscopic example, the first shape feature vector can be used to represent the shape features of the nose, chin, forehead, etc. of the face.
[0126] In practical applications, when training an image processing model to be trained, a large number of sample images are required. In order to clearly describe the scheme, the objects included in the sample images are referred to as second objects. The object type of the second object is the same as the object type of the first object. For example, if the first object is a face, then the second object is also a face. In addition, in order to enable the image processing model to achieve the purpose of deformation, the shape features of the second object are different from the shape features of the first object.
[0127] Furthermore, in order to make the output image deformed by the image processing model have the attribute characteristics of the second object in the sample image, in addition to obtaining the second shape feature vector of the second object included in the sample image, it is also necessary to obtain the attribute feature vector of the second object.
[0128] The attribute feature vector of the second object can be used to characterize the attribute features of the second object itself, such as posture, expression, texture, etc.; it can also be used to characterize the environmental features corresponding to the second object in the sample image, such as lighting, etc. The disclosed embodiment does not specifically limit the attribute feature vector.
[0129] In order to describe the solution clearly, the specific implementation of S110 will be described in detail in the following embodiments.
[0130] S120, inputting the first shape feature vector and the second shape feature vector into the image processing model to be trained to obtain a target shape feature vector of the second object.
[0131] The target shape feature vector is obtained by fusing the first shape feature vector and the second shape feature vector through the image processing model to be trained.
[0132] Specifically, after obtaining the first shape feature vector of the first object included in the reference image and the second shape feature vector of the second object included in the sample image, the first shape feature vector and the second shape feature vector can be input into the image processing model to be trained. After obtaining the first shape feature vector and the second shape feature vector, the image processing model to be trained can process and fuse the first shape feature vector and the second shape feature vector respectively to obtain the target shape feature vector of the second object.
[0133] In one embodiment, S120, inputting the first shape feature vector and the second shape feature vector into the image processing model to be trained to obtain the target shape feature vector of the second object may include the following steps, namely step a1 and step a2:
[0134] Step a1: input the second shape feature vector into the first fully connected layer of the image processing model to be trained to obtain the deformed second shape feature vector.
[0135] Specifically, the second shape feature vector may be referred to as Sori. Sori passes through the first fully connected layer FC of the image processing model to be trained, and thus the deformed second shape feature vector Sori' may be obtained.
[0136] Step a2: input the deformed second shape feature vector and the first shape feature vector with weight coefficient into the second fully connected layer of the image processing model to be trained to obtain the target shape feature vector of the second object.
[0137] Among them, the weight coefficient is preset.
[0138] Specifically, the first shape feature vector can be called Sk, and the sum of Sori' and alpha*Sk can be input into the second fully connected layer of the image processing model to be trained. Among them, alpha is the weight coefficient of Sk, which is a manually set scalar. It can be understood that the larger the weight coefficient, the closer the target shape feature vector is to the first shape feature vector, and the closer the shape features of the object of the subsequent output image are to the shape features of the reference image.
[0139] For example, still taking the deformation purpose of the face as a three-dimensional example, the reference image includes the face of a European, so the facial shape features are more three-dimensional, and the first shape feature vector Sk can be used to characterize the shape features of the three-dimensional face. The sample image includes the face of an Asian, so the facial shape features are relatively flat, and the second shape feature vector Sori can be used to characterize the shape features of the flat face. Sori'+alpha*Sk is input into the second fully connected layer of the image processing model to be trained to obtain the target shape feature vector of the second object. It can be seen that the larger the alpha, the closer the target shape feature vector is to Sk, and the more three-dimensional the face of the subsequent output image is.
[0140] It can be seen that through the technical solution provided by the embodiment of the present disclosure, by fusing the first shape feature vector and the second shape feature vector, the target shape feature vector can include the first shape feature vector of the first object included in the reference image, so that in the subsequent steps, the output image can have the shape features of the first object, thereby making the shape features of the second object included in the sample image can be deformed into the shape features of the first object included in the reference image.
[0141] S130, rendering the target shape feature vector and the attribute feature vector to obtain an output image corresponding to the sample image.
[0142] Specifically, after obtaining the target shape feature vector, the target shape feature vector and the attribute feature vector may be input into a rendering layer for rendering to obtain an output image corresponding to the sample image.
[0143] S140, training the image processing model to be trained according to the first loss value between the reference image and the output image, and the second loss value between the sample image and the output image, to obtain a trained image processing model.
[0144] Among them, the first loss value is used to characterize the loss size of the shape feature of the object in the output image relative to the shape feature of the first object, and the second loss value is used to characterize the loss size of the attribute feature of the object in the output image relative to the attribute feature of the second object. The attribute feature of an object is the feature of the object other than the shape feature.
[0145] Specifically, the main goals of training image processing models are twofold:
[0146] First, the image output from the image processing model has the attribute features of the second object in the sample image, such as the skin color and ID of the second object, that is, the object in the output image is still the second object in the sample image. Therefore, the loss value between the attribute features of the object in the output image and the attribute features of the second object can be calculated. The smaller the loss value, the closer the attribute features of the object in the output image are to the attribute features of the second object in the sample image.
[0147] Secondly, the output image output from the image processing model is made close to the shape features of the first object in the reference image. For example, the face of the person in the reference image is more three-dimensional, and the face of the person in the sample image is relatively flat. Then, the output image output from the image processing model should be a more three-dimensional face, that is, the face of the person in the sample image is changed from flat to three-dimensional. Therefore, the loss value between the shape features of the object in the output image and the shape features of the first object can be calculated. The smaller this loss value is, the closer the shape features of the object in the output image are to the shape features of the first object in the reference image.
[0148] Therefore, according to the first loss value between the reference image and the output image, and the second loss value between the sample image and the output image, the image processing model to be trained is trained, and the trained image processing model obtained can ensure that the shape features of the output image are closer to the shape features of the reference image, and can ensure that the attribute features of the object in the output image are closer to the attribute features of the second object in the sample image, that is, to ensure that the object in the output image is still the second object in the sample image, so that the image processing model can make the shape of the object in the sample image deform to a shape close to the first object in the reference image. Instead of relying on the inherent three-dimensional template designed by the 3D designer to achieve deformation as in the related art. For different input images, by selecting different reference images, the output image output by the trained image processing model has different deformation results, thereby solving the problem of relatively single deformation results in the related art.
[0149] In order to describe the solution clearly, the specific implementation of S140 will be described in detail in the following embodiments.
[0150] The technical solution provided by the embodiment of the present disclosure obtains a first shape feature vector of a first object included in a reference image, and a second shape feature vector and an attribute feature vector of a second object included in a sample image; the first shape feature vector and the second shape feature vector are input into an image processing model to be trained, and the image processing model fuses the first shape feature vector and the second shape feature vector to obtain a target shape feature vector of the second object; the target shape feature vector and the attribute feature vector are rendered to obtain an output image corresponding to the sample image; and the image processing model to be trained is trained according to a first loss value between the reference image and the output image, and a second loss value between the sample image and the output image to obtain a trained image processing model.
[0151] It can be seen that through the technical solution provided by the embodiment of the present disclosure, when training the image processing model, the loss size of the shape feature of the object in the output image relative to the shape feature of the first object is used as the first loss value, and the loss size of the attribute feature of the object in the output image relative to the attribute feature of the second object is used as the second loss value. The image processing model to be trained is trained by the first loss value and the second loss value, so that the shape feature of the output image can be closer to the shape feature of the reference image, and the closer the attribute feature of the object in the output image is to the attribute feature of the second object in the sample image, that is, the object in the output image is still the second object in the sample image, so that the image processing model can make the shape of the object in the sample image deform to a shape close to the first object in the reference image. Instead of relying on the inherent three-dimensional template designed by the 3D designer to achieve deformation like the related art, for different input images, by selecting different reference images, the output image output by the trained image processing model has different deformation results, thereby solving the problem of relatively single deformation results in the related art.
[0152] exist Figure 1 Based on the embodiment shown, in one implementation, as Figure 2 As shown, S110, obtaining a first shape feature vector of a first object included in a reference image may include the following steps:
[0153] S111, inputting a reference image into a pre-trained shape feature extraction model, extracting a plurality of first shape feature maps of a first object included in the reference image through the shape feature extraction model, and outputting the plurality of first shape feature maps.
[0154] The different first shape feature maps are used to characterize shape features of different dimensions of the first object.
[0155] Specifically, before obtaining the first shape feature vector of the first object included in the reference image, a shape feature extraction model can be trained. When training the shape feature extraction model, a large number of images including different types of objects can be collected as training samples. Taking facial stereo as an example, two types of images, three-dimensional face (such as Europeans) and flat face (such as Asians), can be used to train the shape feature extraction model in binary classification, so that the shape feature extraction model has the ability to extract three-dimensional facial shape features. Of course, this is just an example. In actual applications, the shape feature extraction model can also be a multi-classification model, and for shape feature extraction models that extract different types of shapes, the collected second training images are different. For example, taking face thinning as an example, two types of images, fat face and thin face, can be collected. The present disclosed embodiments are not limited.
[0156] In order to describe the solution clearly, the training process of the shape feature extraction model will be described in detail in the following embodiments.
[0157] After the shape feature extraction model is trained, the reference image can be input into the shape feature extraction model, and the shape feature extraction model extracts multiple first shape feature maps of the first object included in the reference image, and outputs multiple first shape feature maps. In practical applications, the shape feature extraction model may include a multi-layer network, and can flexibly output semantically advanced shape feature maps extracted by the last few layers of the network. For example, in practical applications, the feature maps of the middle three layers can be extracted, and the embodiments of the present disclosure do not specifically limit this.
[0158] Moreover, different first shape feature maps are used to characterize shape features of different dimensions of the first object. Taking the face stereo as an example, if three feature maps are extracted, the first feature map is used to characterize the face shape features of the first object, the second feature map is used to characterize the forehead shape features of the first object, and the third feature map is used to characterize the chin shape features of the first object.
[0159] S112, performing global pooling on the multiple first shape feature maps respectively to obtain multiple first sub-shape feature vectors.
[0160] After obtaining a plurality of first shape feature maps, the plurality of first shape feature maps may be subjected to GAP (global average pooling) to obtain a plurality of first sub-shape feature vectors. Each first sub-shape feature vector is used to characterize a shape feature of a dimension of the first object.
[0161] For example, taking facial stereo as an example, if three feature maps are extracted, three first sub-shape feature vectors are obtained, the first sub-shape feature vector is used to characterize the facial shape features of the first object, the second sub-shape feature vector is used to characterize the forehead shape features of the first object, and the third sub-shape feature vector is used to characterize the chin shape features of the first object.
[0162] S113: Concatenate the multiple first sub-shape feature vectors to obtain a first shape feature vector of the first object included in the reference image.
[0163] Specifically, since the multiple first sub-shape feature vectors are used to represent the shape features of different dimensions of the first object, the multiple first sub-shape feature vectors can be concatenated to obtain the first shape feature vector, that is, the first shape feature vector can represent the shape features of multiple dimensions of the first object. As a result, the shapes of multiple dimensions of the output image can be close to the shapes of the corresponding dimensions of the reference image, so that the whole face deformation can be achieved, unlike the related art, which uses the same local deformation result for different faces.
[0164] It can be seen that through the technical solution provided by this embodiment, by extracting the first shape feature maps of multiple different dimensions of the first object in the reference image, and converting them into first sub-shape feature vectors corresponding to multiple different dimensions, and fusing the multiple first sub-shape feature vectors to obtain the first shape feature vector, the first shape feature vector can characterize the shape features of the first object in multiple different dimensions, so that the shapes of the multiple different dimensions of the output image are close to the shapes of the corresponding dimensions of the reference image, and then the whole face deformation can be achieved, unlike the related technology, which uses the same local deformation result for different faces.
[0165] In order to describe the solution clearly, the training process of the shape feature extraction model will be described in detail in the following embodiments.
[0166] exist Figure 2 Based on the embodiment shown, in one implementation, the training process of the shape feature extraction model is as follows: Figure 3 As shown, the following steps may be included:
[0167] S310: Acquire a first training image including third objects of different types.
[0168] Different types of third objects have different shape features, and the first training image is annotated with a classification label, which is used to characterize the shape features of the third object.
[0169] Specifically, when training the shape feature extraction model, a large number of training images are required. For the sake of clarity in the scheme description, the training images are referred to as first training images. Furthermore, in order to enable the trained shape feature extraction model to have the ability to extract shape features, the first training images may include different types of third objects, and different types of third objects have different shape features, and each first training image is annotated with a classification label for characterizing the shape features of the third object.
[0170] For example, taking rhinoplasty as an example, assuming that the shape feature extraction vector needs to extract the shape features of the nose in the face, then the first training image can include three different types of third objects. The first type of third object is a face image with a very high nose bridge. In this case, the classification label of the first training image is used to characterize that the third object has a very high nose bridge; the second type of third object is a face image with a normal nose bridge. In this case, the classification label of the first training image is used to characterize that the third object has a normal nose bridge; the third type of third object is a face image with a normal nose bridge. In this case, the classification label of the first training image is used to characterize that the third object has a normal nose bridge.
[0171] S320: Input the first training image into the shape feature extraction model to be trained to obtain an output result.
[0172] The output result is used to characterize the shape features of the objects included in the image output from the shape feature extraction model to be trained.
[0173] After labeling each first training image with a classification label, the first training image is input into the shape feature extraction model to be trained, the shape feature extraction model extracts the shape features of the third object included in the first training image, and outputs an output result for characterizing the shape features of the third object.
[0174] S330, calculating the loss function value of the shape feature extraction model to be trained based on the classification label and the output result.
[0175] After obtaining the output result from the shape feature extraction model to be trained, the loss function value of the shape feature extraction model to be trained is calculated by using the classification label and the output result. It can be understood that the smaller the loss function value of the shape feature extraction model to be trained, the closer the output result is to the classification label. On the contrary, the larger the loss function value of the shape feature extraction model to be trained, the greater the gap between the output result and the classification label.
[0176] S340, when the calculated loss function value is less than the first preset loss value, determine the model parameters of the shape feature extraction model to be trained to obtain the trained shape feature extraction model.
[0177] Specifically, when the calculated loss function value is less than the first preset loss value, it means that the loss function value of the shape feature extraction model to be trained is small enough, and the output result is very close to the classification label, that is, the accuracy of the output result is high. Therefore, the model parameters of the shape feature extraction model to be trained can be determined to obtain the trained shape feature extraction model.
[0178] It should be noted that the size of the first preset loss value can be determined according to actual conditions, and the embodiment of the present disclosure does not make any specific limitation on this.
[0179] It can be seen that through the technical solution provided by this embodiment, when training the shape feature extraction model, the collected first training image includes a third object with different shape features, and when the loss function value of the shape feature extraction model to be trained is less than the first preset loss value, the model parameters of the shape feature extraction model to be trained are determined to obtain the trained shape feature extraction model. It can be seen that the trained shape feature extraction model has the ability to accurately extract the shape features of the object, so that in the subsequent steps, the first shape feature vector of the first object included in the reference image can be accurately obtained.
[0180] In the above Figures 1 to 3 Based on the embodiment shown, S140, the image processing model to be trained is trained according to the first loss value between the reference image and the output image, and the second loss value between the sample image and the output image, to obtain a trained image processing model, such as Figure 4 As shown, the following two steps may be included:
[0181] S141, calculating a first loss value between a reference image and an output image, and a second loss value between a sample image and an output image.
[0182] Specifically, since the trained image processing model needs to ensure that the shape features of the output image are closer to the shape features of the reference image, and also needs to ensure that the attribute features of the object in the output image are closer to the attribute features of the second object in the sample image, that is, to ensure that the object in the output image is still the second object in the sample image, it is necessary to calculate the first loss value between the reference image and the output image, and the second loss value between the sample image and the output image. The first loss value is used to characterize the loss of the shape features of the object in the output image relative to the shape features of the first object, and the second loss value is used to characterize the loss of the attribute features of the object in the output image relative to the attribute features of the second object.
[0183] In one implementation, S141, a first loss value between the reference image and the output image, and a second loss value between the sample image and the output image are calculated, such as Figure 5 As shown, the following steps may be included:
[0184] S1411, calculating the adversarial loss value between the reference image and the output image as the first loss value between the reference image and the output image.
[0185] After obtaining the output image, the adversarial loss value between the reference image and the output image can be calculated, that is, the least squares GAN of the output image and the reference image is calculated as the first loss value.
[0186] S1412, calculating the loss value between the object feature vectors obtained by object recognition of the sample image and the output image, and the loss value between the feature maps obtained by downsampling the sample image and the output image.
[0187] S1413, taking the sum of the loss value between the object feature vectors and the loss value between the feature maps obtained by downsampling as the second loss value.
[0188] Specifically, the L2 loss value between the 512-dimensional feature vectors obtained by the sample image and the output image through the existing face recognition network, that is, the minimum square error of the two 512-dimensional feature vectors, and the L2 loss value between the feature map obtained after the sample image and the output image are downsampled, that is, the minimum square error between the feature map obtained after the sample image is downsampled and the feature map obtained after the output image is downsampled, can be calculated. The sum of the two calculated L2 loss values is determined as the second loss value between the sample image and the output image.
[0189] It can be seen that through the technical solution provided by this embodiment, by calculating the adversarial loss value between the reference image and the output image, the loss value between the shape feature of the output image and the shape feature of the reference image can be obtained. By controlling this loss value, the shape feature of the output image can be made closer to the shape feature of the reference image. And by calculating the loss value between the attribute features of the sample image and the output image, the attribute features of the object in the output image can be made closer to the attribute features of the second object in the sample image, that is, it is ensured that the object in the output image is still the second object in the sample image.
[0190] S142, when the sum of the first loss value and the second loss value is less than the second preset loss value, determine the model parameters of the image processing model to be trained to obtain the trained image processing model.
[0191] Specifically, when the sum of the first loss value and the second loss value is less than the second preset loss value, it means that the first loss value and the second loss value are both small enough, that is, the loss value of the shape feature of the output image and the shape feature of the reference image is small enough. At this time, the shape feature of the output image is closer to the shape feature of the reference image.
[0192] It should be noted that the size of the second preset loss value can be determined according to actual conditions, and the embodiment of the present disclosure does not make any specific limitation on this.
[0193] Moreover, the loss value between the target attribute features of the output image and the attribute features of the second object in the sample image is also small enough. At this time, the closer the attribute features of the object in the output image are to the attribute features of the second object in the sample image, the more likely it is that the object in the output image is still the second object in the sample image.
[0194] From the above description, it can be seen that when the sum of the first loss value and the second loss value is less than the preset loss value, the image processing model can accurately deform the object in the sample image. At this time, the model parameters of the image processing model can be determined to obtain the trained image processing model.
[0195] It can be seen that through the technical solution provided by this embodiment, when the sum of the first loss value and the second loss value is less than the second preset loss value, the model parameters of the image processing model to be trained are determined so that the shape features of the output image are closer to the shape features of the reference image, and the attribute features of the object in the output image are closer to the attribute features of the second object in the sample image, so that the trained image processing model can deform the shape of the object in the sample image to be close to the shape of the first object in the reference image.
[0196] Based on the above embodiment, in one implementation manner, obtaining a second shape feature vector and an attribute feature vector of a second object included in a sample image may include the following steps:
[0197] The sample image is input into a pre-trained three-dimensional reconstruction model, and the second shape feature vector and attribute feature vector of the second object included in the sample image are extracted through the three-dimensional reconstruction model.
[0198] Specifically, before obtaining the second shape feature vector and attribute feature vector of the second object included in the sample image, a three-dimensional reconstruction model can be trained. In this way, by inputting the sample image into the pre-trained three-dimensional reconstruction model, the second shape feature vector and attribute feature vector of the second object included in the sample image can be accurately obtained.
[0199] In order to describe the scheme clearly, the specific process of training the three-dimensional reconstruction model will be described in detail in the following embodiments.
[0200] It can be seen that through the technical solution provided by this embodiment, by pre-training the three-dimensional reconstruction model, when it is necessary to obtain the second shape feature direction and attribute feature vector of the second object included in the sample image, the sample image is input into the pre-trained three-dimensional reconstruction model, and the three-dimensional reconstruction model can accurately extract the second shape feature direction and attribute feature vector of the second object included in the sample image, thereby improving the accuracy and efficiency of obtaining the second shape feature direction and attribute feature vector of the second object included in the sample image.
[0201] In order to describe the scheme clearly, the specific process of training the three-dimensional reconstruction model will be described in detail in the following embodiments.
[0202] Based on the above embodiment, the training process of the 3D reconstruction model is as follows, which can be divided into steps b1 to b4:
[0203] Step b1, obtaining a second training image including a fourth object, and inputting the second training image into the 3D reconstruction model to be trained, and extracting a shape feature vector, a first attribute feature vector and a second attribute feature vector of the fourth object through the 3D reconstruction model to be trained.
[0204] The first attribute feature vector is used to characterize the features of the fourth object itself, and the second attribute feature is used to characterize the environmental features of the fourth object in the second training image.
[0205] Specifically, when training the 3D reconstruction model, the second training image including the fourth object may be input into the 3D reconstruction model to be trained, and the 3D reconstruction model to be trained may extract the shape feature vector of the fourth object, and may also extract the first attribute feature vector used to characterize the features of the fourth object itself. The features of the fourth object itself may be expression and posture, etc. A second attribute feature vector used to characterize the environmental features of the fourth object in the second training image may also be extracted, and the environmental features of the fourth object in the second training image may be reflectivity and illumination, etc.
[0206] Step b2: inputting the shape feature vector and the first attribute feature vector of the fourth object into the three-dimensional deformation model to obtain a three-dimensional mesh corresponding to the fourth object.
[0207] Specifically, taking the fourth object as a human face as an example, the shape feature vector of the fourth object and the first attribute feature vector used to characterize expression and posture can be used through a three-dimensional deformation model, namely a 3DMM face base, to obtain a 3D face mesh aligned with the input training image.
[0208] Step b3: rendering to obtain an output image based on the second attribute feature vector and the three-dimensional grid.
[0209] The 3D mesh and the second attribute feature vector are input into the rendering layer to obtain an output image. For example, a 3D face mesh, reflectivity, and illumination can be input into the rendering layer to obtain an output image.
[0210] In step b4, when the sum of the pixel-level loss value between the second training image and the output image, the loss value between the object feature vectors obtained by object recognition of the second training image and the output image, and the loss value between the key points obtained by object key point detection of the second training image and the output image is less than a preset loss value, a trained three-dimensional reconstruction model is obtained.
[0211] Specifically, the 3D reconstruction network is trained by reconstruction / semantic / key point loss of the input second training image and the output image, wherein the reconstruction loss refers to the pixel-level L1 loss of the input second training image and the output image, wherein the pixel-wise mean square error MSE between the two is calculated. The semantic loss refers to the L2 loss of the 512-dimensional feature vector obtained by the input second training image and the output image through the face recognition network, i.e., the minimum square error between the two; the key point loss refers to the L1 loss of the 68 key points obtained by the input second training image and the output image through face key point detection, i.e., the mean square error between the key points.
[0212] When the sum of the above three loss values is less than the preset loss value, it means that the 3D reconstruction model can accurately reconstruct the image. At this time, the training of the 3D reconstruction model is stopped to obtain the trained 3D reconstruction model.
[0213] It can be seen that through the technical solution provided by the present embodiment, by controlling the pixel-level loss value between the second training image and the output image, the loss value between the object feature vectors obtained by object recognition of the second training image and the output image, and the loss value between the key points obtained by object key point detection of the second training image and the output image, the three-dimensional reconstruction model can accurately reconstruct the image, and then the three-dimensional reconstruction model can accurately extract the second shape feature vector and attribute feature vector of the second object included in the sample image, thereby improving the accuracy and efficiency of obtaining the second shape feature vector and attribute feature vector of the second object included in the sample image.
[0214] In order to make the description of the solution complete and clear, the training process of the image processing model will be explained in detail with specific examples.
[0215] like Figure 6 As shown, this is a schematic diagram of the training process of the 3D reconstruction model.
[0216] from Figure 6 It can be seen that the training process of the 3D reconstruction model is roughly as follows: input the input image to the 3D reconstruction network to be trained, and output the shape parameters, expression parameters, posture, reflectivity and illumination of the face from the 3D reconstruction network. The shape parameters, expression parameters and posture are passed through the 3DMM face base to obtain a 3D face mesh aligned with the input image, which is then rendered with the albedo and illumination by the renderer to obtain the output image.
[0217] The 3D reconstruction network is trained through the reconstruction / semantic / key point losses of the input and output images, where the reconstruction loss refers to the pixel-level L1 loss of the input and output images, that is, the mean square error (MSE) in the pixel direction of the two; the semantic loss refers to the L2 loss of the 512-dimensional feature vectors obtained by the input and output images after the existing face recognition network, that is, the minimum square error between the two; the key point loss refers to the L1 loss of 68 key points obtained by face key point detection of the input and output images, that is, the mean square error in the pixel direction of the two.
[0218] When the sum of the above three loss values is less than the preset loss value, the 3D reconstruction network is trained.
[0219] like Figure 7 As shown, taking face stereo as an example, a schematic diagram of the training process of the image processing model of an embodiment of the present disclosure is explained.
[0220] from Figure 7 It can be seen that the training process is divided into three stages:
[0221] The first stage is to train the geometric feature extraction network.
[0222] When training the geometric feature extraction network, two types of pictures are collected: three-dimensional faces (such as Europeans) and flat faces (such as Asians). The geometric feature extraction network is trained by binary classification so that the geometric feature extraction network has the ability to extract three-dimensional facial shape features.
[0223] In practical applications, the geometric feature extraction network can also be trained in multiple categories. For example, three types of pictures of noses that are particularly high, generally high, and normal can be collected as training pictures. This enables the geometric feature extraction network to have the ability to extract the three types of shape features of noses that are particularly high, generally high, and normally high.
[0224] The geometric feature extraction network may include multiple network layers, and the multiple network layers are used to extract the facial three-dimensional shape features, namely, feature maps. Figure 7 As shown, these multiple network layers may include multiple con-bn-relu and pooling, wherein con-bn-relu is a combination layer, namely, a CBR combination layer, specifically, a combination of a convolution layer con, a batch normalization layer bn and an activation layer relu. Pooling is a pooling layer.
[0225] The second stage is to train the 3D reconstruction network.
[0226] Because in Figure 6The training process of the 3D reconstruction network has been described in , so it will not be repeated here. The 3D reconstruction network includes con-bn-relu, which is a combination layer, namely the CBR combination layer, specifically, a combination of the convolution layer con, the batch normalization layer bn and the activation layer relu. Pooling is a pooling layer.
[0227] The third stage is to train the deformation network.
[0228] Since the geometric feature extraction network is trained in the first stage and the 3D reconstruction network is trained in the second stage, the geometric feature extraction network and the 3D reconstruction network are fixed in this stage, and only the deformation network is trained in this stage.
[0229] Specifically, the input of the deformation network comes from two parts. The first part is the initial shape parameter Sori output by the 3D reconstruction network. The second part is the geometric feature extraction network. The feature map of the middle three layers is taken out and three one-dimensional feature vectors are obtained through GAP (global average pooling). These three one-dimensional feature vectors can be used to characterize the shape of the nose, chin and forehead respectively; these three one-dimensional feature vectors are then concatenated into a one-dimensional vector Sk. The initial shape parameter Sori is converted into Sori' through the fully connected layer FC, and Sori'+alpha*Sk is passed to the next layer FC (alpha is a manually set scalar) to output the deformed shape parameters. The output deformed shape parameters, posture parameters, expression parameters, texture parameters and lighting parameters output from the 3D reconstruction network are then input into the differentiable renderer, i.e., the rendering layer, to obtain the output image.
[0230] The deformation network is trained by high-level semantic loss and skin color loss between the output image and the input image, and GAN loss between the output image and the reference image. Among them, high-level semantic loss refers to the L2 loss of the 512-dimensional features obtained by the input image and the output image through the existing face recognition network, that is, the minimum square error of the two 512-dimensional feature vectors; skin color loss refers to the L2 loss of the shape feature map after downsampling of the input image and the output image, that is, the minimum square error between the feature map obtained after downsampling the sample image and the feature map obtained after downsampling the output image; GAN loss refers to the binary cross entropy function loss value of the output image and the reference image.
[0231] When the sum of the above three loss function values is less than the preset loss function value, the trained deformable network is obtained. At this time, the output image has the same skin color and ID as the face in the input image, that is, the output image and the input image are the same face, and the shape of the face in the output image will follow the shape of the face in the reference image, and the larger the alpha, the more the shape of the face in the output image tends to be the shape of the face in the reference image.
[0232] In the second aspect, an image processing method provided by an embodiment of the present disclosure will be described in detail.
[0233] like Figure 8 As shown, an image processing method provided by an embodiment of the present disclosure may include the following steps:
[0234] S810, acquiring a shape feature vector of a reference object included in a target reference image, and a shape feature vector and a target attribute feature vector of a target object included in a target input image.
[0235] Among them, the shape feature vector of the reference object is used to characterize the shape features of the reference object, the shape feature vector of the target object is used to characterize the shape features of the target object, and the target attribute feature vector is the feature vector of the target object other than the shape feature vector. The shape features of the target object are different from those of the reference object.
[0236] Specifically, the target reference image can be selected according to actual conditions. Taking the face stereoscopic as an example, an image of a European with a relatively stereoscopic face can be selected as the target reference image, or an image of a celebrity with a relatively stereoscopic face can be selected as the target reference image, which is reasonable.
[0237] After selecting the target reference image, the shape feature vector of the reference object included in the target reference image can be extracted. The shape feature vector of the reference object can be used to characterize the shape features of the reference object. Still taking the face stereo as an example, the shape feature vector of the reference object can be used to characterize the shape of the nose, the shape of the chin and the shape of the forehead of the reference object.
[0238] Furthermore, in order to make the object in the target output image have the attribute characteristics of the target object, in addition to obtaining the shape feature vector of the target object, it is also necessary to obtain the feature vector of the second object other than the shape feature vector, that is, it is necessary to obtain the target attribute feature vector of the target object.
[0239] The target attribute feature vector can be used to characterize the attribute features of the target object itself, such as posture, expression, texture, etc.; it can also be used to characterize the environmental features corresponding to the target object, such as lighting, etc. The embodiment of the present disclosure does not specifically limit the target attribute feature vector.
[0240] In one embodiment, the shape feature vector and target attribute feature vector of the target object can be obtained by inputting the target input image into the pre-trained 3D reconstruction model. Since the training process of the 3D reconstruction model has been described in detail in the embodiment of the first aspect, it will not be repeated here.
[0241] S820, inputting the shape feature vector of the reference object and the shape feature vector of the target object into the trained image processing model to obtain the deformed shape feature vector of the target object.
[0242] The trained image processing model is obtained by training using the method described in the embodiment of the first aspect.
[0243] Specifically, after obtaining the shape feature vector of the reference object and the shape feature vector of the target object, the shape feature vector of the reference object and the shape feature vector of the target object can be input into the trained image processing model obtained in the first aspect embodiment. After obtaining the shape feature vector of the reference object and the shape feature vector of the target object, the trained image processing model can process and fuse the shape feature vector of the reference object and the shape feature vector of the target object respectively to obtain the deformed shape feature vector of the target object.
[0244] In one embodiment, the shape feature vector of the reference object and the shape feature vector of the target object are input into the trained image processing model to obtain the deformed shape feature vector of the target object, which may include the following steps, namely step e1 and step e2:
[0245] Step c1, inputting the shape feature vector of the target object into the first fully connected layer of the trained image processing model to obtain the deformed shape feature sub-vector of the target object.
[0246] Step c2, inputting the deformed shape feature subvector of the target object and the shape feature vector of the reference object with weight coefficients into the second fully connected layer of the trained image processing model to obtain the deformed shape feature vector of the target object.
[0247] Among them, the weight coefficient is preset.
[0248] Specifically, assuming that the deformed shape feature subvector is Sori', and the shape feature vector of the reference object with a weight coefficient is alpha*Sk, Sori' and alpha*Sk can be input into the second fully connected layer together to obtain the deformed shape feature vector of the target object. Among them, alpha is the weight coefficient of Sk, which is a manually set scalar. It can be understood that the larger the weight coefficient, the closer the deformed shape feature vector of the target object is to the shape feature vector of the reference object, and the closer the shape features of the target object in the subsequent target output image are to the shape features of the reference object in the reference image.
[0249] It can be seen that by processing and fusing the shape feature vector of the target object and the shape feature vector of the reference object, the deformed shape feature vector of the target object is obtained, so that the deformed shape feature vector of the target object can include the shape feature vector of the reference object, so that in the subsequent steps, the shape features of the target object in the target output image are close to the shape features of the reference object.
[0250] S830, rendering the deformed shape feature vector and the target attribute feature vector to obtain a target output image corresponding to the target input image.
[0251] Specifically, after obtaining the deformed shape feature vector, the deformed shape feature vector and the target attribute feature vector may be input into a rendering layer for rendering to obtain a target output image corresponding to the target input image.
[0252] Through the technical solution provided by this embodiment, the target output image corresponding to the target input image is obtained by rendering the deformed shape feature vector and the target attribute feature vector, and the deformed shape feature vector is obtained by fusing the shape feature vector of the target object and the shape feature vector of the reference object, so that the shape feature of the target object in the target output image is close to the shape feature of the reference object. In addition, the object in the target output image has the target attribute feature of the target object, ensuring that the object in the target output image is still the target object in the target input image, so that the image processing model can deform the shape of the target object in the target input image into the shape of the reference object in the target reference image. Instead of relying on the inherent three-dimensional template designed by the 3D designer to achieve deformation like the related art, it can be seen that the trained image processing model selects different reference images, and the output image has different deformation results for different input images, thereby solving the problem of relatively single deformation results in the related art.
[0253] exist Figure 8Based on the illustrated embodiment, in one implementation, S810, obtaining a shape feature vector of a reference object included in a target reference image, may include the following steps, namely, step d1 to step d3:
[0254] Step d1, inputting the target reference image into a pre-trained shape feature extraction model, extracting multiple reference shape feature maps of the reference object included in the target reference image through the shape feature extraction model, and outputting multiple reference shape feature maps.
[0255] Among them, different reference shape feature maps are used to characterize shape features of different dimensions of the reference object.
[0256] Specifically, the target reference image can be input into the shape feature extraction model, and the shape feature extraction model extracts multiple reference shape feature maps of the reference object included in the target reference image, and outputs multiple reference shape feature maps. In practical applications, the shape feature extraction model can include a multi-layer network, and can flexibly output the reference shape feature maps with relatively advanced semantics extracted by the latter layers of the network. For example, in practical applications, three feature maps of the middle three layers can be extracted, and the embodiments of the present disclosure do not specifically limit this.
[0257] Moreover, different reference shape feature maps are used to represent the shape features of different dimensions of the reference object. Taking the face stereo as an example, if three feature maps are extracted, the first feature map is used to represent the face shape features of the reference object, the second feature map is used to represent the forehead shape features of the reference object, and the third feature map is used to represent the chin shape features of the reference object.
[0258] In step d2, multiple reference shape feature maps are respectively subjected to global pooling to obtain multiple reference sub-shape feature vectors.
[0259] After obtaining a plurality of reference shape feature maps, the plurality of reference shape feature maps may be subjected to GAP (global average pooling) to obtain a plurality of reference sub-shape feature vectors. Each reference sub-shape feature vector is used to characterize a shape feature of a dimension of the reference object.
[0260] For example, taking facial stereo as an example, if three feature maps are extracted, three reference sub-shape feature vectors are obtained. The first reference sub-shape feature vector is used to characterize the facial shape features of the reference object, the second reference sub-shape feature vector is used to characterize the forehead shape features of the reference object, and the third reference sub-shape feature vector is used to characterize the chin shape features of the reference object.
[0261] Step d3, concatenating multiple reference sub-shape feature vectors to obtain a shape feature vector of the reference object included in the target reference image.
[0262] Specifically, since multiple reference sub-shape feature vectors are used for shape features of different dimensions of the reference object, multiple reference sub-shape feature vectors can be concatenated to obtain a reference shape feature vector, that is, the reference shape feature vector can represent the shape features of multiple dimensions of the reference object. As a result, the shapes of multiple dimensions of the output image can be close to the shapes of the corresponding dimensions of the reference image, and the whole face deformation can be achieved, unlike the related art, which uses the same local deformation result for different faces.
[0263] According to a third aspect of the embodiments of the present disclosure, an image processing model training device is provided. Fig. 9 As shown, including:
[0264] The feature vector acquisition module 910 is configured to acquire a first shape feature vector of a first object included in a reference image, and a second shape feature vector and an attribute feature vector of a second object included in a sample image; the first shape feature vector is used to characterize a shape feature of the first object; the second shape feature vector is used to characterize a shape feature of the second object, and the attribute feature vector is a feature vector of the second object other than the second shape feature vector; the shape feature of the second object is different from the shape feature of the first object;
[0265] The feature vector fusion module 920 is configured to input the first shape feature vector and the second shape feature vector into the image processing model to be trained to obtain a target shape feature vector of the second object; the target shape feature vector is obtained by fusing the first shape feature vector and the second shape feature vector through the image processing model to be trained;
[0266] The output image acquisition module 930 is configured to render the target shape feature vector and the attribute feature vector to obtain an output image corresponding to the sample image;
[0267] The image processing model determination module 940 is configured to execute training of the image processing model to be trained according to a first loss value between the reference image and the output image, and a second loss value between the sample image and the output image, to obtain a trained image processing model; the first loss value is used to characterize the loss size of the shape feature of the object in the output image relative to the shape feature of the first object, and the second loss value is used to characterize the loss size of the attribute feature of the object in the output image relative to the attribute feature of the second object, and the attribute feature of an object is the feature of the object other than the shape feature.
[0268] It can be seen that through the technical solution provided by the embodiment of the present disclosure, when training the image processing model, the loss size of the shape feature of the object in the output image relative to the shape feature of the first object is used as the first loss value, and the loss size of the attribute feature of the object in the output image relative to the attribute feature of the second object is used as the second loss value. The image processing model to be trained is trained by the first loss value and the second loss value, so that the shape feature of the output image can be closer to the shape feature of the reference image, and the closer the attribute feature of the object in the output image is to the attribute feature of the second object in the sample image, that is, the object in the output image is still the second object in the sample image, so that the trained image processing model can make the shape of the object in the sample image deform to a shape close to the first object in the reference image. Instead of relying on the inherent three-dimensional template designed by the 3D designer to achieve deformation like the related art, for different input images, by selecting different reference images, the output image output by the trained image processing model has different deformation results, thereby solving the problem of relatively single deformation results in the related art.
[0269] Optionally, the feature vector acquisition module is specifically configured to execute:
[0270] Inputting a reference image into a pre-trained shape feature extraction model, extracting a plurality of first shape feature maps of a first object included in the reference image through the shape feature extraction model, and outputting the plurality of first shape feature maps; different first shape feature maps are used to characterize shape features of different dimensions of the first object;
[0271] The multiple first shape feature maps are respectively subjected to global pooling to obtain multiple first sub-shape feature vectors;
[0272] The multiple first sub-shape feature vectors are concatenated to obtain a first shape feature vector of the first object included in the reference image.
[0273] Optionally, the device further comprises a shape feature extraction model training module, configured to execute:
[0274] Acquire a first training image including different types of third objects; the different types of third objects have different shape features, and the first training image is annotated with a classification label, and the classification label is used to characterize the shape features of the third objects;
[0275] Inputting the first training image into a shape feature extraction model to be trained to obtain an output result; the output result is used to characterize the shape features of the object included in the image output from the shape feature extraction model to be trained;
[0276] Based on the classification label and the output result, calculating the loss function value of the shape feature extraction model to be trained;
[0277] When the calculated loss function value is less than the first preset loss value, the model parameters of the shape feature extraction model to be trained are determined to obtain the trained shape feature extraction model.
[0278] Optionally, a feature vector fusion module is specifically configured to perform:
[0279] Inputting the second shape feature vector into the first fully connected layer of the image processing model to be trained to obtain a deformed second shape feature vector;
[0280] The deformed second shape feature vector and the first shape feature vector with a weight coefficient are input into a second fully connected layer of the image processing model to be trained to obtain a target shape feature vector of the second object; the weight coefficient is preset.
[0281] Optionally, the image processing model determination module includes:
[0282] A loss value calculation module, configured to calculate a first loss value between the reference image and the output image, and a second loss value between the sample image and the output image;
[0283] The image processing model determination unit is configured to determine the model parameters of the image processing model to be trained when the sum of the first loss value and the second loss value is less than a second preset loss value, so as to obtain the trained image processing model.
[0284] Optionally, the loss value calculation module is specifically configured to perform:
[0285] Calculating an adversarial loss value between the reference image and the output image as a first loss value between the reference image and the output image;
[0286] Calculating a loss value between an object feature vector obtained by object recognition of the sample image and the output image, and a loss value between a feature map obtained by downsampling the sample image and the output image;
[0287] The sum of the loss value between the object feature vectors and the loss value between the feature maps obtained by downsampling is used as the second loss value.
[0288] Optionally, the feature vector acquisition module is further specifically configured to execute:
[0289] The sample image is input into a pre-trained three-dimensional reconstruction model, and a second shape feature vector and an attribute feature vector of a second object included in the sample image are extracted through the three-dimensional reconstruction model.
[0290] The device also includes a three-dimensional reconstruction model training module, which is specifically configured to execute:
[0291] Acquire a second training image including a fourth object, input the second training image into a 3D reconstruction model to be trained, and extract a shape feature vector, a first attribute feature vector, and a second attribute feature vector of the fourth object through the 3D reconstruction model to be trained; the first attribute feature vector is used to characterize the features of the fourth object itself, and the second attribute feature vector is used to characterize the environmental features of the fourth object in the second training image;
[0292] Inputting the shape feature vector of the fourth object and the first attribute feature vector into a three-dimensional deformation model to obtain a three-dimensional mesh corresponding to the fourth object;
[0293] Rendering to obtain an output image based on the second attribute feature vector and the three-dimensional grid;
[0294] When the sum of the pixel-level loss value between the second training image and the output image, the loss value between the object feature vectors obtained by object recognition of the second training image and the output image, and the loss value between the key points obtained by object key point detection of the second training image and the output image is less than a preset loss value, a trained three-dimensional reconstruction model is obtained.
[0295] According to a fourth aspect of the embodiments of the present disclosure, there is provided an image processing device, such as Fig.10 As shown, including:
[0296] The feature vector acquisition module 1010 is configured to execute acquisition of a shape feature vector of a reference object included in a target reference image, and a shape feature vector and a target attribute feature vector of a target object included in a target input image; the shape feature vector of the reference object is used to characterize a shape feature of the reference object, the shape feature vector of the target object is used to characterize a shape feature of the target object, and the target attribute feature vector is a feature vector of the target object other than the shape feature vector, and the shape feature of the target object is different from the shape feature of the reference object;
[0297] The deformed shape feature vector acquisition module 1020 is configured to input the shape feature vector of the reference object and the shape feature vector of the target object into a trained image processing model to obtain a deformed shape feature vector of the target object; the trained image processing model is trained by the method described in the embodiment of the first aspect;
[0298] The target output image acquisition module 1030 is configured to render the deformed shape feature vector and the target attribute feature vector to obtain a target output image corresponding to the target input image.
[0299] Through the technical solution provided by this embodiment, the target output image corresponding to the target input image is obtained by rendering the deformed shape feature vector and the target attribute feature vector, and the deformed shape feature vector is obtained by fusing the shape feature vector of the target object and the shape feature vector of the reference object, so that the shape feature of the target object in the target output image is close to the shape feature of the reference object. In addition, the object in the target output image has the target attribute feature of the target object, ensuring that the object in the target output image is still the target object in the target input image, so that the image processing model can deform the shape of the target object in the target input image into the shape of the reference object in the target reference image. Instead of relying on the inherent three-dimensional template designed by the 3D designer to achieve deformation like the related art, it can be seen that the trained image processing model selects different reference images, and the output image has different deformation results for different input images, thereby solving the problem of relatively single deformation results in the related art.
[0300] Optionally, the feature vector acquisition module is specifically configured to execute:
[0301] Inputting the target reference image into a pre-trained shape feature extraction model, extracting multiple reference shape feature maps of the reference object included in the target reference image through the shape feature extraction model, and outputting the multiple reference shape feature maps; different reference shape feature maps are used to characterize shape features of different dimensions of the reference object;
[0302] The multiple reference shape feature maps are respectively subjected to global pooling to obtain multiple reference sub-shape feature vectors;
[0303] The multiple reference sub-shape feature vectors are concatenated to obtain a shape feature vector of the reference object included in the target reference image.
[0304] Optionally, the deformation shape feature vector acquisition module is specifically configured to execute:
[0305] Inputting the shape feature vector of the target object into the first fully connected layer of the trained image processing model to obtain a deformed shape feature sub-vector of the target object;
[0306] The deformed shape feature subvector of the target object and the shape feature vector of the reference object with a weight coefficient are input into the second fully connected layer of the trained image processing model to obtain the deformed shape feature vector of the target object; the weight coefficient is preset.
[0307] Fig.11 1 is a block diagram of a device 1100 according to an exemplary embodiment. For example, the device 1100 may be provided as a server. Fig.11 The apparatus 1100 includes a processing component 1122, which further includes one or more processors, and a memory resource represented by a memory 1132 for storing instructions executable by the processing component 1122, such as an application. The application stored in the memory 1132 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 1122 is configured to execute instructions to perform the image processing model training method described in the first aspect, or the image processing method described in the second aspect.
[0308] The device 1100 may also include a power supply component 1126 configured to perform power management of the device 1100, a wired or wireless network interface 1150 configured to connect the device 1100 to a network, and an input / output (I / O) interface 11511. The device 1100 may operate based on an operating system stored in the memory 1132, such as Windows Server™, MacOS X™, Unix™, Linux™, FreeBSD™, or the like.
[0309] According to a fifth aspect of an embodiment of the present disclosure, there is provided an electronic device, including:
[0310] processor;
[0311] a memory for storing instructions executable by the processor;
[0312] Wherein, the processor is configured to execute the instructions to implement the image processing model training method described in the first aspect, or the image processing method described in the second aspect.
[0313] According to the sixth aspect of an embodiment of the present disclosure, a storage medium is provided. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the image processing model training method described in the first aspect, or the image processing method described in the second aspect.
[0314] According to the seventh aspect of the embodiments of the present disclosure, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to implement the image processing model training method described in the first aspect, or the image processing method described in the second aspect.
[0315] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0316] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A method for training an image processing model, characterized in that: include: Acquire a first shape feature vector of a first object included in a reference image, and a second shape feature vector and an attribute feature vector of a second object included in a sample image; the first shape feature vector is used to characterize a shape feature of the first object; the second shape feature vector is used to characterize a shape feature of the second object, and the attribute feature vector is a feature vector of the second object other than the second shape feature vector; the shape feature of the second object is different from the shape feature of the first object; Inputting the first shape feature vector and the second shape feature vector into an image processing model to be trained to obtain a target shape feature vector of the second object; The target shape feature vector is obtained by fusing the first shape feature vector and the second shape feature vector through the image processing model to be trained; Rendering the target shape feature vector and the attribute feature vector to obtain an output image corresponding to the sample image; The image processing model to be trained is trained according to a first loss value between the reference image and the output image, and a second loss value between the sample image and the output image to obtain a trained image processing model; the first loss value is used to characterize the loss size of the shape feature of the object in the output image relative to the shape feature of the first object, and the second loss value is used to characterize the loss size of the attribute feature of the object in the output image relative to the attribute feature of the second object. The attribute feature of an object is the feature of the object other than the shape feature.
2. The method according to claim 1, characterized in that The step of acquiring a first shape feature vector of a first object included in a reference image comprises: Inputting a reference image into a pre-trained shape feature extraction model, extracting a plurality of first shape feature maps of a first object included in the reference image through the shape feature extraction model, and outputting the plurality of first shape feature maps; different first shape feature maps are used to characterize shape features of different dimensions of the first object; The multiple first shape feature maps are respectively subjected to global pooling to obtain multiple first sub-shape feature vectors; The multiple first sub-shape feature vectors are concatenated to obtain a first shape feature vector of the first object included in the reference image.
3. The method according to claim 2, characterized in that The training process of the shape feature extraction model includes: Acquire a first training image including different types of third objects; the different types of third objects have different shape features, and the first training image is annotated with a classification label, and the classification label is used to characterize the shape features of the third objects; Inputting the first training image into a shape feature extraction model to be trained to obtain an output result; the output result is used to characterize the shape features of the object included in the image output from the shape feature extraction model to be trained; Based on the classification label and the output result, calculating the loss function value of the shape feature extraction model to be trained; When the calculated loss function value is less than the first preset loss value, the model parameters of the shape feature extraction model to be trained are determined to obtain the trained shape feature extraction model.
4. The method according to claim 1, characterized in that: The step of inputting the first shape feature vector and the second shape feature vector into the image processing model to be trained to obtain the target shape feature vector of the second object comprises: Inputting the second shape feature vector into the first fully connected layer of the image processing model to be trained to obtain a deformed second shape feature vector; The deformed second shape feature vector and the first shape feature vector with a weight coefficient are input into a second fully connected layer of the image processing model to be trained to obtain a target shape feature vector of the second object; the weight coefficient is preset.
5. The method according to any one of claims 1 to 4, characterized in that: The step of training the image processing model to be trained according to the first loss value between the reference image and the output image, and the second loss value between the sample image and the output image, to obtain the trained image processing model comprises: Calculating a first loss value between the reference image and the output image, and a second loss value between the sample image and the output image; When the sum of the first loss value and the second loss value is less than a second preset loss value, the model parameters of the image processing model to be trained are determined to obtain the trained image processing model.
6. The method according to claim 5, characterized in that The calculating a first loss value between the reference image and the output image, and a second loss value between the sample image and the output image, comprises: Calculating an adversarial loss value between the reference image and the output image as a first loss value between the reference image and the output image; Calculating a loss value between an object feature vector obtained by object recognition of the sample image and the output image, and a loss value between a feature map obtained by downsampling the sample image and the output image; The sum of the loss value between the object feature vectors and the loss value between the feature maps obtained by downsampling is used as the second loss value.
7. The method according to any one of claims 1 to 4, characterized in that: The step of acquiring a second shape feature vector and an attribute feature vector of a second object included in the sample image includes: The sample image is input into a pre-trained three-dimensional reconstruction model, and a second shape feature vector and an attribute feature vector of a second object included in the sample image are extracted through the three-dimensional reconstruction model.
8. The method according to claim 7, characterized in that The training process of the three-dimensional reconstruction model includes: Acquire a second training image including a fourth object, input the second training image into a 3D reconstruction model to be trained, and extract a shape feature vector, a first attribute feature vector, and a second attribute feature vector of the fourth object through the 3D reconstruction model to be trained; the first attribute feature vector is used to characterize the features of the fourth object itself, and the second attribute feature vector is used to characterize the environmental features of the fourth object in the second training image; Inputting the shape feature vector of the fourth object and the first attribute feature vector into a three-dimensional deformation model to obtain a three-dimensional mesh corresponding to the fourth object; Rendering to obtain an output image based on the second attribute feature vector and the three-dimensional grid; When the sum of the pixel-level loss value between the second training image and the output image, the loss value between the object feature vectors obtained by object recognition of the second training image and the output image, and the loss value between the key points obtained by object key point detection of the second training image and the output image is less than a preset loss value, a trained three-dimensional reconstruction model is obtained.
9. An image processing method, characterized in that: include: Acquire a shape feature vector of a reference object included in a target reference image, and a shape feature vector and a target attribute feature vector of a target object included in a target input image; The shape feature vector of the reference object is used to characterize the shape feature of the reference object, the shape feature vector of the target object is used to characterize the shape feature of the target object, the target attribute feature vector is a feature vector of the target object other than the shape feature vector, and the shape feature of the target object is different from the shape feature of the reference object; Inputting the shape feature vector of the reference object and the shape feature vector of the target object into a trained image processing model to obtain a deformed shape feature vector of the target object; the trained image processing model is trained by the method according to any one of claims 1 to 8; The deformed shape feature vector and the target attribute feature vector are rendered to obtain a target output image corresponding to the target input image.
10. The method according to claim 9, characterized in that The step of acquiring a shape feature vector of a reference object included in a target reference image comprises: Inputting the target reference image into a pre-trained shape feature extraction model, extracting multiple reference shape feature maps of the reference object included in the target reference image through the shape feature extraction model, and outputting the multiple reference shape feature maps; different reference shape feature maps are used to characterize shape features of different dimensions of the reference object; The multiple reference shape feature maps are respectively subjected to global pooling to obtain multiple reference sub-shape feature vectors; The multiple reference sub-shape feature vectors are concatenated to obtain a shape feature vector of the reference object included in the target reference image.
11. The method according to claim 9 or 10, characterized in that: The step of inputting the shape feature vector of the reference object and the shape feature vector of the target object into a trained image processing model to obtain the deformed shape feature vector of the target object comprises: Inputting the shape feature vector of the target object into the first fully connected layer of the trained image processing model to obtain a deformed shape feature sub-vector of the target object; The deformed shape feature subvector of the target object and the shape feature vector of the reference object with a weight coefficient are input into the second fully connected layer of the trained image processing model to obtain the deformed shape feature vector of the target object; the weight coefficient is preset.
12. An image processing model training device, characterized in that: include: a feature vector acquisition module, configured to acquire a first shape feature vector of a first object included in a reference image, and a second shape feature vector and an attribute feature vector of a second object included in a sample image; the first shape feature vector is used to characterize a shape feature of the first object; the second shape feature vector is used to characterize a shape feature of the second object, and the attribute feature vector is a feature vector of the second object other than the second shape feature vector; the shape feature of the second object is different from the shape feature of the first object; a feature vector fusion module, configured to input the first shape feature vector and the second shape feature vector into the image processing model to be trained to obtain a target shape feature vector of the second object; the target shape feature vector is obtained by fusing the first shape feature vector and the second shape feature vector through the image processing model to be trained; An output image acquisition module is configured to render the target shape feature vector and the attribute feature vector to obtain an output image corresponding to the sample image; The image processing model determination module is configured to execute training of the image processing model to be trained according to a first loss value between the reference image and the output image, and a second loss value between the sample image and the output image, to obtain a trained image processing model; the first loss value is used to characterize the loss size of the shape feature of the object in the output image relative to the shape feature of the first object, and the second loss value is used to characterize the loss size of the attribute feature of the object in the output image relative to the attribute feature of the second object, and the attribute feature of an object is the feature of the object other than the shape feature.
13. An image processing device, characterized in that: include: a feature vector acquisition module, configured to acquire a shape feature vector of a reference object included in a target reference image, and a shape feature vector and a target attribute feature vector of a target object included in a target input image; the shape feature vector of the reference object is used to characterize a shape feature of the reference object, the shape feature vector of the target object is used to characterize a shape feature of the target object, the target attribute feature vector is a feature vector of the target object other than the shape feature vector, and the shape feature of the target object is different from the shape feature of the reference object; A deformation shape feature vector acquisition module, configured to input the shape feature vector of the reference object and the shape feature vector of the target object into a trained image processing model to obtain a deformed shape feature vector of the target object; the trained image processing model is trained by the method according to any one of claims 1 to 8; The target output image acquisition module is configured to render the deformed shape feature vector and the target attribute feature vector to obtain a target output image corresponding to the target input image.
14. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; Wherein, the processor is configured to execute the instructions to implement the image processing model training method as described in any one of claims 1 to 8, or the image processing method as described in any one of claims 9 to 11.
15. A storage medium, when the instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to execute the image processing model training method as described in any one of claims 1 to 8, or the image processing method as described in any one of claims 9 to 11.
16. A computer program product, characterized in that When it runs on a computer, it enables the computer to implement the image processing model training method as described in any one of claims 1 to 8, or the image processing method as described in any one of claims 9 to 11.
Citation Information
Patent Citations
Image rendering method and device, electronic equipment and computer readable storage medium
CN110084154A
Model training method, three-dimensional face image generation method and equipment
CN113838176A
