A Face Spoofing Detection Method Based on Watermark Feature Assistance and Cross-Task Distillation

By embedding watermark features into the face forgery detection model and introducing a knowledge distillation mechanism, the problems of insufficient accuracy and generalization ability of existing models in detecting diverse forgery samples are solved, and more efficient forgery detection is achieved.

CN121747207BActive Publication Date: 2026-05-26QILU UNIVERSITY OF TECHNOLOGY (SHANDONG ACADEMY OF SCIENCES)

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
QILU UNIVERSITY OF TECHNOLOGY (SHANDONG ACADEMY OF SCIENCES)
Filing Date
2026-02-28
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

Existing deepfake detection models lack sufficient accuracy and generalization ability when faced with diverse and high-quality forgery samples, and lack effective cross-task knowledge guidance, making it difficult to identify fine-grained tampering traces in deepfakes.

Method used

A face forgery detection method based on watermark feature assistance and cross-task distillation is adopted. By constructing a watermarked image and introducing a knowledge distillation mechanism, fine-grained image feature knowledge is transferred to the forgery detection branch, realizing dual-task collaborative optimization.

Benefits of technology

It improves the accuracy of face forgery detection, enhances the ability to identify highly realistic forged samples, and improves the model's generalization ability and detection accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121747207B_ABST
    Figure CN121747207B_ABST
Patent Text Reader

Abstract

This invention relates to the field of face forgery detection technology, and in particular provides a face forgery detection method based on watermark feature assistance and cross-task distillation. The method includes constructing a dataset of face image samples, embedding watermarks into the preprocessed face image samples to obtain watermarked images; inputting the watermarked images into a jointly trained model with dual-task branches for watermark extraction and forgery detection to obtain fine-grained image feature knowledge; and introducing knowledge distillation to transfer the fine-grained image feature knowledge to the forgery detection branch for dual-task collaborative optimization, thereby detecting face forgery. This method improves the detection accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of face forgery detection technology, and in particular to a face forgery detection method based on watermark feature assistance and cross-task distillation. Background Technology

[0002] With the rapid iteration of deep learning technology, the realism and dissemination range of deepfake content continue to improve, posing a serious challenge to information security and social trust systems. Therefore, efficient and accurate deepfake detection technology has become a research hotspot. However, traditional single-task detection models generally suffer from limitations in feature learning, only able to capture superficial visual differences in fake content. When faced with diverse and high-quality fake samples, their detection accuracy and generalization ability are difficult to meet practical standards.

[0003] While deepfake detection technology has made some progress, the inherent bottlenecks of traditional single-task detection models remain unbroken. Their feature learning is limited to surface-level visual information, only capturing explicit differences in forged content, making it difficult to uncover fine-grained, deep-level tampering traces hidden during the forgery process. This results in poor detection accuracy and generalization ability when faced with diverse, high-quality new forgery samples, failing to meet practical application standards. Furthermore, single-task training lacks effective cross-task knowledge guidance, preventing the model from leveraging feature learning experience from other related tasks to enhance its discrimination capabilities. This leads to insufficient sensitivity to potential tampering traces, hindering high-precision authentication. Existing deepfake detection models based on dual-task collaboration primarily construct a dual-task model for forgery detection and facial attribute recognition, achieving knowledge transfer through shared ResNet feature extractors and weighted fusion of dual-task losses. However, existing solutions have significant shortcomings: low correlation between dual-task features, inability of facial attribute recognition to provide effective feature supplementation for the detection task, lack of a dedicated knowledge transfer mechanism leading to negative transfer, and no design for capturing fine-grained tampering features, resulting in weak generalization ability when facing highly realistic forgery samples. Summary of the Invention

[0004] In view of this, the present invention provides a face forgery detection method based on watermark feature assistance and cross-task distillation to improve the detection accuracy.

[0005] In a first aspect, the present invention provides a face forgery detection method based on watermark feature assistance and cross-task distillation, the method comprising:

