CN-121982137-A - Image generation method and related equipment
Abstract
The application discloses an image generation method and related equipment, which can acquire an original face image of a target object and a reference face image of a reference object, detect key points of the reference face image to obtain face key point information, generate a template image with a face to be complemented based on the face key point information and a background area in the reference face image, perform object identification processing on the original face image to obtain object identity characteristic information, and perform face complementation operation on the template image based on the object identity characteristic information and the face key point information to obtain the target face image of the target object. The application can carry out face complement by depending on the background area of the reference face image and the face key point information, and the generated target face image is strongly dependent on the object identity characteristic information of the original face image, so that the face change result and the target object have better face similarity, the face change effect is greatly improved, and the image harmony is enhanced.
Inventors
- HE KEKE
Assignees
- 腾讯科技(深圳)有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20241029
Claims (14)
- 1. An image generation method, comprising: Acquiring an original face image of a target object and a reference face image of a reference object; Performing key point detection on the reference face image to obtain face key point information; Generating a template image with a face to be complemented based on the face key point information and a background area in the reference face image; performing object recognition processing on the original face image to obtain object identity characteristic information of the target object; and carrying out face complement operation processing on the template image based on the object identity characteristic information and the face key point information to obtain a target face image of the target object.
- 2. The method of claim 1, wherein the generating a template image for a face to be complemented based on the face keypoint information and a background region in the reference face image comprises: performing face segmentation processing on the reference face image to obtain a face region; mask shielding processing of the face area is carried out on the reference face image, and a template background area image containing a background area in the reference face image is obtained; Carrying out fusion processing on the facial region and the facial key point information to obtain a template facial region image; And carrying out fusion processing on the template background area image and the template face area image to generate a template image with the face to be complemented.
- 3. The method according to claim 1, wherein the performing face-complement operation processing on the template image based on the object identity feature information and the face key point information to obtain a target face image of the target object includes: Performing feature coding processing on the template image to obtain hidden layer feature information of the template image; Performing face complement operation processing on the hidden layer characteristic information based on the identity characteristic information of the object and the face key point information of the reference face image to obtain a face complement image; And performing feature decoding processing on the face-complement image to obtain a target face image of the target object.
- 4. A method according to claim 3, wherein said performing face-complement operation processing on the hidden-layer feature information based on the subject identity feature information and the face key point information of the reference face image to obtain a face-complement image comprises: Carrying out fusion processing on the identity characteristic information of the object and the facial key point information of the reference facial image to obtain fusion characteristic information; And performing attention processing on the fusion characteristic information and the hidden layer characteristic information to obtain a face complement image.
- 5. The method of claim 4, wherein the performing attention processing on the fusion feature information and the hidden layer feature information to obtain a face complement image comprises: Performing feature coding processing on the hidden layer feature information to obtain processed hidden layer feature information; Performing attention processing on the fusion characteristic information and the processed hidden layer characteristic information to obtain target characteristic information; And performing feature decoding processing on the target feature information to obtain a face-complement image.
- 6. The method according to claim 1, wherein the performing face-complement operation processing on the template image based on the object identity feature information and the face key point information to obtain a target face image of the target object includes: Performing face complement operation processing on the template image based on the identity characteristic information of the object and the face key point information through an image generation model to obtain a target face image of the target object; The generating the model through the image, based on the identity characteristic information of the object and the facial key point information, performing facial completion operation processing on the template image, and before obtaining the target facial image of the target object, further comprises: acquiring training data, wherein the training data comprises a sample original face image and a sample reference face image of a sample object; performing object recognition processing on the sample original face image to obtain original identity characteristic information of the sample object; performing key point detection on the sample reference face image to obtain sample face key point information; Generating a sample template image with a face to be complemented based on a background area in the sample reference face image and the sample face key point information; performing face complement operation processing on the sample template image based on the original identity characteristic information and the sample face key point information through an image generation model to obtain a sample target face image of the sample object; And adjusting parameters of the image generation model according to the sample target face image and the sample reference face image to obtain a trained image generation model.
- 7. The method of claim 6, wherein adjusting parameters of the image generation model based on the sample target face image and the sample reference face image to obtain a trained image generation model comprises: calculating reconstruction loss information between the sample target face image and the sample reference face image; Performing object recognition processing on the sample target face image to obtain actual identity characteristic information of the sample target face image; according to the actual identity characteristic information and the original identity characteristic information, calculating identity loss information corresponding to the sample object; And adjusting parameters of the image generation model according to the identity loss information and the reconstruction loss information to obtain a trained image generation model.
- 8. The method of claim 7, wherein adjusting parameters of the image generation model according to the identity loss information and the reconstruction loss information to obtain a trained image generation model comprises: calculating feature loss information between the sample target face image and the sample reference face image based on feature information of the sample target face image and feature information of the sample reference face image; carrying out authenticity judgment processing on the sample target face image through a discriminator so as to determine generation countermeasures loss information of the image generation model according to a judgment result; and adjusting parameters of the image generation model according to the identity loss information, the reconstruction loss information, the characteristic loss information and the generation counterloss information to obtain a trained image generation model.
- 9. The method of claim 8, wherein the calculating feature loss information between the sample target face image and the sample reference face image based on feature information of the sample target face image and feature information of the sample reference face image comprises: Extracting at least one dimension of characteristics of the sample target face image and the sample reference face image respectively to obtain characteristic information of the sample target face image in at least one dimension and characteristic information of the sample reference face image in at least one dimension; And calculating feature loss information between the sample target face image and the sample reference face image according to the feature information of the sample target face image in at least one dimension and the feature information of the sample reference face image in at least one dimension.
- 10. The method of claim 8, wherein the method further comprises: Respectively carrying out authenticity judgment processing on the sample target face image and the sample reference face image through the discriminator so as to obtain a judgment result of the sample target face image and a judgment result of the sample reference face image; Determining discrimination counterdamage information according to the discrimination result of the sample target face image and the discrimination result of the sample reference face image; And updating parameters of the discriminator according to the discriminating and countering loss information.
- 11. An image generating apparatus, comprising: an acquisition unit configured to acquire an original face image of a target object and a reference face image of a reference object; The detection unit is used for carrying out key point detection on the reference face image to obtain face key point information; a generating unit, configured to generate a template image to be complemented of a face based on the face key point information and a background area in the reference face image; the identification unit is used for carrying out object identification processing on the original face image to obtain object identity characteristic information of the target object; And the completion unit is used for carrying out face completion operation processing on the template image based on the identity characteristic information of the object and the face key point information to obtain a target face image of the target object.
- 12. An electronic device comprising a memory storing an application and a processor for running the application in the memory to perform the operations in the image generation method of any one of claims 1 to 10.
- 13. A computer readable storage medium storing a plurality of instructions adapted to be loaded by a processor to perform the steps in the image generation method of any of claims 1 to 10.
- 14. A computer program product comprising a computer program or instructions which, when executed by a processor, carries out the steps of the image generation method of any one of claims 1 to 10.
Description
Image generation method and related equipment Technical Field The application relates to the technical field of computers, in particular to an image generation method and related equipment. Background With the development of computer technology, image processing technology is applied to more and more fields, for example, the image processing technology may include face replacement, and the face replacement may be applied to various scenes such as professional photographic photo production, movie and television portrait production, game character design, avatar design, and the like. In the related art, a face change is generally performed using a neural network model, for example, an image is input into the neural network model for face change, and the image after face change is output through the neural network model. However, the existing face-changing technology has a large difference between the image obtained by the face-changing technology and the ideal image after face-changing, and the face-changing effect is poor. Disclosure of Invention The embodiment of the application provides an image generation method and related equipment, wherein the related equipment can comprise an image generation device, electronic equipment, a computer readable storage medium and a computer program product, so that the face changing effect can be greatly improved, and the image harmony is enhanced. The embodiment of the application provides an image generation method, which comprises the following steps: Acquiring an original face image of a target object and a reference face image of a reference object; Performing key point detection on the reference face image to obtain face key point information; Generating a template image with a face to be complemented based on the face key point information and a background area in the reference face image; performing object recognition processing on the original face image to obtain object identity characteristic information of the target object; and carrying out face complement operation processing on the template image based on the object identity characteristic information and the face key point information to obtain a target face image of the target object. Accordingly, an embodiment of the present application provides an image generating apparatus, including: an acquisition unit configured to acquire an original face image of a target object and a reference face image of a reference object; The detection unit is used for carrying out key point detection on the reference face image to obtain face key point information; a generating unit, configured to generate a template image to be complemented of a face based on the face key point information and a background area in the reference face image; the identification unit is used for carrying out object identification processing on the original face image to obtain object identity characteristic information of the target object; And the completion unit is used for carrying out face completion operation processing on the template image based on the identity characteristic information of the object and the face key point information to obtain a target face image of the target object. Alternatively, in some embodiments of the present application, the generating unit may include a dividing subunit, a first processing subunit, a second processing subunit, and a generating subunit, as follows: the segmentation subunit is used for carrying out face segmentation processing on the reference face image to obtain a face area; a first processing subunit, configured to perform mask masking processing on the face area on the reference face image, to obtain a template background area image that includes a background area in the reference face image; the second processing subunit is used for carrying out fusion processing on the facial area and the facial key point information to obtain a template facial area image; And the generating subunit is used for carrying out fusion processing on the template background area image and the template face area image so as to generate a template image with the face to be complemented. Alternatively, in some embodiments of the present application, the complement unit may include a coding subunit, a complement subunit, and a decoding subunit, as follows: The coding subunit is used for carrying out feature coding processing on the template image to obtain hidden layer feature information of the template image; The completion subunit is used for carrying out face completion operation processing on the hidden layer characteristic information based on the identity characteristic information of the object and the face key point information of the reference face image to obtain a face-completed image; And the decoding subunit is used for carrying out feature decoding processing on the face-complement image to obtain a target face image of the target object. Optionally, in some embodiments of the present application,