A method and device for generating an ID photo, a terminal device and a storage medium

By combining the salient object detection, feature extraction, and image editing modules of the image generation model with linear and nonlinear parameter adjustments, the problem of poor ID photo processing results is solved, generating realistic ID photos.

CN117114972BActive Publication Date: 2026-01-23DONGGUAN UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310984148.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-04
Publication Date
2026-01-23
Estimated Expiration
2043-08-04

AI Technical Summary

Technical Problem

Existing technologies struggle to handle complex scenes and non-linear changes in ID photos, resulting in poor processing quality.

Method used

Using an image generation model, through salient object detection, feature extraction, and image editing modules, combined with linear and nonlinear parameter adjustments, realistic ID photos are generated.

Benefits of technology

It achieves adaptability to complex scenes and nonlinear changes, generates realistic ID photos, and improves processing results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117114972B_ABST
    Figure CN117114972B_ABST
Patent Text Reader

Abstract

The application discloses a kind of certificate photo generation method, device, terminal equipment and storage medium, the method includes: obtaining initial certificate photo, background adjustment parameter for adjusting certificate photo background and several face adjustment parameters for adjusting face image;Wherein, face adjustment parameter includes following any one or its combination: for linear adjustment parameter of face image is adjusted to face image and for the nonlinear adjustment parameter of face image is adjusted;Initial certificate photo, background adjustment parameter and face adjustment parameter are input into image generation model, to make the image generation model according to face adjustment parameter and background adjustment parameter adjusts the initial certificate photo, generates final certificate photo.Compared with prior art, the application can process the optimization adjustment of the nonlinear change of the deformation of face or some face attributes, so that the certificate photo restores the real state of face more, improves the processing effect of certificate photo.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of image processing, and in particular to a method and device for generating an ID photo, a terminal device and a storage medium. BACKGROUND

[0002] An ID photo is an important document for proving the identity of a person and other legal matters, and therefore needs to meet certain specifications and requirements, such as the face being clearly visible, no occlusion, and uniform light, etc. However, in real life, due to environmental, equipment, and shooting technology reasons, it is often difficult to meet these requirements, resulting in uneven quality of ID photos and affecting their use effect. Existing technologies often use image processing techniques to denoise, correct light, detect and align faces, and crop ID photos based on traditional image processing algorithms to improve the quality and aesthetics of ID photos. However, they can only perform simple processing on images and are difficult to handle complex scenes and nonlinear changes. For example, for non-standard shooting poses, different light conditions, or different ID photo specifications, the processing effect of traditional image processing algorithms will be unsatisfactory. Traditional image processing algorithms often require manual setting of parameters such as filters and brightness adjustment, which requires experienced professionals or trial and error to achieve, and are difficult to handle face deformations and nonlinear changes, such as large rotation angles, expression changes, or age of the face in the ID photo. Traditional image processing algorithms lack adaptability and processing methods for complex scenes and nonlinear changes, making the ID photo less realistic and restored, resulting in poor final processing effect of the ID photo. SUMMARY

[0003] The embodiments of the present application provide a method and device for generating an ID photo, a terminal device and a storage medium, which effectively solve the problem of poor adaptability and processing methods for complex scenes and nonlinear changes in the prior art, making the ID photo less realistic and restored, and resulting in poor final processing effect of the ID photo.

[0004] An embodiment of the present application provides a method for generating an ID photo, comprising:

[0005] obtaining an initial ID photo, background adjustment parameters for adjusting the background of the ID photo, and a plurality of face adjustment parameters for adjusting a face image; wherein the face adjustment parameters include any one or a combination of the following: linear adjustment parameters for linearly adjusting the face image, and nonlinear adjustment parameters for nonlinearly adjusting the face image;

[0006] The initial ID photo, background adjustment parameters, and face adjustment parameters are input into the image generation model so that the image generation model adjusts the initial ID photo according to the face adjustment parameters and background adjustment parameters to generate the final ID photo.

[0007] The image generation model generates the following:

[0008] The image generation model is generated by training a model with an unadjusted ID photo, the corresponding face adjustment parameters, and the background adjustment parameters as inputs, and the adjusted ID photo as the output.

