A face forgery detection method, device, equipment and storage medium
By using the Swin Transformer network and the cross-attention feature fusion module, the problem of insufficient robustness and generality of feature extraction in existing methods is solved, and more efficient face forgery detection performance and generalization ability are achieved.
Patent Information
- Application Number
- CN202311473195.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-07
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2043-11-07
AI Technical Summary
Existing face forgery detection methods, based on convolutional neural networks and Vision Transformers, tend to extract local or global features, respectively, resulting in features that are not robust or universal enough, and the connection and inconsistency between the frequency domain and the spatial domain are not fully utilized.
The Swing Transformer network is used to extract intra-frame inconsistency features from the image to be detected. A cross-attention feature fusion module is designed to fuse inconsistency features between spatial and frequency domain modes. Multi-head self-attention mechanism and patch merging layer are used for feature merging.
It improves the performance and generalization ability of face forgery detection, enabling more comprehensive feature extraction and enhancing the accuracy and adaptability of detection.
Smart Images

Figure CN117523629B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing, and in particular to a method, apparatus, device, and storage medium for detecting face forgery. Background Technology
[0002] In recent years, with the rapid development of deep learning technology, face spoofing techniques have made fake faces increasingly realistic in appearance and expression, making them difficult to distinguish from real faces. Face spoofing detection technology is used to detect synthesized fake faces to avoid a crisis of trust. Face spoofing traces usually manifest as local texture, geometry, and lighting anomalies, leading to a large number of face spoofing detection methods based on Convolutional Neural Networks (CNNs). Early methods utilized intuitive inconsistencies generated during the synthesis process (such as irregular blinking frequencies and inconsistent head poses) for spoofing detection. Recent methods have leveraged deep neural networks to capture high-level features from the spatial domain, achieving excellent performance. While most CNN-based methods achieve significant results, CNNs have relatively weak capabilities in modeling global context and long-range dependencies. To further improve the performance and generalization of spoofing detection, some methods have begun to explore intra-frame inconsistencies. These methods utilize the attention mapping between the self-attention mechanism and patch embedding in Vision Transformers (ViTs) to represent consistency relationships, extracting more global feature representations and achieving satisfactory results.
[0003] In addition, some subtle forgery traces can cause anomalies in the frequency domain. Some methods utilize frequency domain information to capture forgery traces. They typically use Discrete Fourier Transform (DFT), Discrete Cosine Transform (DCT), or Wavelet Transform (WT) to transform the image to the frequency domain.
[0004] However, current face forgery detection methods, whether based on Convolutional Neural Networks (CNNs) or Vision Transformers (ViTs), tend to extract local or global features, respectively. These methods are somewhat one-sided, and the extracted features lack robustness and generality. Furthermore, face forgery detection methods that use the frequency domain as auxiliary information rarely consider the relationship and inconsistencies between the spatial and frequency domains. They typically use simple fusion modules (such as feature concatenation operations or convolutional layers) to fuse the spatial and frequency domains. This simple fusion method fails to fully utilize the correlation between spatial and frequency modalities, resulting in insufficiently generalizable extracted features. Therefore, improving the performance and generality of face forgery detection is a problem that needs to be solved in this field. Summary of the Invention
[0005] In view of this, the purpose of this invention is to provide a method, apparatus, device, and storage medium for face forgery detection. It can utilize the Swing Transformer network to extract intra-frame inconsistency features of the image to be detected, and designs a cross-attention feature fusion module to detect inconsistencies between spatial and frequency domain modes of the image to be detected, thereby improving the performance and generalization ability of face forgery detection. The specific scheme is as follows:
[0006] Firstly, this application provides a method for detecting face forgery, including:
[0007] A frame to be detected is acquired, and the spatial and frequency domain features of the frame to be detected are extracted using a preset Swin Transformer network. The first detection result of the frame to be detected is determined based on the spatial features.
[0008] The spatial domain features and frequency domain features of the frame to be detected are fused using a preset cross-attention feature fusion module to obtain the target features of the frame to be detected;
[0009] Based on the target features, a second detection result of the frame to be detected is determined, and based on the first detection result and the second detection result, a face forgery result of the frame to be detected is determined.
[0010] Optionally, extracting the frequency domain features of the frame to be detected includes:
[0011] Determine the RGB face image corresponding to the frame to be detected, and convert the RGB face image into a grayscale image;
[0012] The grayscale image is converted to the frequency domain using discrete cosine transform to obtain the corresponding frequency domain image, thereby obtaining the frequency domain features of the frame to be detected.
[0013] Optionally, after converting the grayscale image to the frequency domain using discrete cosine transform, the method further includes:
[0014] The target low-frequency information in the frequency domain image is filtered using a high-pass filter function to obtain the frequency domain features of the frame to be detected.
[0015] Optionally, determining the first detection result of the frame to be detected based on the spatial features includes:
[0016] The spatial image corresponding to the frame to be detected is detected by a translation operation based on the self-attention mechanism of the moving window of the preset Swin Transformer network, so as to obtain the local features of the frame to be detected, and the first detection result of the frame to be detected is determined based on the local features.
[0017] Optionally, determining the first detection result of the frame to be detected based on the local features includes:
[0018] The local features are merged using the patch merging layer in the preset Swin Transformer network to obtain the global features of the frame to be detected, and the first detection result of the frame to be detected is determined based on the local features and the global features.
[0019] Optionally, the step of merging the local features using the patch merging layer in the preset Swing Transformer network to obtain the global features of the frame to be detected includes:
[0020] The patch merging layer in the preset Swing Transformer network is used to concatenate the features of neighboring 2×2-sized patches in the local features to generate concatenated features with four times the number of channels.
[0021] By using a preset linear layer, the cascaded features of the four-fold number of channels are reduced to half, so as to obtain the global features of the frame to be detected.
[0022] Optionally, fusing the spatial domain features and the frequency domain features of the frame to be detected includes:
[0023] The spatial domain features and frequency domain features of the frame to be detected are fused based on a multi-head self-attention mechanism.
[0024] Secondly, this application provides a face forgery detection device, comprising:
[0025] The feature extraction module is used to acquire the frame to be detected, extract the spatial and frequency domain features of the frame to be detected using a preset Swin Transformer network, and determine the first detection result of the frame to be detected based on the spatial features.
[0026] The feature fusion module is used to fuse the spatial domain features and the frequency domain features of the frame to be detected using a preset cross-attention feature fusion module to obtain the target features of the frame to be detected.
[0027] The result determination module is used to determine a second detection result of the frame to be detected based on the target features, and to determine the face forgery result of the frame to be detected based on the first detection result and the second detection result.
[0028] Thirdly, this application provides an electronic device, which includes a processor and a memory; wherein the memory is used to store a computer program, which is loaded and executed by the processor to implement the aforementioned face forgery detection method.
[0029] Fourthly, this application provides a computer-readable storage medium for storing a computer program that, when executed by a processor, implements the aforementioned face forgery detection method.
[0030] This application first acquires a frame to be detected, extracts its spatial and frequency domain features using a pre-defined Swin Transformer network, and determines a first detection result based on the spatial features. Then, it fuses the spatial and frequency domain features using a pre-defined cross-attention feature fusion module to obtain the target features of the frame to be detected. A second detection result is determined based on the target features, and a face forgery result is determined based on the first and second detection results. In this way, the Swin Transformer network can be used to extract intra-frame inconsistency features of the image to be detected, and the cross-attention feature fusion module is designed to detect inconsistencies between the spatial and frequency domain modalities of the image to be detected. This avoids the problem of extracting only local or global features, or using simple fusion modules that result in insufficiently generalizable features, thus improving the performance and generalization ability of face forgery detection. Attached Figure Description
[0031] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0032] Figure 1 A flowchart of a face forgery detection method provided in this application;
[0033] Figure 2This application provides a flowchart for face forgery detection based on spatial and frequency domain inconsistencies;
[0034] Figure 3 This application provides a schematic diagram of a cross-attention feature fusion module structure.
[0035] Figure 4 A flowchart of a specific face forgery detection method provided in this application;
[0036] Figure 5 This application provides a schematic diagram of the structure of a face forgery detection device;
[0037] Figure 6 This application provides a structural diagram of an electronic device. Detailed Implementation
[0038] 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, and 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.
[0039] Face forgery detection technology is used to detect synthetic fake faces. Current methods, whether based on convolutional neural networks or Vision Transformers, tend to extract local or global features, resulting in features that are not robust or generalizable. Furthermore, face forgery detection methods that use the frequency domain as auxiliary information rarely consider the relationship and inconsistencies between the spatial and frequency domains. The simple fusion modules used to fuse the spatial and frequency domains often fail to fully utilize the correlation between spatial and frequency modalities, leading to insufficiently generalizable extracted features. This application, however, utilizes the Swing Transformer network to extract intra-frame inconsistency features from the image to be detected and designs a cross-attention feature fusion module to detect inconsistencies between the spatial and frequency modalities of the image, thus improving the performance and generalization ability of face forgery detection.
[0040] See Figure 1 As shown, this embodiment of the invention discloses a method for detecting face forgery, including:
[0041] Step S11: Obtain the frame to be detected, extract the spatial and frequency domain features of the frame to be detected using a preset Swin Transformer network, and determine the first detection result of the frame to be detected based on the spatial features.
[0042] In this embodiment, the frame to be detected is first acquired, and its spatial and frequency domain features are extracted using a preset Swin Transformer network. The first detection result of the frame is then determined based on the spatial features. When extracting the frequency domain features of the frame to be detected, the corresponding RGB face image is first determined, and the RGB (Red, Green, Blue) face image is converted to a grayscale image. Then, a discrete cosine transform is used to convert the grayscale image to the frequency domain to obtain the corresponding frequency domain image, thus obtaining the frequency domain features of the frame to be detected. Furthermore, after converting the grayscale image to the frequency domain using the discrete cosine transform, a high-pass filter function is used to filter the target low-frequency information in the frequency domain image to obtain the frequency domain features of the frame to be detected.
[0043] It is understandable that, such as Figure 2 As shown, this embodiment uses Discrete Cosine Transform (DCT) to extract frequency cues. Other feature extraction methods can also be selected based on the actual situation when extracting image frequency features. Assume the input RGB face image is represented as... Where H and W represent the height and width of the face image, respectively. First, convert x1 to a grayscale image:
[0044]
[0045] in G represents grayscale image transformation. Next, DCT is used to transform it from the spatial domain to the frequency domain:
[0046]
[0047] Where D represents the DCT operation. Then, low-frequency information is filtered out to amplify the subtle artifacts at high frequencies, achieved through a high-pass filter operation:
[0048]
[0049] Where F represents the high-pass filter function, and the parameter α is used to control the filtering of low-frequency components. Specifically, in this embodiment, F filters low-frequency components within a triangular region of length α. The top left corner is set to 0.
[0050] Finally, by performing the inverse DCT transform D -1 Will Reverse the color space back to RGB to ensure that the artifact positions in the spatial and frequency domains correspond. Based on the above steps, the entire process can be summarized as follows:
[0051] x2=D -1 (F(D(G(x1)),α));
[0052] in This represents the frequency domain image. In this way, the frequency domain features of the frame to be detected can be extracted. Then, based on the spatial domain features and the aforementioned frequency domain features, the first detection result of the frame to be detected is determined.
[0053] Step S12: Use a preset cross-attention feature fusion module to fuse the spatial domain features and frequency domain features of the frame to be detected to obtain the target features of the frame to be detected.
[0054] In this embodiment, a preset cross-attention feature fusion module is used to fuse the spatial and frequency domain features of the frame to be detected based on a multi-head self-attention mechanism to obtain the target features of the frame. It is understandable that for forged images, spatial information is very useful for locating abnormal textures, while frequency information helps to amplify small artifacts. Therefore, as... Figure 3 As shown, this embodiment introduces multiple spatial and frequency domain cross-attention feature fusion modules in the backbone network to utilize the inconsistency between the two modalities, thereby improving the quality of feature extraction and effectively fusing the two types of information to achieve a more comprehensive feature representation.
[0055] like Figure 3 The cross-attention feature fusion module shown above, for the spatial domain feature F1 and frequency domain feature F2 extracted by the Swing Transformer module, where H, W, and D represent height, width, and feature dimension, respectively. This embodiment uses cross-attention to fuse F1 and F2. F1 fuses the information from F2 by linearly projecting F1 to obtain q, and then linearly projecting F2 to obtain k and v. Conversely, F2 fuses the information from F1 in the same way. To achieve parallel computation of the cross-fusion process of F1 and F2, F1 and F2 are concatenated. The specific calculation formula is shown below:
[0056] q=LN([F1,F2])W q ;
[0057] k = LN([F2,F1])W k ;
[0058] v = LN([F2,F1])W v ;
[0059] [F1,F2]′=MSA(q,k,v)+[F1,F2];
[0060] [F1,F2] o =MLP(LN([F1,F2]′)+[F1,F2]′;
[0061] In this implementation, LN represents a Layer Normalization (LN) layer, MSA (multi-head self-attention) represents standard multi-head self-attention, and MLP (multi-layer perceptron) represents a multilayer perceptron. Thus, this embodiment uses frequency as supplementary information and develops a cross-attention feature fusion module to discover inconsistencies between the spatial and frequency domain modalities. This module provides complementary information based on these inconsistencies, allowing for full interaction of information from both modalities to extract more general features.
[0062] Step S13: Determine the second detection result of the frame to be detected based on the target features, and determine the face forgery result of the frame to be detected based on the first detection result and the second detection result.
[0063] In this embodiment, a second detection result is determined based on the above target features to identify inconsistencies between representation modalities of the frame to be detected, and a face forgery result of the frame to be detected is determined based on the first and second detection results.
[0064] Through the above technical solution, this embodiment obtains a frame to be detected, extracts its spatial and frequency domain features using a preset Swin Transformer network, and determines a first detection result based on the spatial features. A preset cross-attention feature fusion module fuses the spatial and frequency domain features of the frame to be detected to obtain the target features. A second detection result is determined based on the target features, and a face forgery result is determined based on the first and second detection results. Figure 2 As shown, this embodiment employs a dual-stream architecture for face forgery detection. The Swing Transformer is used to extract spatial and frequency domain features separately, and a cross-attention mechanism is used to fuse the information from these two modalities to detect intra-frame inconsistencies and inter-modal inconsistencies. In this way, the Swing Transformer network can be used to extract intra-frame inconsistency features of the image to be detected, and a cross-attention feature fusion module is designed to detect inter-modal inconsistencies in the spatial and frequency domains of the image to be detected, thus improving the performance and generalization ability of face forgery detection.
[0065] Based on the previous embodiment, this application can utilize the Swing Transformer network to extract intra-frame inconsistency features of the image to be detected, and determine the inconsistency features between spatial and frequency domain modes. Next, this embodiment will elaborate on the detection of intra-frame spatial features. See [link to documentation]. Figure 4 As shown, this embodiment of the invention discloses a specific method for detecting face forgery, including:
[0066] Step S21: Obtain the frame to be detected, extract the spatial and frequency features of the frame to be detected using a preset Swin Transformer network, and detect the spatial image corresponding to the frame to be detected by translation operation based on the moving window self-attention mechanism of the preset Swin Transformer network to obtain the local features of the frame to be detected.
[0067] In this embodiment, a frame to be detected is acquired, and its spatial and frequency domain features are extracted using a preset Swing Transformer network. The spatial image corresponding to the frame is detected through a translation operation based on the moving window self-attention mechanism of the preset Swing Transformer network, thus obtaining the local features of the frame. It can be understood that this embodiment utilizes the window-based self-attention mechanism and hierarchical structure of the Swing Transformer to capture inconsistencies between different spatial locations and different levels. It mainly includes two structures: a Swing Transformer block and a patchmerizing layer. The Swing Transformer block employs a shifted window self-attention mechanism, applying a local window to the feature map and using a translation operation to ensure the window covers the entire feature map. This mechanism can learn more representative intra-frame inconsistencies. The calculation formula for the Swing Transformer block for the input feature F is as follows:
[0068] q=LN(F)W q ;
[0069] k=LN(F)W k ;
[0070] v=LN(F)W v ;
[0071] F′=(S)W-MSA(q,k,v)+F;
[0072] F o =MLP(LN(F′)+F′);
[0073] Where LN represents the layer normalization layer, W q W k W v It is the parameter matrix of linear projection, W-MSA and SW-MSA represent multi-head self-attention using regular windows and translation windows, respectively, and MLP represents multilayer perceptron.
[0074] Step S22: Use the patch merging layer in the preset Swing Transformer network to merge the local features to obtain the global features of the frame to be detected, and determine the first detection result of the frame to be detected based on the local features and the global features.
[0075] In this embodiment, the patch merging layer in a pre-defined Swin Transformer network concatenates features from neighboring 2×2-sized local patches to generate concatenated features with four times the number of channels. A pre-defined linear layer then reduces this concatenated feature count to half, yielding the global features of the frame to be detected. The first detection result for the frame is then determined based on both the local and global features. It should be noted that, to generate a hierarchical representation, as the network deepens, the patch merging layer in this embodiment merges the extracted local features to obtain a more global feature representation. Specifically, the features of each group of 2×2 neighboring patches can be concatenated to form a concatenated feature count with four times the number of channels. A linear layer is then applied to reduce the number of channels to half, thus merging small blocks into larger blocks. The specific dimensions of the feature merging can be adjusted according to the actual situation. In this way, combined with the window self-attention mechanism, the network can simultaneously capture local details and global context.
[0076] Step S23: Determine the second detection result of the frame to be detected based on the target features, and determine the face forgery result of the frame to be detected based on the first detection result and the second detection result.
[0077] For a more detailed explanation of step S23, please refer to the relevant content disclosed in the foregoing embodiments, which will not be repeated here.
[0078] In this embodiment, a frame to be detected is acquired, and its spatial and frequency domain features are extracted using a preset Swing Transformer network. The spatial image corresponding to the frame is detected through a translation operation based on the moving window self-attention mechanism of the preset Swing Transformer network to obtain local features of the frame. The local features are then merged using a patch merging layer in the preset Swing Transformer network to obtain global features of the frame. A first detection result for the frame is determined based on the local and global features. A second detection result is determined based on target features, and a face forgery result is determined based on the first and second detection results. Thus, in conjunction with the above embodiments, this application utilizes intra-frame inconsistencies and inconsistencies between spatial and frequency modalities for face detection. The capabilities of the Swing Transformer can be used to effectively extract intra-frame inconsistencies; the window-based self-attention mechanism and hierarchical structure of the Swing Transformer can simultaneously model both local and global features. Meanwhile, frequency is used as supplementary information, and a cross-attention feature fusion module is developed to discover inconsistencies between the spatial and frequency domain modalities. This module provides complementary information based on the inconsistencies between the modalities, and can fully interact the information of the two modalities to extract more general features, which is beneficial to improving the performance and generalization ability of face forgery detection.
[0079] See Figure 5 As shown in the illustration, this application also discloses a face forgery detection device, comprising:
[0080] The feature extraction module 11 is used to acquire the frame to be detected, extract the spatial and frequency domain features of the frame to be detected using a preset Swing Transformer network, and determine the first detection result of the frame to be detected based on the spatial features.
[0081] Feature fusion module 12 is used to fuse the spatial features and frequency features of the frame to be detected using a preset cross-attention feature fusion module to obtain the target features of the frame to be detected;
[0082] The result determination module 13 is used to determine the second detection result of the frame to be detected based on the target features, and to determine the face forgery result of the frame to be detected based on the first detection result and the second detection result.
[0083] In this embodiment, the frame to be detected is first acquired, and its spatial and frequency domain features are extracted using a preset Swin Transformer network. A first detection result is determined based on the spatial features. Then, a preset cross-attention feature fusion module is used to fuse the spatial and frequency domain features of the frame to obtain the target features. A second detection result is determined based on the target features, and the face forgery result is determined based on both the first and second detection results. This approach allows the Swin Transformer network to extract intra-frame inconsistency features of the image to be detected, and the cross-attention feature fusion module detects inconsistencies between the spatial and frequency domain modalities of the image. This avoids the problem of extracting only local or global features, or using simple fusion modules that result in insufficient feature generality, thus improving the performance and generalization ability of face forgery detection.
[0084] In some specific embodiments, the feature extraction module 11 specifically includes:
[0085] An image conversion unit is used to determine the RGB face image corresponding to the frame to be detected and convert the RGB face image into a grayscale image;
[0086] The frequency domain feature extraction submodule is used to convert the grayscale image to the frequency domain using discrete cosine transform to obtain the corresponding frequency domain image, so as to obtain the frequency domain features of the frame to be detected.
[0087] In some specific embodiments, the frequency domain feature extraction submodule further includes:
[0088] The information filtering unit is used to filter the target low-frequency information in the frequency domain image using a high-pass filter function to obtain the frequency domain features of the frame to be detected.
[0089] In some specific embodiments, the feature extraction module 11 specifically includes:
[0090] The first detection result determination submodule is used to detect the spatial image corresponding to the frame to be detected by means of translation operation based on the self-attention mechanism of the moving window of the preset Swing Transformer network, so as to obtain the local features of the frame to be detected, and determine the first detection result of the frame to be detected based on the local features.
[0091] In some specific embodiments, the first detection result determination submodule specifically includes:
[0092] The feature merging unit is used to merge the local features using the patch merging layer in the preset Swin Transformer network to obtain the global features of the frame to be detected, and to determine the first detection result of the frame to be detected based on the local features and the global features.
[0093] In some specific embodiments, the feature merging unit specifically includes:
[0094] The feature concatenation subunit is used to concatenate the features of neighboring 2×2-sized patches in the local features using the patch merging layer in the preset Swin Transformer network to generate concatenated features with four times the number of channels.
[0095] The global feature determination subunit is used to reduce the cascaded features of the four-fold number of channels to twice the number using a preset linear layer, so as to obtain the global features of the frame to be detected.
[0096] In some specific embodiments, the feature fusion module 12 specifically includes:
[0097] The feature fusion unit is used to fuse the spatial domain features and the frequency domain features of the frame to be detected based on a multi-head self-attention mechanism.
[0098] Furthermore, embodiments of this application also disclose an electronic device, Figure 6 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application.
[0099] Figure 6 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of this application. Specifically, the electronic device 20 may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the face forgery detection method disclosed in any of the foregoing embodiments. Alternatively, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0100] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0101] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0102] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the face spoofing detection method executed by the electronic device 20 as disclosed in any of the foregoing embodiments, the computer program 222 may further include computer programs capable of performing other specific tasks.
[0103] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned disclosed face forgery detection method. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.
[0104] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0105] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0106] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0107] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0108] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for detecting face forgery, characterized in that, include: A frame to be detected is acquired, and the spatial and frequency domain features of the frame to be detected are extracted using a preset Swin Transformer network. The first detection result of the frame to be detected is determined based on the spatial features. The spatial domain features and frequency domain features of the frame to be detected are fused using a preset cross-attention feature fusion module to obtain the target features of the frame to be detected; Based on the target features, a second detection result of the frame to be detected is determined, and based on the first detection result and the second detection result, a face forgery result of the frame to be detected is determined; The process of fusing the spatial domain features and the frequency domain features of the frame to be detected includes: The query is obtained by linearly projecting the spatial features. The frequency domain features are linearly projected to obtain the key. Sum ; And, the query is obtained by linearly projecting the frequency domain features. The spatial features are linearly projected to obtain the key. Sum .
2. The face forgery detection method according to claim 1, characterized in that, Extracting the frequency domain features of the frame to be detected includes: Determine the RGB face image corresponding to the frame to be detected, and convert the RGB face image into a grayscale image; The grayscale image is converted to the frequency domain using discrete cosine transform to obtain the corresponding frequency domain image, thereby obtaining the frequency domain features of the frame to be detected.
3. The face forgery detection method according to claim 2, characterized in that, After converting the grayscale image to the frequency domain using discrete cosine transform, the process further includes: The target low-frequency information in the frequency domain image is filtered using a high-pass filter function to obtain the frequency domain features of the frame to be detected.
4. The face forgery detection method according to claim 1, characterized in that, The determination of the first detection result of the frame to be detected based on the spatial features includes: The spatial image corresponding to the frame to be detected is detected by a translation operation based on the self-attention mechanism of the moving window of the preset Swin Transformer network, so as to obtain the local features of the frame to be detected, and the first detection result of the frame to be detected is determined based on the local features.
5. The face forgery detection method according to claim 4, characterized in that, The step of determining the first detection result of the frame to be detected based on the local features includes: The local features are merged using the patch merging layer in the preset Swin Transformer network to obtain the global features of the frame to be detected, and the first detection result of the frame to be detected is determined based on the local features and the global features.
6. The face forgery detection method according to claim 5, characterized in that, The step of merging the local features using the patch merging layer in the preset SwinTransformer network to obtain the global features of the frame to be detected includes: The patch merging layer in the preset Swing Transformer network is used to concatenate the features of neighboring 2×2-sized patches in the local features to generate concatenated features with four times the number of channels. By using a preset linear layer, the cascaded features of the four-fold number of channels are reduced to half, so as to obtain the global features of the frame to be detected.
7. The face forgery detection method according to any one of claims 1 to 6, characterized in that, The fusion of the spatial domain features and the frequency domain features of the frame to be detected includes: The spatial domain features and frequency domain features of the frame to be detected are fused based on a multi-head self-attention mechanism.
8. A face forgery detection device, characterized in that, include: The feature extraction module is used to acquire the frame to be detected, extract the spatial and frequency domain features of the frame to be detected using a preset Swin Transformer network, and determine the first detection result of the frame to be detected based on the spatial features. The feature fusion module is used to fuse the spatial domain features and the frequency domain features of the frame to be detected using a preset cross-attention feature fusion module to obtain the target features of the frame to be detected. The result determination module is used to determine a second detection result of the frame to be detected based on the target features, and to determine the face forgery result of the frame to be detected based on the first detection result and the second detection result; Specifically, the feature fusion module is used for: The query is obtained by linearly projecting the spatial features. The frequency domain features are linearly projected to obtain the key. Sum ; And, the query is obtained by linearly projecting the frequency domain features. The spatial features are linearly projected to obtain the key. Sum .
9. An electronic device, characterized in that, The electronic device includes a processor and a memory; wherein the memory is used to store a computer program, which is loaded and executed by the processor to implement the face forgery detection method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, Used to store a computer program, which, when executed by a processor, implements the face forgery detection method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Deep fake face data identification method
CN113536990A
Face image detection method and device, electronic equipment, and storage medium
CN114078274A
Optical fiber end face detection device and method and optical fiber end face detection model training method
CN115797746A
