ID photo generation method and device, electronic device and storage medium

By fusing the features of the original and standard ID photos, and using the face LoRA model for facial redrawing, the problem of low accuracy in ID photo generation in the existing technology is solved, and higher personal feature retention and ID photo quality are achieved. control.

CN118430052BActive Publication Date: 2024-09-24HAIMA CLOUD TIANJIN INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410887794.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-03
Publication Date
2024-09-24
Estimated Expiration
2044-07-03

AI Technical Summary

Technical Problem

Existing ID photo generation technology based on artificial intelligence is difficult to effectively retain the personal characteristics in the original photos, resulting in low accuracy in generating ID photos. It is especially difficult to ensure consistency and quality when processing a large number of photos.

Method used

By obtaining the features of the original image and the standard ID photo, merging the facial features, generating the ID photo latent space, and using the UNet model embedded in the face LoRA model to perform facial redrawing processing, the ID photo is adjusted to retain the original facial features while satisfying Standard ID photo requirements.

Benefits of technology

It improves the accuracy and consistency of personal characteristics in ID photos, ensuring that the quality of generated ID photos meets standard requirements, while simplifying the processing process and improving efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118430052B
    Figure CN118430052B
Patent Text Reader

Abstract

The present application relates to a method and device for generating ID photos, an electronic device and a storage medium. The method comprises: extracting original facial features corresponding to the original image and ID photo facial features corresponding to the standard ID photo, fusing the original facial features and the ID photo facial features to obtain face fusion features. Extracting the ID photo description information, generating the ID photo latent space according to the ID photo description information and the initial image latent space, adjusting the ID photo latent space according to the face fusion features to obtain a first-stage image latent space, and performing feature decoding on the first-stage image latent space to obtain the initial ID photo. Performing facial redrawing processing on the initial ID photo using the first UNet model embedded with the face LoRA model to obtain a target ID photo corresponding to the original image. The use of this method can improve the accuracy of personal features in the generated ID photo.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a method and device for generating ID photos, an electronic device, and a storage medium. Background Art

[0002] In the prior art, generating ID photos usually requires users to go to a photo studio in person or use specific automatic camera equipment to take photos, which is not only time-consuming and inconvenient, but also often leads to uneven quality of ID photos due to differences in ambient light, equipment quality, or operator skills. In addition, traditional ID photo generation technology makes it difficult to ensure that the personal features in the photo are highly consistent with the real identity, especially when a large number of photos need to be processed, maintaining consistency and quality control becomes a major challenge. In order to ensure the consistency of personal features in the photos and actual identity information when processing a large number of photos, and to control the quality of the generated ID photos, a method of generating ID photos based on artificial intelligence image generation technology has emerged.

[0003] In traditional technology, when using artificial intelligence-based image generation technology to generate ID photos, it is usually necessary to train a deep learning model based on standard ID photos to obtain a trained model, which can then be used to generate an ID photo corresponding to the original image input by the user.

[0004] However, in the current method of generating ID photos based on artificial intelligence image generation technology, the trained model only learns the features of standard ID photos, such as the angle or clothing of standard ID photos, and is unable to retain the identity features of the person in the original photo well. Complex settings or post-processing are required to achieve a usable ID photo effect, and there is still the problem of inaccurate personal features in the generated ID photos. Summary of the invention

[0005] Based on this, it is necessary to provide a method and device for generating ID photos, an electronic device and a storage medium that can improve the accuracy of personal features in ID photos in response to the above technical problems.

[0006] In a first aspect, the present application provides a method for generating a certificate photo, comprising:

[0007] Acquire an original image and a standard ID photo, and extract original facial features corresponding to the original image and ID photo facial features corresponding to the standard ID photo respectively;

[0008] Acquire the ID photo description information, and generate the ID photo latent space according to the ID photo description information and the initial image latent space;

[0009] The original face features and the face features of the ID photo are fused to obtain face fusion features, the ID photo latent space is adjusted according to the face fusion features to obtain a first-stage image latent space, and the first-stage image latent space is feature decoded to obtain an initial ID photo;

[0010] The initial ID photo is subjected to facial redrawing processing using a first UNet model embedded with a face LoRA model to obtain a target ID photo corresponding to the original image.

[0011] In a second aspect, the present application also provides a device for generating a certificate photo, comprising:

[0012] A feature extraction module is used to obtain an original image and a standard ID photo, and respectively extract original facial features corresponding to the original image and ID photo facial features corresponding to the standard ID photo;

[0013] An ID photo latent space generation module, used to obtain ID photo description information, and generate an ID photo latent space according to the ID photo description information and the initial image latent space;

[0014] An initial ID photo acquisition module is used to fuse the original face features and the ID photo face features to obtain face fusion features, adjust the ID photo latent space according to the face fusion features to obtain a first-stage image latent space, and perform feature decoding on the first-stage image latent space to obtain an initial ID photo;

[0015] The target ID photo acquisition module is used to use the first UNet model embedded with the face LoRA model to perform facial redrawing processing on the initial ID photo to obtain a target ID photo corresponding to the original image.

[0016] In a third aspect, the present application further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the method steps of the first aspect when executing the computer program.

[0017] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the method steps of the first aspect.

[0018] In the above-mentioned ID photo generation method and device, electronic device and storage medium, by obtaining the original image and the standard ID photo, and extracting the original facial features corresponding to the original image and the ID photo facial features corresponding to the standard ID photo respectively, the original facial features and the ID photo facial features can be fused to obtain the face fusion features, so that the original facial features can be retained and the standard ID photo features of the image can be maintained in the process of generating the ID photo. Further, by obtaining the ID photo description information, and generating the ID photo latent space according to the ID photo description information and the initial image latent space, the ID photo latent space can be adjusted according to the face fusion features to obtain a first-stage image latent space, and by further decoding the first-stage image latent space, the initial ID photo can be obtained, so that the obtained initial ID photo can fuse the standard characteristics of the ID photo and the facial features of the original photo provided by the user, while maintaining the user's identity characteristics, and meet the standard requirements of the ID photo. Furthermore, by utilizing the first UNet model embedded with the face LoRA model to perform facial redrawing on the initial ID photo, a target ID photo corresponding to the original image is obtained, thereby achieving the purpose of making local fine adjustments to the ID photo and redrawing facial details, so that the generated ID photo meets the quality requirements of standard ID photos while further improving the accuracy of personal features in the corresponding ID photo. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0020] Figure 1 Schematic diagram of a process of generating a certificate photo in one embodiment;

[0021] Figure 2 A schematic diagram of the overall processing process of a method for generating a certificate photo in one embodiment;

[0022] Figure 3 It is a structural block diagram of a device for generating a certificate photo in one embodiment;

[0023] Figure 4 FIG. 4 is a diagram showing the internal structure of an electronic device in one embodiment. DETAILED DESCRIPTION

[0024] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0025] In an exemplary embodiment, Figure 1 As shown, a method for generating a certificate photo is provided, comprising the following steps S102 to S110. Among them:

[0026] Step S102, obtaining an original image and a standard ID photo, and extracting original facial features corresponding to the original image and ID photo facial features corresponding to the standard ID photo.

[0027] Specifically, the original image may be an image provided by the user including a face area. The standard ID photo is a user face image taken at a standard face shooting angle, which includes a complete and comprehensive user face area, and is provided with standard dress requirements, hairstyle requirements, and light and shadow requirements. After obtaining the original image, a pre-trained face feature extraction model (such as the face feature extraction model of InstantID technology, where InstantID is a solution based on a powerful diffusion model, specifically used for image personalization while ensuring identity retention and high fidelity) can be used to extract face portrait features from the face area in the original image to obtain the original face features corresponding to the original image. Similarly, after obtaining the standard ID photo, a facial control network model (such as a ControlNet-face model) can be used to extract the face key points of the standard ID photo, so as to obtain the ID photo face features corresponding to the standard ID photo according to each face key point.

[0028] Step S104, obtaining the ID photo description information, and generating the ID photo latent space according to the ID photo description information and the initial image latent space.

[0029] Specifically, the ID photo description information can be obtained in advance, and the ID photo description information is encoded and applied to the initial image latent space to generate the ID photo latent space. Specifically, the UNet model of stable dffusion (a potential diffusion model) can be used to initialize the empty initial image latent space.

[0030] Among them, the ID photo description information represents specific description information of the ID photo to be generated, such as the quality of the ID photo (such as masterpiece, best quality), shooting angle (such as facing the audience), shooting background (such as dark gray background), light and shadow during shooting (bright lighting conditions), user's image (such as fair skin, red lips), clothing (such as wearing a white business suit) and hairstyle (such as a tied hair that does not cover the ears and face).