[0006] Step 1: Construct a dataset of face image samples and embed watermarks into the preprocessed face image samples to obtain watermarked images;

[0007] Step 2: Input the watermarked image into the jointly trained model with dual tasks of watermark extraction and forgery detection to obtain fine-grained feature knowledge of the image;

[0008] Step 3: Introduce knowledge distillation to transfer fine-grained image feature knowledge to the forgery detection branch for dual-task collaborative optimization to detect face forgery.

[0009] Optionally, step 1 includes:

[0010] A dataset of face image samples was constructed based on the Celeba dataset. 30,000 face images were selected from the Celeba dataset and uniformly cropped to a resolution of 256×256. The dataset was divided into training set, validation set and test set in a 26:2:2 ratio to ensure a uniform distribution of face image samples.

[0011] A joint training model with dual task branches is adopted, which includes a watermarking module; robust watermark embedding based on quaternion radial harmonic Fourier moments (QRHFMs) embeds a 256-bit binary structured watermark into each preprocessed image, as follows:

[0012] Step 11, Polar coordinate transformation and QRHFMs calculation; transform the original image Convert to polar coordinates Calculate its maximum order. Maximum number of repetitions QRHFMs coefficients The formula is:

[0013] ;

[0014] in, Let be the order of the moment. Let be the number of repetitions of the moment. Polar radius Differential elements, Polar angle Differential elements, For a unit pure quaternion, For radial basis functions, For a complex exponential term, The integral symbol is used.

[0015] Step 12, Exact Moment Extraction; from QRHFMs coefficients By selecting coefficients that are not integer multiples of 4, a set of exact moments is constructed. This is used to ensure the stability of the embedded carrier, where , It is a set of integers;

[0016] Step 13: Quantize the embedded watermark; randomly select 256 original moment coefficients from the exact moment set S. , and For coefficient indexing; 256-bit binary structured watermark The coefficient amplitude is embedded in the quantization method, and the formula is:

[0017] ;

[0018] in, The moment coefficients after watermarking are shown. for amplitude, This is the quantization step size, with a value of 0.02. For dot product, For rounding operations, This is the watermark location;

[0019] Step 14, Image Reconstruction; Based on the Original Moment Coefficients and the moment coefficient after embedding watermark Reconstruct the image separately and The watermarked image is obtained by superimposing residuals. The formula is:

[0020] .

[0021] Optionally, step 2 includes:

[0022] The joint training model employs a dual-task branch, which also includes a hybrid attack module, a feature extraction module, a watermark extraction module, and a forgery detection module;

[0023] Step 21: In the hybrid attack module, embed the watermark image. Two types of attacks are applied: common attacks include JPEG compression, salt-and-pepper noise, Gaussian blur, and tone adjustment; deepfake attacks include face swapping, face anonymization, and adding glasses; after applying both types of attacks, a watermarked image is obtained. ;

[0024] Step 22, Feature Extraction Module: VMamba is selected as the feature extraction network to enhance the collaborative capture of local and global features and adapt to face tampering feature detection; input the watermarked image after the attack. The number of channels was adjusted to 64 using a 3×3 convolutional layer to obtain the initial feature map. ;Will Input VMamba network architecture, output enhanced feature map Feature dimensionality reduction, using 1×1 convolution to enhance the feature map. The number of channels was reduced to 256, resulting in the final enhanced feature map. It balances feature representation capability with computational efficiency;

[0025] Step 23: The goal of the watermark extraction module is to provide image clues for the forgery detection branch through the watermark extraction effect. Its structure includes: a) a feature refinement layer, which refines the final enhanced feature map. The number of channels is compressed to 64, resulting in watermark-specific features. b. QRHFMs moment decoding layer, for watermark-specific features Polar coordinate transformation and QRHFMs moment calculation are performed to extract mid-to-high frequency coefficients and map them to a 256-dimensional vector. The predicted watermark value is then obtained by applying the sigmoid activation function. The formula for the activation function sigmoid is:

[0026] ;

[0027] in, x The input to the function is denoted as , and e is the natural constant.