[0009] Preferably, the image generation model includes: a salient object detection module, a feature extraction module, and an image editing module;

[0010] The salient object detection module is used to separate the portrait and background in the initial ID photo, and then adjust the background of the initial ID photo according to the background adjustment parameters to generate the adjusted background;

[0011] The feature extraction module is used to extract feature vectors from the portrait and send the feature vectors to the image editing module;

[0012] The image editing module is used to segment the facial attributes of the portrait based on the feature vector and generate several facial attributes;

[0013] The corresponding facial attributes are adjusted according to the facial adjustment parameters to generate the adjusted portrait;

[0014] Based on the adjusted background and the adjusted portrait, the final ID photo is generated.

[0015] Preferably, the salient object detection module is used to separate the human image from the initial ID photo, including:

[0016] The salient object detection module is used to identify the human image in the initial ID photo through a salient object detection algorithm, and then separate the human image from the initial ID photo.

[0017] Preferably, when adjusting the corresponding facial attributes according to the facial adjustment parameters, if the facial adjustment parameters are non-linear adjustment parameters, the image editing module extracts the non-linear path corresponding to the feature vector through the built-in residual MLP module, and adjusts the facial attributes according to the non-linear path and the corresponding non-linear adjustment parameters.

[0018] Preferably, the step of training the model to generate the image generation model, using an unadjusted ID photo, the corresponding face adjustment parameters, and background adjustment parameters as inputs, and an adjusted ID photo as output, includes:

[0019] The unadjusted ID photo, the face adjustment parameters corresponding to the unadjusted ID photo, and the background adjustment parameters are used as inputs to the generative adversarial network (GAN), and the adjusted ID photo is used as the output of the GAN. The generator and discriminator in the GAN are trained iteratively and alternately.

[0020] When the convergence of the GAN neural network is detected, the generator after training is used as the image generation model.

[0021] Based on the above method embodiments, the present invention provides corresponding apparatus embodiments.

[0022] An embodiment of the present invention provides an ID photo generation device, including: a data acquisition module and an ID photo adjustment module;

[0023] The data acquisition module is used to acquire an initial ID photo, background adjustment parameters for adjusting the background of the ID photo, and several face adjustment parameters for adjusting the face image; wherein, the face adjustment parameters include any one or a combination of the following: linear adjustment parameters for linear adjustment of the face image and nonlinear adjustment parameters for nonlinear adjustment of the face image;

[0024] The ID photo adjustment module is used to input the initial ID photo, background adjustment parameters, and face adjustment parameters into the image generation model, so that the image generation model adjusts the initial ID photo according to the face adjustment parameters and background adjustment parameters to generate the final ID photo.

[0025] The image generation model generates the following:

[0026] The image generation model is generated by training a model with an unadjusted ID photo, the corresponding face adjustment parameters, and the background adjustment parameters as inputs, and the adjusted ID photo as the output.

[0027] Based on the above method embodiments, the present invention provides corresponding terminal device embodiments.

[0028] Another embodiment of the present invention provides a terminal device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements a method for generating an ID photo as described in the above-described embodiment of the invention.

[0029] Based on the above method embodiments, the present invention provides corresponding storage medium embodiments.

[0030] Another embodiment of the present invention provides a storage medium, the computer-readable storage medium including a stored computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform a method for generating an ID photo as described in the above-described embodiment of the invention.

[0031] The following benefits can be obtained by implementing the present invention:

[0032] This invention provides a method, apparatus, terminal device, and storage medium for generating ID photos. The method includes: acquiring an initial ID photo, background adjustment parameters for adjusting the background of the ID photo, and several face adjustment parameters for adjusting a face image; wherein the face adjustment parameters include any one or a combination of the following: linear adjustment parameters for linearly adjusting the face image and nonlinear adjustment parameters for nonlinearly adjusting the face image; inputting the initial ID photo, background adjustment parameters, and face adjustment parameters into an image generation model, so that the image generation model adjusts the initial ID photo according to the face adjustment parameters and background adjustment parameters to generate a final ID photo. Compared with existing technologies, this invention can adjust the initial input ID photo based on a trained image generation model, user-defined background adjustment parameters, and several face adjustment parameters for adjusting facial images. During the adjustment process, it can adjust photos with non-linear changes in the ID photo based on non-linear adjustment parameters for non-linear adjustment of facial images, thereby optimizing or adjusting faces with non-linear changes. In other words, this invention can handle the optimization and adjustment of facial deformation or non-linear changes in some facial attributes, making the ID photo more realistic and improving the processing effect of the ID photo. Attached Figure Description

