A method for generating image detection based on cross-layer feature aggregation
By using a cross-layer feature aggregation method, a dual-branch detection architecture with spatial semantic and frequency domain enhancements is constructed, which solves the problems of insufficient generalization ability and poor robustness of generated image detection in existing technologies, and achieves higher detection accuracy and stability.
Patent Information
- Application Number
- CN202611257382.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-19
- Publication Date
- 2026-11-24
AI Technical Summary
Existing generated image forgery detection technologies suffer from insufficient generalization ability and poor robustness when faced with unknown generation mechanisms and diverse generation architectures, and fail to fully utilize multi-level and multi-view feature information.
A cross-layer feature aggregation method is adopted, which extracts spatial semantic and frequency domain enhanced features in parallel through a pre-trained visual encoder with frozen parameters. The attention mechanism is used for feature interaction and fusion to construct a dual-branch detection architecture, and feature expression and interaction are performed through a self-attention mechanism.
It improves the generalization performance and robustness of generated image detection, effectively extracts and utilizes multi-level and multi-view discrimination information, and improves the accuracy and stability of detection.
Smart Images

Figure CN123160904A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the technical field of digital image security and forgery detection, specifically relating to a method for generating image detection based on cross-layer feature aggregation. Background Technology
[0002] In recent years, with the development of deep learning technology, generative artificial intelligence models have achieved revolutionary breakthroughs, especially generative algorithms represented by Generative Adversarial Networks (GANs) and Diffusion Models. The images generated by these algorithms have reached a highly human-like level in terms of visual realism and semantic logical coherence. Currently, such generated images have been widely applied in practical fields such as digital content creation, visual art design, film and television special effects production, and internet social media dissemination, greatly enriching the production forms of multimedia content. However, the open-source nature and ease of use of generative technologies have also brought serious information security challenges, such as the frequent occurrence of security incidents involving fake news creation, infringement of portrait rights, and malicious public opinion manipulation. Therefore, forgery detection technology for generated images has become a crucial research direction in the field of deepfake detection, and is of great significance for maintaining a trustworthy ecosystem in cyberspace.
[0003] For the aforementioned generated image detection task, those skilled in the art have conducted extensive research. Existing mainstream detection technologies can be broadly classified into the following three categories, but each type of technology has obvious technical shortcomings and limitations in specific implementation:
[0004] The first category comprises generated image detection methods based on anomalous artifacts. The core idea of this type of method is to actively extract or simulate inherent anomalous artifacts left over from the generation process through preprocessing operations as a criterion for discrimination. For example, the LGrad method in existing technologies extracts image gradient information as a general artifact representation, the DIRE method uses the reconstruction error of a pre-trained diffusion model for identification, and the NPR method captures structural artifacts by analyzing the statistical dependencies between local pixels. However, the generation mechanism of such anomalous artifacts often highly depends on the underlying prior knowledge of a specific generation architecture or a specific image generation mechanism. Once faced with an unknown generator not encountered during the training phase, or when the generation mechanism undergoes cross-model transfer (e.g., from GAN to diffusion model), the artifact features relied upon by this type of method will drift drastically or even disappear, severely limiting its artifact extraction ability and drastically reducing detection performance.
[0005] The second category comprises generative image detection methods based on feature learning. These methods focus on end-to-end feature learning and classification decisions directly from the pixel data of the image to be detected, utilizing deep convolutional neural networks (such as using classic classification network architectures like ResNet-50 as binary discriminators). For example, typical existing techniques like CNNDet directly use classic classification network architectures like ResNet-50 as binary discriminators, while PatchFor and others employ feature learning based on local image patches. Although these methods can achieve high detection accuracy on specific datasets, their discriminative performance is highly dependent on the data distribution of training samples and the shallow discriminative cues mined by the network. Due to the lack of deep modeling of the inherent statistical characteristics of generated images, these models are prone to decision boundary shifts when facing generalization scenarios across generator types or generation paradigms, exhibiting significant performance instability and generalization fragility.
[0006] The third category comprises generative image detection methods based on pre-trained models. These methods leverage large-scale visual models (such as the contrastive language-image pre-trained model CLIP) pre-trained on massive multimodal data to extract high-level semantic features, aiming to improve the generalizability of detection by utilizing the powerful representational capabilities of these large models. However, analysis reveals that existing implementations based on pre-trained models are generally limited to feature analysis from a single spatial perspective, failing to fully utilize the frequency or spatial domain statistical anomaly artifact information contained in the generated images. Furthermore, they typically only rigidly extract the output features of a specific network layer (such as the last layer) in the pre-trained model as the classification basis, ignoring the complementary discriminative information contained between different layers of the visual model (shallow texture layers, mid-level structural layers, and deep semantic layers). This results in a large number of multi-scale hierarchical features sensitive to forgery traces not being effectively mined and fused, thus limiting the upper limit of detection accuracy and the improvement of generalization ability.
[0007] In summary, existing generative image forgery detection technologies generally suffer from common problems such as weak generalization ability, poor robustness, and insufficient utilization of multi-level and multi-view feature fusion when facing complex real-world application environments with unknown generation sources and diverse generation architectures. Therefore, there is an urgent need for a generative image forgery detection scheme that can overcome these shortcomings and possess strong generalization ability and high robustness. Summary of the Invention
[0008] The main objective of this invention is to overcome the shortcomings and deficiencies of the prior art and provide a generative image detection method based on cross-layer feature aggregation, so as to solve the problems of insufficient generalization ability of existing detectors to unknown generation mechanisms, difficulty in learning general features, and poor ability of single spatial semantic representation to characterize fine-grained anomalies.
[0009] To achieve the above objectives, the present invention provides a method for generating image detection based on cross-layer feature aggregation, comprising the following steps:
[0010] The image to be detected is acquired as a spatial domain image; simultaneously, the image to be detected is sequentially converted to grayscale, subjected to discrete cosine transform and frequency band modulation, and then reconstructed and stitched after inverse transform to generate a frequency domain enhanced image.
[0011] Using a pre-trained visual encoder with frozen parameters, multi-layer feature parallel extraction is performed on spatial domain images and frequency domain enhanced images respectively. Multi-layer classification branch features are extracted from multiple selected feature layers to construct the corresponding cross-layer feature sequence.
[0012] Each query vector is taken as the highest-level classification branch feature in the corresponding cross-layer feature sequence, and the corresponding branch-level representation is output through an attention mechanism; the branch-level representation includes spatial semantic branch-level representation and frequency domain enhanced branch-level representation.
[0013] The spatial semantic branch-level representation and the frequency domain enhanced branch-level representation are stacked in dimensions and then interacted and fused through a self-attention mechanism to output a fused feature representation.
[0014] The fused feature representation is input into a single-layer fully connected network, which outputs a binary classification result indicating whether the image to be detected is a real image or a generated image.
[0015] As a preferred technical solution, the frequency domain enhanced image is generated in the following way:
[0016] The image to be detected is converted into a grayscale image, and a two-dimensional discrete cosine transform is applied to obtain the overall frequency domain coefficient matrix;
[0017] The spectrum of the overall frequency domain coefficient matrix is divided into three frequency bands: low frequency, mid frequency, and high frequency using a preset frequency band mask. Learnable frequency modulation weights are applied to each frequency band, and then the spatial domain of the corresponding frequency band is reconstructed through inverse two-dimensional discrete cosine transform.
[0018] The reconstructed spatial domain images of low frequency, mid frequency, and high frequency are stitched together along the channel dimension to generate a three-channel frequency domain enhanced image.
[0019] As a preferred technical solution, the pre-trained visual encoder for freezing parameters constructs the cross-layer feature sequence in the following way:
[0020] The input image is divided into several image patches and mapped to feature sequences;
[0021] After introducing classification features for aggregating global information at the beginning of the feature sequence, the feature sequence is input into the backbone network of the pre-trained visual encoder and encoded layer by layer to obtain the classification branch features of each layer.
[0022] Extract the classification branch features of the corresponding level from multiple selected feature layers, and stack the features to construct a cross-layer feature sequence of the input image.
[0023] As a preferred technical solution, the step of outputting the corresponding branch-level representation through the attention mechanism specifically includes:
[0024] The highest-level classification branch feature in the corresponding cross-layer feature sequence is used as the query vector, and the input cross-layer feature sequence is linearly mapped to generate its corresponding key vector and value vector.
[0025] By calculating the scaled dot product between the query vector and the key vector, the attention weights between the highest-level classification branch features and the classification branch features of each layer are obtained, and the value vectors are weighted and summed to obtain the weighted fusion features.
[0026] The weighted fusion features are processed by layer normalization and adaptively converged to obtain the corresponding branch-level representation.
[0027] As a preferred technical solution, the method for obtaining the fused feature representation is as follows:
[0028] By stacking the spatial semantic branch-level representation and the frequency domain enhanced branch-level representation in terms of dimensions, a dual-branch input sequence is constructed.
[0029] Based on the dual-branch input sequence, a lightweight self-attention interaction mechanism is used to perform linear mapping to generate query vector, key vector and value vector, and then interactive fusion is performed and layer normalization is performed to obtain the dual-branch interaction result.
[0030] The fused feature representation is obtained by mean pooling the results of the two-branch interaction.
[0031] As a preferred technical solution, the method adopts a multi-generator joint training approach, and its training set includes generated image samples constructed based on multiple generation mechanisms;
[0032] During the training process, while keeping the pre-trained visual encoder backbone network parameters frozen, the network parameters are updated using the binary cross-entropy loss function, the calculation formula of which is:
[0033] ,
[0034] Where M represents the batch size during the training phase, y i Let Φ(E) represent the true label of the i-th training sample. i E represents the model output probability corresponding to the i-th training sample; i Let be the fusion feature representation of the i-th training sample.
[0035] As a preferred technical solution, the various generation mechanisms include generative adversarial network mechanisms and diffusion model mechanisms;
[0036] The model outputs the probability as the classification log odds.
[0037] On the other hand, the present invention provides a generated image detection system based on cross-layer feature aggregation, which is applied to the above-mentioned generated image detection method based on cross-layer feature aggregation, including an image processing module, a cross-layer feature construction module, a branch representation module, a feature fusion module, and a classification and determination module;
[0038] The image processing module acquires the image to be detected as a spatial domain image; at the same time, it sequentially performs grayscale conversion, discrete cosine transform and frequency band modulation on the image to be detected, and generates a frequency domain enhanced image through inverse transform recombination and stitching.
[0039] The cross-layer feature construction module uses a pre-trained visual encoder with frozen parameters to perform multi-layer feature parallel extraction on spatial domain images and frequency domain enhanced images respectively, extracts multi-layer classification branch features from multiple selected feature layers, and constructs corresponding cross-layer feature sequences.
[0040] The branch representation module uses the highest-level classification branch feature in the corresponding cross-layer feature sequence as the query vector and outputs the corresponding branch-level representation through an attention mechanism; the branch-level representation includes spatial semantic branch-level representation and frequency domain enhanced branch-level representation.
[0041] The feature fusion module stacks the spatial semantic branch-level representation and the frequency domain enhanced branch-level representation in dimensions, and performs interactive fusion through a self-attention mechanism to output a fused feature representation.
[0042] The classification and determination module inputs the fused feature representation into a single-layer fully connected network and outputs a binary classification result indicating whether the image to be detected is a real image or a generated image.
[0043] In another aspect, an electronic device is provided, comprising:
[0044] At least one processor; and a memory communicatively connected to said at least one processor; wherein,
[0045] The memory stores computer program instructions that can be executed by the at least one processor, which enable the at least one processor to perform the above-described image detection method based on cross-layer feature aggregation.
[0046] On the other hand, a computer-readable storage medium is provided, which stores a program that, when executed by a processor, implements the aforementioned method for generating image detection based on cross-layer feature aggregation.
[0047] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0048] 1. This invention provides a dual-branch detection architecture that combines spatial semantics and frequency domain enhancement. By performing a two-dimensional discrete cosine transform on the image to be detected, and using a preset frequency band mask to perform learnable frequency weight modulation on the divided high-frequency, mid-frequency, and low-frequency components, followed by inverse transform and recombination, the statistical anomaly features in the spectral distribution of the generated image are explicitly extracted. This technique makes frequency domain features and spatial semantic features complementary, effectively improving the model's ability to characterize fine-grained features and hidden anomaly clues in the generated image.
[0049] 2. This invention constructs a cross-layer feature aggregation mechanism. While keeping the parameters of the pre-trained visual encoder network frozen, it extracts classification branch features from multiple network layers of different depths in parallel and uses an attention mechanism to adaptively weight and aggregate the feature sequences from each layer. This technique can fully utilize the complementary discriminative information contained in the pre-trained visual model at the shallow texture, mid-level structure, and deep semantic levels, improving the network's efficiency in extracting and utilizing mechanism-independent discriminative cues.
[0050] 3. In the model training and feature interaction stages, this invention employs a joint training set constructed by mixing generative adversarial networks (GANs) and diffusion model data. Furthermore, a self-attention mechanism is used at the ends of spatial and frequency domain features for dimensional stacking and feature interaction. This joint training and interaction mechanism further decouples feature representations and reduces information redundancy between the two branches. In cross-generator detection scenarios, this invention achieves a detection accuracy of 92.89% on out-of-domain test sets, demonstrating good generalization performance and cross-domain detection stability. Attached Figure Description
[0051] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0052] Figure 1 This is an overall flowchart of a generative image detection method based on cross-layer feature aggregation in an embodiment of the present invention.
[0053] Figure 2 This is a network structure diagram of the pre-trained visual encoder in an embodiment of the present invention.
[0054] Figure 3 This is a schematic diagram of the branch-level representation of the attention mechanism output in an embodiment of the present invention.
[0055] Figure 4This is a schematic diagram of the structure of a generative image detection system based on cross-layer feature aggregation in an embodiment of the present invention.
[0056] Figure 5 This is a schematic diagram of the structure of an electronic device in an embodiment of the present invention. Detailed Implementation
[0057] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of the present application without creative effort are within the scope of protection of the present application.
[0058] In this application, the reference to "embodiment" means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a mutually exclusive, independent, or alternative embodiment. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described in this application can be combined with other embodiments.
[0059] like Figure 1 As shown, this embodiment discloses a generated image detection method based on cross-layer feature aggregation. It extracts information by constructing spatial semantic branches and frequency domain enhancement branches, modeling the input image from different feature perspectives, thus overcoming the shortcomings of a single spatial semantic representation in characterizing fine-grained anomalies in generated images. The specific method of this invention is as follows:
[0060] S1. Obtain the image to be detected as a spatial domain image; simultaneously, perform grayscale conversion, discrete cosine transform, and frequency band modulation on the image to be detected in sequence, and generate a frequency domain enhanced image through inverse transform recombination and splicing.
[0061] Furthermore, after acquiring the image to be detected, it is used as the spatial domain image input to the spatial semantic branch; additionally, the input to the frequency domain enhancement branch is constructed as follows:
[0062] First, the image to be detected is converted to a grayscale image, and a two-dimensional discrete cosine transform (2D-DCT) is applied to obtain the overall frequency domain coefficient matrix: D = DCT(I gray ), where I gray This represents the converted single-channel grayscale image; DCT() represents the two-dimensional discrete cosine transform operation; D represents the obtained global frequency domain coefficient matrix.
[0063] Subsequently, the spectrum of the overall frequency domain coefficient matrix is divided into three frequency bands—low frequency, mid frequency, and high frequency—using a preset frequency band mask. Learnable frequency modulation weights are then applied to each frequency band, and the spatial domain of the corresponding frequency band is reconstructed via inverse two-dimensional discrete cosine transform (2D-DCT). The process is described as follows:
[0064] I k =IDCT(W k (M k D)), k {L,M,H}
[0065] Where k is the frequency band index, representing low frequency (L), medium frequency (M), or high frequency (H); M k W represents the binary frequency mask matrix corresponding to the frequency band. k This represents the learnable frequency modulation weight matrix for the corresponding frequency band; The `IDCT()` method represents the element-wise multiplication of matrices (Hadamard product); it represents the inverse two-dimensional discrete cosine transform operation; I k This represents the reconstructed single-band spatial domain image.
[0066] Finally, the reconstructed spatial data from low-frequency, mid-frequency, and high-frequency frequencies are stitched together with the image along the channel dimension to generate a three-channel frequency-domain enhanced image: x f =Concat(I L ,I M ,I H ), where Concat() represents the concatenation operation along the channel dimension, x f This represents the final generated three-channel frequency domain enhanced image.
[0067] S2. Using a pre-trained visual encoder with frozen parameters, perform multi-layer feature parallel extraction on spatial domain images and frequency domain enhanced images respectively, extract multi-layer classification branch features from multiple selected feature layers, and construct corresponding cross-layer feature sequences.
[0068] Furthermore, taking the input spatial domain image of the spatial semantic branch as an example, the pre-trained visual encoder with frozen parameters constructs its cross-layer feature sequence as follows:
[0069] S2.1 Divide the input spatial domain image into several image patches and map them into feature sequences.
[0070] S2.2 In order to represent the global state of the image uniformly with a single vector, a classification feature (CLS Token) for aggregating global information is introduced at the beginning of the feature sequence. Then, it is input into the backbone network of the pre-trained visual encoder for layer-by-layer encoding to obtain the classification branch features of each layer. During the layer-by-layer encoding process, the classification branch features continuously absorb contextual information, with the shallow layer reflecting fine-grained texture and the deep layer reflecting high-level semantics.
[0071] S2.3 Extract the classification branch features of the corresponding level from multiple selected feature layers, and stack the features to construct the cross-layer feature sequence of the input spatial domain image.
[0072] Let the set of selected feature layers in the backbone network be L = {l1, l2, ..., l...} N}, for any selected feature layer l k Its classification branch features are denoted as Where C represents the number of feature channels, and H is the cross-layer feature sequence of the extracted spatial semantic branch. sp : Similarly, the frequency domain enhanced image is also input into the pre-trained visual encoder with the same freezing parameters, extracting multi-level classification branch features from the same selected feature layer set to construct the corresponding cross-layer feature sequence H. fr : In this embodiment, the pre-trained visual encoder uses CLIP ViT-L / 14, and its backbone network Vision Transformer has the following network structure: Figure 2 As shown, by utilizing the general representation prior knowledge obtained in the open world, the inputs of the above two branches are encoded respectively, thereby extracting stable and complementary multi-layer global semantic representations.
[0073] S3. Using the highest-level classification branch features in the corresponding cross-layer feature sequence as query vectors, output the corresponding branch-level representation through the attention mechanism, including spatial semantic branch-level representation and frequency domain enhanced branch-level representation.
[0074] Furthermore, to break the limitation of using only a single-layer output, such as Figure 3 As shown, this invention proposes a cross-layer feature aggregation mechanism, which enhances the ability to utilize mechanism-independent discriminative cues and the generalization ability across generators by jointly utilizing complementary discriminative information from different level representations. The cross-layer feature sequence H of the frequency domain enhancement branch is used as an example. fr For example, the cross-layer feature aggregation mechanism is as follows:
[0075] S3.1, Cross-layer feature sequence H with frequency domain enhancement branch fr The highest-level classification branch features As the query vector, and by performing a linear mapping on the input cross-layer feature sequence to generate its corresponding key vector and value vector, it is represented as:
[0076] K=H fr W k V=H fr W v ,
[0077] Among them W q W k W v For the learnable parameter matrix, d k This represents the feature dimension after projection.
[0078] S3.2. By calculating the scaled dot product between the query vector and the key vector, the attention weights between the highest-level classification branch features and the classification branch features of each layer are obtained, and the value vectors are weighted and summed to obtain the weighted fusion features:
[0079] ,
[0080] In the formula, Q represents the query vector, K represents the key vector, and V represents the value vector. Represents the transpose of the key vector. is the scaling factor, used to prevent the gradient from vanishing due to excessively large dot products; Softmax() represents the normalization exponential function, used to transform the score into a probability distribution of attention weights that sums to 1.
[0081] S3.3 Finally, the weighted fused features are processed by layer normalization and adaptively converged to obtain the corresponding branch-level representation z. f =LayerNorm(Attention(Q,K,V)) Similarly, the branch-level representation z of spatial semantic branches is obtained. s .
[0082] S4. Stack the spatial semantic branch-level representation and the frequency domain enhanced branch-level representation in dimensions, and then interact and fuse them through a self-attention mechanism to output a fused feature representation.
[0083] Furthermore, since spatial semantics and frequency domain cues differ in their representational forms and discriminative emphases, a self-attention mechanism is used to achieve weighted interaction and complementary modeling of the two types of cues, thereby forming a more unified and discriminative fusion feature. Specifically:
[0084] S4.1, Represent the spatial semantic branch level z s With frequency domain enhancement branch level representation z f Perform dimension stacking to construct a bi-branch input sequence Z=Stack(zs ,z f ) .
[0085] S4.2 Subsequently, based on the dual-branch input sequence Z, a lightweight self-attention interaction mechanism is used to perform linear mapping to generate query vectors, key vectors, and value vectors. After interactive fusion and layer normalization, the dual-branch interaction result Z is obtained. ' The description is as follows:
[0086] , , , ,
[0087] Among them, Q ' K ' V ' These are the query vector, key vector, and value vector generated from the two-branch input sequence, respectively. , , These are the learnable parameter matrices, and LayerNorm() is the layer normalization operation.
[0088] S4.3. Perform mean pooling on the bi-branch interaction results to obtain the fused feature representation. This achieves complementary integration of spatial structure and frequency domain statistical anomaly characteristics.
[0089] S5. Input the fused feature representation into a single-layer fully connected network and output a binary classification result indicating whether the image to be detected is a real image or a generated image.
[0090] Furthermore, the method of this invention employs a multi-generator joint training approach during the training phase, with its training set containing generated image samples constructed based on various different generation mechanisms. When faced with images generated by an unknown generator, this method can concurrently perform spatial semantic feature extraction and frequency domain enhancement feature extraction (obtained through DCT transform, band separation, and IDCT reconstruction). Assuming a batch size of M training samples is given during the training phase, while keeping the parameters of the pre-trained visual encoder backbone network frozen, the network is updated using the binary cross-entropy loss function, the calculation formula of which is:
[0091] ,
[0092] Among them, y i Indicates the first The true label of each training sample, Φ(E) i E represents the model output probability corresponding to the i-th training sample; iThis represents the fused feature representation of the i-th training sample. More specifically, the model output probability is the classification log odds (logits) calculated by a single-layer fully connected network; various generation mechanisms include generative adversarial networks and diffusion models.
[0093] In summary, the detection method provided by this invention compensates for the shortcomings of a single spatial semantic representation in characterizing fine-grained anomalies by constructing a dual branch in both the spatial and frequency domains. At the same time, by combining a cross-layer feature aggregation mechanism with dual-branch adaptive fusion, the model's ability to extract general discriminative clues is improved, thereby achieving more stable generalized detection performance in cross-generator detection scenarios.
[0094] To verify the stability of the method described in this invention, this embodiment uses different methods on a known source test set to verify the stability of the method's detection. The verification metrics are accuracy (ACC) and average precision (AP). The different methods include CNNDet, Patchfor, DIRE, UFD, NPR, and D... 3 And Ours (this method), the known source test set refers to images obtained by known generators (within the domain), including image samples generated by ProGAN, BigGAN, ADM, and LDM. The results are shown in Table 1 below, where bold indicates the best and underline indicates the second best.
[0095] Table 1. ACC and AP results for different methods on known source test sets.
[0096]
[0097] As shown in Table 1, in the evaluation of test sets with known sources, the detection system of this invention achieved an average accuracy (ACC) of 98.93% and an average precision (AP) of 99.96%, both of which are better than the average accuracy and average precision of other methods, indicating that this method has extremely high detection stability when targeting known sources.
[0098] In addition, to verify the generalization detection performance of the method of the present invention when faced with unknown generation mechanisms and complex multi-source data, this embodiment also constructs a cross-generator (outside domain) test set covering various generation architectures, specifically including:
[0099] (1) Unknown Generative Adversarial Network (GAN) test set: contains image samples generated by StyleGAN, StyleGAN2, CycleGAN, StarGAN and GauGAN;
[0100] (2) Unknown diffusion model test set: includes image samples generated by DDPM, IDDPM, GLIDE, VQDM and PNDM;
[0101] (3) Open source test set: includes commercial APIs and complex multi-source models, such as image samples generated by DALLE, DALLE2, Wukong, Midjourney and WhichFacelsReal.
[0102] Based on the multi-generator joint training setting, the accuracy (ACC) and average precision (AP) were used to objectively evaluate the different methods on the three sets of out-of-domain test sets (test sets of unknown sources). The experimental results are shown in Tables 2, 3 and 4 below. In the tables, bold indicates the best and underline indicates the second best.
[0103] Table 2. ACC and AP results of different methods on the unknown GAN test set.
[0104]
[0105] Table 3. ACC and AP results for different methods on the unknown diffusion model test set.
[0106]
[0107] Table 4. ACC and AP results for different methods on the open-source test set.
[0108]
[0109] As shown in the results above, in the evaluation of the unknown GAN test set in Table 2, the average accuracy (ACC) of the detection system of our invention (Ours) reached 97.04%, and the average precision (AP) reached 99.58%; in the evaluation of the unknown diffusion model test set in Table 3, the average accuracy (ACC) of the detection system of our invention (Ours) reached 92.44%, and the average precision (AP) reached 97.87%; in the evaluation of the open source test set in Table 4, the average accuracy (ACC) of the detection system of our invention (Ours) reached 89.21%, and the average precision (AP) reached 97.86%. Based on the above test results, the overall average detection accuracy of our invention on all cross-generator (outside domain) test sets reached 92.89%, demonstrating good generalization detection performance.
[0110] Therefore, this invention successfully extracts and utilizes mechanism-independent general discriminative cues by constructing a dual-branch architecture that runs in both the spatial and frequency domains, supplemented by cross-layer feature aggregation and self-attention fusion mechanisms. This technical solution effectively overcomes the persistent problem of traditional detectors overfitting to a single specific generator (e.g., only to certain GAN artifacts). In multi-generator joint training and complex multi-source testing scenarios, no serious shift in the decision boundary occurs, demonstrating excellent and stable cross-domain detection generalization performance and robustness.
[0111] It should be noted that, for the sake of simplicity, the aforementioned method embodiments are all described as a series of actions. However, those skilled in the art should understand that the present invention is not limited to the described order of actions, because according to the present invention, some steps can be performed in other orders or simultaneously.
[0112] Based on the same idea as the generated image detection method based on cross-layer feature aggregation in the above embodiments, the present invention also provides a generated image detection system based on cross-layer feature aggregation, which can be used to execute the above-described generated image detection method based on cross-layer feature aggregation. For ease of explanation, the schematic diagram of an embodiment of the generated image detection system based on cross-layer feature aggregation only shows the parts related to the embodiments of the present invention. Those skilled in the art will understand that the illustrated structure does not constitute a limitation on the device, and may include more or fewer components than illustrated, or combine certain components, or have different component arrangements.
[0113] like Figure 4 As shown, another embodiment of the present invention provides a generated image detection system based on cross-layer feature aggregation, including an image processing module, a cross-layer feature construction module, a branch representation module, a feature fusion module, and a classification and determination module;
[0114] The image processing module acquires the image to be detected as a spatial domain image; at the same time, it sequentially performs grayscale conversion, discrete cosine transform and frequency band modulation on the image to be detected, and generates a frequency domain enhanced image through inverse transform recombination and stitching.
[0115] The cross-layer feature construction module utilizes a pre-trained visual encoder with frozen parameters to perform multi-layer feature parallel extraction on spatial domain images and frequency domain enhanced images respectively, extracting multi-layer classification branch features from multiple selected feature layers to construct the corresponding cross-layer feature sequence;
[0116] The branch representation module uses the highest-level classification branch feature in the corresponding cross-layer feature sequence as the query vector and outputs the corresponding branch-level representation through the attention mechanism, including spatial semantic branch-level representation and frequency domain enhanced branch-level representation.
[0117] The feature fusion module stacks the spatial semantic branch-level representation and the frequency domain enhanced branch-level representation in terms of dimensions, and performs interactive fusion through a self-attention mechanism to output a fused feature representation;
[0118] The classification and determination module inputs the fused feature representation into a single-layer fully connected network and outputs a binary classification result, determining whether the image to be detected is a real image or a generated image.
[0119] It should be noted that the image detection system based on cross-layer feature aggregation of the present invention corresponds one-to-one with the image detection method based on cross-layer feature aggregation of the present invention. The technical features and beneficial effects described in the embodiment of the image detection method based on cross-layer feature aggregation are applicable to the embodiment of the image detection system based on cross-layer feature aggregation. For details, please refer to the description in the embodiment of the method of the present invention, which will not be repeated here.
[0120] Furthermore, in the above embodiment of a generative image detection system based on cross-layer feature aggregation, the logical division of each program module is merely an example. In actual applications, the above functions can be assigned to different program modules as needed, for example, for the sake of corresponding hardware configuration requirements or the convenience of software implementation. That is, the internal structure of the generative image detection system based on cross-layer feature aggregation can be divided into different program modules to complete all or part of the functions described above.
[0121] Please see Figure 5 In one embodiment, an electronic device is provided for implementing a generative image detection method based on cross-layer feature aggregation. The electronic device may include a first processor, a first memory, and a bus, and may also include a computer program stored in the first memory and executable on the first processor, such as a generative image detection program based on cross-layer feature aggregation.
[0122] The first memory includes at least one type of readable storage medium, such as flash memory, portable hard drive, multimedia card, card-type memory (e.g., SD or DX memory), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the first memory can be an internal storage unit of an electronic device, such as a portable hard drive. In other embodiments, the first memory can be an external storage device of the electronic device, such as a plug-in portable hard drive, Smart Media Card (SMC), Secure Digital (SD) card, Flash Card, etc. Furthermore, the first memory can include both internal and external storage units of the electronic device. The first memory can be used not only to store application software and various types of data installed on the electronic device, such as code for an image detection program based on cross-layer feature aggregation, but also to temporarily store data that has been output or will be output.
[0123] In some embodiments, the first processor may be composed of integrated circuits, such as a single packaged integrated circuit or multiple integrated circuits with the same or different functions, including combinations of one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips. The first processor is the control unit of the electronic device, connecting various components of the entire electronic device through various interfaces and lines. It executes programs or modules stored in the first memory (e.g., image detection programs based on cross-layer feature aggregation) and calls data stored in the first memory to perform various functions of the electronic device and process data.
[0124] Figure 5 Only electronic devices with components are shown; it will be understood by those skilled in the art that... Figure 5 The structure shown does not constitute a limitation on the electronic device and may include fewer or more components than shown, or combine certain components, or have different component arrangements.
[0125] The image detection program based on cross-layer feature aggregation stored in the first memory of the electronic device is a combination of multiple instructions. When run in the first processor, it can achieve the following:
[0126] The image to be detected is acquired as a spatial domain image; simultaneously, the image to be detected is sequentially converted to grayscale, subjected to discrete cosine transform and frequency band modulation, and then reconstructed and stitched to generate a frequency domain enhanced image.
[0127] Using a pre-trained visual encoder with frozen parameters, multi-layer feature parallel extraction is performed on spatial domain images and frequency domain enhanced images respectively. Multi-layer classification branch features are extracted from multiple selected feature layers to construct the corresponding cross-layer feature sequence.
[0128] Each query vector is taken as the highest-level classification branch feature in the corresponding cross-layer feature sequence. The corresponding branch-level representation is output through the attention mechanism, including spatial semantic branch-level representation and frequency domain enhanced branch-level representation.
[0129] The spatial semantic branch-level representation and the frequency domain enhanced branch-level representation are stacked in dimensions and then interacted and fused through a self-attention mechanism to output a fused feature representation.
[0130] The fused feature representation is input into a single-layer fully connected network, which outputs a binary classification result indicating whether the image to be detected is a real image or a generated image.
[0131] Furthermore, if the modules / units integrated in the electronic device are implemented as software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium. The computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, or a read-only memory (ROM).
[0132] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM), etc.
[0133] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0134] The above embodiments are preferred embodiments of the present invention, but the embodiments of the present invention are not limited to the above embodiments. Any changes, modifications, substitutions, combinations, or simplifications made without departing from the spirit and principle of the present invention shall be considered equivalent substitutions and shall be included within the protection scope of the present invention.
Claims
1. A generative image detection method based on cross-layer feature aggregation, characterized in that, Includes the following steps: The image to be detected is acquired as a spatial domain image; simultaneously, the image to be detected is sequentially converted to grayscale, subjected to discrete cosine transform and frequency band modulation, and then reconstructed and stitched after inverse transform to generate a frequency domain enhanced image. Using a pre-trained visual encoder with frozen parameters, multi-layer feature parallel extraction is performed on spatial domain images and frequency domain enhanced images respectively. Multi-layer classification branch features are extracted from multiple selected feature layers to construct the corresponding cross-layer feature sequence. Each query vector is taken as the highest-level classification branch feature in the corresponding cross-layer feature sequence, and the corresponding branch-level representation is output through an attention mechanism; the branch-level representation includes spatial semantic branch-level representation and frequency domain enhanced branch-level representation. The spatial semantic branch-level representation and the frequency domain enhanced branch-level representation are stacked in dimensions and then interacted and fused through a self-attention mechanism to output a fused feature representation. The fused feature representation is input into a single-layer fully connected network, which outputs a binary classification result indicating whether the image to be detected is a real image or a generated image.
2. The image detection method based on cross-layer feature aggregation according to claim 1, characterized in that, The frequency domain enhanced image is generated as follows: The image to be detected is converted into a grayscale image, and a two-dimensional discrete cosine transform is applied to obtain the overall frequency domain coefficient matrix; The spectrum of the overall frequency domain coefficient matrix is divided into three frequency bands: low frequency, mid frequency, and high frequency using a preset frequency band mask. Learnable frequency modulation weights are applied to each frequency band, and then the spatial domain of the corresponding frequency band is reconstructed through inverse two-dimensional discrete cosine transform. The reconstructed spatial domain images of low frequency, mid frequency, and high frequency are stitched together along the channel dimension to generate a three-channel frequency domain enhanced image.
3. The image detection method based on cross-layer feature aggregation according to claim 1, characterized in that, The pre-trained visual encoder for the frozen parameters constructs the cross-layer feature sequence in the following way: The input image is divided into several image patches and mapped to feature sequences; After introducing classification features for aggregating global information at the beginning of the feature sequence, the feature sequence is input into the backbone network of the pre-trained visual encoder and encoded layer by layer to obtain the classification branch features of each layer. Extract the classification branch features of the corresponding level from multiple selected feature layers, and stack the features to construct a cross-layer feature sequence of the input image.
4. The image detection method based on cross-layer feature aggregation according to claim 1, characterized in that, The step of outputting the corresponding branch-level representation through the attention mechanism is specifically as follows: The highest-level classification branch feature in the corresponding cross-layer feature sequence is used as the query vector, and the input cross-layer feature sequence is linearly mapped to generate its corresponding key vector and value vector. By calculating the scaled dot product between the query vector and the key vector, the attention weights between the highest-level classification branch features and the classification branch features of each layer are obtained, and the value vectors are weighted and summed to obtain the weighted fusion features. The weighted fusion features are processed by layer normalization and adaptively converged to obtain the corresponding branch-level representation.
5. The image detection method based on cross-layer feature aggregation according to claim 1, characterized in that, The method for obtaining the fusion feature representation is as follows: By stacking the spatial semantic branch-level representation and the frequency domain enhanced branch-level representation in terms of dimensions, a dual-branch input sequence is constructed. Based on the dual-branch input sequence, a lightweight self-attention interaction mechanism is used to perform linear mapping to generate query vector, key vector and value vector, and then interactive fusion is performed and layer normalization is performed to obtain the dual-branch interaction result. The fused feature representation is obtained by mean pooling the results of the two-branch interaction.
6. The image detection method based on cross-layer feature aggregation according to claim 1, characterized in that, The method employs a multi-generator joint training approach, and its training set contains generated image samples constructed based on multiple generation mechanisms. During the training process, while keeping the pre-trained visual encoder backbone network parameters frozen, the network parameters are updated using the binary cross-entropy loss function, the calculation formula of which is: , Where M represents the batch size during the training phase, y i Let Φ(E) represent the true label of the i-th training sample. i E represents the model output probability corresponding to the i-th training sample; i Let be the fusion feature representation of the i-th training sample.
7. The image detection method based on cross-layer feature aggregation according to claim 6, characterized in that, The various generation mechanisms include generative adversarial network mechanisms and diffusion model mechanisms; The model outputs the probability as the classification log odds.
8. A generative image detection system based on cross-layer feature aggregation, characterized in that, The image generation detection method based on cross-layer feature aggregation as described in any one of claims 1-7 includes an image processing module, a cross-layer feature construction module, a branch representation module, a feature fusion module, and a classification and determination module; The image processing module acquires the image to be detected as a spatial domain image; at the same time, it sequentially performs grayscale conversion, discrete cosine transform and frequency band modulation on the image to be detected, and generates a frequency domain enhanced image through inverse transform recombination and stitching. The cross-layer feature construction module uses a pre-trained visual encoder with frozen parameters to perform multi-layer feature parallel extraction on spatial domain images and frequency domain enhanced images respectively, extracts multi-layer classification branch features from multiple selected feature layers, and constructs corresponding cross-layer feature sequences. The branch representation module uses the highest-level classification branch feature in the corresponding cross-layer feature sequence as the query vector and outputs the corresponding branch-level representation through an attention mechanism; the branch-level representation includes spatial semantic branch-level representation and frequency domain enhanced branch-level representation. The feature fusion module stacks the spatial semantic branch-level representation and the frequency domain enhanced branch-level representation in dimensions, and performs interactive fusion through a self-attention mechanism to output a fused feature representation. The classification and determination module inputs the fused feature representation into a single-layer fully connected network and outputs a binary classification result indicating whether the image to be detected is a real image or a generated image.
9. An electronic device, characterized in that, The electronic device includes: At least one processor; and a memory communicatively connected to said at least one processor; wherein, The memory stores computer program instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform a generative image detection method based on cross-layer feature aggregation as described in any one of claims 1-7.
10. A computer-readable storage medium storing a program, characterized in that, When the program is executed by the processor, it implements the image generation detection method based on cross-layer feature aggregation as described in any one of claims 1-8.