[0028] c. Composite Loss Function: The designed composite loss function ensures accurate extraction of watermarks from real images while completely invalidating watermarks in deepfake images. The formula is:

[0029] ;

[0030] in, This is the result of watermark extraction from a real image. The result of watermark extraction from a Deepfake image. For interval items, This indicates a positive value operation. Denotes the Euclidean norm;

[0031] Step 24: The core objective of the forgery detection module is to identify whether an image is a deepfake attack. Its structure includes: e) a feature adaptation layer, where a 1×1 convolutional layer enhances the final feature map. The number of channels was adjusted to 128 to obtain dedicated detection features. f. Classification head, consisting of two fully connected layers, outputs the predicted label probability of the sample. g. Classification loss: Cross-entropy loss is used to optimize the detection task, and the formula is as follows:

[0032] ;

[0033] in, The loss is the cross-entropy loss, where N is the batch size. For the summation operator, It is the natural logarithm function. For the sample, the true single label is 1 or 0. The detection branch predicts the probability of the i-th sample. .

[0034] Optionally, step 3 includes:

[0035] The core of knowledge distillation is to transfer the fine-grained image feature knowledge learned by the watermark extraction module in the watermark extraction task to the forgery detection module, so as to enhance the forgery detection module’s ability to capture the features of the inherent attributes and tampering traces of the image.

[0036] Step 31: Transfer of knowledge about fine-grained image features;

[0037] To achieve feature alignment, a 1×1 convolutional layer is added after the feature adaptation layer in the forgery detection module to integrate detection-specific features. Dimensionality reduced to 64 channels to obtain adapted features ;

[0038] By constraining with cosine similarity loss, the adapted features of the forgery detection module are... Watermark-specific features of the watermark extraction module Alignment is achieved so that the forgery detection module learns the feature capture logic of the watermark extraction module. The formula is:

[0039] ;

[0040] in, Characteristic distillation loss, The smaller the loss is, the closer the feature representation of the forgery detection module is to that of the watermark extraction module, that is, the fine-grained feature knowledge of the image has been learned.

[0041] Step 32: Consistency constraint of feature structure;

[0042] Watermark-specific features Features after adaptation Each feature is divided into multiple local feature blocks of 3×3 size, denoted as follows: and ;

[0043] The structural consistency of local feature blocks at corresponding locations is constrained by the L2 norm, as shown in the formula:

[0044] ;

[0045] in, The loss is the local structure constraint loss, where K is the total number of local feature blocks. This loss is used to ensure that the features learned by the forgery detection module have both global distribution and local structure effectiveness.

[0046] Optionally, it includes:

[0047] Pre-training strategy for the total loss function: A weighted fusion of the classification loss from the forgery detection module, the composite loss from the watermark extraction module, and the loss from knowledge distillation is used. Based on the collaborative optimization objective of the dual tasks of watermark extraction and forgery detection, the total loss function is constructed, with the following formula:

[0048] ;

[0049] in, Cross-entropy loss; This represents the composite loss of the watermark extraction module; Characteristic distillation loss; This is a loss due to local structural constraints. , , The corresponding weights for the losses are set to 0.6, 0.5, and 0.3, respectively.

[0050] The technical solution provided by this invention includes constructing a dataset of face image samples and embedding watermarks into the preprocessed face image samples to obtain watermarked images; inputting the watermarked images into a jointly trained model with dual-task branches for watermark extraction and forgery detection to obtain fine-grained image feature knowledge; introducing knowledge distillation to transfer the fine-grained image feature knowledge to the forgery detection branch for dual-task collaborative optimization to detect face forgery. This method improves the detection accuracy. Attached Figure Description

[0051] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0052] Figure 1 A flowchart of a face forgery detection method based on watermark feature assistance and cross-task distillation provided in an embodiment of the present invention;

[0053] Figure 2 A flowchart for watermark embedding provided in an embodiment of the present invention;

[0054] Figure 3 This is a schematic diagram of a joint training model with dual task branches provided in an embodiment of the present invention. Detailed Implementation

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