[0031] Step S106, fusing the original face features and the face features of the ID photo to obtain face fusion features, adjusting the ID photo latent space according to the face fusion features to obtain a first-stage image latent space, and performing feature decoding on the first-stage image latent space to obtain an initial ID photo.

[0032] Specifically, the original facial features and the ID photo facial features can be fused to obtain facial fusion features, and the facial fusion features can be applied to the ID photo latent space. The image parameters of the ID photo latent space can be further adjusted to obtain a first-stage image latent space.

[0033] It can be understood that the first-stage image latent space includes facial feature parameters and face shape parameters used to characterize the user's identity, and also includes parameters such as the quality of the ID photo to be generated carried by the ID photo latent space, the image shooting angle, the image shooting background, the specific light and shadow parameters of the image shooting, the standard dress requirements, and the standard hairstyle requirements.

[0034] Furthermore, by performing feature decoding on the first-stage image latent space, an initial ID photo that combines specific features corresponding to the description information of the ID photo and facial features in the original image can be decoded.

[0035] Step S108, using the first UNet model embedded with the face LoRA model to perform facial redrawing processing on the initial ID photo to obtain a target ID photo corresponding to the original image.

[0036] Specifically, a face detection model (such as a yolo-face model) can be used to perform face recognition on the initial ID photo to obtain a face area, and a face redrawing component (such as a Detailer component) can be used to mask the non-face area in the initial ID photo. The masked initial ID photo is input into a first UNet model embedded with a face LoRA (Low-Rank Adaptation) model (the face LoRA model is a face LoRA model of the person in the original image) to redraw the face area in the initial ID photo. Finally, the redrawn face area is pasted on the face area of ​​the initial ID photo, and the face area boundary of the obtained ID photo is repaired to obtain a target ID photo, where the face in the target ID photo is the face of the person in the original image. The first UNet model can be a UNet model that conforms to Asian faces.

[0037] In an exemplary embodiment, the face LoRA model is trained in the following manner:

[0038] The face area in the original image is extracted, and image transformation processing is performed on the face area to obtain candidate face images at multiple different angles; a face data training set is constructed based on the candidate face images at multiple different angles; the face LoRA model is trained based on the face data training set to obtain a trained face LoRA model.

[0039] Specifically, the face area in the original image can be extracted, and the face area in the original image can be transformed, including rotation, scaling and other transformation processing, to obtain multiple candidate face images of different sizes and angles, and a face data training set for model training can be constructed based on multiple candidate face images of different sizes and angles. This method can expand the face data training set obtained by a single original image without a large amount of original training data, and can quickly and effectively perform model training by using an expansion method, and maintain the high quality of the generated image and the accuracy of personal features. .

[0040] Furthermore, the face LoRA model in the initial state is trained according to the face data training set to obtain a trained face LoRA model.

[0041] In an exemplary embodiment, training a face LoRA model according to a face data training set to obtain a trained face LoRA model includes:

[0042] 1) According to the face data training set, the face LoRA model is trained (it needs to be trained in the UNet model), and during the model training process, the intermediate models at different training steps are saved respectively until the model training loss meets the convergence condition and the training is stopped to obtain multiple intermediate models.

[0043] Specifically, the initial state face LoRA model can be trained according to the face data training set, and during the model training process, an intermediate model is saved after each certain number of training steps, that is, the intermediate models at different training steps are saved respectively, and the training is stopped when the model training loss meets the convergence conditions. For example, when the model training loss reaches the minimum loss value threshold (such as loss_threshold), or the model training loss decrease rate reaches the preset decrease rate threshold (such as lossrate_threshold), the training is stopped to obtain multiple intermediate models (including model_1, model_2, ..., model_n).

[0044] 2) For each candidate facial image in the multiple candidate facial images in the facial data training set, multiple images are generated according to the candidate facial image and multiple second UNet models, and multiple intermediate models are voted based on the facial similarity between the candidate facial image and the multiple images, wherein each of the multiple second UNet models is embedded in an intermediate model, and different second UNet models embed different intermediate models.

[0045] Specifically, for each candidate facial image in the multiple candidate facial images in the face data training set, multiple images are generated according to the candidate facial image and multiple second UNet models, that is, each candidate facial image in the multiple candidate facial images in the face data training set, such as candidate facial image 1, candidate facial image 2, ..., candidate facial image m included in the face data training set, is respectively input into multiple second UNet models to obtain images output by the multiple second UNet models for each candidate facial image.