[0033] Figure 1 This is a flowchart illustrating a method for generating ID photos according to an embodiment of the present invention.

[0034] Figure 2 This is a schematic diagram of the adjustment of ID photo by various modules in the image generation model provided in an embodiment of the present invention.

[0035] Figure 3 This is a schematic diagram of human image separation provided by a salient object detection module according to an embodiment of the present invention.

[0036] Figure 4 This is a schematic diagram of a feature extraction module extracting feature vectors according to an embodiment of the present invention.

[0037] Figure 5This is a schematic diagram of an image editing module adjusting facial attributes according to an embodiment of the present invention.

[0038] Figure 6 This is a schematic diagram of adjusting feature vectors based on a residual MLP module according to an embodiment of the present invention.

[0039] Figure 7 This is a schematic diagram of the structure of an ID photo generation device provided in an embodiment of the present invention. Detailed Implementation

[0040] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0041] like Figure 1 The diagram shown is a flowchart illustrating a method for generating ID photos according to an embodiment of the present invention. The method includes:

[0042] Step S1: Obtain the initial ID photo, background adjustment parameters for adjusting the background of the ID photo, and several face adjustment parameters for adjusting the face image; wherein, the face adjustment parameters include any one or a combination of the following: linear adjustment parameters for linear adjustment of the face image and nonlinear adjustment parameters for nonlinear adjustment of the face image;

[0043] Step S2: Input the initial ID photo, background adjustment parameters, and face adjustment parameters into the image generation model, so that the image generation model adjusts the initial ID photo according to the face adjustment parameters and background adjustment parameters to generate the final ID photo;

[0044] The image generation model generates the following:

[0045] The image generation model is generated by training a model with an unadjusted ID photo, the corresponding face adjustment parameters, and the background adjustment parameters as inputs, and the adjusted ID photo as the output.

[0046] For step S1, in a preferred embodiment, the linear adjustment parameters used to linearly adjust the face image are typically used to adjust the visual effects of the image, such as image contrast, brightness, translation, and scaling, which are operations that are directly adjusted based on the adjustment data.

[0047] Non-linear adjustment parameters used for non-linear adjustments to facial images typically involve adjusting for wrinkles or skin brightness when adjusting the age of a face, as well as adjusting for facial deformation. These adjustments involve data that do not have a specific corresponding relationship, i.e., adjusting the image non-linearly based on data that does not have a direct correlation.

[0048] In a preferred embodiment, for step S2, if traditional image processing algorithms are directly used to process ID photos based on user-set linear or non-linear adjustment parameters, experienced professionals are required to know how to implement non-linear adjustments. Therefore, these traditional algorithms have poor adjustability, making it difficult to meet users' personalized needs and handle facial deformation and non-linear changes. For example, when the face in the ID photo has a large rotation angle, expression changes, or occlusion, the processing effect of traditional image processing algorithms will be affected.

[0049] The present invention inputs an initial ID photo, background adjustment parameters, and face adjustment parameters into an image generation model, so that the image generation model adjusts the initial ID photo according to the face adjustment parameters and background adjustment parameters, thereby generating a final adjusted ID photo.

[0050] like Figure 2 As shown, the image generation model includes: a salient object detection module, a feature extraction module, and an image editing module;

[0051] The salient object detection module is used to separate the portrait and background in the initial ID photo, and then adjust the background of the initial ID photo according to the background adjustment parameters to generate the adjusted background;

[0052] The feature extraction module is used to extract feature vectors from the portrait and send the feature vectors to the image editing module;

[0053] The image editing module is used to segment the facial attributes of the portrait based on the feature vector and generate several facial attributes;

[0054] The corresponding facial attributes are adjusted according to the facial adjustment parameters to generate the adjusted portrait;