[0056] The terminology used in the embodiments of this invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. The singular forms “a,” “the,” and “the” used in the embodiments of this invention are also intended to include the plural forms unless the context clearly indicates otherwise.

[0057] It should be understood that the term "and / or" used in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.

[0058] Depending on the context, the word "if" as used here can be interpreted as "when," "when," "in response to determination," or "in response to detection." Similarly, depending on the context, the phrase "if determination" or "if detection (of the stated condition or event)" can be interpreted as "when determination," "in response to determination," "when detection (of the stated condition or event)," or "in response to detection (of the stated condition or event)."

[0059] Figure 1 The flowchart of the face forgery detection method based on watermark feature assistance and cross-task distillation provided in the embodiments of the present invention is as follows: Figure 1 As shown, the method includes:

[0060] Step 1: Construct a dataset of face image samples and embed watermarks into the preprocessed face image samples to obtain watermarked images.

[0061] In this embodiment of the invention, step 1 includes:

[0062] A dataset of face image samples was constructed based on the Celeba dataset. This dataset contains 202,599 face images, covering 101 face attributes. The data processing workflow revolves around watermark embedding and attack simulation. The core issue is that the watermark extraction effect differs after an attack; that is, the watermark can be perfectly extracted after a normal attack, but the watermark is destroyed after a deepfake attack. 30,000 face images were selected from the Celeba dataset and uniformly cropped to 256×256 resolution. The images were then divided into training, validation, and test sets in a 26:2:2 ratio to ensure a uniform distribution of face image samples and reduce the impact of background interference on model training.

[0063] A joint training model employing a dual-task branching approach is used, which includes a watermarking module; such as... Figure 2 As shown, robust watermark embedding based on quaternion radial harmonic Fourier moments (QRHFMs) embeds a 256-bit binary structured watermark into each preprocessed image. The embedding process requires no model training, balancing imperceptibility and attack resistance. The process is as follows:

[0064] Step 11, Polar coordinate transformation and QRHFMs calculation; transform the original image Convert to polar coordinates Calculate its maximum order. Maximum number of repetitions QRHFMs coefficients The formula is:

[0065] ;

[0066] in, Let be the order of the moment. Let be the number of repetitions of the moment. Polar radius Differential elements, Polar angle Differential elements, For a unit pure quaternion, For radial basis functions, For a complex exponential term, The integral symbol is used.

[0067] Step 12, Exact Moment Extraction; from QRHFMs coefficients By selecting coefficients that are not integer multiples of 4, a set of exact moments is constructed. This is used to ensure the stability of the embedded carrier, where , It is a set of integers;

[0068] Step 13: Quantize the embedded watermark; randomly select 256 original moment coefficients from the exact moment set S. , and For coefficient indexing; 256-bit binary structured watermark The coefficient amplitude is embedded in the quantization method, and the formula is:

[0069] ;

[0070] in, The moment coefficients after watermarking are shown. for amplitude, This is the quantization step size, with a value of 0.02. For dot product, For rounding operations, This is the watermark location, ensuring that the embedded watermark does not affect the visual quality of the image;

[0071] Step 14, Image Reconstruction; Based on the Original Moment Coefficients and the moment coefficient after embedding watermark Reconstruct the image separately and The watermarked image is obtained by superimposing residuals. The formula is:

[0072] .

[0073] Step 2: Input the watermarked image into the jointly trained model with dual tasks of watermark extraction and forgery detection to obtain fine-grained feature knowledge of the image.

[0074] In this embodiment of the invention, step 2 includes:

[0075] A joint training model employing dual-task branches, such as Figure 3 As shown, it also includes a hybrid attack module, a feature extraction module, a watermark extraction module, and a forgery detection module;

[0076] Step 21: In the hybrid attack module, embed the watermark image. Two types of attacks were applied: standard attacks included JPEG compression (quality factor of 0.7), salt-and-pepper noise (noise density of 0.01), Gaussian blur (3×3 convolution kernel), and tone adjustment; deepfake attacks included face swapping (based on StyleGAN2, face fusion score of 0.9), face anonymization, and adding glasses; after applying both types of attacks, a watermarked image was obtained. ;