[0046] Exemplarily, the candidate face image 1 is input into multiple second UNet models, and the facial similarities between the images output by each of the multiple second UNet models and the candidate face image 1 are compared, the second UNet model corresponding to the maximum facial similarity is determined, and the number of votes of the intermediate model embedded in the second UNet model is increased by 1. The processing process of candidate face image 2, ..., candidate face image m is the same as that of candidate face image 1, and will not be repeated here. In this way, the number of votes of each intermediate model can be obtained.

[0047] 3) Based on the number of votes for the intermediate models, determine the model weights corresponding to the multiple intermediate models.

[0048] Specifically, after the number of votes for each intermediate model is determined, the ratio of the number of votes for each intermediate model to m can be used as the model weight of the intermediate model.

[0049] 4) According to the model weights corresponding to each of the multiple intermediate models, multiple intermediate models are fused to obtain a trained face LoRA model.

[0050] Specifically, each intermediate model can be weighted and summed according to the model weight to fuse multiple intermediate models to obtain a trained face LoRA model.

[0051] Among them, after obtaining the target ID photo, the target ID photo can be further whitened, such as whitening processing including brightness adjustment processing, contrast adjustment processing, and clarity adjustment processing, so as to obtain a further optimized target ID photo.

[0052] In the above-mentioned ID photo generation method, by obtaining the original image and the standard ID photo, and extracting the original face features corresponding to the original image and the ID photo face features corresponding to the standard ID photo, respectively, the original face features and the ID photo face features can be fused to obtain face fusion features, so that the original face features can be retained while maintaining the standard ID photo features of the image during the ID photo generation process. Further, by obtaining the ID photo description information, and generating the ID photo latent space according to the ID photo description information and the initial image latent space, the ID photo latent space can be adjusted according to the face fusion features to obtain a first-stage image latent space, and by further decoding the first-stage image latent space, the initial ID photo can be obtained, so that the obtained initial ID photo can fuse the standard characteristics of the ID photo and the face features of the original photo provided by the user, while maintaining the user's identity characteristics, and meet the standard requirements of the ID photo. Furthermore, by utilizing the first UNet model embedded with the face LoRA model to perform facial redrawing on the initial ID photo, a target ID photo corresponding to the original image is obtained, thereby achieving the purpose of making local fine adjustments to the ID photo and redrawing facial details, so that the generated ID photo meets the quality requirements of standard ID photos while further improving the accuracy of personal features in the corresponding ID photo.

[0053] In an exemplary embodiment, Figure 2 , provides a schematic diagram of the overall processing process of a method for generating a certificate photo, referring to Figure 2 It can be seen that the overall processing process of the ID photo generation method specifically includes P1, feature extraction stage, P2, initial ID photo generation stage, P3, model training stage, P4, local optimization stage, and P5, optimization processing stage.

[0054] Among them, in P1, the feature extraction stage, the original facial features corresponding to the original image input by the user can be extracted according to the pre-trained facial feature extraction model, and the ID photo facial features corresponding to the standard ID photo can be extracted according to the facial control network model. In P2, the initial ID photo generation stage, the initial ID photo can be generated based on the original facial features and the ID photo facial features. In P3, the model training stage, the device can construct a facial data training set based on candidate facial images of multiple different angles, and train the initial state of the face LoRA model according to the facial data training set to obtain a trained face LoRA model. In P4, the local optimization stage of the face LoRA model, the first UNet model embedded with the trained face LoRA model can be used to locally optimize the initial ID photo to obtain the target ID photo. In P5, the beautification stage, the target ID photo can be whitened. Specifically:

[0055] P1, feature extraction stage:

[0056] 1) The original image input by the user can be obtained, the face area in the original image can be extracted, and the face features of the face area in the original image can be extracted according to a pre-trained face feature extraction model (such as a pre-trained face feature extraction model of InstantID) to obtain the original face features corresponding to the original image.

[0057] 2) A standard ID photo can be obtained, and the facial key points of the standard ID photo can be extracted according to a facial control network model (such as ControlNet-face), and the facial features of the ID photo corresponding to the standard ID photo can be obtained according to each facial key point.

[0058] P2, initial ID photo generation stage:

[0059] 3) The Unet model of the stable dffusion model can be used to initialize the empty initial image latent space.

[0060] 4) Obtain the description information of the ID photo, encode the description information of the ID photo and apply it to the initial image latent space to obtain the ID photo latent space.

[0061] 5) The original face features and the ID photo face features can be fused to obtain face fusion features, the ID photo latent space can be adjusted according to the face fusion features to obtain a first-stage image latent space, and the first-stage image latent space can be feature decoded to obtain the initial ID photo.

[0062] P3, model training phase:

[0063] 6) The face area in the original image can be extracted, and image transformation processing can be performed on the face area to obtain candidate face images at multiple different angles. A face data training set can be constructed based on the candidate face images at multiple different angles. The face LoRA model can be trained based on the face data training set to obtain a trained face LoRA model.

[0064] P4, local optimization stage of face LoRA model:

[0065] 7) The Detailer component can be used to perform face recognition on the initial ID photo, and the non-face area can be masked based on the recognition result. The face area in the masked image can be redrawn using the first UNet model embedded with the face LoRA model, and the redrawn face area can be pasted on the face area of ​​the initial ID photo, and the boundary of the face area can be repaired to obtain the target ID photo corresponding to the original image.

[0066] P5, beautification stage:

[0067] 8) The target ID photo can be whitened and optimized to obtain a further optimized target ID photo.

[0068] In an exemplary embodiment, Figure 3 As shown, a device for generating an ID photo is provided, comprising: a feature extraction module 302, an ID photo latent space generation module 304, an initial ID photo acquisition module 306, a two-stage image latent space acquisition module 308, and a target ID photo acquisition module 310, wherein:

[0069] The feature extraction module 302 is used to obtain the original image and the standard ID photo, and respectively extract the original face features corresponding to the original image and the ID photo face features corresponding to the standard ID photo;

[0070] The ID photo latent space generation module 304 is used to obtain the ID photo description information, and generate the ID photo latent space according to the ID photo description information and the initial image latent space;

[0071] The initial ID photo acquisition module 306 is used to fuse the original face features and the ID photo face features to obtain face fusion features, adjust the ID photo latent space according to the face fusion features to obtain a first-stage image latent space, and perform feature decoding on the first-stage image latent space to obtain the initial ID photo;

[0072] A two-stage image latent space acquisition module 308 is used to perform face segmentation on the initial ID photo to obtain an initial face image, and encode the initial face image into a two-stage image latent space using a first UNet model embedded with a face LoRA model;

[0073] The target ID photo obtaining module 310 is used to perform face redrawing processing on the second-stage image latent space to obtain a target ID photo corresponding to the original image.

[0074] Based on the above device embodiment, the device may further include:

[0075] An image transformation module is used to extract the face area in the original image, perform image transformation processing on the face area, and obtain candidate face images at multiple different angles;

[0076] A training set construction module is used to construct a face data training set based on candidate face images from multiple different angles;

[0077] The model training module is used to train the face LoRA model according to the face data training set to obtain the trained face LoRA model.

[0078] Based on the above device embodiment, the model training module can be specifically used for:

[0079] According to the face data training set, the face LoRA model is trained, and during the model training process, the intermediate models at different training steps are saved respectively, and the training is stopped when the model training loss meets the convergence condition, and multiple intermediate models are obtained;

[0080] For each candidate facial image in a plurality of candidate facial images in a facial data training set, multiple images are generated according to the candidate facial image and a plurality of second UNet models, and a plurality of intermediate models are voted on based on the facial similarity between the candidate facial image and the plurality of images, wherein each of the plurality of second UNet models is embedded with an intermediate model, and different second UNet models are embedded with different intermediate models;

[0081] Based on the number of votes of the intermediate models, the model weights corresponding to the multiple intermediate models are determined;

[0082] According to the model weights corresponding to each of the multiple intermediate models, multiple intermediate models are fused to obtain a trained face LoRA model.

[0083] The ID photo generation device provided in the embodiment of the present application has an implementation process that is consistent with the ID photo generation method provided in the embodiment of the present application, and the effect that can be achieved is also the same as the ID photo generation method provided in the embodiment of the present application, and will not be repeated here.

[0084] like Figure 4 As shown, in one embodiment, an electronic device is provided, including a memory 402 and a processor 404, wherein the memory 402 stores a computer program, and the processor 404 implements the steps in the above-mentioned method embodiments when executing the computer program.