[0055] Based on the adjusted background and the adjusted portrait, the final ID photo is generated.

[0056] In a preferred embodiment, the architecture diagram of the salient object detection module is as follows: Figure 3As shown, the salient object detection module is used to identify and segment the human figure in the initial ID photo using U2-Net as the salient object detection algorithm. Compared to other salient object detection algorithms, the U2-Net algorithm is more efficient, has more accurate edge segmentation, and can automatically identify and segment the most salient object in an image and mark it. The ID photo to be processed is then transmitted to the salient object detection module, which separates the person from the background. Subsequently, the background of the initial ID photo is adjusted according to background adjustment parameters to generate an adjusted background.

[0057] A schematic diagram of the feature extraction module extracting feature vectors based on human images is shown below. Figure 4 As shown, features can be extracted from the portrait output by the salient object detection module, enabling subsequent use of these extracted features in conjunction with a depth generation model to accurately reconstruct the portrait's details. Illustratively, the feature extraction module is StylGAN, and the fitting model used is VGG.

[0058] The diagram illustrating how the image editing module adjusts facial attributes is shown below. Figure 5 As shown, the image editing module employs a local scoring mechanism to improve the stability of face editing and adds a residual MLP module to achieve non-linear face attribute editing. Specifically, the local scoring mechanism uses a face attribute segmentation model to segment the face attributes to be edited, thus avoiding interference between attributes.

[0059] The residual MLP module can effectively find a non-linear path among the facial features learned in the feature extraction module, thereby enabling continuous editing of facial attributes based on the non-linear path and corresponding non-linear adjustment parameters, such as adjusting the opening degree of the mouth and eyes, and so on. Figure 5 The image shows adjustments made to the facial features, resulting in better ID photo processing.

[0060] Tuning details for the residual MLP module are as follows: Figure 6 As shown, ω and ω+ represent the feature vectors before and after editing, respectively:

[0061] Specifically, for binary facial features, such as mouth opening and closing, and eye opening and closing, different direction vectors need to be trained. For non-linear, continuously editable facial features, such as the degree of a smile and the size of the mouth opening, different residual MLP network parameters need to be trained. Based on these parameters, different attributes can be adjusted for different situations to meet user needs. Furthermore, it can handle facial deformation or non-linear changes in facial attributes, optimizing and adjusting them to make ID photos more realistic and improving the processing quality.

[0062] In a preferred embodiment, the unadjusted ID photo, the face adjustment parameters corresponding to the unadjusted ID photo, and the background adjustment parameters are used as inputs to the generative adversarial network (GAN), and the adjusted ID photo is used as the output of the GAN. The generator and discriminator in the GAN are trained iteratively and alternately.

[0063] When the convergence of the GAN neural network is detected, the generator after training is used as the image generation model.

[0064] Specifically, the unadjusted ID photo, the corresponding sample face adjustment parameters, and the sample background adjustment parameters are input into the generative adversarial network (GAN), so that the generator in the GAN adjusts the unadjusted ID photo according to the sample face adjustment parameters and the sample background adjustment parameters to generate the final sample ID photo.

[0065] The discriminator in the generative adversarial network compares the final sample ID photo with the adjusted ID photo. When it determines that the final sample ID photo is inconsistent with the adjusted ID photo, it causes the generator to repeat the following ID photo adjustment training operation until the GAN neural network is detected to have converged. The trained generator is then used as the image generation model.

[0066] The generator separates the portrait and background in the unadjusted ID photo to generate a sample portrait; then, it adjusts the background of the unadjusted ID photo according to the sample background adjustment parameters to generate an adjusted sample background.

[0067] The generator extracts the sample feature vector from the sample portrait, segments the sample face attributes of the sample portrait according to the sample feature vector, generates several sample face attributes, adjusts the corresponding sample face attributes according to the sample face adjustment parameters, and generates an adjusted sample portrait; and generates the final sample ID photo based on the adjusted sample background and the adjusted sample portrait.

[0068] Therefore, once the image generation model is trained, it can support adjustments for facial deformation and nonlinear changes. The image generation model of this invention can handle facial deformation and nonlinear changes, such as rotation, occlusion, and expression changes, thereby meeting the personalized needs of users.