[0077] Step 22, Feature Extraction Module: VMamba is selected as the feature extraction network to enhance the collaborative capture of local and global features and adapt to face tampering feature detection; input the watermarked image after the attack. The number of channels was adjusted to 64 using a 3×3 convolutional layer to obtain the initial feature map. ;Will Input VMamba network architecture, output enhanced feature map Feature dimensionality reduction, using 1×1 convolution to enhance the feature map. The number of channels was reduced to 256, resulting in the final enhanced feature map. It balances feature representation capability with computational efficiency;

[0078] Step 23: The goal of the watermark extraction module is to provide image clues for the forgery detection branch through the watermark extraction effect. Its structure includes: a) a feature refinement layer, which refines the final enhanced feature map. The number of channels is compressed to 64, resulting in watermark-specific features. b. QRHFMs moment decoding layer, for watermark-specific features Polar coordinate transformation and QRHFMs moment calculation are performed to extract mid-to-high frequency coefficients and map them to a 256-dimensional vector. The predicted watermark value is then obtained by applying the sigmoid activation function. The formula for the activation function sigmoid is:

[0079] ;

[0080] in, x The input to the function is denoted as , and e is the natural constant.

[0081] c. Composite Loss Function: The designed composite loss function ensures accurate extraction of watermarks from real images while completely invalidating watermarks in deepfake images. The formula is:

[0082] ;

[0083] in, This is the result of watermark extraction from a real image. The result of watermark extraction from a Deepfake image. For interval items, This indicates a positive value operation. Denotes the Euclidean norm;

[0084] Step 24: The core objective of the forgery detection module is to identify whether an image is a deepfake attack. Its structure includes: e) a feature adaptation layer, where a 1×1 convolutional layer enhances the final feature map. The number of channels was adjusted to 128 to obtain dedicated detection features. f. Classification head, consisting of two fully connected layers, outputs the predicted label probability of the sample. g. Classification loss: Cross-entropy loss is used to optimize the detection task, and the formula is as follows:

[0085] ;

[0086] in, The loss is the cross-entropy loss, where N is the batch size. For the summation operator, It is the natural logarithm function. For the sample, the true single label is 1 or 0. The detection branch predicts the probability of the i-th sample. .

[0087] Step 3: Introduce knowledge distillation to transfer fine-grained image feature knowledge to the forgery detection branch for dual-task collaborative optimization to detect face forgery.

[0088] In this embodiment of the invention, step 3 includes:

[0089] The core of knowledge distillation is to transfer the fine-grained image feature knowledge learned by the watermark extraction module in the watermark extraction task to the forgery detection module. This is used to enhance the forgery detection module's ability to capture the features of the inherent attributes of the image and traces of tampering, thereby achieving efficient transfer of cross-task feature knowledge and collaborative optimization between the two tasks.

[0090] Step 31: Image fine-grained feature knowledge transfer; the purpose is to enable the forgery detection branch to learn the pattern of the watermark extraction branch in capturing deep features of the image, master the representation method of mid-to-high frequency fine-grained features, and make up for the feature learning limitations of the single-task model.

[0091] To achieve feature alignment, a 1×1 convolutional layer is added after the feature adaptation layer in the forgery detection module to integrate detection-specific features. Dimensionality reduced to 64 channels to obtain adapted features This ensures that the feature dimensions are consistent and that core information is not lost.

[0092] By constraining with cosine similarity loss, the adapted features of the forgery detection module are... Watermark-specific features of the watermark extraction module Alignment is achieved so that the forgery detection module learns the feature capture logic of the watermark extraction module. The formula is:

[0093] ;

[0094] in, Characteristic distillation loss, The smaller the loss is, the closer the feature representation of the forgery detection module is to that of the watermark extraction module, that is, the fine-grained feature knowledge of the image has been learned.

