Counterfeit face image detection method and device
By using the opposite force mechanism and paired authentic and false face image samples in the face forgery detection model, multiple iterative training of the initial model is solved, and the problem that the existing model cannot accurately learn the forgery details is achieved, achieving higher detection accuracy and generalization ability.
Patent Information
- Application Number
- CN202411978567.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-05-06
AI Technical Summary
When detecting forged face images, the existing face forged identification models cannot accurately learn the forged details, resulting in low detection accuracy.
The training sample data pair containing real face image samples and corresponding fake face image samples is used, and the initial face forged detection model is trained through the reverse force mechanism to obtain the target face forged detection model. During the training process, this model updates paired authentic and false face image samples in the opposite direction, enhancing attention to forged features.
The model's attention and detection ability to deal with forged areas is improved, the accuracy of detection of forged face images is enhanced, and the existing models' inaccurate identification of forged faces is solved.
Smart Images

Figure CN119942611A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and more specifically, to a method and device for detecting forged facial images. Background Art
[0002] The existing mainstream methods for face forgery identification usually rely on deep learning models, especially variants of convolutional neural networks (CNN) or variational auto-encoders (VAE), generative adversarial networks (GAN), and other models. These models collect large-scale datasets of real and fake faces and use classification models for binary classification training to distinguish between real face images and forged face images. Another type of technology attempts to distinguish forged face images from real face images by extracting specific features related to forgery technology, such as texture, color distortion, unnatural edge transitions and other forgery traces. Although these methods have achieved good results in some scenarios, there are still some key technical problems:
[0003] (1) Insufficient attention to forged areas: Existing forgery identification models mainly rely on overall facial image classification, without explicitly detecting which areas in the facial image may contain forgeries. This causes the model to sometimes focus more on irrelevant background or facial identity features rather than the details of the forged areas, resulting in a decrease in the model's accuracy.
[0004] (2) Insufficient supervisory signals for forged areas: Most existing forgery detection methods train models through an overall binary classification loss without providing clear supervisory signals for forged areas. This makes it difficult for the model to focus on the forged local features in the face image, and the generalization ability of the model is limited.
[0005] (3) Insufficient training for authenticity comparison: Although methods such as adversarial learning have been applied in forgery identification, most existing methods are based on adversarially generated forged face images for model training, rather than using paired authentic and fake face images for targeted comparative learning. This makes it difficult for the model to more accurately learn forgery features through similar pairs of authentic and fake face images.
[0006] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0007] The embodiments of the present application provide a method and device for detecting forged facial images, so as to at least solve the technical problem that the relevant forged facial image detection model cannot accurately learn the forged detail features in the forged facial image, resulting in low accuracy in detecting forged facial images.
[0008] According to one aspect of an embodiment of the present application, a method for detecting a forged facial image is provided, comprising: obtaining a target facial image to be detected; analyzing the target facial image using a pre-trained target face forgery detection model to obtain a corresponding detection result, wherein the detection result is used to reflect whether the target facial image is a forged facial image, and the target face forgery detection model is obtained by using training sample data pairs including real facial image samples and corresponding forged facial image samples, and adopting an opposing force mechanism to train an initial facial forgery detection model.
[0009] Optionally, the training process of the target face forgery detection model includes: constructing an initial face forgery detection model; obtaining multiple training sample data pairs, wherein the training sample data pairs include: a group of training sample data consisting of real face image samples and corresponding all-zero Map images as training samples, and real types of real face image samples as sample labels, and another group of training sample data consisting of forged face image samples corresponding to the real face image samples and corresponding forged area Map images as training samples, and forged types of forged face image samples as sample labels; based on the multiple training sample data, the initial face forgery detection model is trained for multiple rounds of iterations using the opposite force mechanism to obtain the target face forgery detection model.
[0010] Optionally, a plurality of training sample data pairs are obtained, including: obtaining a plurality of real face image samples; for each real face image sample, setting the pixel values of all pixels in the real face image to 0 to obtain a corresponding all-zero Map; forming a group of training sample data by using the real face image samples and the corresponding all-zero Map as training samples and the real types of the real face image samples as sample labels; obtaining a forged face image sample corresponding to each real face image sample; for each forged face image sample, determining the absolute difference between the pixel value of each pixel in the real face image sample and the pixel value of each pixel in the corresponding forged face image sample to obtain a differential image; and removing the target pixel whose pixel value in the differential image is less than a preset pixel threshold. The pixel value of the point is set to 0, and the pixel values of other pixels in the differential image except the target pixel are set to 1, to obtain the corresponding forged area Map; a group of training sample data is composed of the forged face image samples and the corresponding forged area Map as training samples, and the forged type of the forged face image samples as sample labels; a group of training sample data is composed of the real face image samples and the corresponding all-zero Map as training samples, and the real type of the real face image samples as sample labels, and another group of training sample data is composed of the forged face image samples corresponding to the real face image samples and the corresponding forged area Map as training samples, and the forged type of the forged face image samples as sample labels, to obtain a training sample data pair.
[0011] Optionally, obtaining the forged face image sample corresponding to each real face image sample includes: calling a preset forging tool to perform a forging operation on each real face image sample respectively to obtain the forged face image sample corresponding to each real face image sample.
[0012] Optionally, the process of determining the forged area Map also includes: determining the image size of the differential image, and determining a fine pixel threshold corresponding to the image size; setting the pixel value of the target pixel in the differential image whose pixel value is less than the fine pixel threshold to 0, and setting the pixel value of other pixel points in the differential image except the target pixel to 1, to obtain the corresponding forged area Map.
[0013] Optionally, based on multiple training sample data, an opposing force mechanism is used to perform multiple rounds of iterative training on the initial face forgery detection model to obtain a target face forgery detection model, including: in each round of iteration, multiple training sample data pairs are loaded into the same small batch, and the training samples in the training sample data pairs in the same small batch are input into the initial face forgery detection model to obtain the prediction labels corresponding to each training sample output by the initial face forgery detection model; a target loss function of the initial face forgery detection model is constructed based on the sample labels in the training sample data pairs in the same small batch and the prediction labels corresponding to each training sample; and a preset gradient optimization algorithm is used to optimize the target loss function to adjust the model parameters of the initial face forgery detection model until the model converges to obtain the target face forgery detection model.
[0014] Optionally, the objective loss function of the initial face forgery detection model is expressed as: Where L represents the target loss function, N represents the total number of training sample data pairs in the same small batch, and p ir represents the predicted probability corresponding to the all-zero Map in the i-th training sample data pair, p if represents the predicted probability of the forged region map in the i-th training sample data pair, P xy represents the value of the predicted forged area Map at (x, y) output by the initial face forgery detection model, M xy represents the value of the Map at (x, y) in the training sample, H and W represent the height and width of the face image sample, α and β represent the weighting coefficients, and W xy represents the adaptive weight, and W xy =1+γ·|P xy -M xy |, where γ represents a hyperparameter.
[0015] According to another aspect of an embodiment of the present application, a forged facial image detection device is also provided, including: an acquisition module, used to acquire a target facial image to be detected; a detection module, used to analyze the target facial image using a pre-trained target face forgery detection model to obtain a corresponding detection result, wherein the detection result is used to reflect whether the target facial image is a forged facial image, and the target face forgery detection model is obtained by using training sample data pairs including real facial image samples and corresponding forged facial image samples, and adopting an opposite force mechanism to train an initial facial forgery detection model.
[0016] According to another aspect of an embodiment of the present application, a computer program product is further provided, the computer program product comprising: a computer program, wherein when the computer program is executed by a processor, the forged facial image detection method described above is implemented.
[0017] According to another aspect of an embodiment of the present application, an electronic device is further provided, comprising: a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to execute the forged facial image detection method through the computer program.
[0018] In the embodiment of the present application, a training sample data pair including a real face image sample and a corresponding forged face image sample is used, and an opposite force mechanism is used to train the initial face forgery detection model to obtain a target face forgery detection model, that is, in the model training process, pairs of true and false face image samples (i.e., training sample data pairs including real face image samples and corresponding forged face image samples) are simultaneously input into the model, and by updating the real face image samples and the forged face image samples in opposite directions, the model pays more attention to the forgery features, improves the model's attention to and detection capabilities of the forged area, and weakens the reliance on irrelevant information (such as face identity features), thereby solving the problem of inaccurate forgery recognition and insufficient generalization capabilities of the model in the prior art. Therefore, by using the target face forgery detection model to analyze the target face image to be detected, an accurate detection result can be obtained, and the detection result is used to reflect whether the target face image is a forged face image, so as to solve the technical problem that the relevant face forgery detection model cannot accurately learn the forgery detail features in the forged face image, resulting in low accuracy in detecting the forged face image. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0020] Figure 1 is a flow chart of an optional forged face image detection method according to an embodiment of the present application;
[0021] Figure 2 is a schematic diagram of an optional target face forgery detection model according to an embodiment of the present application;
[0022] Figure 3 is a schematic structural diagram of an optional forged face image detection device according to an embodiment of the present application;
[0023] Figure 4 It is a schematic diagram of the structure of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0024] 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.
[0025] It should be noted that the terms "first", "second", etc. in the specification, claims and drawings of the present application 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.
[0026] In order to better understand the embodiments of the present application, some nouns or terms that appear in the description of the embodiments of the present application are first translated and explained as follows:
[0027] Mini-batch: refers to the training data set that is input into the model in batches during the deep learning training process.
[0028] Example 1
[0029] According to an embodiment of the present application, a method for detecting a forged facial image is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a 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.
[0030] Figure 1 is a flow chart of a forged face image detection method provided in accordance with an embodiment of the present application, such as Figure 1 As shown, the method includes the following steps S102-S104, wherein:
[0031] Step S102, obtaining a target face image to be detected.
[0032] In the technical solution provided in the above step S102, the above target facial image includes but is not limited to a facial image captured in real time from a camera, a face in a photo uploaded by a user, or a face in a frame image extracted from a video stream.
[0033] Step S104, using the pre-trained target face forgery detection model to analyze the target face image to obtain a corresponding detection result.
[0034] In the technical solution provided in the above step S104, the training sample data pair containing the real face image sample and the corresponding forged face image sample is used in advance, and the initial face forgery detection model is trained by using the opposite force mechanism to obtain the target face forgery detection model that can perform targeted analysis on the true and false face images. Among them, the training sample data pair containing the real face image sample and the corresponding forged face image sample refers to a sample pair consisting of the training sample data of the real face image sample and the training sample data of the forged face image sample corresponding to the real face image sample. In addition, the opposite force mechanism refers to that during the model training process, the paired true and false face image samples (i.e., the training sample data pair containing the real face image sample and the corresponding forged face image sample) are simultaneously input into the model, and by updating the real face image sample and the forged face image sample in opposite directions, the model pays more attention to the forgery features, improves the model's attention to the forgery area and the detection ability, and weakens the dependence on irrelevant information (such as face identity features), thereby solving the problem of inaccurate forgery recognition and insufficient generalization ability of the model in the prior art. Therefore, by analyzing the target face image using the trained target face forgery detection model, an accurate detection result can be obtained, and the detection result is used to reflect whether the target face image is a forged face image.
[0035] The following describes each step of the forged face image detection method in conjunction with a specific implementation process.
[0036] As an optional implementation, the training process of the target face forgery detection model may include:
[0037] Step S1, constructing an initial face forgery detection model. The initial face forgery detection model can be an initial face forgery detection model, such as a variant of a convolutional neural network (CNN), a variational autoencoder (VAE), or a generative adversarial network (GAN).
[0038] Step S2, obtaining multiple training sample data pairs.
[0039] The training sample data pair includes: a group of training sample data consisting of real face image samples and corresponding all-zero maps as training samples, and real types of real face image samples as sample labels, and another group of training sample data consisting of forged face image samples corresponding to real face image samples and corresponding forged area maps as training samples, and forged types of forged face image samples as sample labels. In other words, the training sample data pair includes paired real and fake face image samples.
[0040] Optionally, in the technical solution provided in the above step S2, the following steps may be used to obtain the training sample data pair, including:
[0041] Step S21, obtaining multiple real face image samples.
[0042] Step S22, for each real face image sample, set the pixel values of all pixels in the real face image to 0 to obtain a corresponding all-zero Map; a group of training sample data is composed of the real face image samples and the corresponding all-zero Map as training samples, and the real types of the real face image samples as sample labels.
[0043] Step S23, obtaining a forged face image sample corresponding to each real face image sample.
[0044] Specifically, the specific implementation of the above step S23 may include: calling a preset forging tool to perform forging operations on each real face image sample, respectively, to obtain a forged face image sample corresponding to each real face image sample, wherein the forging tool may be a forging tool based on deep learning technology (i.e., generating realistic forged face images), or a face replacement tool based on the FaceSwap program (i.e., replacing the facial features of one face with another face to generate a forged face image). Through these forging tools, the real face image can be modified, replaced or synthesized to regenerate a forged face image that looks real but is actually edited.
[0045] Step S24, for each forged face image sample, determine the absolute difference between the pixel value of each pixel point in the real face image sample and the pixel value of each pixel point in the corresponding forged face image sample to obtain a differential image; set the pixel value of the target pixel point in the differential image whose pixel value is less than a preset pixel threshold to 0, and set the pixel value of other pixels in the differential image except the target pixel point to 1 to obtain a corresponding forged area Map; a group of training sample data is composed of the forged face image samples and the corresponding forged area Map as training samples, and the forged type of the forged face image samples as sample labels.
[0046] Specifically, if the real face image sample is recorded as I real , and the corresponding forged face image sample is recorded as I fake , then the real face image sample I real And fake face image sample I fake Pixel-level difference calculation is performed between them to obtain the corresponding absolute difference, which is expressed as:
[0047] D(x,y)=|I real (x,y)-I fake (x,y)|
[0048] Among them, I real (x,y) and I fake (x, y) represent the pixel values of the true and false face image samples at the pixel point (x, y) respectively.
[0049] Next, a pixel threshold τ is set, and the pixel values of pixels whose absolute difference is greater than the pixel threshold τ (such as τ = 5) are set to 1, and the pixel values of pixels whose absolute difference is less than or equal to the pixel threshold τ are set to 0, thereby obtaining a 0 / 1 binary forged area map, which is expressed as follows:
[0050]
[0051] In addition, a variety of image processing methods can be used to enhance the detection of forged areas during pixel-level differential calculations.
[0052] Optionally, determine the image size of the differential image, and determine a fine pixel threshold corresponding to the image size; set the pixel value of the target pixel in the differential image whose pixel value is less than the fine pixel threshold to 0, and set the pixel value of other pixel points in the differential image except the target pixel to 1, to obtain the corresponding forged area Map.
[0053] In other words, the multi-scale information of the face image can be introduced into the differential calculation to generate a more refined forged area map, which can be written as:
[0054]
[0055] Where s represents the scale information of the image, τ s is the pixel threshold at different scales. This method can make the forged region map capture the forged features at different scales more accurately.
[0056] Step S24, a group of training sample data is composed of real face image samples and corresponding all-zero Map images as training samples, and the real types of real face image samples are used as sample labels, and another group of training sample data is composed of forged face image samples corresponding to the real face image samples and corresponding forged area Map images as training samples, and the forged types of forged face image samples are used as sample labels, to obtain a training sample data pair.
[0057] Among them, the all-zero map corresponding to the real face image samples and the forged area map corresponding to the forged face image samples can be used as auxiliary supervision signals during the model training process, so that the model can more directly learn the characteristics of real face images and forged face images during training, thereby improving the accuracy of forgery detection. At the same time, the map can also be used as a true and false identification of the forged area, providing an additional training target for the model, and combined with the main classification or detection tasks of the model to form a more comprehensive training framework, ensuring that the model can converge to the optimal solution faster during the training process and avoid overfitting.
[0058] Step S3, based on multiple training sample data, adopting the opposing force mechanism to perform multiple rounds of iterative training on the initial face forgery detection model to obtain the target face forgery detection model.
[0059] Optionally, in the technical solution provided in the above step S3, the following steps may be used for iterative training, including:
[0060] Step S31, in each round of iteration, multiple training sample data pairs are loaded into the same small batch, and the training samples in the training sample data pairs in the same small batch are input into the initial face forgery detection model to obtain the prediction labels corresponding to each training sample output by the initial face forgery detection model.
[0061] Step S32, constructing a target loss function of the initial face forgery detection model based on the sample labels within the training sample data pairs within the same small batch and the predicted labels corresponding to each training sample.
[0062] Specifically, Figure 2 is a schematic diagram of a target face forgery detection model according to an embodiment of the present application, such as Figure 2As shown. Since the training sample data pairs of paired true and false face image samples are loaded into the same mini-batch at the same time and input into the initial face forgery detection model, the model can use the training sample data pairs as supervisory signals to set a map of all 0s for the true face image samples and a map of forged regions for the forged face image samples, respectively, to ensure that the model clearly distinguishes between the true and forged regions in the image during learning. Therefore, the above objective loss function includes a loss function L based on adaptive weighting and regional difference sensitivity. AW-RD , to calculate the distance between the forged area output by the model and the auxiliary supervisory signal. This function not only measures the direct difference between the model output and the supervisory signal, but also dynamically adjusts the weight according to the importance of the forged area and the non-forged area. Among them, the above loss function L based on adaptive weighting and regional difference sensitivity AW-RD The expression can be written as:
[0063]
[0064] Where P xy M represents the value of the predicted forged area Map at (x, y) output by the initial face forgery detection model; xy represents the value of the Map graph (i.e., auxiliary supervision signal) in the training sample at (x, y), and M xy =0 indicates a non-forged area, if M xy =1 indicates a non-forged area; H, W represent the height and width of the face image samples (real face image samples, forged face image samples), respectively; α, β represent weighting coefficients, respectively controlling the influence of the absolute error term (i.e., the absolute difference between the model prediction value and the true value, used to measure the deviation between the model output and the actual label) and the square error term (used to calculate the square of the error between the model output value and the true value, and the square error can highlight the influence of larger deviations and help the model converge faster); W xy Represents adaptive weight, which is used to assign different weights to pixels at different positions, and is defined as W xy =1+γ·|P xy -M xy |, where γ is a hyperparameter used to adjust the contribution of different pixel differences to the overall loss. This weight mechanism makes the area with large differences contribute more to the loss function.
[0065] In addition, during the model training process, pairs of training sample data of real and fake face image samples are input into the model, where the goal of the real face image samples is to make the model output close to the real label, while the fake face image samples will make the model focus on learning fake features through the opposite gradient effect. At the same time, the model parameters are updated using the opposite force mechanism, which enables the model to strengthen its focus on fake features during the comparative learning process by loading similar pairs of real and fake face image samples at the same time. Therefore, the above objective loss function also includes the comparative classification loss L C , and the comparison classification loss L C The expression can be written as:
[0066]
[0067] Where N represents the total number of training sample data pairs in the same small batch, p ir represents the predicted probability corresponding to the all-zero Map in the i-th training sample data pair, p if Represents the predicted probability of the forged area Map in the i-th training sample data pair.
[0068] Therefore, the objective loss function of the initial face forgery detection model can be written as:
[0069]
[0070] Among them, the hyperparameters α, β, and γ in the above objective loss function can be set to 1, 0.5, and 0.04, respectively.
[0071] Step S33, using a preset gradient optimization algorithm to optimize the target loss function to adjust the model parameters of the initial face forgery detection model until the model converges to obtain the target face forgery detection model.
[0072] Among them, the above-mentioned gradient optimization algorithms include but are not limited to: Stochastic Gradient Descent (SGD) algorithm, Momentum Gradient Descent (Momentum) algorithm, Adam (Adaptive Moment Estimation) and the like.
[0073] Compared with the existing forged face detection models, the target forged face detection model trained by the above method has the following advantages:
[0074] (1) During the training process, the real face image is set to a map with all 0s as the supervisory signal, and the forged face image is generated according to the difference result. The forged area map is used as the supervisory signal. The model can clearly identify the forged part during the training process, reducing the misjudgment of false positive samples and improving the generalization ability and detection accuracy of the model. At the same time, in the process of optimizing the model parameters, the difference between the forged area predicted by the model and the real forged area map is considered, and an adaptive weighted area difference loss function is added to the objective loss function of the model. This loss function combines the absolute error and the square error, and can dynamically adjust the weights of different areas according to the difference, so that the error of the forged area contributes more to the loss, prompting the model to focus more on the accurate prediction of the forged area, especially at the edge of the forged area and in complex forged scenes, which improves the accuracy of forged detection and the robustness of the model.
[0075] (2) During the model training process, pairs of real and fake face image samples are loaded into the same mini-batch at the same time, and the model parameters are updated using an opposing force mechanism. Through this mechanism, the model is updated positively when processing real images, and negatively when processing fake images, which enhances the model's sensitivity to fake face images, prompting the model to pay more attention to the extraction of fake features and reduce the focus on irrelevant information such as facial identity features.
[0076] (3) Generate corresponding forged face image samples for real face image samples through open source forging tools or forging programs, and construct pairs of real and fake face image samples. Through this method, a one-to-one correspondence is formed between real face image samples and forged face image samples, which can ensure that real and fake images can be accurately loaded and matched during the training process. At the same time, by performing pixel-by-pixel differential operations on real face image samples and forged face image samples, the differences between real face image samples and forged face image samples are effectively captured. This differential calculation method helps the model learn the features of the forged area more efficiently, greatly improving the model's forgery detection capabilities, especially when dealing with complex forgery scenes.
[0077] Example 2
[0078] According to an embodiment of the present application, a forged face image detection device for implementing the forged face image detection method in Embodiment 1 is also provided. Figure 3 As shown, the forged face image detection device at least includes: an acquisition module 32 and a detection module 34, wherein:
[0079] An acquisition module 32 is used to acquire a target face image to be detected;
[0080] The detection module 34 is used to analyze the target face image using a pre-trained target face forgery detection model to obtain a corresponding detection result, wherein the detection result is used to reflect whether the target face image is a forged face image. The target face forgery detection model is obtained by using a training sample data pair including a real face image sample and a corresponding forged face image sample, and adopting an opposite force mechanism to train the initial face forgery detection model.
[0081] It should be noted that each module in the forged facial image detection device in the embodiment of the present application corresponds one-to-one to each implementation step of the forged facial image detection method in Example 1. Since a detailed description has been given in Example 1, some details not reflected in this embodiment can be referred to Example 1 and will not be repeated here.
[0082] Example 3
[0083] According to an embodiment of the present application, a computer program product is also provided. The computer program product includes a computer program. When the computer program is executed by a processor, the forged facial image detection method in Embodiment 1 is implemented.
[0084] According to an embodiment of the present application, a non-volatile storage medium is also provided, which includes a stored computer program, wherein the device where the non-volatile storage medium is located executes the forged facial image detection method in Example 1 by running the computer program.
[0085] According to an embodiment of the present application, a processor is also provided, which is used to run a computer program, wherein the forged facial image detection method in Example 1 is executed when the computer program is running.
[0086] According to an embodiment of the present application, an electronic device is also provided, which includes: a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to execute the forged facial image detection method in Example 1 through the computer program.
[0087] Specifically, when the computer program is running, the following steps are executed: obtaining a target face image to be detected; analyzing the target face image using a pre-trained target face forgery detection model to obtain a corresponding detection result, wherein the detection result is used to reflect whether the target face image is a forged face image, and the target face forgery detection model is obtained by using training sample data pairs including real face image samples and corresponding forged face image samples, and adopting an opposite force mechanism to train the initial face forgery detection model.
[0088] As an optional implementation, the electronic device may be in the form of a mobile terminal, a computer terminal or a similar computing device. Figure 4FIG. 1 shows a hardware structure block diagram of an electronic device for implementing a method for detecting a forged face image. Figure 4 As shown, the electronic device 40 may include one or more (402a, 402b, ..., 402n are used to illustrate) processors 402 (the processor 402 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 404 for storing data, and a transmission device 406 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 4 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 4 More or fewer components as shown, or with Figure 4 Different configurations are shown.
[0089] It should be noted that the one or more processors 402 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 electronic device 40. 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).
[0090] The memory 404 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the forged face image detection method in the embodiment of the present application. The processor 402 executes various functional applications and data processing by running the software programs and modules stored in the memory 404, that is, realizing the vulnerability detection method of the above-mentioned application. The memory 404 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 404 may further include a memory remotely arranged relative to the processor 402, and these remote memories may be connected to the electronic device 40 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.
[0091] The transmission device 406 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 electronic device 40. In one example, the transmission device 406 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 406 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0092] 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 electronic device 40 .
[0093] The serial numbers of the above embodiments are only for description and do not represent the advantages or disadvantages of the embodiments.
[0094] 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.
[0095] 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 units can be 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.
[0096] 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 over multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0097] 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.
[0098] 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, or the part that contributes to the relevant technology or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for 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, etc. Various media that can store program codes.
[0099] 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 method for detecting forged facial images, characterized in that: include: Obtain the target face image to be detected; The target face image is analyzed using a pre-trained target face forgery detection model to obtain a corresponding detection result, wherein the detection result is used to reflect whether the target face image is a forged face image. The target face forgery detection model is obtained by using training sample data pairs including real face image samples and corresponding forged face image samples, and adopting an opposing force mechanism to train the initial face forgery detection model.
2. The method according to claim 1, characterized in that The training process of the target face forgery detection model includes: Constructing the initial face forgery detection model; Acquire multiple training sample data pairs, wherein the training sample data pairs include: a group of training sample data consisting of the real face image samples and the corresponding all-zero Map as training samples, and the real types of the real face image samples as sample labels, and another group of training sample data consisting of the forged face image samples corresponding to the real face image samples and the corresponding forged region Map as training samples, and the forged types of the forged face image samples as sample labels; Based on the multiple training sample data, the initial face forgery detection model is trained for multiple rounds of iterations using an opposing force mechanism to obtain the target face forgery detection model.
3. The method according to claim 2, characterized in that Get multiple training sample data pairs, including: Obtain multiple real face image samples; For each real face image sample, the pixel values of all pixels in the real face image are set to 0 to obtain a corresponding all-zero Map; a group of training sample data is formed by using the real face image samples and the corresponding all-zero Map as training samples and using the real types of the real face image samples as sample labels; Obtaining a forged face image sample corresponding to each of the real face image samples; For each of the forged face image samples, determine the absolute difference between the pixel value of each pixel point in the real face image sample and the pixel value of each pixel point in the corresponding forged face image sample to obtain a differential image; set the pixel value of the target pixel point in the differential image whose pixel value is less than a preset pixel threshold to 0, and set the pixel values of other pixels in the differential image except the target pixel point to 1 to obtain a corresponding forged area map; form a set of the training sample data using the forged face image samples and the corresponding forged area map as training samples and the forged type of the forged face image samples as sample labels; A group of training sample data is composed of the real face image samples and the corresponding all-zero Map as training samples, and the real types of the real face image samples are used as sample labels. Another group of training sample data is composed of the forged face image samples corresponding to the real face image samples and the corresponding forged area Map as training samples, and the forged types of the forged face image samples are used as sample labels, to obtain a training sample data pair.
4. The method according to claim 3, characterized in that Obtaining a forged face image sample corresponding to each of the real face image samples, including: A preset forging tool is called to perform a forging operation on each of the real face image samples to obtain a forged face image sample corresponding to each of the real face image samples.
5. The method according to claim 3, characterized in that: The process of determining the forged area map also includes: Determining an image size of the differential image, and determining a fine pixel threshold corresponding to the image size; The pixel value of the target pixel point whose pixel value in the differential image is less than the fine pixel threshold is set to 0, and the pixel values of other pixel points in the differential image except the target pixel point are set to 1, so as to obtain the corresponding forged area Map.
6. The method according to claim 3, characterized in that: Based on the plurality of training sample data, the initial face forgery detection model is trained for multiple rounds of iterations using an opposing force mechanism to obtain the target face forgery detection model, including: In each round of iteration, multiple training sample data pairs are loaded into the same small batch, and the training samples in the training sample data pairs in the same small batch are input into the initial face forgery detection model to obtain the prediction labels corresponding to each of the training samples output by the initial face forgery detection model; Constructing a target loss function of the initial face forgery detection model according to the sample labels in the training sample data pairs in the same small batch and the predicted labels corresponding to each of the training samples; The target loss function is optimized using a preset gradient optimization algorithm to adjust the model parameters of the initial face forgery detection model until the model converges to obtain the target face forgery detection model.
7. The method according to claim 6, characterized in that The expression of the target loss function of the initial face forgery detection model is: Where L represents the target loss function, N represents the total number of training sample data pairs in the same small batch, and p ir represents the predicted probability corresponding to the all-zero Map in the i-th training sample data pair, p if represents the predicted probability of the forged region Map in the i-th training sample data pair, P xy represents the value of the predicted forged area Map at (x, y) output by the initial face forgery detection model, M xy represents the value of the map at (x, y) in the training sample, H, W represent the height and width of the face image sample, α, β represent the weighting coefficients, W xy represents the adaptive weight, and W xy =1+γ·|P xy -M xy |, where γ represents a hyperparameter.
8. A forged face image detection device, characterized in that: include: An acquisition module is used to acquire a target face image to be detected; A detection module is used to analyze the target face image using a pre-trained target face forgery detection model to obtain a corresponding detection result, wherein the detection result is used to reflect whether the target face image is a forged face image, and the target face forgery detection model is obtained by using a training sample data pair including a real face image sample and a corresponding forged face image sample, and adopting an opposing force mechanism to train the initial face forgery detection model.
9. A computer program product, characterized in that include: A computer program, wherein when the computer program is executed by a processor, the forged facial image detection method according to any one of claims 1 to 7 is implemented.
10. An electronic device, characterized in that: include: A memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the forged facial image detection method according to any one of claims 1 to 7 through the computer program.
Citation Information
Cited By
Intelligent agent-based counterfeited face detection method and device, equipment, storage medium and product
CN120452075A
Detection reliability determination method and system for image authenticity detection tool, and related equipment
CN121074612A
Image authenticity detection tool detection reliability determination method, system and related devices
CN121074612B
Model training method, forged image detection method and device
CN121767786A
Model training method, fake image detection method and device
CN121767786B