[0069] This invention employs a deep generative model-based approach. By training a generative model, it enables the editing and generation of ID photos. Compared to traditional image processing algorithms, it can generate more realistic ID photos and automatically learn and simulate various details in the image, thus providing higher-quality editing results. By introducing modeling of different deformations into the generative model, this invention can achieve higher-quality personalized customization. Users can input adjustment parameters according to their needs, and based on these linear or non-linear adjustment parameters, the invention can fulfill their linear or non-linear adjustment requirements for the ID photo.

[0070] This invention, based on a deep generative model, can better handle complex scenes and non-linear changes, while automatically learning and simulating various details in images, thus providing higher-quality editing results. Furthermore, the deep generative model-based method enables automated editing and generation without manual intervention, thereby improving efficiency and reducing costs.

[0071] like Figure 7 As shown, based on the embodiments of the various methods for generating ID photos described above, the present invention provides corresponding embodiments of the apparatus.

[0072] An embodiment of the present invention provides an ID photo generation device, including: a data acquisition module and an ID photo adjustment module;

[0073] The data acquisition module is used to acquire an initial ID photo, background adjustment parameters for adjusting the background of the ID photo, and several face adjustment parameters for adjusting the face image; wherein, the face adjustment parameters include any one or a combination of the following: linear adjustment parameters for linear adjustment of the face image and nonlinear adjustment parameters for nonlinear adjustment of the face image;

[0074] The ID photo adjustment module is used to input the initial ID photo, background adjustment parameters, and face adjustment parameters into the image generation model, so that the image generation model adjusts the initial ID photo according to the face adjustment parameters and background adjustment parameters to generate the final ID photo.

[0075] The image generation model generates the following:

[0076] The image generation model is generated by training a model with an unadjusted ID photo, the corresponding face adjustment parameters, and the background adjustment parameters as inputs, and the adjusted ID photo as the output.

[0077] It should be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the device embodiments provided by this invention, the connection relationships between modules indicate that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort.

[0078] Those skilled in the art will clearly understand that, for convenience and simplicity, the specific working process of the device described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0079] Based on the above embodiments of various methods for generating ID photos, the present invention provides corresponding embodiments of terminal devices.

[0080] One embodiment of the present invention provides a terminal device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements a method for generating an ID photo as described in any embodiment of the present invention.

[0081] The terminal device may be a desktop computer, laptop, handheld computer, or cloud server, etc. The terminal device may include, but is not limited to, a processor and a memory.

[0082] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor. The processor is the control center of the terminal device, connecting all parts of the terminal device via various interfaces and lines.

[0083] The memory can be used to store the computer program. The processor implements various functions of the terminal device by running or executing the computer program stored in the memory and calling data stored in the memory. The memory may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function, etc.; the data storage area may store data created based on the use of the mobile phone, etc. In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, RAM, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.

[0084] Based on the above embodiments of various methods for generating ID photos, the present invention provides corresponding embodiments of storage media.

[0085] One embodiment of the present invention provides a storage medium including a stored computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to execute a method for generating an ID photo as described in any embodiment of the present invention.

[0086] The storage medium is a computer-readable storage medium, and the computer program is stored in the computer-readable storage medium. When executed by a processor, the computer program can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable file, or some intermediate form. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electrical carrier signals and telecommunication signals.

[0087] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications are also considered to be within the scope of protection of the present invention.

Claims