[0085] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0086] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A method for generating a certificate photo, characterized in that: The method comprises: Acquire an original image and a standard ID photo, and extract original facial features corresponding to the original image and ID photo facial features corresponding to the standard ID photo respectively; Acquire the ID photo description information, and generate the ID photo latent space according to the ID photo description information and the initial image latent space; The original face features and the face features of the ID photo are fused to obtain face fusion features, the ID photo latent space is adjusted according to the face fusion features to obtain a first-stage image latent space, and the first-stage image latent space is feature decoded to obtain an initial ID photo; The initial ID photo is subjected to facial redrawing processing using a first UNet model embedded with a face LoRA model to obtain a target ID photo corresponding to the original image.

2. The method according to claim 1, characterized in that The face LoRA model is trained in the following way: Extracting a human face region from the original image, performing image transformation processing on the human face region, and obtaining a plurality of candidate human face images at different angles; Constructing a face data training set based on the multiple candidate face images at different angles; According to the face data training set, the face LoRA model is trained to obtain a trained face LoRA model.

3. The method according to claim 2, characterized in that The step of training the face LoRA model according to the face data training set to obtain the trained face LoRA model includes: According to the face data training set, the face LoRA model is trained, and during the model training process, intermediate models at different training steps are saved respectively, and the training is stopped when the model training loss meets the convergence condition, so as to obtain multiple intermediate models; For each candidate facial image in the plurality of candidate facial images in the facial data training set, multiple images are generated according to the candidate facial image and the plurality of second UNet models, and the plurality of intermediate models are voted on based on the facial similarity between the candidate facial image and the plurality of images, wherein each of the plurality of second UNet models is embedded with an intermediate model, and different second UNet models are embedded with different intermediate models; Determining model weights corresponding to each of the plurality of intermediate models based on the number of votes of the intermediate models; According to the model weights corresponding to the multiple intermediate models, the multiple intermediate models are fused to obtain a trained face LoRA model.

4. The method according to claim 3, characterized in that The step of voting on the multiple intermediate models based on the facial similarities between the candidate human face image and the multiple images includes: The number of votes of the intermediate model corresponding to the image with the highest face similarity to the candidate face image among the multiple images is increased by 1.

5. The method according to any one of claims 1 to 4, characterized in that: Also includes: The target ID photo is whitened.

6. A device for generating a certificate photo, characterized in that: The device comprises: A feature extraction module is used to obtain an original image and a standard ID photo, and respectively extract original facial features corresponding to the original image and ID photo facial features corresponding to the standard ID photo; An ID photo latent space generation module, used to obtain ID photo description information, and generate an ID photo latent space according to the ID photo description information and the initial image latent space; An initial ID photo acquisition module is used to fuse the original face features and the ID photo face features to obtain face fusion features, adjust the ID photo latent space according to the face fusion features to obtain a first-stage image latent space, and perform feature decoding on the first-stage image latent space to obtain an initial ID photo; The target ID photo acquisition module is used to use the first UNet model embedded with the face LoRA model to perform facial redrawing processing on the initial ID photo to obtain a target ID photo corresponding to the original image.

7. The device according to claim 6, characterized in that Also includes: An image transformation module is used to extract the face area in the original image, perform image transformation processing on the face area, and obtain multiple candidate face images at different angles; A training set construction module, used to construct a face data training set based on the candidate face images at different angles; The model training module is used to train the face LoRA model according to the face data training set to obtain a trained face LoRA model.

8. The device according to claim 7, characterized in that The model training module is specifically used for: According to the face data training set, the face LoRA model is trained, and during the model training process, intermediate models at different training steps are saved respectively, and the training is stopped when the model training loss meets the convergence condition, so as to obtain multiple intermediate models; For each candidate facial image in the plurality of candidate facial images in the facial data training set, multiple images are generated according to the candidate facial image and the plurality of second UNet models, and the plurality of intermediate models are voted on based on the facial similarity between the candidate facial image and the plurality of images, wherein each of the plurality of second UNet models is embedded with an intermediate model, and different second UNet models are embedded with different intermediate models; Determining model weights corresponding to each of the plurality of intermediate models based on the number of votes of the intermediate models; According to the model weights corresponding to the multiple intermediate models, the multiple intermediate models are fused to obtain a trained face LoRA model.

9. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.