[0095] Step 32, Feature Structure Consistency Constraint; The purpose is to strengthen the learning of the local structure of features by the forgery detection branch, ensuring that it can not only capture the global feature distribution, but also identify the broken local feature associations in the forged image.

[0096] Watermark-specific features Features after adaptation Each feature is divided into multiple local feature blocks of 3×3 size, denoted as follows: and ;

[0097] The structural consistency of local feature blocks at corresponding locations is constrained by the L2 norm, as shown in the formula:

[0098] ;

[0099] in, The loss is the local structure constraint loss, where K is the total number of local feature blocks. This loss is used to ensure that the features learned by the forgery detection module have both global distribution and local structure effectiveness.

[0100] In this embodiment of the invention, it includes:

[0101] Pre-training strategy for the total loss function: A weighted fusion of the classification loss from the forgery detection module, the composite loss from the watermark extraction module, and the loss from knowledge distillation is used. Based on the collaborative optimization objective of the dual tasks of watermark extraction and forgery detection, the total loss function is constructed, with the following formula:

[0102] ;

[0103] in, Cross-entropy loss; This represents the composite loss of the watermark extraction module; Characteristic distillation loss; This is a loss due to local structural constraints. , , The corresponding weights for the losses are set to 0.6, 0.5, and 0.3, respectively.

[0104] In this embodiment of the invention, the Adam optimizer is selected, and the area under the ROC curve (AUC) and accuracy (ACC) are used as core evaluation metrics to quantify the model's ability to distinguish between real and fake images. The AUC value ranges from [0,1]: AUC=0.5 indicates that the model has no discriminative ability; the closer the AUC is to 1, the stronger the model's ability to distinguish between real and fake images; the closer the AUC is to 0, the weaker the model's discriminative ability. ACC directly reflects the degree of agreement between the model's prediction results and the real labels; the higher the ACC value, the better the model's discriminative performance.

[0105] This invention effectively complements the natural fit between the watermark extraction task's need to capture mid-to-high frequency fine-grained features and the forgery detection task's feature targets. It also innovatively designs a dual-branch fine-grained feature knowledge distillation mechanism, achieving accurate and efficient cross-task knowledge transfer through feature distribution alignment and local structural constraints. Combined with a robust watermark embedding strategy based on QRHFMs orthogonal moments, it balances imperceptibility and attack resistance. Furthermore, it uses a VMamba network as the core feature extractor, and through convolutional layer channel adjustment and dimensionality reduction optimization, it strengthens the collaborative capture of local and global tampering features.

[0106] This invention constructs a joint training model with dual-task branches for deepfake detection and watermark extraction. On the one hand, it transfers the fine-grained image feature knowledge learned from the watermark extraction task to the forgery detection task to help improve detection accuracy. On the other hand, it innovatively introduces a dual-branch fine-grained feature knowledge distillation method to enhance the efficiency of cross-task knowledge transfer and achieve dual-task collaborative optimization. This enables the model to more accurately identify potential tampering traces and further improve detection accuracy, providing a new technical path to address the security challenges brought by the ever-evolving deepfake technology.

[0107] Compared with the prior art, the present invention has the following advantages:

[0108] Firstly, the dual-task collaboration is superior. Watermark extraction is selected as an auxiliary task, and the medium-to-high frequency fine-grained features it needs to capture are highly consistent with the forgery and tampering features. It can provide accurate and effective feature supplementation for the forgery detection task. In contrast, the auxiliary task of the existing technology has low correlation with the detection task features and it is difficult to form a synergistic gain.

[0109] Secondly, the knowledge transfer is precise and efficient. The innovative knowledge distillation mechanism optimizes the knowledge transfer path through a dual-constraint design, effectively avoiding the negative transfer problem that easily occurs in traditional cross-task transfer. Existing technologies lack dedicated transfer mechanisms, resulting in low knowledge transfer efficiency.

[0110] Third, the watermark embedding strategy is robust. Based on QRHFMs, it selects precise moments of a specific order as watermark carriers, taking into account both the imperceptibility of the watermark and its anti-attack capability, and can provide a stable and reliable strong supervision signal for the detection task.

