Face editing method, device, equipment and readable storage medium
Through deep learning, high-dimensional vector editing is carried out using encoder and SVM, and combined with pre-training segmentation network, the high-definition natural problem of multi-type face editing at high resolution is solved, achieving high decoupling and natural effects.
Patent Information
- Application Number
- CN202211109590.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-13
- Publication Date
- 2025-08-29
- Estimated Expiration
- 2042-09-13
AI Technical Summary
Existing face editing algorithms are difficult to generate high-definition, natural and harmonious multi-type face editing effects at high resolution, and there is a problem of attribute coupling.
Using deep learning methods, by constructing face models, including mapping networks and generator networks, using encoders to encode face information into high-dimensional vectors, combining SVM for linear hyperplanar classification, obtaining direction vectors for editing, and using pre-trained segmentation network to extract masks of editing areas, and finally fusion at the high-dimensional feature level.
It realizes high-definition and natural multi-type face editing, with high decoupling, and only edits the required areas, avoiding attribute coupling and unnatural transition edges.
Smart Images

Figure CN115564852B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a face editing method, apparatus, device and readable storage medium. Background Art
[0002] In the field of image generation, face editing is a direction that is difficult for traditional image algorithms to handle and has very great application value. Especially with the increasing resolution of images today, the resolution requirements for editing algorithms are getting higher and higher. Editing facial features such as facial features and hair to obtain a high-definition, natural and harmonious effect has always been one of the difficulties in image generation.
[0003] Existing face editing algorithms can be basically divided into two categories. The first category has good generation effects but can only handle a certain type of editing. The second category can handle the effects of multiple types of editing but the generated effects are poor in clarity and unnatural. Summary of the Invention
[0004] The purpose of the present invention is to provide a face editing method, device, equipment and readable storage medium to improve the above problems. To achieve the above objectives, the technical solutions adopted by the present invention are as follows:
[0005] In a first aspect, the present application provides a face editing method, comprising:
[0006] Acquire facial information to be edited and construct a facial model, wherein the facial model includes a mapping network and a generator network;
[0007] Encoding the face information to be edited according to a preset encoder to obtain a high-dimensional vector, inputting the high-dimensional vector into the face model for calculation to obtain the updated high-dimensional vector;
[0008] Based on SVM, a linear hyperplane classification calculation is performed on the high-dimensional vector of the first attribute to obtain a direction vector, which is then used to edit the high-dimensional vector to obtain high-dimensional features and a mask of the edited area.
[0009] The face information to be edited, the high-dimensional features and the mask of the editing area are fused to obtain a final editing image.
[0010] Preferably, encoding the face information to be edited to obtain a high-dimensional vector according to a preset encoder includes:
[0011] Constructing a face model, the face model includes a generator, the generator includes a first network and a second network, the first network maps random noise obeying a Gaussian distribution to a high-dimensional vector obeying the distribution of a face dataset; the second network generates the high-dimensional vector output by the first network through a convolutional neural network algorithm and an upsampling method;
[0012] Connecting the preset encoder to the trained second network;
[0013] Encoding the image of the facial information to be edited by the encoder to obtain the high-dimensional vector;
[0014] The high-dimensional vector is input into the generator again, the image of the facial information is reconstructed and calculated, and the loss is obtained to update the weight of the encoder until convergence.
[0015] Preferably, the SVM-based linear hyperplane classification calculation is performed on the high-dimensional vector of the first attribute to obtain a direction vector, and the direction vector is used to edit the high-dimensional vector to obtain a high-dimensional feature and an edited area mask, which includes:
[0016] Obtaining a randomly sampled image from the generator;
[0017] Pairing the image with the high-dimensional vector, and performing binary classification on the attributes in the image to obtain a new high-dimensional vector;
[0018] Based on SVM, a linear hyperplane classification calculation is performed on the new high-dimensional vector to obtain the direction vector of the corresponding attribute;
[0019] Editing the high-dimensional vector using the direction vector, and inputting the edited high-dimensional vector into the generator to obtain an edited image;
[0020] The edited image is input into a pre-trained segmentation network to extract the mask of the edited area.
[0021] Preferably, the face information to be edited, the high-dimensional features and the mask of the editing area are fused to obtain a final editing image, which includes:
[0022] Calling first information, where the first information includes the high-dimensional features and edited high-dimensional features corresponding to the face information to be edited in the encoder and the generator;
[0023] calling second information, where the second information includes the mask of the editing area;
[0024] The mask is adjusted to the same size as the high-dimensional feature by using bilinear interpolation, and the high-dimensional feature and the mask are fused using an alpha fusion method.
[0025] In a second aspect, the present application further provides a face editing device, comprising:
[0026] Acquisition module: used to obtain the face information to be edited and build a face model, which includes a mapping network and a generator network;
[0027] Encoding module: used for encoding the face information to be edited according to a preset encoder to obtain a high-dimensional vector, inputting the high-dimensional vector into the face model for calculation to obtain the updated high-dimensional vector;
[0028] A calculation module is used to perform a linear hyperplane classification calculation on the high-dimensional vector of the first attribute based on the SVM to obtain a direction vector, and use the direction vector to edit the high-dimensional vector to obtain a high-dimensional feature and a mask of the editing area;
[0029] Fusion module: used to fuse the face information to be edited, the high-dimensional features and the mask of the editing area to obtain the final editing image.
[0030] Preferably, the encoding module previously includes:
[0031] A construction unit is configured to construct a face model, the face model comprising a generator, the generator comprising a first network and a second network, the first network mapping random noise that obeys a Gaussian distribution to a high-dimensional vector that obeys the distribution of a face dataset; the second network generating the high-dimensional vector output by the first network through a convolutional neural network algorithm and an upsampling method;
[0032] An access unit is configured to connect the preset encoder to the trained second network;
[0033] Encoding unit: configured to encode the image of the face information to be edited by the encoder to obtain the high-dimensional vector;
[0034] Input unit: used to input the high-dimensional vector into the generator again, reconstruct and calculate the image of the facial information, and obtain the loss to update the weight of the encoder until convergence.
[0035] Preferably, the calculation module includes:
[0036] Acquisition unit: used to obtain the randomly sampled pictures of the generator;
[0037] A pairing unit is used to pair the image with the high-dimensional vector and perform binary classification on the attributes in the image to obtain a new high-dimensional vector;
[0038] A calculation unit is configured to perform a linear hyperplane classification calculation on the new high-dimensional vector based on SVM to obtain a direction vector of the corresponding attribute;
[0039] An editing unit: configured to edit the high-dimensional vector using the direction vector, and input the edited high-dimensional vector into the generator to obtain an edited image;
[0040] Extraction unit: used to input the edited image into a pre-trained segmentation network to extract the mask of the edited area.
[0041] Preferably, the fusion module includes:
[0042] A first calling unit: configured to call first information, wherein the first information includes the high-dimensional features and edited high-dimensional features corresponding to the face information to be edited in the encoder and the generator;
[0043] A second calling unit is used to call second information, where the second information includes the mask of the editing area;
[0044] Interpolation unit: used to adjust the mask to the same size as the high-dimensional feature using bilinear interpolation, and fuse the high-dimensional feature and the mask using alpha fusion method.
[0045] In a third aspect, the present application further provides a face editing device, comprising:
[0046] Memory for storing computer programs;
[0047] A processor is configured to implement the steps of the face editing method when executing the computer program.
[0048] In a fourth aspect, the present application also provides a readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned face editing method are implemented.
[0049] The beneficial effects of the present invention are: based on deep learning, a solution is designed that can generate high-definition natural images and can handle multi-type face editing. First, it is necessary to encode the user graph into a high-dimensional vector and a high-dimensional feature space, then edit the obtained high-dimensional vector and map it to a new high-dimensional feature space, and finally fuse the two high-dimensional features to restore them into a picture, so that the effect of high-definition multi-type face editing can be achieved. The present invention is applicable to any facial attribute editing task; the edited picture is high-definition, real and natural, and only the required area is edited, with very high decoupling; competing products usually have limited editable attributes, the generated picture quality is not high, and there is a problem of attribute coupling.
[0050] Other features and advantages of the present invention will be described in the following description, and in part will become apparent from the description, or understood by practicing the embodiments of the present invention. The purposes and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without paying any creative work.
[0052] Figure 1 Schematic diagram of the face editing method according to an embodiment of the present invention;
[0053] Figure 2 Schematic diagram of the structure of the face editing device according to an embodiment of the present invention;
[0054] Figure 3 Schematic diagram of the structure of the face editing device described in an embodiment of the present invention.
[0055] In the figure: 701, acquisition module; 702, encoding module; 7021, construction unit; 7022, access unit; 7023, encoding unit; 7024, input unit; 703, calculation module; 7031, acquisition unit; 7032, pairing unit; 7033, calculation unit; 7034, editing unit; 7035, extraction unit; 704, fusion module; 7041, first calling unit; 7042, second calling unit; 7043, interpolation unit; 800, face editing device; 801, processor; 802, memory; 803, multimedia component; 804, I / O interface; 805, communication component. DETAILED DESCRIPTION
[0056] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. The components of the embodiments of the present invention generally described and shown in the drawings herein can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0057] It should be noted that similar reference numerals and letters represent similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined or explained in subsequent drawings. At the same time, in the description of the present invention, the terms "first", "second", etc. are used only to distinguish the description and should not be understood as indicating or implying relative importance.
[0058] Example 1:
[0059] This embodiment provides a face editing method.
[0060] See also Figure 1 , the figure shows that the method includes step S100, step S200, step S300 and step S400.
[0061] S100: Acquire facial information to be edited and construct a facial model, where the facial model includes a mapping network and a generator network.
[0062] It's understandable that in this step, we first need to obtain the original image to be edited, for example, a facial image in this implementation, and build a model. This involves training a generator that randomly generates high-definition faces. To accommodate diverse high-definition editing tasks, training a generator capable of generating high-definition images is essential. Retraining a new model for each edit type is costly, but training a model that randomly generates high-definition faces is relatively simple and versatile.
[0063] S200 , encoding the facial information to be edited according to a preset encoder to obtain a high-dimensional vector, inputting the high-dimensional vector into the facial model for calculation, and obtaining the updated high-dimensional vector.
[0064] It is understood that before this step, the following steps are included:
[0065] Constructing a face model, the face model includes a generator, the generator includes a first network and a second network, the first network maps random noise obeying a Gaussian distribution to a high-dimensional vector obeying the distribution of a face dataset; the second network generates the high-dimensional vector output by the first network through a convolutional neural network algorithm and an upsampling method;
[0066] It can be understood that the generator consists of two networks. The first mapping network can map random noise that obeys the Gaussian distribution to a high-dimensional vector that obeys the distribution of the high-definition face dataset. The second generation network needs to input the high-dimensional vector output from the mapping network, and through convolution and upsampling, it can achieve the generation of high-definition face images from small resolution to large resolution.
[0067] Connecting the preset encoder to the trained second network;
[0068] Encoding the image of the facial information to be edited by the encoder to obtain the high-dimensional vector;
[0069] The high-dimensional vector is input into the generator again, the image of the facial information is reconstructed and calculated, and the loss is obtained to update the weight of the encoder until convergence.
[0070] It should be noted that the encoder is first connected to the generator trained in the previous step. The training image is first encoded into a high-dimensional vector by the encoder, and then input into the generator to reconstruct the image. The L1 and VGG losses of the training image and the reconstructed image are calculated to update the encoder weights until convergence.
[0071] Among them, the main function of the encoder is to encode and compress image information, extract features and decouple attributes, and map them into a high-dimensional space for subsequent processing.
[0072] S300 , performing linear hyperplane classification calculation on the high-dimensional vector of the first attribute based on SVM to obtain a direction vector, and using the direction vector to edit the high-dimensional vector to obtain a high-dimensional feature and a mask of the editing area.
[0073] It is understandable that this step includes:
[0074] Obtaining a randomly sampled image from the generator;
[0075] Pairing the image with the high-dimensional vector, and performing binary classification on the attributes in the image to obtain a new high-dimensional vector;
[0076] It can be understood as randomly sampling a batch of image and high-dimensional vector pairing data through the generator, and then performing binary classification on any attribute of the image and extracting the corresponding high-dimensional vector.
[0077] Based on SVM, a linear hyperplane classification calculation is performed on the new high-dimensional vector to obtain the direction vector of the corresponding attribute;
[0078] Editing the high-dimensional vector using the direction vector, and inputting the edited high-dimensional vector into the generator to obtain an edited image;
[0079] In this implementation, SVM (support vector machine) is used to perform linear hyperplane classification to calculate the normal vector, that is, the direction vector of the corresponding attribute. In theory, this solution can realize any interpretable attribute editing.
[0080] The edited image is input into a pre-trained segmentation network to extract the mask of the edited area.
[0081] This can be understood as using the direction vector to edit the high-dimensional vector obtained by the image encoder. This input into the generator yields a preliminary edited image. Directly outputting the result presents a significant problem: the entanglement of attributes can affect unrelated areas after editing, significantly impacting the editing effect. Finally, the preliminary edited image is fed into a pre-trained segmentation network to extract a mask of the edited area, preparing for the next step of feature fusion.
[0082] S400 , fusing the face information to be edited, the high-dimensional features, and the mask of the editing area to obtain a final editing image.
[0083] To address the issue of edit attribute entanglement, the simplest solution is to reuse the original image information and use a pre-trained segmentation network to extract a mask for the edited area, while applying a mask to unrelated areas. However, this approach results in an unnatural transition between the edited and protected areas. While pixel-level protection is not feasible for achieving a natural transition, a more feasible solution is to perform specialized fusion protection at the high-dimensional feature level.
[0084] It is understandable that this step includes:
[0085] Calling first information, where the first information includes the high-dimensional features and edited high-dimensional features corresponding to the face information to be edited in the encoder and the generator;
[0086] calling second information, where the second information includes the mask of the editing area;
[0087] The mask is adjusted to the same size as the high-dimensional feature by using bilinear interpolation, and the high-dimensional feature and the mask are fused using an alpha fusion method.
[0088] It can be understood as first getting the corresponding original image high-dimensional features and edited high-dimensional features from the encoder and generator, getting the mask of the edited area from the previous segmentation network and using bilinear interpolation to the same size as the high-dimensional features, and then using alpha fusion to fuse the two high-dimensional features, as shown in Formula 1
[0089] F merge =M*F edit +(1-M)*F origin (1)
[0090] Among them F merge represents the fused high-dimensional features, M represents the edited area mask, and F origin Represents the high-dimensional features of the original image, F edit Indicates editing high-dimensional features.
[0091] Compared with fusion at the pixel level, the advantage of feature-level fusion is that there will be no unnatural transition edges after editing, while maintaining the consistency between irrelevant areas and the original image.
[0092] Example 2:
[0093] like Figure 2 As shown, this embodiment provides a face editing device, see Figure 2 The device comprises:
[0094] Acquisition module 701: used to acquire facial information to be edited and construct a facial model, wherein the facial model includes a mapping network and a generator network;
[0095] Encoding module 702: used for encoding the face information to be edited according to a preset encoder to obtain a high-dimensional vector, and inputting the high-dimensional vector into the face model for calculation to obtain the updated high-dimensional vector;
[0096] Calculation module 703: configured to perform linear hyperplane classification calculation on the high-dimensional vector of the first attribute based on SVM to obtain a direction vector, and use the direction vector to edit the high-dimensional vector to obtain a high-dimensional feature and a mask of the editing area;
[0097] Fusion module 704: used for fusing the face information to be edited, the high-dimensional features and the mask of the editing area to obtain a final editing image.
[0098] Specifically, the encoding module 702 previously includes:
[0099] Construction unit 7021: configured to construct a face model, the face model including a generator, the generator including a first network and a second network, the first network mapping random noise obeying a Gaussian distribution to a high-dimensional vector obeying the distribution of a face dataset; the second network generating the high-dimensional vector output by the first network through a convolutional neural network algorithm and an upsampling method;
[0100] The access unit 7022 is configured to access the preset encoder into the trained second network;
[0101] Encoding unit 7023: configured to encode the image of the face information to be edited by the encoder to obtain the high-dimensional vector;
[0102] Input unit 7024: used to input the high-dimensional vector into the generator again, reconstruct and calculate the image of the facial information, and obtain the loss to update the weight of the encoder until convergence.
[0103] Specifically, the calculation module 703 includes:
[0104] Acquisition unit 7031: used to obtain the image randomly sampled by the generator;
[0105] Pairing unit 7032: used to perform data pairing between the image and the high-dimensional vector, and perform binary classification on the attributes in the image to obtain a new high-dimensional vector;
[0106] The calculation unit 7033 is configured to perform a linear hyperplane classification calculation on the new high-dimensional vector based on the SVM to obtain a direction vector of the corresponding attribute;
[0107] An editing unit 7034 is configured to edit the high-dimensional vector using the direction vector, and input the edited high-dimensional vector into the generator to obtain an edited image;
[0108] Extraction unit 7035: used to input the edited image into a pre-trained segmentation network to extract the mask of the edited area.
[0109] Specifically, the fusion module 704 includes:
[0110] A first calling unit 7041 is configured to call first information, where the first information includes the high-dimensional features and edited high-dimensional features corresponding to the face information to be edited in the encoder and the generator;
[0111] The second calling unit 7042 is configured to call second information, where the second information includes the mask of the editing area;
[0112] The interpolation unit 7043 is used to adjust the mask to the same size as the high-dimensional feature by using bilinear interpolation, and fuse the high-dimensional feature and the mask by using an alpha fusion method.
[0113] It should be noted that, regarding the apparatus in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated on here.
[0114] Example 3:
[0115] Corresponding to the above method embodiment, this embodiment further provides a face editing device. The face editing device described below and the face editing method described above can refer to each other.
[0116] Figure 3 FIG. 8 is a block diagram of a face editing device 800 according to an exemplary embodiment. Figure 3 As shown, the face editing device 800 may include: a processor 801 and a memory 802 . The face editing device 800 may also include one or more of a multimedia component 803 , an I / O interface 804 , and a communication component 805 .
[0117] The processor 801 is used to control the overall operation of the face editing device 800 to complete all or part of the steps in the above-mentioned face editing method. The memory 802 is used to store various types of data to support the operation of the face editing device 800. This data may include, for example, instructions for any application or method operating on the face editing device 800, as well as application-related data, such as contact information, sent and received messages, images, audio, video, etc. The memory 802 can be implemented by any type of volatile or non-volatile storage device, or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The multimedia component 803 may include a screen and an audio component. The screen may be, for example, a touch screen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may be further stored in the memory 802 or sent through the communication component 805. The audio component also includes at least one speaker for outputting audio signals. The I / O interface 804 provides an interface between the processor 801 and other interface modules. The above-mentioned other interface modules may be a keyboard, a mouse, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 805 is used for wired or wireless communication between the face editing device 800 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, near field communication (NFC), 2G, 3G or 4G, or a combination of one or more of them, so the corresponding communication component 805 may include: a Wi-Fi module, a Bluetooth module, an NFC module.
[0118] In an exemplary embodiment, the face editing device 800 can be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to execute the above-mentioned face editing method.
[0119] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided. When executed by a processor, the program instructions implement the steps of the above-described face editing method. For example, the computer-readable storage medium may be the aforementioned memory 802 including the program instructions. The program instructions may be executed by the processor 801 of the face editing device 800 to perform the above-described face editing method.
[0120] Example 4:
[0121] Corresponding to the above method embodiment, this embodiment further provides a readable storage medium. The readable storage medium described below and the face editing method described above can refer to each other.
[0122] A readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the face editing method of the above method embodiment.
[0123] The readable storage medium may specifically be any readable storage medium that can store program code, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0124] In summary, first, a generator that can randomly generate high-definition faces is trained. This generator can generate a specific face through a certain high-dimensional vector. Then, an encoder is trained to encode the image into high-dimensional features and high-dimensional vectors. The SVM classification hyperplane normal vector scheme can be used to extract different editing direction vectors. The direction vector is used to edit the high-dimensional vector. The edited high-dimensional vector can be used to extract high-dimensional features through the generator. A pre-trained segmentation network is used to extract the mask of the editing area and interpolate it to the same resolution as the high-dimensional feature. The mask is used to fuse the high-dimensional features of the original image and the edited high-dimensional features. Finally, the fused high-dimensional features can be used by the generator to generate a high-definition image with only the editing area changed. The present invention is applicable to any facial attribute editing task; the edited image is high-definition, real and natural, and only the required area is edited, with very high decoupling; competing products usually have limited editable attributes, the generated image quality is not high, and there is a problem of attribute coupling.
[0125] The foregoing description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Those skilled in the art will readily appreciate that various modifications and variations of the present invention are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention are intended to be within the scope of protection of the present invention.
[0126] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any modifications or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be based on the scope of protection of the claims.
Claims
1. A face editing method, characterized in that: include: Acquire facial information to be edited and construct a facial model, wherein the facial model includes a mapping network and a generator network; Encoding the face information to be edited according to a preset encoder to obtain a high-dimensional vector, inputting the high-dimensional vector into the face model for calculation to obtain the updated high-dimensional vector; Performing a linear hyperplane classification calculation on the high-dimensional vector of the first attribute based on the SVM to obtain a direction vector, and using the direction vector to edit the high-dimensional vector to obtain a high-dimensional feature and a mask of the edited area; performing a linear hyperplane classification calculation on the high-dimensional vector of the first attribute based on the SVM to obtain a direction vector, and using the direction vector to edit the high-dimensional vector to obtain a high-dimensional feature and a mask of the edited area, including: Get the randomly sampled images from the generator; Pairing the image with the high-dimensional vector, and performing binary classification on the attributes in the image to obtain a new high-dimensional vector; Based on SVM, a linear hyperplane classification calculation is performed on the new high-dimensional vector to obtain the direction vector of the corresponding attribute; Editing the high-dimensional vector using the direction vector, and inputting the edited high-dimensional vector into the generator to obtain an edited image; Inputting the edited image into a pre-trained segmentation network to extract the mask of the edited area; The face information to be edited, the high-dimensional features and the mask of the editing area are fused to obtain a final editing image.
2. The face editing method according to claim 1, characterized in that , the face information to be edited is encoded according to a preset encoder to obtain a high-dimensional vector, which includes: Constructing a face model, the face model includes a generator, the generator includes a first network and a second network, the first network maps random noise obeying a Gaussian distribution to a high-dimensional vector obeying the distribution of a face dataset; the second network generates the high-dimensional vector output by the first network through a convolutional neural network algorithm and an upsampling method; Connecting the preset encoder to the trained second network; Encoding the image of the facial information to be edited by the encoder to obtain the high-dimensional vector; The high-dimensional vector is input into the generator again, the image of the facial information is reconstructed and calculated, and the loss is obtained to update the weight of the encoder until convergence.
3. The face editing method according to claim 1, characterized in that , the face information to be edited, the high-dimensional features and the mask of the editing area are fused to obtain a final editing image, which includes: Calling first information, where the first information includes the high-dimensional features and edited high-dimensional features corresponding to the face information to be edited in the encoder and the generator; calling second information, where the second information includes the mask of the editing area; The mask is adjusted to the same size as the high-dimensional feature by using bilinear interpolation, and the high-dimensional feature and the mask are fused using an alpha fusion method.
4. A face editing device, characterized in that: include: Acquisition module: used to obtain the face information to be edited and build a face model, which includes a mapping network and a generator network; Encoding module: used for encoding the face information to be edited according to a preset encoder to obtain a high-dimensional vector, inputting the high-dimensional vector into the face model for calculation to obtain the updated high-dimensional vector; A calculation module is used to perform a linear hyperplane classification calculation on the high-dimensional vector of the first attribute based on the SVM to obtain a direction vector, and use the direction vector to edit the high-dimensional vector to obtain a high-dimensional feature and a mask of the editing area; The computing module includes: Acquisition unit: used to obtain randomly sampled images from the generator; A pairing unit is used to pair the image with the high-dimensional vector and perform binary classification on the attributes in the image to obtain a new high-dimensional vector; A calculation unit is configured to perform a linear hyperplane classification calculation on the new high-dimensional vector based on SVM to obtain a direction vector of the corresponding attribute; An editing unit: configured to edit the high-dimensional vector using the direction vector, and input the edited high-dimensional vector into the generator to obtain an edited image; Extraction unit: used to input the edited image into the pre-trained segmentation network to extract the mask of the edited area Fusion module: used to fuse the face information to be edited, the high-dimensional features and the mask of the editing area to obtain the final editing image.
5. The face editing device according to claim 4, characterized in that: The encoding module previously included: A construction unit is configured to construct a face model, the face model comprising a generator, the generator comprising a first network and a second network, the first network mapping random noise that obeys a Gaussian distribution to a high-dimensional vector that obeys the distribution of a face dataset; the second network generating the high-dimensional vector output by the first network through a convolutional neural network algorithm and an upsampling method; An access unit is configured to connect the preset encoder to the trained second network; Encoding unit: configured to encode the image of the face information to be edited by the encoder to obtain the high-dimensional vector; Input unit: used to input the high-dimensional vector into the generator again, reconstruct and calculate the image of the facial information, and obtain the loss to update the weight of the encoder until convergence.
6. The face editing device according to claim 4, characterized in that: The fusion module includes: A first calling unit: configured to call first information, wherein the first information includes the high-dimensional features and edited high-dimensional features corresponding to the face information to be edited in the encoder and the generator; A second calling unit is used to call second information, where the second information includes the mask of the editing area; Interpolation unit: used to adjust the mask to the same size as the high-dimensional feature using bilinear interpolation, and fuse the high-dimensional feature and the mask using alpha fusion method.
7. A face editing device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the face editing method according to any one of claims 1 to 3 when executing the computer program.
8. A readable storage medium, characterized in that: The readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the face editing method according to any one of claims 1 to 3.
Citation Information
Patent Citations
Image processing method and device, electronic equipment and storage medium
CN110189249A
Face attribute editing method and system, electronic equipment and storage medium
CN112560758A