Face image detection method and device, electronic equipment and storage medium
By using adversarial training technology of generative models and discriminant models in face image detection, the target discriminant model is generated, which solves the problem of low accuracy in cross-data set detection in the existing technology, and achieves higher detection accuracy and generalization capabilities.
Patent Information
- Application Number
- CN202411954728.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-27
- Publication Date
- 2025-04-04
AI Technical Summary
The prior art has significantly reduced accuracy when facing fake face detection tasks across data sets, and it is impossible to effectively identify the diverse image features and data distributions generated by different face tampering technologies.
Adversarial training technology based on generative models and discriminative models is used to generate target discriminative models. Through the adversarial training process, this model learns features with strong generalization capabilities and can effectively identify real and fake faces on different data distributions.
Improves the accuracy of face image detection, enhances the generalization ability of the model and the ability to identify different data sets, thereby maintaining high accuracy in the face of unknown forgery types.
Smart Images

Figure CN119763200A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence, and more specifically, to a facial image detection method, device, electronic device and storage medium. Background Art
[0002] In recent years, with the rapid development of deep learning technology, face recognition systems have been widely used in many fields such as finance, security and social media. It provides an efficient and convenient solution for the identity authentication of legitimate users and public safety monitoring. However, at the same time, deep fake technology has become a hot topic of social concern. This technology uses deep learning algorithms to synthesize or tamper with facial images, so that the generated fake faces are almost indistinguishable from the real ones, posing a serious threat to existing image-based face recognition systems.
[0003] Existing fake face detection technologies usually perform well within a dataset, that is, when the training data and test data come from the same forgery method or similar image processing technology, the detection model can achieve a high accuracy rate. However, when the model faces cross-dataset detection tasks, its performance is often greatly reduced. Cross-dataset detection means that the model needs to effectively identify forgery methods or image processing methods that have not been encountered during training, which requires the model to have strong generalization capabilities and be able to work stably on different data distributions. The core of the problem is that different face tampering techniques, such as whole face synthesis, identity exchange, attribute tampering, and expression exchange, will produce different types of image features and data distributions. When faced with these diverse datasets, most existing technologies lack corresponding types of forged samples in the training dataset, resulting in the model being unable to learn enough generalized features, resulting in a significant drop in accuracy when faced with unknown forgery types in actual applications.
[0004] With regard to the problem of low accuracy in face image detection in related technologies, no effective solution has been proposed so far. Summary of the invention
[0005] The main purpose of the present application is to provide a face image detection method, device, electronic device and storage medium to solve the problem of low accuracy in face image detection in related technologies.
[0006] In order to achieve the above-mentioned purpose, according to one aspect of the present application, a face image detection method is provided. The method comprises: determining a target face image to be detected; inputting the target face image into a target discrimination model, wherein the target discrimination model is a discrimination model obtained through adversarial training of a generative model and a discriminant model, and the target discrimination model is used to discriminate whether the target face image is a real face image or a forged face image; and outputting the detection result of the target face image through the target discrimination model.
[0007] Furthermore, generating a target discriminant model includes: determining a training set, wherein the training set includes multiple real face images; inputting the real face images in the training set into the generation model, and outputting reconstructed face images corresponding to the real face images in the training set; inputting the first training face image into the discriminant model to obtain a discrimination result, wherein the first training face image is a real face image or a reconstructed face image in the training set; calculating the adversarial loss based on the discrimination result; updating the generation model and the discriminant model based on the adversarial loss until the adversarial loss meets a preset condition, and the obtained discriminant model is the target discriminant model.
[0008] Furthermore, the real face images in the training set are input into the generative model, and the reconstructed face images corresponding to the real face images in the training set are output, including: inputting the real face images in the training set into the encoder in the generative model; extracting the image information of the real face images in the training set through the encoder, and generating a coding vector based on the image information; sending the coding vector to the decoder in the generative model, and generating the reconstructed face images corresponding to the real face images in the training set based on the coding vector through the decoder.
[0009] Furthermore, generating a reconstructed face image corresponding to the real face image in the training set based on the coding vector through the decoder includes: converting the coding vector into a multidimensional feature map; inputting the multidimensional feature map, image information and Gaussian noise into the decoder, and generating a reconstructed face image corresponding to the real face image in the training set through the decoder.
[0010] Furthermore, inputting the first training face image into the discriminant model to obtain a discriminant result includes: receiving the first training face image through the discriminant model; normalizing the first training face image to obtain a second training face image; and inputting the second training face image into the capsule network to obtain a discriminant result.
[0011] Furthermore, the second training face image is input into the capsule network to obtain a discrimination result, including: preprocessing the second training face image through a high-pass filter to obtain a third training face image and a residual; cascading the third training face image and the residual to form a fourth training face image; extracting features of the fourth training face image to obtain features of the first training image; inputting the features of the first training image into the convolution layer to output features of the second training image; inputting the features of the second training image into the activation function to output features of the third training image; inputting the features of the third training image into the basic capsule layer to output features of the fourth training image; inputting the features of the fourth training image into the classification capsule layer to output two target vectors; performing nonlinear compression on the two target vectors to obtain two compressed target vectors; and obtaining a discrimination result based on the lengths of the two compressed target vectors.
[0012] Furthermore, outputting the detection result of the target facial image through the target discrimination model includes: outputting the probability of discriminating the target facial image as a real facial image and the probability of discriminating the target facial image as a forged facial image through the target discrimination model; and determining the detection result based on the probability of the real facial image, the probability of the forged facial image and preset discrimination rules.
[0013] In order to achieve the above-mentioned purpose, according to another aspect of the present application, a facial image detection device is provided. The device comprises: a determination unit, used to determine a target facial image to be detected; an input unit, used to input the target facial image into a target discrimination model, wherein the target discrimination model is a discrimination model obtained through adversarial training of a generative model and a discriminant model, and the target discrimination model is used to discriminate whether the target facial image is a real facial image or a forged facial image; and an output unit, used to output the detection result of the target facial image through the target discrimination model.
[0014] Furthermore, the input unit includes: a first determination subunit, used to determine a training set, wherein the training set includes multiple real face images; a first input subunit, used to input the real face images in the training set into the generation model, and output reconstructed face images corresponding to the real face images in the training set; a second input subunit, used to input the first training face image into the discriminant model to obtain a discrimination result, wherein the first training face image is a real face image or a reconstructed face image in the training set; a calculation subunit, used to calculate the adversarial loss based on the discrimination result; an update subunit, used to update the generation model and the discriminant model based on the adversarial loss until the adversarial loss meets a preset condition and the obtained discriminant model is the target discriminant model.
[0015] Furthermore, the first input subunit includes: a first input module, used to input the real face images in the training set into the encoder in the generation model; an extraction module, used to extract the image information of the real face images in the training set through the encoder, and generate a coding vector based on the image information; a generation module, used to send the coding vector to the decoder in the generation model, and generate a reconstructed face image corresponding to the real face images in the training set based on the coding vector through the decoder.
[0016] Furthermore, the generation module includes: a conversion submodule, used to convert the encoding vector into a multidimensional feature map; an input submodule, used to input the multidimensional feature map, image information and Gaussian noise into a decoder, and generate a reconstructed face image corresponding to the real face image in the training set through the decoder.
[0017] Furthermore, the second input subunit includes: a receiving module, used to receive a first training face image through a discriminant model; a normalization module, used to normalize the first training face image to obtain a second training face image; and a second input module, used to input the second training face image into the capsule network to obtain a discriminant result.
[0018] Furthermore, the second input module includes: a preprocessing submodule, which is used to preprocess the second training face image input into a high-pass filter to obtain a third training face image and a residual; a cascade submodule, which is used to cascade the third training face image and the residual to combine them into a fourth training face image; an extraction submodule, which is used to extract the features of the fourth training face image to obtain the features of the first training image; a first output submodule, which is used to input the features of the first training image into the convolution layer and output the features of the second training image; a second output submodule, which is used to input the features of the second training image into the activation function and output the features of the third training image; a third output submodule, which is used to input the features of the third training image into the basic capsule layer and output the features of the fourth training image; a fourth output submodule, which is used to input the features of the fourth training image into the classification capsule layer and output two target vectors; a compression submodule, which is used to perform nonlinear compression on the two target vectors to obtain two compressed target vectors; a determination submodule, which is used to obtain a discrimination result based on the lengths of the two compressed target vectors.
[0019] Furthermore, the output unit includes: an output subunit, which is used to output the probability of the target face image being a real face image and the probability of a forged face image through a target discrimination model; a second determination subunit, which is used to determine the detection result based on the probability of a real face image, the probability of a forged face image and preset discrimination rules.
[0020] According to another aspect of the present application, a computer-readable storage medium is provided, the computer-readable storage medium including a stored program, wherein when the program is executed, a device where the computer-readable storage medium is located is controlled to execute any one of the face image detection methods.
[0021] According to another aspect of the present application, an electronic device is provided, comprising: one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include a method for executing any one of the face image detection methods.
[0022] According to another aspect of the present application, a computer program product is provided, comprising computer instructions, which implement the steps of any one of the above-mentioned face image detection methods when executed by a processor.
[0023] In an embodiment of the present application, by determining a target facial image to be detected; inputting the target facial image into a target discrimination model, wherein the target discrimination model is a discrimination model obtained through adversarial training of a generative model and a discrimination model, and the target discrimination model is used to discriminate whether the target facial image is a real facial image or a forged facial image; outputting the detection result of the target facial image through the target discrimination model, the technical problem of low accuracy in facial image detection is solved. In the present application, by inputting the target facial image to be detected into a target discrimination model, using the target discrimination model to discriminate whether the target facial image is a real facial image or a forged facial image, the detection result of the target facial image is obtained, and the target discrimination model is obtained through adversarial training of a generative model and a discrimination model, which can improve the generalization ability of the target discrimination model and the ability to identify different data sets, thereby achieving the technical effect of improving the accuracy of identifying forged faces. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0025] Figure 1 A hardware structure block diagram of a computer terminal (or mobile device) for implementing a face image detection method is shown;
[0026] Figure 2 is a flowchart of a face image detection method provided according to an embodiment of the present application;
[0027] Figure 3 is a flow chart of a training target discrimination model provided according to an embodiment of the present application;
[0028] Figure 4 is a schematic diagram of generating a reconstructed face image according to the generation model provided in an embodiment of the present application;
[0029] Figure 5 It is a schematic diagram of generating a discrimination result according to the discrimination model provided in the embodiment of the present application;
[0030] Figure 6 is a schematic diagram of a face image detection device provided according to an embodiment of the present application;
[0031] Figure 7 It is a structural block diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0032] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0033] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0034] It should be noted that the relevant information (including but not limited to user facial information, etc.) and data (including but not limited to data for display, data for analysis, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. For example, an interface is set up between this system and the relevant user or organization. Before obtaining the relevant facial information, it is necessary to send an acquisition request to the aforementioned user or organization through the interface, and obtain the relevant facial information after receiving the consent information fed back by the aforementioned user or organization.
[0035] Example 1
[0036] According to an embodiment of the present application, a method embodiment of face image detection is also provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0037] The method embodiment provided in the first embodiment of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 FIG. 1 shows a hardware structure block diagram of a computer terminal (or mobile device) for implementing a face image detection method. Figure 1As shown, the computer terminal 10 (or mobile device) may include one or more (102a, 102b, ..., 102n are used to illustrate) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0038] It should be noted that the one or more processors 102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the computer terminal 10 (or mobile device). As described in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).
[0039] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the face image detection method in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, the above-mentioned face image detection method is realized. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0040] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computer terminal 10. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0041] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 (or mobile device).
[0042] Under the above operating environment, this application provides Figure 2 The face image detection method shown. Figure 2 It is a flowchart of a face image detection method provided according to an embodiment of the present application.
[0043] Step S201, determining a target face image to be detected.
[0044] Optionally, the target facial image can be a facial image to be detected by a financial institution in various security verification processes. Financial institutions can use the target facial image to be detected as the target input, for example: during remote account opening or online identity verification, a selfie or video screenshot uploaded by a customer; when confirming a large transaction, a real-time facial image of the user captured by the system camera; in security monitoring or suspicious transaction investigations, facial images obtained from surveillance videos or social media, etc. By inputting these target facial images into the target discrimination model optimized by adversarial learning, the financial institution can obtain a probabilistic result indicating the authenticity of the image.
[0045] Step S202, inputting the target face image into a target discriminant model, wherein the target discriminant model is a discriminant model obtained based on adversarial training of the generative model and the discriminant model, and the target discriminant model is used to discriminate whether the target face image is a real face image or a forged face image.
[0046] Optionally, after determining the target face image to be detected, the target face image is then input into the target discriminant model obtained through adversarial training. The target discriminant model is obtained by optimizing the adversarial training between the generative model and the discriminant model. This training method enables the target discriminant model to not only learn the features of real face images, but also learn more about the characteristics of forged face images through the game with the generative model. Specifically, the generative model can reconstruct these images by learning the distribution of real face images, while the discriminant model can distinguish between the output of the generative model and the original real face image. During the training process, the generative model and the discriminant model will compete with each other. The generative model strives to generate more realistic face images to "cheat" the discriminant model, while the discriminant model is continuously optimized to more accurately distinguish between real and fake images. In this way, the discriminant model can learn more robust and generalized features, not just features for specific forgery methods.
[0047] For example, a target face image is input into the trained target discrimination model. The target face image is forged using a technique that has never been seen during the training of the target discrimination model. However, since the target discrimination model is obtained through adversarial training with the generative model, even if the target face image uses a technique that has never been seen during the model training, the target discrimination model can accurately identify that the target face image is a forged face image.
[0048] Step S203: output the detection result of the target face image through the target discrimination model.
[0049] For example, in a remote account opening scenario, a financial institution can use the method of this application to verify the identity photo submitted by the user. The financial institution system receives a face photo uploaded by the user and inputs it into the target discrimination model as the target face image. The "fake" probability output by the target discrimination model is 0.7, while the "real" probability is 0.3. According to the previously set threshold (such as 0.5), the target face image will be judged as a fake face image, and the remote account opening application will be rejected, thereby preventing the creation of illegal accounts and protecting financial security.
[0050] In summary, the face image detection method provided in the embodiment of the present application determines the target face image to be detected; inputs the target face image into the target discrimination model, wherein the target discrimination model is a discrimination model obtained through adversarial training of the generation model and the discrimination model, and the target discrimination model is used to discriminate whether the target face image is a real face image or a forged face image; and outputs the detection result of the target face image through the target discrimination model, thereby solving the technical problem of low accuracy in face image detection. In the present application, by inputting the target face image to be detected into the target discrimination model, the target discrimination model is used to discriminate whether the target face image is a real face image or a forged face image, and the detection result of the target face image is obtained. The target discrimination model is obtained through adversarial training of the generation model and the discrimination model, and the generalization ability of the target discrimination model and the ability to identify different data sets can be improved, thereby achieving the technical effect of improving the accuracy of identifying forged faces.
[0051] In an optional embodiment, Figure 3 is a flow chart of a training target discrimination model provided in an embodiment of the present application, such as Figure 3 As shown, generating a target discrimination model includes:
[0052] Step S301, determining a training set, wherein the training set includes a plurality of real face images.
[0053] Optionally, the training set is composed of a large number of real face images and does not contain any forged face images. These real face images can come from databases, public data sets, or customer files within financial institutions. For example, a financial institution can collect 80,000 real face images from its database. These real face images include faces of different ages, genders, and expressions, ensuring the diversity and representativeness of the training set.
[0054] Step S302: input the real face images in the training set into the generation model, and output the reconstructed face images corresponding to the real face images in the training set.
[0055] Optionally, after the training set is determined, the real face images in the training set can be input into the generative model, which attempts to reconstruct these images. The reconstruction process can be achieved by learning the distribution and characteristics of real face images, and the generative model will output reconstructed face images that are similar to the input real face images but have undergone some deformation or distortion. For example, a financial institution uses the Xception network as the basis for the generative model, inputs 80,000 real face images into the generative model, and the generative model outputs the same number of reconstructed face images, which are visually similar to the original real images but contain some minor deformation or distortion.
[0056] Step S303: input the first training face image into the discrimination model to obtain a discrimination result, wherein the first training face image is a real face image or a reconstructed face image in a training set.
[0057] Optionally, the real face images in the training set or the reconstructed face images output by the generative model can be input into the discriminative model to train the discriminative model's ability to distinguish. The task of the discriminative model is to determine whether the input image is an image reconstructed by the generative model, that is, to identify the difference between the real image and the reconstructed image. Through this training method, the discriminative model can learn the key features that distinguish between real face images and reconstructed images, which helps to improve the discriminative model's ability to distinguish, especially for those subtle image features that may be used by counterfeiting technology.
[0058] Step S304: Calculate the adversarial loss based on the discrimination result.
[0059] Optionally, the adversarial loss is calculated to measure the adversarial training effect between the discriminant model and the generative model, thereby guiding the further optimization of the model. The adversarial loss is calculated based on the discrimination result of the discriminant model on the first training face image (i.e., the real face image in the training set or the corresponding reconstructed face image). The goal is to minimize the discriminant model's misjudgment of the real image and maximize the correct discrimination of the generated image. For example, if the discriminant model mistakenly identifies the reconstructed image as a real image, the adversarial loss will increase, otherwise it will decrease. The calculation of the adversarial loss ensures a dynamic balance between the generative model and the discriminant model, driving the two sides to engage in more intense games, thereby prompting the discriminant model to continuously optimize itself and enhance its ability to recognize forged face images.
[0060] Optionally, there are two different loss functions: one for training the generative model and the other for training the discriminative model. The two target loss functions are optimized alternately to obtain the target discriminative model. The loss function of the generative network can be expressed as:
[0061]
[0062] in, Refers to the input real face image, represents the Huber loss in the airspace, Represents the high-frequency coefficient difference loss in the discrete wavelet transform domain (DWT), In order to make each loss item on the same order of magnitude, α, β, and θ are set as weight coefficients of different loss items. The ultimate goal is to minimize L G .
[0063] The adversarial loss can be expressed as:
[0064]
[0065] Among them, D represents the discriminant network and G represents the generative network.
[0066] The loss function of the discriminant network can be expressed as:
[0067]
[0068] in, Refers to the input real face image, Refers to reconstructing facial images.
[0069] Optionally, the generative model and the discriminative model can be trained alternately by minimizing the hinge loss. For example, the total number of training iterations is 33. Only the generative model is trained in the first and second iterations, and the discriminative model and the generative model are trained alternately in the following 31 iterations. α, β, and θ are 50, 1, and 0.1 respectively, and the learning rates of the generative model and the discriminative model are 1e-4 and 1e-3 respectively, and they decay to 1 / 10 of the original after every 10 iterations. The BatchSize is 16, and the Adam optimizer is used for model training.
[0070] Step S305, updating the generative model and the discriminant model based on the adversarial loss until the adversarial loss meets the preset conditions, and the obtained discriminant model is the target discriminant model.
[0071] Optionally, after calculating the adversarial loss, use this loss value to update the parameters of the generative model and the discriminative model, with the goal of minimizing the adversarial loss through iterative training until the preset convergence condition is met. For example, a financial institution can set a threshold for adversarial loss, and when the loss value is lower than this threshold, the discriminative model training is considered complete. During the entire training process, the generative model and the discriminative model are updated alternately until the adversarial loss reaches stability or meets the convergence condition, at which point the discriminative model obtained is the target discriminative model with high generalization ability.
[0072] Through the above steps S301-S305, the parameters of the generation model and the discriminant model can be continuously optimized until the adversarial loss reaches stability, ensuring that the discriminant model can make accurate judgments when encountering any type of target face image, greatly enhancing the robustness and generalization ability of the discriminant model, allowing financial institutions to maintain a high level of detection results when facing unknown counterfeit technologies, providing strong security protection for financial institutions.
[0073] In an optional embodiment, inputting the real face image in the training set into the generation model, and outputting the reconstructed face image corresponding to the real face image in the training set includes:
[0074] Feed real face images from the training set into the encoder in the generative model.
[0075] Optionally, the encoder is a component of the generative model, and its function is to extract features and compress information from the input real face image. For example, the encoder can be based on the first 4 modules of the Xception network. The encoder can convert high-dimensional image data into a low-dimensional encoding vector, which contains the core feature information of the image and helps the subsequent reconstruction and discrimination process of the model. Through the encoder, the model can focus on the key features in the image, reduce redundant information, and improve the training efficiency and recognition accuracy of the model. For example, a 256*256 pixel real face image in the training set is processed by the encoder to extract key facial features, such as the location of the eyes, nose, and mouth, as well as facial contours, textures, and color information.
[0076] The encoder extracts the image information of the real face images in the training set and generates an encoding vector based on the image information.
[0077] Optionally, after the encoder processes the real face image, it can generate a coding vector, which can contain the core information and features of the real face image. Generating coding vectors is one of the core functions of the generative model, which enables the generative model to store and process image information in a compact and abstract form, which not only helps the learning and memory of the generative model, but also prevents information loss, so that the generative model can retain the details and features of the original image as much as possible when reconstructing the image.
[0078] For example, for the aforementioned 256*256 pixel real face image, the encoder will output a fixed-length encoding vector, which may contain hundreds to thousands of elements, each element representing a feature of a certain aspect of the image, such as the relative position of the eyes, the coordinates of the feature points of the facial contour, the details of the skin texture, etc.
[0079] The encoded vector is sent to the decoder in the generative model, and the decoder generates a reconstructed face image corresponding to the real face image in the training set based on the encoded vector.
[0080] Optionally, the decoder is another key component of the generative model. The decoder's task is to reconstruct the original real face image based on the encoding vector generated by the encoder. The decoder can use the opposite processing flow of the encoder to gradually decode and restore the encoding vector, and finally generate a reconstructed face image.
[0081] For example, the decoder can be based on the last three modules of the Xception network. The decoder receives the encoding vector and can decode the information in the encoding vector into a reconstructed face image of the same size through a series of reverse operations, such as deconvolution and upsampling. During the decoding process, the decoder can combine Gaussian noise with the encoding vector to increase the diversity of the reconstructed image and make the model more robust.
[0082] In summary, through the above technical solutions, financial institutions can use generative models to extract features from real face images and generate reconstructed face images. This process not only enhances the feature learning ability of the generative model, but also improves the reconstruction accuracy and generalization performance of the generative model through the encoding-decoding mechanism, thereby improving the accuracy of subsequent detection of forged face images.
[0083] In an optional embodiment, generating a reconstructed face image corresponding to the real face image in the training set based on the coding vector by a decoder includes: converting the coding vector into a multidimensional feature map; inputting the multidimensional feature map, image information and Gaussian noise into the decoder, and generating a reconstructed face image corresponding to the real face image in the training set by the decoder.
[0084] Optionally, the encoding vector is an abstract feature representation obtained by the encoder after processing a real face image. Converting the encoding vector into a multidimensional feature map is the first step in the decoding process. The multidimensional feature map is a matrix that can reflect the spatial distribution of image features. By converting the encoding vector into a multidimensional feature map, the decoder can redistribute the compressed feature information in space, making subsequent image reconstruction easier to understand and operate. This conversion helps the decoder to more accurately restore the local details and structure of the image during the reconstruction process, thereby improving the quality of the reconstructed image.
[0085] For example, the decoder first receives a coded vector generated by the encoder, which may have 2048 elements. The decoder then reorganizes the coded vector into a 16*16*8 three-dimensional matrix (i.e., a multidimensional feature map), which is equivalent to expanding the coded vector in space so that each element corresponds to a feature representation of a local area of the image.
[0086] Optionally, after the decoder receives the multidimensional feature map, the multidimensional feature map can be further combined with the original image information and Gaussian noise to generate a reconstructed face image. The addition of Gaussian noise is used to increase the diversity of the image and prevent the decoder from generating completely identical images (i.e., overfitting), thereby improving the generalization ability of the model. The image information output by each layer in the encoder can be connected to the corresponding decoder module using short-circuit connections, thereby enhancing the focus on image details.
[0087] For example, the decoder receives a 16*16*8 multidimensional feature map and a 16*16 Gaussian noise matrix, it will cascade the two matrices and then start the reconstruction process. After being processed by the decoder, the cascade matrix is gradually enlarged to a size of 256*256 pixels, and finally generates a reconstructed face image, which is visually very similar to the original real face image, but may contain some minor deformations or random changes.
[0088] Through the above steps, by converting the encoding vector into a multi-dimensional feature map, and then combining the multi-dimensional feature map, the image information output by the decoder and Gaussian noise, it can be ensured that the reconstructed face image retains the core features of the original real face image. By introducing random noise to increase the diversity of the reconstructed image, it can prevent the generation model and the discriminant model from being overly dependent on specific image features during the training process, which helps to train a more robust and generalized discriminant model.
[0089] For example, Figure 4 is a schematic diagram of generating a reconstructed face image according to the generation model provided in the embodiment of the present application, such as Figure 4 As shown, the structure of the generative model is an encoder-decoder structure. Xception can be used as the basic skeleton of the generative model, with the first four modules of Xception as encoders and the 5th to 7th modules as decoders. The specific steps can be as follows:
[0090] In the first step, after the real face image is input into the encoder, an encoding vector x is output;
[0091] In the second step, three parts are input into the decoder, namely Gaussian noise, encoding vector x, and the output of each layer in the encoder. The encoding vector x is converted into the same spatial resolution form as each module in the decoder through dimension transformation, and connected to each module of the decoder. The output of each layer in the encoder is connected to the corresponding decoder module using a short-circuit connection;
[0092] The third step is to generate the model output and reconstruct the face image.
[0093] Through the above steps, the generative model's attention to details can be enhanced, thereby improving the reconstruction accuracy and generalization performance of the generative model, and further improving the subsequent detection accuracy of forged face images.
[0094] In an optional embodiment, inputting the first training face image into the discrimination model to obtain the discrimination result comprises the following steps:
[0095] In the first step, the first training face image is received through the discriminant model.
[0096] Optionally, the receiving process can load the image from a file or database into the input layer of the discriminative model, which automatically converts the image into a digital representation that can be processed.
[0097] The second step is to normalize the first training face image to obtain a second training face image.
[0098] Optionally, the above normalization refers to adjusting the pixel values of the first training face image so that the first training face image meets the input requirements of the discriminant model, and the pixel values can be scaled to a fixed range, such as between 0 and 1, or between -1 and 1. Normalization helps the training of the discriminant model, can reduce the differences between images, and make it easier for the discriminant model to learn features.
[0099] For example, if the input image pixel value range is from 0 to 255, these values are adjusted to the range of 0 to 1 to ensure that all image data have the same weight and range for the discriminative model. The adjusted image is called the second training face image.
[0100] The third step is to input the second training face image into the capsule network to obtain the discrimination result.
[0101] Optionally, the capsule network is an advanced neural network architecture that can better handle the spatial relationship and object posture of images compared to traditional convolutional neural networks. The capsule network can decompose the second training face image into multiple capsules, each of which is responsible for identifying a specific type of feature in the image, such as the position and shape of the eyes, nose, and mouth. These capsules can not only identify the type of features, but also capture the relative position and direction of the features, which makes the capsule network more intelligent and flexible when processing images. Ultimately, the capsule network will comprehensively judge whether the input image is a real face image based on the output of all capsules, and output a judgment result, such as a probability value indicating "real" or "fake".
[0102] In summary, through the above steps of receiving images, normalizing images, and applying capsule networks for classification, the discriminant model can be used to judge the authenticity of input face images. This process not only ensures that the discriminant model can correctly receive and preprocess image data, but also improves the detection accuracy and generalization ability of the discriminant model through the advanced feature extraction and spatial relationship understanding capabilities of the capsule network, providing a powerful security tool for financial institutions.
[0103] In an optional embodiment, Figure 5 is a schematic diagram of generating a discrimination result according to the discrimination model provided in the embodiment of the present application, such as Figure 5 As shown, the second training face image is input into the capsule network, and the discrimination results obtained include:
[0104] In the first step, the second training face image is preprocessed by inputting a high-pass filter to obtain a third training face image and a residual.
[0105] Optionally, in order to focus on the high-frequency details in the image, the second training face image can be preprocessed by a high-pass filter. The high-pass filter can highlight the edges, textures and details in the image, which are usually key features in face image detection. After preprocessing, the image is decomposed into two parts: the third training face image (the image with emphasized high-frequency details) and the residual (representing the difference between the original image and the high-frequency detail image).
[0106] Optionally, the second training face image can be input into five high-pass filters for preprocessing, namely, F KV , 12×F KV , point high pass filter F P , second-order horizontal Gabor filter F H , vertical Gabor filter F V , where F KV It can be expressed as the following formula:
[0107]
[0108] Among them, i represents the input image and * represents the convolution operation.
[0109] For example, the detection system of a financial institution receives a normalized second training face image, processes the image through a high-pass filter, and obtains a third training face image that more clearly shows facial edges and tiny texture details, as well as a residual image.
[0110] In the second step, the third training face image and the residual are cascaded to form a fourth training face image.
[0111] Optionally, the third training face image is concatenated with the residual in order to combine the high-frequency details of the image with possible traces of forgery, providing a richer feature set for the model to analyze.
[0112] For example, the financial institution's detection system combines the third training face image (highlighting edges and textures) with the residual image (highlighting smooth areas) side by side to generate a fourth training face image that contains both types of information.
[0113] The third step is to extract the features of the fourth training face image to obtain the features of the first training image.
[0114] Optionally, the first training image features may include local features and spatial relationship information in the image.
[0115] The fourth step is to input the first training image features into the convolutional layer and output the second training image features.
[0116] Optionally, the first training image feature is input to a convolution layer, and after a series of convolution operations, a second training image feature is generated. The function of the convolution layer is to further refine and enhance the representation of image features.
[0117] For example, the first training image feature is input into the convolution layer, and the feature vector is convolved through a 256*9*9 convolution kernel, which enhances the correlation in the feature vector and obtains a more dense and relevant second training image feature.
[0118] The fifth step is to input the second training image features into the activation function and output the third training image features.
[0119] Optionally, the second training image feature can be nonlinearly transformed by an activation function (such as ReLU) to obtain a third training image feature. The role of the activation function is to introduce nonlinearity into the model so that it can learn and represent complex image features.
[0120] For example, the second training image feature is nonlinearly transformed through the ReLU activation function to obtain the third training image feature. The feature vector is sparser, highlights the key features, and helps to discriminate the decision-making process of the model.
[0121] In the sixth step, the third training image feature is input into the basic capsule layer, and the fourth training image feature is output.
[0122] Optionally, the basic capsule layer is composed of a plurality of capsule units, each of which is responsible for processing a specific type of feature. Through the collaboration of these capsule units, a series of fourth training image features can be output eventually, and the fourth training image features are more focused on local areas in the image and their relative positions in space.
[0123] For example, the third training image feature is input into a basic capsule layer consisting of 32 8-dimensional capsules, each of which is responsible for identifying and encoding different types of facial features, such as the shape and position of eyes, nose, and mouth. Finally, the basic capsule layer outputs a series of more structured fourth training image features.
[0124] In the seventh step, the fourth training image features are input into the classification capsule layer and two target vectors are output.
[0125] Optionally, the number of capsules in the classification capsule layer is small, usually 2 (corresponding to the two categories of real and forged). Through the processing of the classification capsule layer, the fourth training image features are mapped to two target vectors, each of which represents the probability representation of the image belonging to the real or forged category.
[0126] For example, the fourth training image feature is input into a classification capsule layer consisting of two 16-dimensional capsules, each capsule representing the real and fake categories. The classification capsule layer outputs two target vectors, and the length of each vector represents the probability that the image belongs to that category.
[0127] In the eighth step, the two target vectors are nonlinearly compressed to obtain two compressed target vectors.
[0128] Optionally, the two target vectors are nonlinearly compressed, and the compressed target vector can better represent the category probability. The length of the compressed vector is closer to 0 or 1, indicating the probability that the target face image belongs to a real face image or a forged face image.
[0129] For example, squashing two target vectors yields two compressed target vectors, each of which has a length that more closely reflects the likelihood that the image belongs to that category.
[0130] In the ninth step, the discrimination result is obtained based on the lengths of the two compressed target vectors.
[0131] For example, the detection system of a financial institution compares two compressed target vectors. If the vector representing the true category is longer, it outputs a value close to 1, indicating that the image is judged to be a real face image. Conversely, if the vector representing the forged category is longer, it outputs a value close to 1, indicating that the image is judged to be a forged face image.
[0132] In summary, through the above nine steps, the second training face image is input into the capsule network for preprocessing, feature extraction and classification, and a more accurate discrimination result can be obtained.
[0133] In an optional embodiment, outputting the detection result of the target face image through the target discrimination model includes:
[0134] The target discrimination model outputs the probability that the target face image is a real face image and the probability that it is a forged face image.
[0135] For example, in the application scenario of a financial institution, a target face image is received, and after a series of processing, the target discrimination model outputs that the probability of the image being a real face is 0.75, and the probability of being a fake face is 0.25. This means that the target discrimination model initially determines that the target face image is more likely to be a real face image.
[0136] The detection result is determined based on the probability of a real face image, the probability of a forged face image and preset discrimination rules.
[0137] Optionally, the above preset discrimination rules can be set according to different actual situations. If faced with a high-risk scenario, financial institutions can choose to set the discrimination threshold higher to reduce the probability of false negatives, even though this may increase some false positive misjudgments. Conversely, in lower-risk scenarios, the discrimination threshold can be appropriately lowered to reduce false positives and increase the user pass rate.
[0138] For example, the preset discrimination rule is that the probability threshold of a real face image is 0.5. According to the probability values obtained in the above example (real: 0.75, fake: 0.25), since the probability of a real face image is higher than the threshold, it can be finally determined that this image is a real face image.
[0139] Through the above steps, the target discrimination model outputs the probability and makes the final judgment according to the preset discrimination rules. The whole process ensures that financial institutions can use the target discrimination model to efficiently and accurately detect the authenticity of face images. This mechanism allows financial institutions to flexibly adjust the discrimination model according to actual scenarios, ensuring that while protecting financial security, they can also provide a smooth customer experience.
[0140] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0141] Example 2
[0142] The embodiment of the present application also provides a face image detection device. It should be noted that the face image detection device of the embodiment of the present application can be used to execute the face image detection method provided in the embodiment of the present application. The face image detection device provided in the embodiment of the present application is introduced below.
[0143] According to an embodiment of the present application, a device for implementing the above-mentioned face image detection method is also provided. Figure 6 is a schematic diagram of a face image detection device provided according to an embodiment of the present application, such as Figure 6 As shown, the device includes: a determination unit 601, an input unit 602, and an output unit 603.
[0144] Specifically, the determination unit 601 is used to determine the target face image to be detected;
[0145] An input unit 602 is used to input a target face image into a target discriminant model, wherein the target discriminant model is a discriminant model obtained through adversarial training based on a generative model and a discriminant model, and the target discriminant model is used to discriminate whether the target face image is a real face image or a forged face image;
[0146] The output unit 603 is used to output the detection result of the target face image through the target discrimination model.
[0147] The face image detection device provided by the embodiment of the present application determines the target face image to be detected by the determination unit 601; the input unit 602 inputs the target face image into the target discrimination model, wherein the target discrimination model is a discrimination model obtained by adversarial training based on the generation model and the discrimination model, and the target discrimination model is used to discriminate whether the target face image is a real face image or a forged face image; the output unit 603 outputs the detection result of the target face image through the target discrimination model, thereby solving the technical problem of low accuracy in the detection of face images. The technical solution of the present application can improve the generalization ability of the target discrimination model and the ability to identify different data sets, thereby achieving the technical effect of improving the accuracy of identifying forged faces.
[0148] Optionally, in the face image detection device provided in the embodiment of the present application, the input unit 602 includes: a first determination subunit, used to determine a training set, wherein the training set includes multiple real face images; a first input subunit, used to input the real face images in the training set into the generation model, and output a reconstructed face image corresponding to the real face images in the training set; a second input subunit, used to input the first training face image into the discriminant model to obtain a discrimination result, wherein the first training face image is a real face image or a reconstructed face image in the training set; a calculation subunit, used to calculate the adversarial loss based on the discrimination result; an update subunit, used to update the generation model and the discriminant model based on the adversarial loss until the adversarial loss meets a preset condition and the obtained discriminant model is the target discriminant model.
[0149] Optionally, in the face image detection device provided in an embodiment of the present application, the first input subunit includes: a first input module, used to input the real face images in the training set into an encoder in the generation model; an extraction module, used to extract image information of the real face images in the training set through the encoder, and generate a coding vector based on the image information; a generation module, used to send the coding vector to the decoder in the generation model, and generate a reconstructed face image corresponding to the real face images in the training set based on the coding vector through the decoder.
[0150] Optionally, in the face image detection device provided in an embodiment of the present application, the generation module includes: a conversion submodule, used to convert the coding vector into a multidimensional feature map; an input submodule, used to input the multidimensional feature map, image information and Gaussian noise into a decoder, and generate a reconstructed face image corresponding to the real face image in the training set through the decoder.
[0151] Optionally, in the face image detection device provided in an embodiment of the present application, the second input subunit includes: a receiving module, used to receive a first training face image through a discriminant model; a normalization module, used to normalize the first training face image to obtain a second training face image; and a second input module, used to input the second training face image into a capsule network to obtain a discriminant result.
[0152] Optionally, in the face image detection device provided in the embodiment of the present application, the second input module includes: a preprocessing submodule, used to preprocess the second training face image input into a high-pass filter to obtain a third training face image and a residual; a cascade submodule, used to cascade the third training face image and the residual to combine them into a fourth training face image; an extraction submodule, used to extract the features of the fourth training face image to obtain the first training image features; a first output submodule, used to input the first training image features into the convolution layer and output the second training image features; a second output submodule, used to input the second training image features into the activation function and output the third training image features; a third output submodule, used to input the third training image features into the basic capsule layer and output the fourth training image features; a fourth output submodule, used to input the fourth training image features into the classification capsule layer and output two target vectors; a compression submodule, used to perform nonlinear compression on the two target vectors to obtain two compressed target vectors; a determination submodule, used to obtain a discrimination result based on the lengths of the two compressed target vectors.
[0153] Optionally, in the face image detection device provided in the embodiment of the present application, the output unit includes: an output subunit, used to output the probability of discriminating the target face image as a real face image and the probability of discriminating the target face image as a forged face image through a target discrimination model; and a second determination subunit, used to determine the detection result based on the probability of a real face image, the probability of a forged face image and preset discrimination rules.
[0154] It should be noted that the above-mentioned determination unit 601, input unit 602 and output unit 603 correspond to steps S201 to S203 in Example 1, and the three units and the corresponding steps implement the same examples and application scenarios, but are not limited to the contents disclosed in the above-mentioned Example 1. It should be noted that the above-mentioned modules or units may be hardware components or software components stored in a memory (e.g., memory 104) and processed by one or more processors (e.g., processors 102a, 102b, ..., 102n), and the above-mentioned modules may also be part of the device and may be run in the computer terminal 10 provided in Example 1.
[0155] Example 3
[0156] The embodiment of the present application may provide a computer terminal, which may be any computer terminal device in a computer terminal group. Optionally, in this embodiment, the computer terminal may also be replaced by a terminal device such as a mobile terminal or an electronic device.
[0157] Optionally, in this embodiment, the computer terminal may be located in at least one network device among a plurality of network devices of the computer network.
[0158] In this embodiment, the above-mentioned computer terminal can execute the program code of the following steps in the face image detection method: determining the target face image to be detected; inputting the target face image into a target discrimination model, wherein the target discrimination model is a discrimination model obtained based on adversarial training of a generative model and a discriminant model, and the target discrimination model is used to discriminate whether the target face image is a real face image or a forged face image; and outputting the detection result of the target face image through the target discrimination model.
[0159] The above-mentioned computer terminal can also execute the program code of the following steps in the face image detection method: generating a target discriminant model includes: determining a training set, wherein the training set includes multiple real face images; inputting the real face images in the training set into the generation model, and outputting reconstructed face images corresponding to the real face images in the training set; inputting the first training face image into the discriminant model to obtain a discrimination result, wherein the first training face image is a real face image or a reconstructed face image in the training set; based on the discrimination result, calculating the adversarial loss; updating the generation model and the discriminant model based on the adversarial loss until the adversarial loss meets the preset conditions, and the obtained discriminant model is the target discriminant model.
[0160] The above-mentioned computer terminal can also execute the program code of the following steps in the face image detection method: inputting the real face images in the training set into the generation model, and outputting the reconstructed face images corresponding to the real face images in the training set, including: inputting the real face images in the training set into the encoder in the generation model; extracting the image information of the real face images in the training set through the encoder, and generating a coding vector based on the image information; sending the coding vector to the decoder in the generation model, and generating the reconstructed face images corresponding to the real face images in the training set based on the coding vector through the decoder.
[0161] The above-mentioned computer terminal can also execute the program code of the following steps in the face image detection method: generating a reconstructed face image corresponding to the real face image in the training set based on the coding vector through the decoder, including: converting the coding vector into a multi-dimensional feature map; inputting the multi-dimensional feature map, image information and Gaussian noise into the decoder, and generating a reconstructed face image corresponding to the real face image in the training set through the decoder.
[0162] The above-mentioned computer terminal can also execute the program code of the following steps in the face image detection method: inputting the first training face image into the discriminant model to obtain the discrimination result includes: receiving the first training face image through the discriminant model; normalizing the first training face image to obtain the second training face image; inputting the second training face image into the capsule network to obtain the discrimination result.
[0163] The computer terminal can also execute the program code of the following steps in the face image detection method: inputting the second training face image into the capsule network, and obtaining the discrimination result includes: preprocessing the second training face image into a high-pass filter to obtain a third training face image and a residual; cascading the third training face image and the residual to form a fourth training face image; extracting the features of the fourth training face image to obtain the features of the first training image; inputting the features of the first training image into the convolution layer to output the features of the second training image; inputting the features of the second training image into the activation function to output the features of the third training image; inputting the features of the third training image into the basic capsule layer to output the features of the fourth training image; inputting the features of the fourth training image into the classification capsule layer to output two target vectors; performing nonlinear compression on the two target vectors to obtain two compressed target vectors; and obtaining the discrimination result based on the lengths of the two compressed target vectors.
[0164] The above-mentioned computer terminal can also execute the program code of the following steps in the face image detection method: outputting the detection result of the target face image through the target discrimination model includes: outputting the probability of judging the target face image as a real face image and the probability of a forged face image through the target discrimination model; determining the detection result according to the probability of a real face image, the probability of a forged face image and preset discrimination rules.
[0165] Optionally, Figure 7 is a structural block diagram of an electronic device according to an embodiment of the present application. Figure 7 As shown, the electronic device may include: one or more ( Figure 7 (only one is shown) processor 702, memory 704, storage controller, and peripheral interface, wherein the peripheral interface is connected to the radio frequency module, audio module and display.
[0166] Among them, the memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the face image detection method and device in the embodiment of the present application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, realizing the above-mentioned face image detection method. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0167] The processor can call the information and application programs stored in the memory through the transmission device to execute the above steps in the above face image detection method.
[0168] By adopting the embodiment of the present application, a solution for face image detection is provided. By determining the target face image to be detected; inputting the target face image into a target discrimination model, wherein the target discrimination model is a discrimination model obtained through adversarial training of a generative model and a discriminant model, and the target discrimination model is used to discriminate whether the target face image is a real face image or a forged face image; outputting the detection result of the target face image through the target discrimination model, the technical problem of low accuracy in face image detection is solved. In the present application, by inputting the target face image to be detected into a target discrimination model, the target discrimination model is used to discriminate whether the target face image is a real face image or a forged face image, and obtaining the detection result of the target face image, the target discrimination model is obtained through adversarial training of a generative model and a discriminant model, and the generalization ability of the target discrimination model and the ability to identify different data sets can be improved, thereby achieving the technical effect of improving the accuracy of identifying forged faces.
[0169] It can be understood by those skilled in the art that Figure 7 The structure shown is for illustration only, and the electronic device may also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (Mobile Internet Devices, MID), a PAD, and other terminal devices. Figure 7 The structure of the electronic device is not limited. Figure 7 More or fewer components (such as network interfaces, display devices, etc.) shown in, or having Figure 7 Different configurations are shown.
[0170] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0171] Example 4
[0172] The embodiment of the present application further provides a storage medium. Optionally, in this embodiment, the storage medium can be used to store the program code executed by the face image detection method provided in the first embodiment.
[0173] Optionally, in this embodiment, the above storage medium may be located in any computer terminal in a computer terminal group in a computer network, or in any mobile terminal in a mobile terminal group.
[0174] In this embodiment, the storage medium is configured to store program codes for executing the following steps: determining a target facial image to be detected; inputting the target facial image into a target discrimination model, wherein the target discrimination model is a discrimination model obtained based on adversarial training of a generative model and a discriminant model, and the target discrimination model is used to discriminate whether the target facial image is a real facial image or a forged facial image; and outputting the detection result of the target facial image through the target discrimination model.
[0175] In this embodiment, the storage medium is also configured to store program code for executing the following steps: generating a target discriminant model includes: determining a training set, wherein the training set includes multiple real face images; inputting the real face images in the training set into the generation model, and outputting reconstructed face images corresponding to the real face images in the training set; inputting the first training face image into the discriminant model to obtain a discrimination result, wherein the first training face image is a real face image or a reconstructed face image in the training set; calculating the adversarial loss based on the discrimination result; updating the generation model and the discriminant model based on the adversarial loss until the adversarial loss meets a preset condition, and the obtained discriminant model is the target discriminant model.
[0176] In this embodiment, the storage medium is also configured to store program codes for executing the following steps: inputting the real face images in the training set into the generation model, and outputting the reconstructed face images corresponding to the real face images in the training set, including: inputting the real face images in the training set into the encoder in the generation model; extracting the image information of the real face images in the training set through the encoder, and generating a coding vector based on the image information; sending the coding vector to the decoder in the generation model, and generating the reconstructed face images corresponding to the real face images in the training set based on the coding vector through the decoder.
[0177] In this embodiment, the storage medium is also configured to store program codes for executing the following steps: generating, through a decoder based on the coding vector, a reconstructed face image corresponding to the real face image in the training set, including: converting the coding vector into a multidimensional feature map; inputting the multidimensional feature map, image information and Gaussian noise into the decoder, and generating, through the decoder, a reconstructed face image corresponding to the real face image in the training set.
[0178] In this embodiment, the storage medium is also configured to store program codes for executing the following steps: inputting the first training face image into the discriminant model to obtain a discrimination result, including: receiving the first training face image through the discriminant model; normalizing the first training face image to obtain a second training face image; inputting the second training face image into the capsule network to obtain a discrimination result.
[0179] In this embodiment, the storage medium is also configured to store program codes for executing the following steps: inputting the second training face image into the capsule network, and obtaining a discrimination result includes: preprocessing the second training face image input into a high-pass filter to obtain a third training face image and a residual; cascading the third training face image and the residual to form a fourth training face image; extracting features of the fourth training face image to obtain features of the first training image; inputting the features of the first training image into the convolution layer to output features of the second training image; inputting the features of the second training image into the activation function to output features of the third training image; inputting the features of the third training image into the basic capsule layer to output features of the fourth training image; inputting the features of the fourth training image into the classification capsule layer to output two target vectors; performing nonlinear compression on the two target vectors to obtain two compressed target vectors; and obtaining a discrimination result based on the lengths of the two compressed target vectors.
[0180] In this embodiment, the storage medium is also configured to store program code for executing the following steps: outputting the detection result of the target facial image through the target discrimination model includes: outputting the probability of discriminating the target facial image as a real facial image and the probability of discriminating the target facial image as a forged facial image through the target discrimination model; determining the detection result based on the probability of a real facial image, the probability of a forged facial image and preset discrimination rules.
[0181] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing the steps of the face image detection method.
[0182] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0183] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0184] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0185] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0186] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0187] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0188] The above is only a preferred implementation 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 face image detection method, characterized in that: include: Determine the target face image to be detected; Inputting the target face image into a target discrimination model, wherein the target discrimination model is a discrimination model obtained based on adversarial training of a generative model and a discriminative model, and the target discrimination model is used to discriminate whether the target face image is a real face image or a forged face image; The target discrimination model is used to output the detection result of the target face image.
2. The method according to claim 1, characterized in that: Generating the target discrimination model includes: Determine a training set, wherein the training set includes a plurality of real face images; Inputting the real face image in the training set into the generation model, and outputting the reconstructed face image corresponding to the real face image in the training set; Inputting a first training face image into the discrimination model to obtain a discrimination result, wherein the first training face image is a real face image in the training set or the reconstructed face image; Based on the discrimination result, calculating the adversarial loss; The generative model and the discriminant model are updated based on the adversarial loss until the adversarial loss meets a preset condition, and the obtained discriminant model is a target discriminant model.
3. The method according to claim 2, characterized in that Inputting the real face image in the training set into the generation model, and outputting the reconstructed face image corresponding to the real face image in the training set comprises: Inputting the real face image in the training set into the encoder in the generative model; Extracting image information of real face images in the training set through the encoder, and generating a coding vector based on the image information; The encoding vector is sent to a decoder in the generation model, and the decoder generates a reconstructed face image corresponding to the real face image in the training set based on the encoding vector.
4. The method according to claim 3, characterized in that Generating, by the decoder based on the encoding vector, a reconstructed face image corresponding to the real face image in the training set comprises: Converting the encoded vector into a multi-dimensional feature map; The multidimensional feature map, the image information and Gaussian noise are input into the decoder, and the decoder is used to generate a reconstructed face image corresponding to the real face image in the training set.
5. The method according to claim 2, characterized in that: Inputting the first training face image into the discrimination model to obtain a discrimination result includes: Receiving the first training face image through the discriminant model; Normalizing the first training face image to obtain a second training face image; The second training face image is input into the capsule network to obtain a discrimination result.
6. The method according to claim 5, characterized in that Inputting the second training face image into the capsule network, obtaining a discrimination result including: Inputting the second training face image into a high-pass filter for preprocessing to obtain a third training face image and a residual; Cascading the third training face image and the residual to form a fourth training face image; Extracting features of the fourth training face image to obtain features of the first training image; Input the first training image feature into the convolution layer, and output the second training image feature; Inputting the second training image feature into an activation function and outputting a third training image feature; Input the third training image feature into the basic capsule layer, and output a fourth training image feature; Input the fourth training image feature into the classification capsule layer, and output two target vectors; Performing nonlinear compression on the two target vectors to obtain two compressed target vectors; A discrimination result is obtained based on the lengths of the two compressed target vectors.
7. The method according to claim 1, characterized in that Outputting the detection result of the target face image through the target discrimination model includes: The target discrimination model outputs the probability of discriminating that the target face image is a real face image and the probability of discriminating that the target face image is a forged face image; The detection result is determined according to the probability of the real face image, the probability of the forged face image and a preset discrimination rule.
8. A facial image detection device, characterized in that: include: A determination unit, used for determining a target face image to be detected; An input unit, used to input the target face image into a target discrimination model, wherein the target discrimination model is a discrimination model obtained based on adversarial training of a generative model and a discriminative model, and the target discrimination model is used to discriminate whether the target face image is a real face image or a forged face image; An output unit is used to output the detection result of the target face image through the target discrimination model.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored executable program, wherein when the executable program is running, the device where the computer-readable storage medium is located is controlled to execute the facial image detection method according to any one of claims 1 to 7.
10. An electronic device, characterized in that: include: A memory storing an executable program; A processor, used to run the program, wherein the program, when running, executes the face image detection method described in any one of claims 1 to 7.
11. A computer program product comprising computer instructions, characterized in that: When the computer instructions are executed by a processor, the steps of the face image detection method described in any one of claims 1 to 7 are implemented.