[0111] Fourth, it has a more comprehensive feature capture capability. By using the VMamba network as the core feature extractor, it can enhance the collaborative capture of local and global tampering features. Compared with the feature extraction networks of existing technologies, it is more suitable for the detection needs of face tampering traces.

[0112] Fifth, it has better generalization ability. Through the joint optimization of dual-task collaboration and knowledge distillation, the model can better adapt to diverse forgery attack scenarios and still has stable detection performance for unseen forgery samples, making it more practical.

[0113] The technical solution provided by this invention includes constructing a dataset of face image samples and embedding watermarks into the preprocessed face image samples to obtain watermarked images; inputting the watermarked images into a jointly trained model with dual-task branches for watermark extraction and forgery detection to obtain fine-grained image feature knowledge; introducing knowledge distillation to transfer the fine-grained image feature knowledge to the forgery detection branch for dual-task collaborative optimization to detect face forgery. This method improves the detection accuracy.

[0114] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A face forgery detection method based on watermark feature assistance and cross-task distillation, characterized in that, The method includes: Step 1: Construct a dataset of face image samples and embed watermarks into the preprocessed face image samples to obtain watermarked images; the watermark embedding is based on robust watermark embedding of quaternion radial harmonic Fourier moments (QRHFMs). Step 2: Input the watermarked image into the jointly trained model with dual tasks of watermark extraction and forgery detection to obtain fine-grained feature knowledge of the image; Step 3: Introduce knowledge distillation to transfer fine-grained image feature knowledge to the forgery detection branch for dual-task collaborative optimization to detect face forgery; Step 2 includes: The joint training model employs a dual-task branch, which also includes a hybrid attack module, a feature extraction module, a watermark extraction module, and a forgery detection module; Step 21: In the hybrid attack module, embed the watermark image. Two types of attacks are applied: common attacks include JPEG compression, salt-and-pepper noise, Gaussian blur, and tone adjustment; deepfake attacks include face swapping, face anonymization, and adding glasses. After applying both types of attacks, a watermarked image is obtained. ; Step 22, Feature Extraction Module: VMamba is selected as the feature extraction network to enhance the collaborative capture of local and global features and adapt to face tampering feature detection; input the watermarked image after the attack. The number of channels was adjusted to 64 using a 3×3 convolutional layer to obtain the initial feature map. ;Will Input VMamba network architecture, output enhanced feature map Feature dimensionality reduction, using 1×1 convolution to enhance the feature map. The number of channels was reduced to 256, resulting in the final enhanced feature map. It balances feature representation capability with computational efficiency; Step 23: The goal of the watermark extraction module is to provide image clues for the forgery detection branch through the watermark extraction effect. Its structure includes: a) a feature refinement layer, which refines the final enhanced feature map. The number of channels is compressed to 64, resulting in watermark-specific features. b. QRHFMs moment decoding layer, for watermark-specific features Polar coordinate transformation and QRHFMs moment calculation are performed to extract mid-to-high frequency coefficients and map them to a 256-dimensional vector. The predicted watermark value is then obtained by applying the sigmoid activation function. The formula for the activation function sigmoid is: ; in, x The input to the function is denoted as , and e is the natural constant. c. Composite Loss Function: The designed composite loss function ensures accurate extraction of watermarks from real images while completely invalidating watermarks in deepfake images. The formula is: ; in, This is the result of watermark extraction from a real image. The result of watermark extraction from a Deepfake image. For interval items, This indicates a positive value operation. Denotes the Euclidean norm; Step 24: The core objective of the forgery detection module is to identify whether an image is a deepfake attack. Its structure includes: e) a feature adaptation layer, where a 1×1 convolutional layer enhances the final feature map. The number of channels was adjusted to 128 to obtain dedicated detection features. f. Classification head, consisting of two fully connected layers, outputs the predicted label probability of the sample. g. Classification loss: Cross-entropy loss is used to optimize the detection task, and the formula is as follows: ; in, The loss is the cross-entropy loss, where N is the batch size. For the summation operator, It is the natural logarithm function. For the sample, the true single label is 1 or 0. The detection branch predicts the probability of the i-th sample. .