1. A method for generating ID photos, characterized in that, include: The system obtains an initial ID photo, background adjustment parameters for adjusting the background of the ID photo, and several face adjustment parameters for adjusting the face image; wherein the face adjustment parameters include any one or a combination of the following: linear adjustment parameters for linear adjustment of the face image and nonlinear adjustment parameters for nonlinear adjustment of the face image; The initial ID photo, background adjustment parameters, and face adjustment parameters are input into the image generation model so that the image generation model adjusts the initial ID photo according to the face adjustment parameters and background adjustment parameters to generate the final ID photo. The image generation model generates the following: Using an unadjusted ID photo, the corresponding face adjustment parameters, and background adjustment parameters as inputs, and an adjusted ID photo as output, the model is trained to generate the image generation model. The image generation model includes: a salient object detection module, a feature extraction module, and an image editing module; The salient object detection module is used to identify and segment the human image in the initial ID photo using U2-Net as the salient object detection algorithm, separate the human image and background in the initial ID photo, and then adjust the background of the initial ID photo according to the background adjustment parameters to generate the adjusted background. The feature extraction module is used to extract feature vectors from the portrait and send the feature vectors to the image editing module; wherein, the feature extraction module is StylGAN, and the fitting model used is VGG; The image editing module is used to segment the facial attributes of the portrait according to the feature vector to generate several facial attributes; adjust the corresponding facial attributes according to the facial adjustment parameters to generate an adjusted portrait; and generate a final ID photo based on the adjusted background and the adjusted portrait. The image editing module employs a local scoring mechanism to improve the stability of face editing and adds a residual MLP module to achieve non-linear face attribute editing.

2. The method for generating ID photos as described in claim 1, characterized in that, The salient object detection module is used to separate the human image from the initial ID photo, including: The salient object detection module is used to identify the human image in the initial ID photo through a salient object detection algorithm, and then separate the human image from the initial ID photo.

3. The method for generating ID photos as described in claim 1, characterized in that, When adjusting the corresponding facial attributes according to the facial adjustment parameters, if the facial adjustment parameters are non-linear adjustment parameters, the image editing module extracts the non-linear path corresponding to the feature vector through the built-in residual MLP module, and adjusts the facial attributes according to the non-linear path and the corresponding non-linear adjustment parameters.

4. The method for generating ID photos as described in claim 1, characterized in that, The process of training a model to generate the image generation model, using an unadjusted ID photo, corresponding face adjustment parameters, and background adjustment parameters as input, and an adjusted ID photo as output, includes: The unadjusted ID photo, the face adjustment parameters corresponding to the unadjusted ID photo, and the background adjustment parameters are used as inputs to the generative adversarial network (GAN), and the adjusted ID photo is used as the output of the GAN. The generator and discriminator in the GAN are trained iteratively and alternately. When the convergence of the GAN neural network is detected, the generator after training is used as the image generation model.

5. A device for generating ID photos, characterized in that, include: Data acquisition module and ID photo adjustment module; The data acquisition module is used to acquire an initial ID photo, background adjustment parameters for adjusting the background of the ID photo, and several face adjustment parameters for adjusting the face image; wherein, the face adjustment parameters include any one or a combination of the following: linear adjustment parameters for linear adjustment of the face image and nonlinear adjustment parameters for nonlinear adjustment of the face image; The ID photo adjustment module is used to input the initial ID photo, background adjustment parameters, and face adjustment parameters into the image generation model, so that the image generation model adjusts the initial ID photo according to the face adjustment parameters and background adjustment parameters to generate the final ID photo. The image generation model generates the following: Using an unadjusted ID photo, the corresponding face adjustment parameters, and background adjustment parameters as inputs, and an adjusted ID photo as output, the model is trained to generate the image generation model. The image generation model includes: a salient object detection module, a feature extraction module, and an image editing module; The salient object detection module is used to identify and segment the human image in the initial ID photo using U2-Net as the salient object detection algorithm, separate the human image and background in the initial ID photo, and then adjust the background of the initial ID photo according to the background adjustment parameters to generate the adjusted background. The feature extraction module is used to extract feature vectors from the portrait and send the feature vectors to the image editing module; wherein, the feature extraction module is StylGAN, and the fitting model used is VGG; The image editing module is used to segment the facial attributes of the portrait according to the feature vector to generate several facial attributes; adjust the corresponding facial attributes according to the facial adjustment parameters to generate an adjusted portrait; and generate a final ID photo based on the adjusted background and the adjusted portrait. The image editing module employs a local scoring mechanism to improve the stability of face editing and adds a residual MLP module to achieve non-linear face attribute editing.

6. A terminal device, characterized in that, The device includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor executes the computer program to implement a method for generating an ID photo as described in any one of claims 1 to 4.

7. A computer storage medium, characterized in that, The storage medium includes a stored computer program, wherein, when the computer program is executed, it controls the device where the storage medium is located to perform a method for generating an ID photo as described in any one of claims 1 to 4.