Face glasses removal model training, application method and its device, equipment and medium
By generating an adversarial model combined with the face glasses removal model of the U-net architecture, and using adversarial learning technology, the problem of low recognition accuracy for users wearing glasses is solved, efficient glasses removal processing is achieved, and the accuracy of face recognition is improved.
Patent Information
- Application Number
- CN202011630413.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-30
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2040-12-30
AI Technical Summary
When face recognition technology faces users who wear glasses, it is affected by the obstruction and reflection of glasses, resulting in a decrease in recognition accuracy, resulting in rejection or misrecognition. It is also difficult to effectively train a face glasses-free model to improve recognition accuracy with existing technology.
The generative adversarial model is combined with the face glasses removal model of the U-net architecture. Through adversarial learning between the generator and the discriminator, the glasses-free face image output by the generator is used as a false value, combined with the artificially pre-marked person without glasses. Face images are used as ground truth for training, and the generator is optimized to improve the accuracy of glasses-free images.
It achieves efficient training of the face glasses removal model with a small number of samples, which can effectively remove glasses, improve face recognition accuracy, reduce the number of samples required, and is suitable for various face image removal processing.
Smart Images

Figure CN112633234B
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of image processing, and in particular to a method for training and applying a face glasses removal model, and corresponding devices, computer equipment, and storage media. Background Art
[0002] One specific application scenario of image recognition is face recognition technology, which is an artificial intelligence technology that recognizes people based on their facial features. Due to its non-contact, convenient and fast features, face recognition technology has a very wide range of application scenarios, such as security, finance, e-government and venue entry and exit.
[0003] In practical applications, the accuracy of face recognition is easily affected by the decorations worn by the face, and glasses are a common artificial decoration. Wearing glasses will cause occlusion and reduce the similarity of the face. On the other hand, under certain lighting conditions, the reflection of the glasses will affect the feature extraction of the eye area. The above two factors will lead to a decrease in the accuracy of face recognition for users wearing glasses, resulting in rejection or misrecognition.
[0004] With the development of artificial intelligence, the technology of using convolutional neural network for image recognition has become increasingly mature. As we all know, the realization of artificial intelligence depends on big data and its algorithms. In other words, an effective face glasses removal model often depends on the sparsity and total number of its training samples.
[0005] Therefore, how to use artificial intelligence technology to efficiently train a face removal model to improve the face recognition accuracy of users wearing glasses is a practical need that needs to be addressed urgently. Summary of the invention
[0006] The present application aims to provide a face glasses removal model training and application method for realizing face image restoration and its corresponding apparatus, computer equipment and storage medium.
[0007] In order to solve the above technical problems, this application adopts the following technical solutions:
[0008] To meet one of the purposes of the present application, a method for training a face glasses removal model is provided, comprising the following steps:
[0009] Feeding a trained face glasses removal model as a generator of a generative adversarial model with an original face image containing glasses to obtain a face glasses removal image generated by the model;
[0010] The face image without glasses output by the face glasses removal model is used as a false value type, and the face image without glasses prepared for the original face image is used as a true value type, and the two types of face images are fed into the discriminator of the generative adversarial model for training;
[0011] The trained discriminator is used as the basis for distinguishing the true and false categories of the face images without glasses output by the generator, and the face glasses removal model used by the generator is trained to improve the accuracy of restoring the face images without glasses from the original face images.
[0012] In some embodiments, the step of feeding a trained face glasses removal model as a generator of a generative adversarial model with an original face image containing a glasses image to obtain a face glasses removal image generated thereby includes:
[0013] Feeding the original face image into the first neural network sub-model in the face glasses removal model, and extracting image features to obtain a feature map set contained in the original face image;
[0014] A face feature map without glasses of the original face image is fused from the feature map set, and the face feature map without glasses is used to segment the original face image to obtain a glasses mask feature map;
[0015] Merging the glasses mask feature map, the glasses-removed face feature map, and the original face image into a multi-channel feature map;
[0016] Feeding the multi-channel feature map into the second neural network sub-model in the face glasses removal model, and extracting image features by the second neural network sub-model to obtain a feature map set contained in the multi-channel feature map;
[0017] The feature maps in the feature map set are fused to generate the face image without glasses corresponding to the original face image.
[0018] In some embodiments, the process of extracting a feature graph set by the first neural network sub-model / the second neural network sub-model includes:
[0019] Obtain an intermediate feature map of the input it receives;
[0020] The intermediate feature map is gradually compressed by multiple encoders in its encoding path to extract multi-scale features;
[0021] The multi-scale features are used as input features, and are gradually decoded by multiple decoders in the decoding path to be restored to feature maps with higher resolutions step by step, wherein each decoder uses the feature map obtained by a corresponding encoder as a reference to implement the restoration;
[0022] All outputs of the decoder constitute the feature map set.
[0023] In some embodiments, the step of feeding the two types of face images into the discriminator of the generative adversarial model for training includes:
[0024] Perform feature extraction on each type of image fed in;
[0025] Classify and judge the image according to the extracted features to obtain corresponding true value and false value judgment results;
[0026] According to the discriminant results, back propagation is performed to correct the weight parameters used by itself.
[0027] In some embodiments, the trained discriminator is used as a basis for distinguishing true and false categories of the face image without glasses output by the generator, and the step of training the face model without glasses adopted by the generator includes:
[0028] Perform feature extraction on each type of image fed in;
[0029] Classify and judge the image according to the extracted features to obtain corresponding true value and false value judgment results;
[0030] Freeze the modifications to the weight parameters used by itself;
[0031] Back-propagate to the generator of the generative adversarial model and correct the relevant weight parameters of the generator to improve the accuracy of the output face glasses removal image;
[0032] Back propagation is performed in the face glasses removal model to correct its relevant weight parameters to improve the accuracy of the face glasses removal image generated by it.
[0033] To meet another purpose of the present application, the present application provides a method for applying a face glasses removal model, comprising the following steps:
[0034] Feeding the posture-corrected face image into the pre-trained face glasses removal model to obtain the glasses-removed face image output by the model;
[0035] Call the preset interface to perform face recognition on the face image without glasses to obtain the recognition result;
[0036] Open or close specific permissions based on the identification results;
[0037] The process of feeding the posture-corrected face image into the pre-trained face glasses removal model includes the following steps:
[0038] Feeding the original face image into the first neural network sub-model in the face glasses removal model, and extracting image features to obtain a feature map set contained in the original face image;
[0039] A face feature map without glasses of the original face image is fused from the feature map set, and the face feature map without glasses is used to segment the original face image to obtain a glasses mask feature map;
[0040] Merging the glasses mask feature map, the glasses-removed face feature map, and the original face image into a multi-channel feature map;
[0041] Feeding the multi-channel feature map into the second neural network sub-model in the face glasses removal model, and extracting image features by the second neural network sub-model to obtain a feature map set contained in the multi-channel feature map;
[0042] The feature maps in the feature map set are fused to generate the face image without glasses corresponding to the original face image.
[0043] In a preferred embodiment, the face glasses removal model is pre-trained through the following steps:
[0044] Feeding a trained face glasses removal model as a generator of a generative adversarial model with an original face image containing glasses to obtain a face glasses removal image generated by the model;
[0045] The face image without glasses output by the face glasses removal model is used as a false value type, and the face image without glasses prepared for the original face image is used as a true value type, and the two types of face images are fed into the discriminator of the generative adversarial model for training;
[0046] The trained discriminator is used as the basis for distinguishing the true and false categories of the face images without glasses output by the generator, and the face glasses removal model used by the generator is trained to improve the accuracy of restoring the face images without glasses from the original face images.
[0047] To meet another purpose of the present application, the present application provides a face glasses removal model training device, which includes:
[0048] An image generation module is used to feed a trained face glasses removal model as a generator of a generative adversarial model with an original face image containing glasses images to obtain a face glasses removal image generated by the model;
[0049] A discriminant training module is used to take the face image without glasses output by the face glasses removal model as a false value type, take the face image without glasses prepared for the original face image as a true value type, and feed the two types of face images into the discriminator of the generative adversarial model for training;
[0050] The model training module is used to use the trained discriminator as the basis for distinguishing the true and false categories of the face images without glasses output by the generator, and to train the face glasses removal model used by the generator to improve the accuracy of restoring the face images without glasses from the original face images.
[0051] In some embodiments, the image production module includes:
[0052] A first extraction submodule is used to feed the original face image into the first neural network submodel in the face glasses removal model, and obtain a feature map set contained in the original face image after performing image feature extraction;
[0053] A first output submodule is used to fuse a face feature map without glasses of the original face image from the feature map set, and use the face feature map without glasses to segment the original face image to obtain a glasses mask feature map;
[0054] A channel merging submodule, used for merging the glasses mask feature map, the glasses-removed face feature map and the original face image into a multi-channel feature map;
[0055] A second extraction submodule is used to feed the multi-channel feature map into the second neural network submodel in the face glasses removal model, and obtain a feature map set contained in the multi-channel feature map after performing image feature extraction;
[0056] The second output submodule is used to fuse the feature maps in the feature map set to generate the face image without glasses corresponding to the original face image.
[0057] To meet another purpose of the present application, the present application provides a face glasses removal model application device, which includes:
[0058] A face restoration module is used to feed the posture-corrected face image into a pre-trained face glasses removal model to obtain a face image without glasses output by the model;
[0059] A face recognition module is used to call a preset interface to perform face recognition on the face image without glasses to obtain a recognition result;
[0060] A permission verification module is used to open or close specific permissions based on the identification result;
[0061] Wherein, the face restoration module includes:
[0062] A first extraction submodule is used to feed the original face image into the first neural network submodel in the face glasses removal model, and obtain a feature map set contained in the original face image after performing image feature extraction;
[0063] A first output submodule is used to fuse a face feature map without glasses of the original face image from the feature map set, and use the face feature map without glasses to segment the original face image to obtain a glasses mask feature map;
[0064] A channel merging submodule, used for merging the glasses mask feature map, the glasses-removed face feature map and the original face image into a multi-channel feature map;
[0065] A second extraction submodule is used to feed the multi-channel feature map into the second neural network submodel in the face glasses removal model, and obtain a feature map set contained in the multi-channel feature map after performing image feature extraction;
[0066] The second output submodule is used to fuse the feature maps in the feature map set to generate the face image without glasses corresponding to the original face image.
[0067] To meet another purpose of the present application, the present application also provides a computer device, which includes a memory and a processor, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the processor executes the steps of any one of the aforementioned methods.
[0068] To meet another purpose of the present application, the present application also provides a storage medium storing computer-readable instructions, which, when executed by one or more processors, enables the one or more processors to perform the steps of any of the aforementioned methods.
[0069] Compared with the prior art, the beneficial effects of this application are:
[0070] This application uses a face glasses removal model to remove the glasses image from the original face image of a person wearing glasses, so as to restore a pure face image without glasses. On this basis, combined with a generative adversarial model, on the one hand, the face image without glasses output by the face glasses removal model is used as a sample of the false value type; on the other hand, an artificially pre-labeled face image without glasses is used as a sample of the true value category. The discriminator of the generative adversarial model is first trained with these two types of samples, so that the discriminator acquires the ability to distinguish whether the face image contained in the picture is a true value or a false value. The trained discriminator is then used as a basis for judgment to assist in training the generator, mainly to train the face glasses removal model therein, so that the face glasses removal face image generated by the face glasses removal model can continue to converge to the ideal effect.
[0071] The present application combines a face glasses removal model with a generative adversarial model, realizes adversarial learning between a generator and a discriminator, utilizes the glasses removal face images produced by the face glasses removal model during the training process to produce richer samples for training, and finally optimizes the face glasses removal model. The number of required samples is significantly reduced, so that it can converge with only a small amount of sample training. The model is suitable for glasses removal processing of face images. By feeding the original face image into the trained face glasses removal model, the performance face image after glasses removal can be obtained. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0073] Figure 1 A schematic diagram of a network architecture suitable for deploying the technical solution of the present application;
[0074] Figure 2 This is a schematic diagram of the system architecture involved in the training of the face glasses removal model of this application;
[0075] Figure 3 A flowchart of the applicant's face glasses removal model training method;
[0076] Figure 4 for Figure 3 The flowchart formed by the specific implementation of step S1100;
[0077] Figure 5 A schematic diagram of the workflow of the sub-model based on the U-net architecture adopted in this application;
[0078] Figure 6 A schematic diagram of the workflow when the discriminator of this application is trained;
[0079] Figure 7 This is a workflow diagram for the discriminator of this application when used to supervise the training of the generator;
[0080] Figure 8 A flowchart of the face glasses removal model training method of the present application;
[0081] Fig. 9 This is a basic structural diagram of the face glasses removal model training device of the present application;
[0082] Fig.10 A basic structural diagram of a face glasses removal model application device of the present application;
[0083] Fig.11 This is a basic structural block diagram of a computer device according to an embodiment of the present application. DETAILED DESCRIPTION
[0084] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be interpreted as limiting the present application.
[0085] Those skilled in the art will appreciate that, unless otherwise stated, the singular forms "a", "an", "said" and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present application refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0086] It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as those generally understood by those skilled in the art to which this application belongs. It should also be understood that terms such as those defined in general dictionaries should be understood to have meanings consistent with those in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless specifically defined as here.
[0087] It will be understood by those skilled in the art that the term "terminal" as used herein includes both devices with wireless signal receivers, which are devices with only wireless signal receivers without transmission capabilities, and devices with receiving and transmitting hardware, which are devices with receiving and transmitting hardware capable of performing two-way communications over a two-way communication link. Such devices may include: cellular or other communication devices, which have a single-line display or a multi-line display or a cellular or other communication device without a multi-line display; PCS (Personal Communications Service), which may combine voice, data processing, fax and / or data communication capabilities; PDA (Personal Digital Assistant), which may include a radio frequency receiver, a pager, Internet / intranet access, a web browser, a notepad, a calendar and / or a GPS (Global Positioning System) receiver; conventional laptop and / or palmtop computers or other devices, which have and / or include a conventional laptop and / or palmtop computer or other device with and / or including a radio frequency receiver. The "terminal" used here can be portable, transportable, installed in a vehicle (air, sea and / or land), or suitable for and / or configured to run locally, and / or in a distributed form, running at any other location on the earth and / or in space. The "terminal" used here can also be a communication terminal, an Internet terminal, a music / video playing terminal, for example, a PDA, a MID (Mobile Internet Device) and / or a mobile phone with a music / video playing function, or a smart TV, a set-top box and other devices.
[0088] The hardware referred to by the names such as "server", "client", and "service node" in this application is essentially an electronic device with the equivalent capabilities of a personal computer. It is a hardware device with the necessary components revealed by the von Neumann principle, such as a central processing unit (including an arithmetic unit and a controller), a memory, an input device, and an output device. The computer program is stored in its memory, and the central processing unit calls the program stored in the external memory into the internal memory for execution, executes the instructions in the program, and interacts with the input and output devices to complete specific functions.
[0089] It should be pointed out that the concept of "server" referred to in this application can also be extended to the case of server clusters. According to the network deployment principle understood by those skilled in the art, the servers should be logically divided. In physical space, these servers can be independent of each other but can be called through interfaces, or integrated into a physical computer or a set of computer clusters. Those skilled in the art should understand this flexibility, and should not use it to restrict the implementation of the network deployment method of this application.
[0090] See also Figure 1 , the hardware foundation required for the implementation of the relevant technical solutions of this application can be deployed according to the architecture shown in the figure. The server 80 referred to in this application is deployed in the cloud, and is mainly used to deploy the generative adversarial model of this application. It is only a server in a logical concept, representing the entire service cluster used to implement the generative adversarial model or to implement the face removal of glasses processing service. By designing an application open call interface, this logical server can be used to provide services for related terminal devices such as the smartphone 81 and personal computer 82 shown in the figure. The smartphone and personal computer can both access the Internet through a well-known network access method, and establish a data communication link with the server 80 in the cloud, so as to start the training of the face removal of glasses model of this application, and use the model to remove glasses from face images.
[0091] See also Figure 2 The technical solution of this application is based on Figure 2 The present invention is implemented by the architecture shown in the figure, in which a training structure combining a generative adversarial model and a face glasses removal model implemented by two U-net principles is implemented.
[0092] Generative Adversarial Network (GAN) is a generative model proposed by Goodfellow et al. in 2014. The structure of GAN is inspired by the two-person zero-sum game in game theory (i.e., the sum of the interests of the two people is zero, and what one party gains is what the other party loses). The system consists of a generator 90 and a discriminator 92. The generator captures the potential distribution of real data samples and generates new data samples; the discriminator 92 is a binary classifier that determines whether the input is real data or a generated sample. Both the generator 90 and the discriminator 92 can be constructed using deep neural networks. The optimization process of GAN is a minimax game problem. The optimization goal is to achieve Nash equilibrium so that the generator estimates the distribution of data samples.
[0093] The U-net network structure consists of two symmetrical parts: the first part of the network is the same as the ordinary convolutional network, which constitutes an encoding path including multiple encoders for extracting local features with gradually decreasing specifications. Each level of encoder uses 3x3 convolution and pooling downsampling to capture the contextual information in the image; the second part of the network is basically symmetrical with the first part, forming a decoding path, which is composed of multiple decoders for gradually increasing specifications to expand the resolution. It uses 3x3 deconvolution layers and upsampling to achieve the purpose of output image segmentation. When deconvolution is implemented in each decoder, the input of the encoder at the same level is received as a reference through a skip-layer connection so that the decoder can restore richer image information when outputting a higher resolution. In addition, feature fusion is also used in the network, which fuses the features of the first part of the downsampling network with the features of the later upsampling part to obtain more accurate contextual information and achieve better segmentation effects.
[0094] The face glasses removal model 900 includes a first neural network sub-model 901 and a second neural network sub-model 902. Both sub-models 901 and 902 are essentially image segmentation models, that is, each sub-model is implemented with a U-net architecture, preferably a U-net architecture. 2 -net architecture, based on the coarse-to-fine idea, the two U-net models are combined into a unified face glasses removal model 900, wherein the first neural network sub-model 901 is responsible for general image segmentation, and the second neural network sub-model 902 is responsible for fine image segmentation. The two sub-models 901 and 902 cooperate from coarse to fine to finally obtain an output result close to the expected one.
[0095] The U-net architecture, including its subsequent development 2 -net architecture, or other architectures suitable for implementing image feature segmentation, can be used as the first neural network sub-model 901 and the second neural network sub-model 902. In some embodiments, the network types used by the first neural network sub-model 901 and the second neural network sub-model 902 can also be (but not limited to): convolutional neural network model, deep convolutional neural network model, recurrent neural network model or variant models of the above neural network models.
[0096] The architecture adopted in the present application uses the face glasses removal model 900 as the main component of the generator 90 in the stage of training the face glasses removal model 900, and is used to produce a face image 69 without glasses corresponding to the original face image 61 with glasses fed in. In addition, a face image without glasses that has been manually pre-labeled is prepared (not shown). Both the face image 69 without glasses and the face image without glasses have the original face image corresponding to them, wherein the former is marked as a false value type because it is produced by the face glasses removal model 900, and the latter is marked as a true value type because it has been manually identified, and correspondingly obtains two types of true and false training samples, thereby, the two types of true and false image data can be fed into the discriminator 92 of the production adversarial model to train it.
[0097] After multiple iterations of training have led to the convergence of the discriminator 92 and the training has been finalized, the discriminator 92 can be used in turn to train the generator 90, specifically to train the face removal of glasses model 900 therein, so that the face removal of glasses model 900 can continuously improve its accuracy in removing glasses from the original face image 61 to obtain a pure face image 69, and finally complete the training of the face removal of glasses model 900, and use the face removal of glasses model 900 for face recognition or for face image beauty modification.
[0098] It can be seen that the above-mentioned network architecture realized based on the technical solution of the present application combines the advantages of U-net and GAN, and organically integrates the two. U-net is responsible for producing some increasingly realistic training samples, and the discriminator 92 of GAN is responsible for improving the identification ability, which is equivalent to putting forward higher requirements on U-net. After many iterations, Nash equilibrium is finally reached. The face glasses removal model trained in this way can effectively remove the glasses image from the original face image, and achieve the ability to effectively output the face image without glasses.
[0099] On the basis of understanding the relevant application environment and development environment related to the technical solution of the present application disclosed above, please refer to the following description to continue to understand the various implementation methods of the present application. It should be pointed out that those skilled in the art should be aware of this: although the various methods of the present application are described based on the same concept and show commonality with each other, unless otherwise specified, these methods can be executed independently. Similarly, for each embodiment disclosed in the present application, they are all proposed based on the same inventive concept. Therefore, concepts with the same expression, and concepts that are appropriately transformed only for convenience despite different conceptual expressions, should be understood equally.
[0100] Please combine Figure 3The present invention discloses a face image recognition model training method, which is used to train a face glasses removal model suitable for removing glasses images from a face original image, and is suitable for deployment and implementation in the cloud. The method provides a calling interface to allow external calls to its services to implement related functions, and includes the following iterative execution steps:
[0101] Step S1100: feeding the original face image containing the glasses image into the trained face glasses removal model as the generator of the generative adversarial model to obtain the glasses removal face image generated by the model:
[0102] The generator for producing adversarial models uses the face glasses removal model as its production factory, and the face glasses removal model is composed of two sub-models based on U-net. When a face original image is fed into the first neural network sub-model, the first neural network sub-model can obtain the face outline feature map corresponding to the face original image after extracting and segmenting the face original image. The face original image is segmented using the face outline feature map to obtain a face glasses feature map, which is essentially a mask. It can be understood that the face outline feature map is relatively fuzzy at this time. Based on the spirit of Coarse-to-fine, it still needs to be refined by the second neural network sub-model. Therefore, after the face glasses feature map, the face outline feature map and the face original image are merged through concat, they are input into the second neural network sub-model for further processing. The second neural network sub-model then further extracts features from the multi-channel feature map after the channel merging, and finally obtains a more refined multi-scale feature map. By fully connecting these feature maps, the face image without glasses can be obtained. It can be understood that the removed-glasses face image obtained by the second neural network sub-model will have a more refined removed-glasses effect compared to the face summary feature map obtained by the first neural network sub-model.
[0103] However, to extract the overall contour features of an irregular glasses image from an original face image, for an untrained face glasses removal model, although its own algorithm has a certain summarization ability, the output results obtained in the initial stage are relatively naive. Therefore, the quality of the glasses removal face images generated by the face glasses removal model in the initial stage is bound to be uneven. Therefore, in the early stage of training the discriminator of the production adversarial model, the glasses removal face images generated by the face glasses removal model will be regarded as false value type training samples for training the discriminator.
[0104] It can be understood that the first neural network sub-model and the second neural network sub-model share weight parameters so as to unify them into the same face glasses removal model. Therefore, an L2 Loss function can be used for back propagation later.
[0105] Step S1200: The face image without glasses output by the face glasses removal model is used as a false value type, and the face image without glasses prepared for the original face image is used as a true value type, and the two types of face images are fed into the discriminator of the generative adversarial model for training:
[0106] In the stage of training the discriminator, according to the GAN principle, two types of training samples need to be provided to the discriminator, one type is pictures representing real data, and the other type is pictures representing pseudo data, so that the discriminator can learn the ability to distinguish the authenticity of pictures from the two types of pictures.
[0107] For the pictures representing real data, as mentioned above, pre-labeled face images without glasses after manual recognition are used to represent real data, which are labeled as true value types as training samples and provided to the discriminator for training.
[0108] For the picture representing pseudo data, it is the output generated by the face glasses removal model, so the generator of the production adversarial model automatically regards it as pseudo data, marks it as a false value type, and then provides this type of training samples to the discriminator training.
[0109] In one embodiment, during the stage of training the discriminator, manual intervention or automatic identification can be performed on the actual effect of the face image without glasses produced by the face removal model, and those images that are manually judged to have a higher degree of match are marked as true value types to constitute real data training samples to participate in the training of the discriminator.
[0110] The purpose of training the discriminator is to improve its ability to distinguish whether the image fed into it is a face image with effective glasses removed and good purification effect, or an image with ineffective glasses removed and poor purification effect.
[0111] The discriminator is a relatively simple classification model, whose main function is to distinguish the false-value type of face images without glasses generated by the generator and the true-value type of face images without glasses manually labeled from the input pictures.
[0112] The discriminator is usually composed of two parts in structure. The front-end part is a CNN convolutional layer, which is used to extract features from synthetic images. Resnet or VGG network is generally used as its backbone. The back-end part is a fully connected layer, which is responsible for mapping the features extracted by the CNN convolutional layer to the [0,1] space for classification. Here, the value 1 represents the true value type and 0 represents the false value type.
[0113] Since the discriminator is a simple two-class model, the cross entropy loss function can be used to meet the requirements. Its loss function Loss d The expression is:
[0114] Loss d =-∑TlogY
[0115] Among them, T is the model target of the discriminator and Y is the output of the model.
[0116] It can be understood that in order to train the discriminator, step S1100-step S1200 can be iterated multiple times. After multiple iterative trainings, the discriminator improves its recognition ability by continuously correcting its own weight parameters, and finally makes the function converge and obtains the ability to distinguish the true and false categories of the pictures fed into it. In essence, it is the ability to distinguish whether the face image without glasses output by the generator is close to or achieves the expected beautification effect.
[0117] It should be pointed out that the pictures that the discriminator can identify after training, although not limited to the various pictures referred to in this application, but in the specific application scenario of this application, in order to solve the specific problems of this application, the discriminator plays the role of providing criteria for the generator. The pictures that the discriminator can identify after training are generally referred to as the glasses-free face images output by the face glasses-free model of this application.
[0118] Step S1300: using the trained discriminator as a basis for distinguishing true and false categories of the face image without glasses output by the generator, training the face glasses removal model used by the generator to improve the accuracy of restoring the face image without glasses from the original face image:
[0119] As mentioned above, after the discriminator completes the training, it has the ability to identify whether a picture is of the true value type or the false value type. Therefore, the discriminator can in turn be used as a basis for judging the training of the generator, and reversely guide the generator, especially to promote the generator to continuously optimize its own weight parameters and to promote the face removal of glasses model it adopts to continuously optimize its own weight parameters to produce a face image with glasses removed that is closer to the true value type, and train the face removal of glasses model to convergence.
[0120] Therefore, it can be understood that when entering the stage of training the generator, the discriminator is no longer trained, so its weight parameters are frozen and no longer corrected. It only provides its judgment results to the generator as a basis for judgment, and backpropagation corrects the relevant weight parameters of the generator and its face removal of glasses model.
[0121] During the generator training phase, the relevant loss function of the generator can be flexibly determined by those skilled in the art according to actual needs. As for the loss function of the face glasses removal model, since there are two sub-models based on U-net, the face summary feature map I obtained by the first neural network sub-model is coarseThe pixel-based L2-pixel loss calculation is performed on the glasses area of the original face image. For the second neural network sub-model, the glasses-free face image I is calculated based on its output. refine The original face image is subjected to pixel-based L2-pixel loss, where the L2-pixel loss refers to the sum of the square differences of each pixel and then the average value. In other embodiments, the L1 Loss commonly used in the art can also achieve the same effect. In the stage of training the generator, the first neural network sub-model and the second neural network sub-model share weights, and under the constraint of the loss function, after multiple rounds of iterations, they gradually converge, and finally the training of the entire face glasses removal model is completed.
[0122] After the above steps, a typical embodiment of the present application first trains the discriminator, and then uses the discriminator to judge the authenticity of the face image without glasses output by the generator, provide a criterion for it, and continuously correct the generator so that it produces face images without glasses that are closer and closer to the ideal effect.
[0123] Correspondingly, since the generator is implemented using a U-net-based face glasses removal model, the process of training the generator is essentially also the process of training the face glasses removal model. As the number of iterative training increases, this process enables the face glasses removal model to generate glasses removal face images that are closer and closer to the ideal effect.
[0124] What is more worth mentioning is that since the face removal of glasses model is trained with the support of the generative adversarial model, the segmented face images without glasses can be efficiently verified by the discriminator on the one hand, and generate representative samples for the generative adversarial model on the other hand. The game mechanism of the generative adversarial model in turn helps the face removal of glasses model to continuously improve the accuracy of its own preparation of face images without glasses, complementing each other and bringing out the best in each other.
[0125] It can be understood that according to the training process implemented in accordance with the technical solution of the present application, only a small number of face images without glasses representing real data need to be used as real data training sample materials to train a U-net-based face glasses removal model.
[0126] In the actual test of the applicant, as long as a small number of samples with sufficient sparse distribution are given, a face glasses removal model based on U-net and coarse-to-fine ideas can be trained. If appropriate manual intervention is made during the training of the discriminator, such as marking a portion of the glasses removal face images with relatively good matching effects produced by the face glasses removal model as true value type training samples during the iteration process, the convergence speed and robustness of the entire architecture-related model, especially the face glasses removal model, will be greatly improved.
[0127] Therefore, it can be seen that the architecture proposed in this application is getting closer and closer to human intelligence. Only a small number of training samples are needed to enable the neural network architecture to summarize relevant rules, greatly improving its learning efficiency and application capabilities.
[0128] Based on the typical embodiment of the face glasses removal model training method of the present application, a variety of flexible implementations or continuously deepened embodiments can be transformed, and other embodiments are further disclosed as follows:
[0129] In some embodiments, step S1100 is further improved. In this step, if Figure 4 As shown, including:
[0130] Step S1110: feeding the original face image into the first neural network sub-model in the face glasses removal model, and extracting image features to obtain a feature map set contained in the original face image:
[0131] The first neural network sub-model is implemented using the U-net architecture. Taking this as an example, when the original face image is fed into the sub-model, a network such as a pre-trained VGG-16 can be used to extract intermediate features to obtain its multi-channel feature map as an intermediate feature map for local feature extraction in subsequent processes. In one embodiment, the first five convolutional layers of VGG-16 can be used, and the convolution kernel can be 3x3 in size.
[0132] On this basis, convolution is performed through encoders at each level of the encoding path of U-net, and multi-scale feature extraction is implemented to gradually increase the feature semantics. Then, deconvolution is performed in the corresponding decoder of the decoding path, and higher resolution feature maps are restored step by step. When decoders at each level restore higher resolution feature maps, the feature maps of the previous level referenced by the encoder of the corresponding level are referenced as a reference through skip-layer connections. Finally, the feature maps generated by decoders at each level of the decoding path constitute the feature map set.
[0133] Step S1120: A face feature map without glasses of the original face image is obtained by fusing the feature map set, and the face feature map without glasses is used to segment the original face image to obtain a glasses mask feature map:
[0134] Among the multiple feature maps obtained by each level of decoder, a feature map of the face without glasses can be obtained by fusion. The feature map of the face without glasses is actually a relatively rough face outline feature map. By using the face outline feature map to perform image segmentation on the original face image, its glasses mask feature map can be obtained.
[0135] Step S1130: Merge the glasses mask feature map, the glasses-removed face feature map, and the original face image into a multi-channel feature map.
[0136] In order to convert the output of the first neural network sub-model into the input of the second neural network sub-model, it is necessary to merge the channels of the glasses mask feature map, the face feature map without glasses and the original face image, wherein the face feature map without glasses and the original face image each occupy 3 channels, while the glasses mask feature map only occupies 1 channel. Therefore, a 7-channel feature map can be generated after channel merging.
[0137] It should be pointed out that when channel merging is performed here, the weight parameters constrained by the L2-pixel loss function of the second neural network sub-model are associated so as to perform back propagation when the second neural network sub-model is trained.
[0138] Step S1140: Feed the multi-channel feature map into the second neural network sub-model in the face glasses removal model, and after performing image feature extraction, obtain a feature map set contained in the multi-channel feature map:
[0139] Similarly, the second neural network sub-model is also implemented using the U-net architecture. Since a 7-channel multi-channel feature map is directly provided for it, there is no need to set up an additional model or convolution layer at the front end of the U-net to perform additional intermediate feature extraction on its input map. Instead, it is only necessary to follow the process described in the first neural network sub-model and directly feed the multi-channel feature map as an intermediate feature map into the U-net through its encoding path and decoding path to perform similar local feature extraction and resolution amplification. The multi-scale feature map finally obtained constitutes the feature map set.
[0140] Step S1150: fuse the feature maps in the feature map set to generate the face image without glasses corresponding to the original face image.
[0141] Finally, the multi-scale feature maps in the feature map set are fed into the fully connected layer for fusion, and the face image without glasses can be obtained. It can be understood that this face image without glasses has a more refined effect of removing glasses than the face summary feature map output by the first neural network sub-model, and under the constraint of L2-pixel loss, after multiple iterations of training, the entire face model without glasses finally converges, and the face image without glasses output by the second neural network sub-model can achieve the ideal effect of removing glasses.
[0142] Although U-net, U 2 -The basic principle of the neural network is well known. To facilitate the understanding of the technical solution of the present application, we continue to combine some embodiments of the present application here to briefly introduce the model structure and function of the common parts of the first neural network sub-model and the second neural network sub-model for the process of extracting the feature map set in the present application as follows. Figure 5 As shown, the process specifically includes:
[0143] Step S1101: Obtain the intermediate feature map of the received input:
[0144] For the first neural network sub-model, the intermediate feature map of the original face image obtained by it can be obtained by filtering using the convolution part of VGG-16 with a 3x3 convolution kernel as mentioned above. For the second neural network sub-model, since it directly obtains the output of the first neural network sub-model and obtains a multi-channel feature map as the intermediate feature map, there is no need to independently set up a convolution part for extracting the intermediate feature map.
[0145] Step S1102: The intermediate feature map is gradually compressed by multiple encoders in its encoding path to extract multi-scale features:
[0146] After the intermediate feature map enters each encoder of the encoding path, each encoder performs convolution and pooling processing on the feature map input therein, downsampling step by step to obtain feature maps of gradually smaller sizes, and finally obtains the feature map with the smallest size but the highest semantics at the output of the last encoder. The encoding path extracts features at multiple scales to obtain the multi-scale features.
[0147] Step S1103: using the multi-scale features as input features, decoding them step by step through multiple decoders in the decoding path, and restoring them step by step into higher-resolution feature maps, wherein each decoder uses the feature map obtained by its corresponding encoder as a reference to implement the restoration:
[0148] The multi-scale features are fed into the decoding path, and the decoding path uses its multiple decoders to perform deconvolution operations to interpolate the reduced feature map. During the interpolation process, the input feature map of the encoder at the same level as the decoder is extracted as a reference through a skip-layer connection to restore the output feature map with a higher resolution.
[0149] Step S1104: All outputs of the decoder form the feature graph set:
[0150] After downsampling in the encoding path and downsampling in the decoding path, feature maps of multiple scales are obtained. However, the feature maps generated by this process are fused and superimposed through the fully connected layer. The fusion and superposition process is to weight the convolution and deconvolution feature maps to obtain a fused face image without glasses.
[0151] The internal working mechanisms of the two sub-models are the same. The difference is that in the first neural network sub-model, the face image without glasses is relatively rough and is actually regarded as the face outline feature map, which is then further segmented to obtain the corresponding glasses mask feature map. Finally, the original face image is used as a reference and can be merged into the multi-channel feature map. In the second neural network sub-model, the face image without glasses is already relatively fine, so it is directly output as the final result.
[0152] Since U-net-based models, especially U2-net-based models, have obvious advantages in image segmentation, adopting such models will be more helpful in producing more perfect facial images without glasses.
[0153] In some embodiments, the operation of the discriminator in the generative adversarial model during its training process is mainly deepened, and by optimizing this process, the effective cooperation between the generative adversarial model and the U-net is ensured. In step S1200, the two types of face images are fed into the discriminator of the generative adversarial model for training, see Figure 6 ,include:
[0154] Step S1210: extract features of each type of image fed in:
[0155] In conjunction with the above, the discriminator is a simple classification model that first extracts features from the composite image through a convolutional layer to obtain a relevant feature map. The types referred to here refer to the true value types that are manually pre-labeled for discriminator training and the false value types that the generator outputs, i.e., the face image produced by the face glasses removal model belongs to. The discriminator extracts necessary features from each type of image fed into it through a convolutional layer for subsequent discrimination.
[0156] Step S1220: classify and discriminate the image based on the extracted features to obtain corresponding true value and false value discrimination results:
[0157] The feature map obtained in the previous step is processed by a fully connected layer and mapped to the [0, 1] space to obtain the corresponding discrimination result.
[0158] Step S1230, back-propagate and correct the weight parameters used by itself according to the discrimination result:
[0159] The discriminator performs backpropagation under the constraint of its own loss function, and associatively modifies its related shared weight parameters according to its classification results, so that it is trained to convergence after multiple iterations.
[0160] In another embodiment of the present application, the main purpose is to further deepen the disclosure of the performance of the discriminator in the process of participating in the training of the generator after the training is completed. In step S1300, the discriminator is no longer trained, but in turn provides a judgment basis for the training of the generator. Therefore, in the step of training the face removal model used by the generator using the trained discriminator as the basis for distinguishing the true and false categories of the face image without glasses output by the generator, as shown in FIG. Figure 7 As shown, it includes:
[0161] Step S1310, extracting features from each type of image fed in;
[0162] Similarly, when the discriminator is used to provide judgment criteria, it first extracts features from the image fed into the generator so that judgment can be made based on the extracted features.
[0163] Step S1320: classify and discriminate the image based on the extracted features to obtain corresponding true value and false value discrimination results:
[0164] After the discriminator obtains the extracted features, it feeds them into the fully connected layer for full connection to achieve classification, and finally determines whether the fed image is a true value type or a false value type.
[0165] Step S1330: Freeze the modification of the weight parameters used by itself:
[0166] It should be pointed out that since the discriminator has theoretically been trained to a convergent state, it has the authority to provide decision-making basis for the generator, and the stability of this authority needs to be ensured. Therefore, in this step, the weight parameters of the discriminator itself are frozen and no longer participate in the correction of the back-propagation process.
[0167] Step S1340: back-propagate to the generator of the generative adversarial model and correct the relevant weight parameters of the generator to improve the accuracy of the output face image without glasses:
[0168] Since the generator is being trained, according to the discrimination result of the discriminator on the image provided by the generator, the generator will perform back propagation according to its own loss function, thereby correcting the relevant weight parameters of the generator itself and improving the accuracy of the output face glasses removal image. Here, the loss function of the generator itself can be flexibly determined by those skilled in the art.
[0169] Step S1350: back propagation is performed in the face glasses removal model to correct its relevant weight parameters to improve the accuracy of the face glasses removal image generated by it:
[0170] Similarly, in the face glasses removal model, back propagation will also be performed under the constraint of its own weight parameters according to the judgment basis of the discriminator to achieve weight update. In particular, in the second neural network sub-model, under the constraint of the L2-pixel loss, the square difference between the multi-channel feature map provided to the second neural network sub-model and the final output glasses face feature map is calculated pixel by pixel, and then the sum is calculated, and then the mean is calculated. In the process of each iteration of training the generator, the various sub-models of the face glasses removal model are trained synchronously. Therefore, under the constraint of its loss function, when the mean value is greater than the corresponding preset threshold, the second neural network sub-model calls the feedback function to implement the correction of the relevant weight parameters. Through multiple such corrections, the face image without glasses output by the face glasses removal model is closer and closer to the ideal result. When the mean value is less than or equal to the preset threshold, there is no need to correct the weight parameters and continue the training of the next training sample. Back propagation also occurs in the path of the first neural network sub-model, and those skilled in the art can understand it in the same way. After multiple iterative trainings, when training continues, if the mean values of the repeatedly outputted face images without glasses obtained under the action of the loss function are all less than the preset threshold, it can be considered that the face without glasses model is trained to a convergence state and is put into practical application.
[0171] It should be noted that the above disclosed embodiments of the present application can be arbitrarily combined or implemented separately, or replaced with other similar technologies or similar technologies based on the creative spirit of the present application. For example, the continuously upgraded network structure based on U-net can also be used to replace the sub-models described in the present application in theory. Those skilled in the art should be aware of this.
[0172] This application also provides a method for applying a face glasses removal model, which mainly utilizes the face glasses removal model proposed in this application, and further applies it on the basis of being trained to convergence by any of the various embodiments of the face glasses removal model training method of this application. Figure 8 Specifically, it includes the following steps:
[0173] Step S2100: feeding the posture-corrected face image into a pre-trained face glasses removal model to obtain the glasses removal face image output by the model:
[0174] Before feeding the face image that needs to remove the glasses image into the face glasses removal model, the face image is first subjected to posture correction, which helps to ensure the glasses removal effect of the model.
[0175] By directly feeding the corrected facial image into the facial glasses removal model, the output facial image without glasses can be obtained. Different from the prior art, in this step, from inputting the facial image to obtaining the facial image without glasses, there is no need to use third-party tools or models to extract features from the facial image.
[0176] Step S2200: Calling a preset interface to perform face recognition on the face image without glasses to obtain a recognition result:
[0177] Based on different applications, different preset interfaces can be called to perform face recognition on the face image without glasses, so as to obtain a recognition result of whether the image belongs to a legitimate user.
[0178] For example, in a face-based identity authentication application scenario, after the camera is started to capture the user's facial image, if the user happens to be wearing glasses, it may affect the recognition effect. By first passing this image frame into the face glasses removal model for glasses removal image processing, a pure facial image is obtained, and then it is transmitted to the preset interface for identifying the user's identity in the background. At this time, the identification program associated with the preset interface can identify the user's identity based on a more efficient facial image, and more efficiently determine the user's identity based on the pure facial image, and output the recognition result.
[0179] Step S2300: Open or close specific permissions based on the recognition result:
[0180] Depending on the specific application requirements, different specific permissions can be opened or closed based on the recognition results. For example, in an online payment scenario, when the recognition result indicates that the user identity has been authenticated, login, payment, etc. can be allowed; in a home security scenario, when the recognition result indicates that the user identity has been authenticated, a door lock can be opened for the user; in the lock screen interface of a mobile terminal device, when the recognition result indicates that the user identity has been authenticated, the user can be allowed to enter the main interface of the system; for example, in the field of live video, based on the video frame, each video frame is input into a face removal model trained to convergence by this application to remove the glasses worn by the user, so that the user can beautify the video. Of course, if the recognition result indicates that the authentication cannot be passed, the relevant permissions can be closed, or ignored without response, etc. Such things can be flexibly applied by technicians in this field.
[0181] Among them, step S2100 may include the following steps: feeding the original face image into the first neural network sub-model in the face glasses removal model, and obtaining a feature map set contained in the original face image after performing image feature extraction; fusing the glasses removal face feature map of the original face image from the feature map set, and using the glasses removal face feature map to segment the original face image to obtain a glasses mask feature map; merging the glasses mask feature map, the glasses removal face feature map and the original face image into a multi-channel feature map; feeding the multi-channel feature map into the second neural network sub-model in the face glasses removal model, and obtaining a feature map set contained in the multi-channel feature map after performing image feature extraction; fusing each feature map in the feature map set to generate the glasses removal face image corresponding to the original face image.
[0182] Among them, the face glasses removal model is pre-trained through the following steps: the trained face glasses removal model, which serves as a generator of a generative adversarial model, is fed with an original face image containing a glasses image to obtain a face image without glasses generated thereby; the face image without glasses output by the face glasses removal model is taken as a false value type, and the face image without glasses prepared for the original face image is taken as a true value type, and the two types of face images are fed into the discriminator of the generative adversarial model for training; the trained discriminator is used as a basis for distinguishing the true and false categories of the face image without glasses output by the generator, and the face glasses removal model adopted by the generator is trained to improve the accuracy of restoring the face image without glasses from the original face image.
[0183] It can be seen that the present application further broadens the application scenarios of the face recognition model without glasses, expands the ability of the present application to solve similar technical problems in different technical fields, and consolidates the economic contribution capacity of the technical solution of the present application.
[0184] The present application can construct a corresponding device by running the application program of each embodiment of the aforementioned method in a computer. For details, please refer to Fig. 9 , which is a basic structural diagram of the face glasses removal model training device of this embodiment.
[0185] like Fig. 9As shown, a face glasses removal model training / application device includes: an image production module 1100, a discrimination training module 1200, and a model training module 1300. The image production module 1100 is used to feed the trained face glasses removal model as a generator of a generative adversarial model with a face original image containing glasses images to obtain a face image without glasses generated by the model; the discrimination training module 1200 is used to take the face image without glasses output by the face glasses removal model as a false value type, and the face image without glasses prepared for the face original image as a true value type, and feed the two types of face images into the discriminator of the generative adversarial model for training; the model training module 1300 is used to use the trained discriminator as a basis for distinguishing the true and false categories of the face image without glasses output by the generator, and train the face glasses removal model used by the generator to improve the accuracy of restoring the face image without glasses from the face original image.
[0186] The image production module 1100 includes: a first extraction submodule, used to feed the original face image into the first neural network submodel in the face glasses removal model, and obtain a feature map set contained in the original face image after the first neural network submodel performs image feature extraction; a first output submodule, used to fuse the glasses removal face feature map of the original face image from the feature map set, and use the glasses removal face feature map to segment the original face image to obtain the glasses mask feature map; a channel merging submodule, used to perform channel merging on the glasses mask feature map, the glasses removal face feature map and the original face image into a multi-channel feature map; a second extraction submodule, used to feed the multi-channel feature map into the second neural network submodel in the face glasses removal model, and obtain a feature map set contained in the multi-channel feature map after the second neural network submodel performs image feature extraction; a second output submodule, used to fuse the feature maps in the feature map set to generate the glasses removal face image corresponding to the original face image.
[0187] The identification training module 1200 includes: a first input submodule, used to extract features of each type of image fed in; a first classification submodule, used to classify and distinguish the image based on the extracted features to obtain corresponding true value and false value distinction results; and a first correction submodule, used to correct the weight parameters used by itself according to the distinction results through back propagation.
[0188] The model training module 1300 includes: a second input submodule, used to extract features for each type of image fed in; a second classification submodule, used to classify and distinguish the image based on the extracted features to obtain corresponding true and false value distinction results; a state control submodule, used to freeze the correction of the weight parameters used by itself; a second correction submodule, used to back-propagate to the generator of the generative adversarial model, and correct the relevant weight parameters of the generator to improve the accuracy of the output face image without glasses; an association correction submodule, used to back-propagate within the face image without glasses model to correct its relevant weight parameters to improve the accuracy of the generated face image without glasses.
[0189] The face glasses removal model training device of the present invention has the same beneficial effects as the face glasses removal model training method of the present invention.
[0190] The present application can construct a corresponding device by running the application program of each embodiment of the aforementioned method in a computer. For details, please refer to Fig.10 , which is a basic structural diagram of the face glasses removal model application device of this embodiment.
[0191] The present application provides a human face glasses removal model application device, such as Fig.10 As shown, it includes: a face restoration module 2100, a face recognition module 2200, and an authority verification module 2300. The face restoration module is used to feed the posture-corrected face image into the pre-trained face glasses removal model to obtain the glasses-removed face image output by the model; the face recognition module is used to call a preset interface to perform face recognition on the glasses-removed face image to obtain a recognition result; the authority verification module is used to open or close specific permissions according to the recognition result.
[0192] Among them, the face restoration module includes: a first extraction submodule, which is used to feed the original face image into the first neural network submodel in the face glasses removal model, and obtain a feature map set contained in the original face image after the first neural network submodel performs image feature extraction; a first output submodule, which is used to fuse the glasses removal face feature map of the original face image from the feature map set, and use the glasses removal face feature map to segment the original face image to obtain the glasses mask feature map; a channel merging submodule, which is used to perform channel merging on the glasses mask feature map, the glasses removal face feature map and the original face image into a multi-channel feature map; a second extraction submodule, which is used to feed the multi-channel feature map into the second neural network submodel in the face glasses removal model, and obtain a feature map set contained in the multi-channel feature map after the second neural network submodel performs image feature extraction; a second output submodule, which is used to fuse the feature maps in the feature map set to generate the glasses removal face image corresponding to the original face image.
[0193] The human face glasses removal model application device of the present invention has the same beneficial effects as the human face glasses removal model application method of the present invention.
[0194] In order to solve the above technical problems, the embodiment of the present application also provides a computer device for running a computer program implemented according to the face glasses removal model training / application method. Fig.11 , Fig.11 This is a basic structural block diagram of the computer device in this embodiment.
[0195] like Fig.11 As shown, a schematic diagram of the internal structure of a computer device. The computer device includes a processor, a non-volatile storage medium, a memory, and a network interface connected via a system bus. Among them, the non-volatile storage medium of the computer device stores an operating system, a database, and computer-readable instructions. The database may store a control information sequence. When the computer-readable instructions are executed by the processor, the processor can implement a method for training / applying a face removal of glasses model. The processor of the computer device is used to provide computing and control capabilities to support the operation of the entire computer device. The memory of the computer device may store computer-readable instructions. When the computer-readable instructions are executed by the processor, the processor can execute a method for training / applying a face removal of glasses model. The network interface of the computer device is used to connect and communicate with a terminal. Those skilled in the art will understand that Fig.11 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0196] In this embodiment, the processor is used to execute the specific functions of each module / submodule of the face glasses removal model training / application device of the present invention, and the memory stores the program code and various data required to execute the above modules. The network interface is used to transmit data between the user terminal or the server. The memory in this embodiment stores the program code and data required to execute all modules / submodules in the face glasses removal model training / application device, and the server can call the server's program code and data to execute the functions of all submodules.
[0197] The present application also provides a non-volatile storage medium, wherein the face glasses removal model training / application method is written into a computer program and stored in the storage medium in the form of computer-readable instructions. When the computer-readable instructions are executed by one or more processors, it means that the program is run in the computer, thereby enabling one or more processors to execute the steps of the face glasses removal model training / application method of any of the above-mentioned embodiments.
[0198] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0199] In summary, the present application can train a model suitable for removing glasses from face images with a small amount of samples, and can efficiently and accurately remove glasses images from face images, and has broad application prospects.
[0200] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0201] Those skilled in the art will appreciate that the various operations, methods, steps, measures, and schemes in the processes discussed in this application may be alternated, altered, combined, or deleted. Further, other steps, measures, and schemes in the various operations, methods, and processes discussed in this application may also be alternated, altered, rearranged, decomposed, combined, or deleted. Further, the steps, measures, and schemes in the prior art that are similar to those disclosed in this application may also be alternated, altered, rearranged, decomposed, combined, or deleted.
[0202] The above description is only a partial implementation method of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for training a face glasses removal model. It is characterized in that The steps include: Feeding a trained face glasses removal model as a generator of a generative adversarial model with an original face image containing glasses to obtain a face glasses removal image generated by the model; The face image without glasses output by the face glasses removal model is used as a false value type, and the face image without glasses prepared for the original face image is used as a true value type, and the two types of face images are fed into the discriminator of the generative adversarial model for training; The trained discriminator is used as a basis for distinguishing true and false categories of the face images without glasses output by the generator, and the face glasses removal model used by the generator is trained to improve the accuracy of restoring the face images without glasses from the original face images; The step of feeding the trained face glasses removal model as a generator of the generative adversarial model with the original face image containing the glasses image to obtain the glasses removal face image generated thereby comprises: feeding the original face image to the first neural network sub-model in the face glasses removal model, and obtaining a feature map set contained in the original face image after the model performs image feature extraction; fusing a glasses removal face feature map of the original face image from the feature map set, and using the glasses removal face feature map to segment the original face image to obtain a glasses mask feature map; performing channel merging on the glasses mask feature map, the glasses removal face feature map and the original face image into a multi-channel feature map; feeding the multi-channel feature map to the second neural network sub-model in the face glasses removal model, and obtaining a feature map set contained in the multi-channel feature map after the model performs image feature extraction; fusing each feature map in the feature map set to generate the glasses removal face image corresponding to the original face image; The process of extracting a set of feature maps by the first neural network sub-model and the second neural network sub-model includes: obtaining an intermediate feature map of the input received by them; gradually compressing the intermediate feature map through multiple encoders in its encoding path to extract multi-scale features; using the multi-scale features as input features, gradually decoding them through multiple decoders in its decoding path, and restoring them step by step to feature maps with higher resolution, wherein each decoder uses the feature map obtained by its corresponding encoder as a reference to implement the restoration; and all outputs of the decoders constitute the set of feature maps.
2. The method for training a face model to remove glasses according to claim 1, It is characterized in that The steps of feeding the two types of face images into the discriminator of the generative adversarial model to implement training include: Perform feature extraction on each type of image fed in; Classify and judge the image according to the extracted features to obtain corresponding true value and false value judgment results; According to the discriminant results, back propagation is performed to correct the weight parameters used by itself.
3. The method for training a face model to remove glasses according to claim 1, It is characterized in that The trained discriminator is used as a basis for distinguishing true and false categories of the glasses-removed face image output by the generator, and the steps of training the face glasses-removed model used by the generator include: Perform feature extraction on each type of image fed in; Classify and judge the image according to the extracted features to obtain corresponding true value and false value judgment results; Freeze the modifications to the weight parameters used by itself; Back-propagate to the generator of the generative adversarial model and correct the relevant weight parameters of the generator to improve the accuracy of the output face glasses removal image; Back propagation is performed in the face glasses removal model to correct its relevant weight parameters to improve the accuracy of the face glasses removal image generated by it.
4. A method for applying a face glasses removal model, It is characterized in that The steps include: Feeding the posture-corrected face image into the pre-trained face glasses removal model to obtain the glasses-removed face image output by the model; Call the preset interface to perform face recognition on the face image without glasses to obtain the recognition result; Open or close specific permissions based on the identification results; The process of feeding the posture-corrected face image into the pre-trained face glasses removal model comprises the following steps: feeding the original face image into the first neural network sub-model in the face glasses removal model, and obtaining a feature map set contained in the original face image after image feature extraction; fusing the glasses removal face feature map of the original face image from the feature map set, and using the glasses removal face feature map to segment the original face image to obtain a glasses mask feature map; performing channel merging on the glasses mask feature map, the glasses removal face feature map and the original face image into a multi-channel feature map; feeding the multi-channel feature map into the second neural network sub-model in the face glasses removal model, and obtaining a feature map set contained in the multi-channel feature map after image feature extraction; fusing each feature map in the feature map set to generate the glasses removal face image corresponding to the original face image; The face glasses removal model is pre-trained through the following steps: feeding the trained face glasses removal model as a generator of the generative adversarial model with an original face image containing glasses images to obtain a face glasses removal image generated by the model; taking the face glasses removal image output by the face glasses removal model as a false value type, taking the face image without glasses prepared for the original face image as a true value type, and feeding the two types of face images into the discriminator of the generative adversarial model for training; using the trained discriminator as a basis for distinguishing the true and false categories of the face glasses removal image output by the generator, and training the face glasses removal model used by the generator to improve the accuracy of restoring the face glasses removal image from the original face image; The process of extracting a set of feature maps by the first neural network sub-model and the second neural network sub-model includes: obtaining an intermediate feature map of the input received by them; gradually compressing the intermediate feature map through multiple encoders in its encoding path to extract multi-scale features; using the multi-scale features as input features, gradually decoding them through multiple decoders in its decoding path, and restoring them step by step to feature maps with higher resolution, wherein each decoder uses the feature map obtained by its corresponding encoder as a reference to implement the restoration; and all outputs of the decoders constitute the set of feature maps.
5. A face glasses removal model training device, It is characterized in that The method for training a face model for removing glasses according to any one of claims 1 to 3 is implemented, comprising: An image generation module is used to feed a trained face glasses removal model as a generator of a generative adversarial model with an original face image containing glasses images to obtain a face glasses removal image generated by the model; A discriminant training module is used to take the face image without glasses output by the face glasses removal model as a false value type, take the face image without glasses prepared for the original face image as a true value type, and feed the two types of face images into the discriminator of the generative adversarial model for training; The model training module is used to use the trained discriminator as the basis for distinguishing the true and false categories of the face images without glasses output by the generator, and to train the face glasses removal model used by the generator to improve the accuracy of restoring the face images without glasses from the original face images.
6. A computer device comprising a memory and a processor, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the processor executes the steps of the method according to any one of claims 1 to 4.
7. A storage medium storing computer-readable instructions, wherein when the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the method according to any one of claims 1 to 4.