2. The method according to claim 1, characterized in that, Step 1 includes: A dataset of face image samples was constructed based on the Celeba dataset. 30,000 face images were selected from the Celeba dataset and uniformly cropped to a resolution of 256×256. The dataset was divided into training set, validation set and test set in a 26:2:2 ratio to ensure a uniform distribution of face image samples. Watermarked images are generated using a watermarking module; robust watermarking based on quaternion radial harmonic Fourier moments (QRHFMs) embeds a 256-bit binary structured watermark into each preprocessed image, as follows: Step 11, Polar coordinate transformation and QRHFMs calculation; transform the original image Convert to polar coordinates Calculate its maximum order. Maximum number of repetitions QRHFMs coefficients The formula is: ; in, Let be the order of the moment. Let be the number of repetitions of the moment. Polar radius Differential elements, Polar angle Differential elements, For a unit pure quaternion, For radial basis functions, For a complex exponential term, The integral symbol is used. Step 12, Exact Moment Extraction; from QRHFMs coefficients By selecting coefficients that are not integer multiples of 4, a set of exact moments is constructed. This is used to ensure the stability of the embedded carrier, where , It is a set of integers; Step 13: Quantize the embedded watermark; randomly select 256 original moment coefficients from the exact moment set S. , and For coefficient indexing; 256-bit binary structured watermark The coefficient amplitude is embedded in the quantization method, and the formula is: ; in, The moment coefficients after watermarking are shown. for amplitude, This is the quantization step size, with a value of 0.

02. For dot product, For rounding operations, This is the watermark location; Step 14, Image Reconstruction; Based on the Original Moment Coefficients and the moment coefficient after embedding watermark Reconstruct the image separately and The watermarked image is obtained by superimposing residuals. The formula is: 。 3. The method according to claim 1, characterized in that, Step 3 includes: The core of knowledge distillation is to transfer the fine-grained image feature knowledge learned by the watermark extraction module in the watermark extraction task to the forgery detection module, so as to enhance the forgery detection module’s ability to capture the features of the inherent attributes and tampering traces of the image. Step 31: Transfer of knowledge about fine-grained image features; To achieve feature alignment, a 1×1 convolutional layer is added after the feature adaptation layer in the forgery detection module to integrate detection-specific features. Dimensionality reduced to 64 channels to obtain adapted features ; By constraining with cosine similarity loss, the adapted features of the forgery detection module are... Watermark-specific features of the watermark extraction module Alignment is achieved so that the forgery detection module learns the feature capture logic of the watermark extraction module. The formula is: ; in, Characteristic distillation loss, The smaller the loss is, the closer the feature representation of the forgery detection module is to that of the watermark extraction module, that is, the fine-grained feature knowledge of the image has been learned. Step 32: Consistency constraint of feature structure; Watermark-specific features Features after adaptation Each feature is divided into multiple local feature blocks of 3×3 size, denoted as follows: and ; The structural consistency of local feature blocks at corresponding locations is constrained by the L2 norm, as shown in the formula: ; in, The loss is the local structure constraint loss, where K is the total number of local feature blocks. This loss is used to ensure that the features learned by the forgery detection module have both global distribution and local structure effectiveness.

4. The method according to claim 3, characterized in that, include: Pre-training strategy for the total loss function: A weighted fusion of the classification loss from the forgery detection module, the composite loss from the watermark extraction module, and the loss from knowledge distillation is used. Based on the collaborative optimization objective of the dual tasks of watermark extraction and forgery detection, the total loss function is constructed, with the following formula: ; in, Cross-entropy loss; This represents the composite loss of the watermark extraction module; Characteristic distillation loss; This is a loss due to local structural constraints. , , The corresponding weights for the losses are set to 0.6, 0.5, and 0.3, respectively.