AI generated image detection method and device, equipment and medium
By combining discrete wavelet transform and high-resolution backbone network with supervised contrastive loss and cross-entropy classification loss, the problems of high-frequency artifact loss and feature entanglement in AI-generated image detection are solved, and efficient image detection is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-10
- Publication Date
- 2026-03-13
AI Technical Summary
Existing AI-generated image detection methods struggle to capture subtle artifacts and sharp features in generated images, resulting in low detection accuracy. Furthermore, methods based on advanced semantic features are computationally expensive and prone to overfitting.
Discrete wavelet transform is used to construct an energy map, and high-frequency regions are adaptively selected. Multi-resolution feature extraction is performed by combining a high-resolution backbone network, and the discriminative and contrastive features are jointly optimized by supervised contrastive loss and cross-entropy classification loss.
It effectively preserves high-frequency artifact information, improves detection accuracy and stability, enhances cross-model generalization ability, and maintains good detection performance under unseen generative models.
Smart Images

Figure CN121660894A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of artificial intelligence image processing and cyberspace security technology, and in particular to an AI-generated image detection method, apparatus, device, and medium. Background Technology
[0002] In recent years, with the rapid iteration of generative technologies such as Generative Adversarial Networks (GANs) and Diffusion Models, artificial intelligence image generation technology has made significant progress. With the emergence of high-quality generative models such as Stable Diffusion, GPT, and Qwen-Image, AI image generation is not only becoming increasingly realistic in its output, but its usage threshold is also continuously decreasing, leading to the rapid popularization of related technologies in various application scenarios. However, the misuse of AI-generated images has also brought serious security risks, with increasing potential risks in areas such as the spread of false information, online fraud, and manipulation of public opinion, posing a serious threat to social stability and the security of people's property and information. Therefore, how to effectively distinguish between real images and AI-generated images has become a crucial issue that urgently needs to be addressed in the field of cyberspace security.
[0003] Currently, AI-generated image detection methods can be divided into detection methods based on low-level pixel features and detection methods based on high-level semantic features. Detection methods based on low-level pixel features determine authenticity by analyzing statistical differences (such as artifacts, textures, and spectral features) in the pixel layer or frequency domain. However, these methods usually rely on downsampling preprocessing or dimensionality reduction operations within the network, which can lead to the loss of high-frequency details and make it difficult to capture subtle artifacts in the generated image. Detection methods based on high-level semantic features extract semantic features through pre-trained large-scale visual models and use classifiers to determine authenticity. However, these methods rely solely on classification loss optimization, which can easily lead to overfitting and feature entanglement, making it difficult to capture clear features in the generated image.
[0004] Therefore, current AI-generated image detection methods have the problem of failing to capture subtle artifacts and clear features in generated images, resulting in low accuracy when judging the images to be detected. Summary of the Invention
[0005] This invention provides an AI-generated image detection method, apparatus, device, and medium, which can solve the problems existing in the prior art.
[0006] This invention provides an AI-generated image detection method, comprising the following steps: Acquire sample images; The sample image is subjected to Discrete Wavelet Transform (DWT) using the wavelet transform module to extract the high-frequency subbands of the sample image and generate an energy map of the sample image; the region with the highest cumulative energy value on the energy map is selected as the target image patch. The high-resolution backbone network HRB is used to extract features from the target image patch at different resolution scales to obtain features of different resolutions. The features of different resolutions are then stitched together and fused into high-resolution features that preserve high-frequency artifact information. A linear layer is used to linearly process high-resolution features to obtain discriminative feature vectors, and the high-resolution features are standardized to obtain contrast feature vectors. Supervised contrastive loss and cross-entropy classification loss are used to jointly optimize the detection model formed by wavelet transform module, high-resolution backbone network HRB and linear layer cascade. In the optimization process, cross-entropy classification loss is used to optimize the discriminative feature vectors, and supervised contrastive loss is used to optimize the contrast feature vectors to obtain the optimized detection model. The optimized detection model is used to obtain the discrimination result vector of the image to be detected. Based on the discrimination result vector, the softmax function is used to obtain the probability value of the image to be detected as a real generated image. The probability value is used to detect whether the image to be detected is an AI generated image.
[0007] Preferably, the construction of the energy map includes: Acquire sample images , Indicates the height of the image. This indicates the width of the image; 3 indicates that the image has three channels: RGB. Perform Discrete Wavelet Transform (DWT) decomposition on the sample image to obtain sub-bands. Among them, high-frequency subband The energy map E is used to construct the energy map, and the energy map E is calculated as follows: ; in: This indicates the high-frequency subband of the input image after discrete wavelet transform. Upper passage The coefficient value at that location, Indicates the energy map at location The energy value at that location.
[0008] Preferably, obtaining the target image patch includes: On the energy map E, search for the region with the highest energy accumulation value using a sliding window, and then crop the region with the highest energy accumulation value as a patch for the target image. ; The coordinates of the top left corner of the target image patch are represented as follows: ; in: This represents the coordinates of the top-left corner of the region where the total energy is maximized; The width and height of the energy map are respectively used; a target image patch P with a size of 256×256×3 is obtained.
[0009] Preferably, the acquisition of the high-resolution features includes: The target image patch P is input into the high-resolution backbone network (HRB) to extract high-resolution features. During feature extraction, the HRB transforms the input patch P into three resolution branches, each corresponding to a different resolution. , and Feature representation, obtaining features at different resolutions; The fusion of features at different resolutions across scales is represented as: ; in: Indicates the first Features of each resolution branch; Indicates branching Feature alignment to branch Spatial resolution operations; Indicates feature concatenation operation; This represents a one-dimensional convolution operation; Indicates the activation function; After the fusion layer, a feature vector with dimensions of 512×64×64 is obtained, and then a high-resolution feature of 512×1 is obtained through average pooling.
[0010] Preferably, obtaining the discrimination result vector includes: The high-resolution features are normalized through a single layer to obtain a contrastive feature vector of size 512×1 for contrastive learning; the high-resolution features are then processed through a linear layer to obtain a discriminative feature vector of size 2×1 for discrimination. The contrastive feature vector is optimized using supervised contrastive loss, as follows: ; in: Represents sample image The embedding vector; Represents sample image The set of positive samples; Indicates the image excluding the sample within the batch. The set of all sample images outside; Indicates temperature parameter; Simultaneously, the cross-entropy classification loss is used to optimize the discriminative feature vector, expressed as: ; in: Indicates the first The true label of each sample image; This indicates the probability that the model predicts the sample image to be a generated image; Indicates the total number of sample images; Furthermore, spatial features are jointly optimized based on supervised contrastive loss and cross-entropy classification loss, expressed as: ; in: and This represents the balancing parameter, used to control the weights of classification loss and contrastive loss; After joint optimization is completed, the linear layer outputs the discrimination result vector.
[0011] Preferably, detecting whether the image to be detected is an AI-generated image includes: The probability value that the image to be detected is a real generated image is calculated using the softmax function, and is expressed as: ; in: Represents the linear layer of the classifier for each category. The output score; Indicates that the input image belongs to a category. The predicted probability, and satisfying Among them, categories Represents real images, categories This means that the AI generates the image and uses the class with the highest probability as the final detection result. Specifically, for the output discrimination result vector of size 2×1, the two values correspond to the output scores of categories 0 and 1, respectively.
[0012] This invention also provides an AI-generated image detection device, comprising: The acquisition module is used to acquire sample images; The feature extraction module is used to perform Discrete Wavelet Transform (DWT) on the sample image using the wavelet transform module to extract the high-frequency subbands of the sample image to generate an energy map of the sample image; the region with the highest cumulative energy value on the energy map is selected as the target image patch; The high-resolution backbone network HRB is used to extract features from the target image patch at different resolution scales to obtain features of different resolutions. The features of different resolutions are then stitched together and fused into high-resolution features that preserve high-frequency artifact information. The optimization module is used to linearly process high-resolution features to obtain discriminative feature vectors and standardize high-resolution features to obtain contrast feature vectors. Supervised contrastive loss and cross-entropy classification loss are used to jointly optimize the detection model formed by wavelet transform module, high-resolution backbone network HRB and linear layer cascade. In the optimization process, cross-entropy classification loss is used to optimize the discriminative feature vectors and supervised contrastive loss is used to optimize the contrast feature vectors to obtain the optimized detection model. The detection module is used to obtain the discrimination result vector of the image to be detected using the optimized detection model. Based on the discrimination result vector, the softmax function is used to obtain the probability value of the image to be detected as a real generated image. The probability value is used to detect whether the image to be detected is an AI generated image.
[0013] This invention also provides an electronic device, including a memory and a processor; The memory is used to store computer programs; When the processor executes the computer program stored in the memory, it implements the steps of the AI-generated image detection method described above.
[0014] This invention also provides a computer-readable storage medium for storing a computer program, which, when executed by a processor, implements the steps of an AI-generated image detection method as described above.
[0015] This invention provides an AI-generated image detection method, apparatus, device, and medium, which have the following advantages compared with the prior art: This invention extracts high-frequency subbands from the image to be detected by performing discrete wavelet transform, generates an energy map based on the high-frequency subbands, and adaptively selects image patches containing the highest frequency energy from the energy map. This effectively avoids the high-frequency distortion problem caused by traditional downsampling preprocessing loss. Multi-resolution feature extraction and fusion are performed on the image patches to overcome the drawback of high-frequency detail loss during downsampling, achieving a simultaneous improvement in the ability to preserve high-frequency artifacts from both the input and feature extraction levels. Then, supervised contrastive loss is used to optimize the contrastive feature vector, maximizing the distance between different classes of samples in the feature space to enhance the inter-class separability of features. At the same time, cross-entropy classification loss is used to optimize the discriminative feature vector to enhance the difference between the prediction result and the true label. This joint optimization process of supervised contrastive loss and cross-entropy classification loss enhances inter-class separability, eliminates feature entanglement, and thus clearly separates features to capture clear features of the generated image. Finally, based on the clear features, it accurately determines whether the image to be detected is an AI-generated image. Attached Figure Description
[0016] Figure 1A schematic diagram illustrating the principle of an AI-generated image detection method provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of the overall process of an AI-generated image detection method provided in an embodiment of the present invention. Detailed Implementation
[0017] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Many specific details are set forth in the following description to provide a thorough understanding of the present invention. However, the present invention can be practiced in many other ways different from those described herein, and those skilled in the art can make similar modifications without departing from the spirit of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0018] Currently, research on AI-generated image detection by scholars both domestically and internationally mainly falls into two categories: detection methods based on low-level pixel features and detection methods based on high-level semantic features. In low-level pixel feature-based detection methods, researchers focus on the differences between generated and real images in terms of low-level statistics and local details. These methods directly affect the image signal itself; for example, CNNSpot uses convolutional networks to directly learn artifact features, GramNet uses the image's gray-level co-occurrence matrix to extract texture features, FreDect uses frequency domain features, and LGrad calculates gradient information. The limitations of these methods are that input preprocessing and downsampling operations within the network (such as resizing, stride convolution, and pooling) can weaken or eliminate high-frequency artifacts, and the overemphasis on training data in the classification loss can lead to overfitting. This reduces generalization performance on unseen datasets. Detection methods based on high-level semantic features rely on CNNs, Transformers, or large-scale visual language models (VLMs) to extract semantic features and use classifiers to determine whether a model is true or false. These methods demonstrate some generalization potential on unseen generators thanks to the powerful semantic extraction capabilities of pre-trained large models. However, they also have some shortcomings in terms of computational cost and generalization performance: on the one hand, high-level semantic features place high demands on the pre-trained semantic feature extraction model, which often requires a large number of parameters, resulting in a significant computational burden; on the other hand, when these methods rely solely on classification loss for optimization, they can also overfit, leading to feature entanglement and making it difficult to form clear decision boundaries, causing the detection model to degrade in performance when facing unseen generative models.
[0019] In summary, the problems and shortcomings of existing technical methods are as follows: 1. Downsampling leads to the loss of high-frequency artifact features, making it difficult for the model to capture high-frequency artifacts that are crucial for resolving the generated image.
[0020] Second, relying solely on classification loss for optimization can easily lead to overfitting and feature entanglement, which reduces the method's generalization ability to generated images that have never been seen before.
[0021] Third, while semantic-based methods have some potential, they are computationally expensive.
[0022] like Figure 1 The diagram illustrates the principle of the AI-generated image detection method based on a high-resolution contrast framework according to the present invention. This invention aims to address the problems of high-frequency artifact loss during downsampling in existing detection methods, and feature entanglement and insufficient cross-model generalization ability caused by relying solely on classification loss training. Specifically, the present invention constructs an energy map in the frequency domain space of the input image using a Discrete Wavelet Transform (DWT) patch selection module, and adaptively selects the patch with the highest energy as the model input, thereby avoiding high-frequency feature loss caused by fixed cropping or preprocessing downsampling. Subsequently, the patch is input into a high-resolution backbone network (HRB), which includes multi-resolution branches and cross-scale feature fusion units, enabling the full fusion of information at different scales while maintaining high-resolution representation, thus capturing high-frequency artifacts in the generated image. Next, the extracted features are transformed into a dual-branch representation of discriminative and contrastive features by a feature construction module. Finally, a loss optimization module applies cross-entropy classification loss to the discriminative features and supervised contrastive loss to the contrastive features, and jointly optimizes both to enhance inter-class separability and improve the model's generalization performance under different generation models.
[0023] Figure 2 The flowchart of the AI-generated image detection method based on a high-resolution contrast framework of the present invention specifically includes: Step S1: Input the image to be detected .
[0024] in: For the height of the image, The width is 3, indicating that the input image has three channels: RGB.
[0025] Step S2: Perform discrete wavelet transform on the image and calculate the energy map E based on the high-frequency subband.
[0026] The subbands obtained from the DWT decomposition include ,in Subbands are used to construct energy maps, which are calculated as follows: .
[0027] in: This indicates the high-frequency subband of the input image after discrete wavelet transform. Upper passage The coefficient value at that location, Indicates the energy map at location The energy value at that location.
[0028] Step S3: Search for the region with the highest energy on the energy map E using a sliding window and crop it to obtain the target patch. .
[0029] The coordinates of the top-left corner of the target patch are determined by the following formula: .
[0030] in: This represents the coordinates of the top-left corner of the region where the total energy is maximized. These represent the width and height of the energy map, respectively; thus, a target patch P with dimensions of 256×256×3 is obtained.
[0031] Step S4: Apply the target patch Input a high-resolution backbone network (HRB) and extract high-resolution features.
[0032] The multi-resolution feature fusion process is as follows: .
[0033] in: Indicates the first Features of each resolution branch Indicates branching Feature alignment to branch Spatial resolution operation, This indicates a feature concatenation operation. This represents a one-dimensional convolution operation. This represents the activation function.
[0034] HRB converts the input patch P into three resolution branches, each corresponding to a different resolution. , and The feature representation is that during cross-scale fusion, the features of each branch are aligned by upsampling or downsampling before being concatenated to achieve effective fusion of information at different scales. After the final fusion layer, a feature vector with a dimension of 512×64×64 is obtained, and then it is transformed into a feature vector of 512×1 through an average pooling.
[0035] Step S5: The high-resolution features are processed through a linear layer and normalized to obtain discriminative feature representations and contrastive feature representations, respectively.
[0036] A standardization layer is used to obtain a feature vector of size 512×1 for contrastive learning. Then, a linear layer is used to obtain a feature vector of size 2×1 for discrimination.
[0037] Step S6: Apply joint optimization of contrastive loss and classification loss to the two feature vectors respectively.
[0038] The contrastive loss function is: .
[0039] in: Indicates sample Embedded vector, Indicates sample The set of positive samples, Indicates that the batch excludes the sample All sample sets outside of, This represents the temperature parameter.
[0040] The classification loss function is: .
[0041] in: Indicates the first The true label of each sample This indicates the probability that the model predicts the sample to be a generated image. This represents the total number of samples.
[0042] The loss function for joint optimization is: .
[0043] in: and To balance the parameters, the weights of the classification loss and the contrastive loss are controlled separately.
[0044] Step S7: Based on the discrimination results of the linear layer output, obtain the predicted probability that the input image is a real image.
[0045] The predicted probability output in step S7 is calculated by the softmax function and is expressed as follows: .
[0046] in: Represents the linear layer of the classifier for each category. The output score, Indicates that the input image belongs to a category. The predicted probability, and satisfying Among them, categories Represents real images, categories This means generating an image and using the class with the highest probability as the final detection result.
[0047] Specifically, for the output discrimination result vector of size 2×1, the two values correspond to the output scores of categories 0 and 1, respectively, and their corresponding probability values are calculated by the softmax function.
[0048] Specific experiment: Table 1 shows the size of the test dataset; Table 1 also shows the source information of the image dataset used in the test.
[0049] Table 1. Size of the test dataset Table 2 shows the accuracy evaluation results of this invention on seven GAN-type image generation algorithm datasets compared with other methods.
[0050] Table 2. Accuracy evaluation comparison of the present invention with other methods on seven GAN class datasets. Table 3 shows the accuracy evaluation results of this invention on eight Diffusion class datasets compared with other methods.
[0051] Table 3. Accuracy evaluation comparison of the present invention with other methods on eight Diffusion class datasets. In the experimental verification of this invention, a single generator training paradigm is adopted. During the training phase, only synthetic images generated by ProGAN and their corresponding real images are used for training. The training data covers 20 semantic categories, with each category containing 18,000 synthetic images generated by ProGAN and the same number of real images. Following existing research conventions, four subsets (horse, chair, car, cat) are selected as the training set. In the testing phase, to comprehensively evaluate the cross-model generalization ability of the method, a comprehensive test set covering 15 different generation models is constructed, including 7 typical GAN models and 8 diffusion models. In comparative experiments, the method of this invention is compared with several representative detection algorithms in recent years, covering detection methods based on low-level artifacts. The methods tested included those based on multiple mainstream generative models (CNNSpot, FreDect, LGrad, FreqNet, NPR, etc.) and those based on advanced semantic features (UniFD, FatFormer, SAFE, AIDE, etc.), all under the same single-generator training setting to ensure experimental fairness. The evaluation metrics used were classification accuracy (ACC) and average precision (AP), where ACC measures the overall detection accuracy and AP measures robustness at different thresholds. Through comprehensive comparisons on multiple mainstream generative models and real image datasets, the method demonstrated significant advantages in more complex generative scenarios such as diffusion models while maintaining high detection accuracy, achieving an average improvement of over 2.1% compared to existing methods, fully validating the advanced nature and practical value of this invention.
[0052] This invention utilizes energy map analysis based on discrete wavelet transform to adaptively select the region with the most significant high-frequency artifacts in the image as input, thereby avoiding the loss of details caused by traditional downsampling operations and better preserving the differences in high-frequency features between the generated and real images. Furthermore, this invention designs a high-resolution backbone network with high-resolution branches throughout to maintain high-frequency information and extracts feature representations at different scales using a cross-scale fusion mechanism. In the feature construction stage, this invention introduces a joint loss of classification and contrast, jointly optimized through cross-entropy loss and supervised contrastive loss. Discriminative features ensure the accuracy of the model in classification tasks, while contrastive features improve inter-class separability and cross-model generalization ability. Finally, this invention is tested on public datasets under various mainstream generation mechanisms such as GAN and Diffusion models. The results show that this method significantly improves cross-model generalization while maintaining high detection accuracy, and can still maintain good detection performance under unseen generation models. This effectively solves the problems of insufficient high-frequency artifact capture and lack of generalization ability in existing detection methods, and has significant practical application value and security implications.
[0053] This invention, based on a high-resolution detection framework, simultaneously enhances the ability to preserve high-frequency artifacts from both the input and feature extraction levels. On one hand, by calculating the energy map through discrete wavelet transform and adaptively selecting high-energy region patches, it effectively avoids the problems of high-frequency distortion caused by traditional downsampling preprocessing and the omission of key information by fixed cropping methods. On the other hand, by introducing a high-resolution backbone network for multi-resolution feature extraction and fusion, it overcomes the drawback of losing high-frequency details during downsampling, thereby achieving accurate capture of subtle artifacts in the generated image and significantly improving the accuracy and stability of detection.
[0054] This invention combines contrastive loss and classification loss in the optimization objective, constructs a dual-branch representation of discriminative and contrastive features, and enhances inter-class separability through joint optimization, alleviating the feature entanglement problem caused by relying solely on classification loss. This design not only improves the model's discriminative ability, but also significantly enhances its adaptability to unseen generated models, making the detection method more generalizable and robust across models.
[0055] This invention, through efficient detection of AI-generated images, can be widely applied in scenarios such as cyberspace security, media content authentication, judicial evidence collection, and financial risk control. It can effectively identify fake images, block the spread of false information, and safeguard public property and information security, thereby playing an important role in protecting the social trust system and promoting the healthy development of industries.
[0056] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these all fall within the protection scope of the present invention. Therefore, the protection scope of this invention patent should be determined by the appended claims.
Claims
1. An AI-generated image detection method, characterized in that, Includes the following steps: Acquire sample images; The sample image is subjected to Discrete Wavelet Transform (DWT) using the wavelet transform module to extract the high-frequency subbands of the sample image and generate an energy map of the sample image; the region with the highest cumulative energy value on the energy map is selected as the target image patch. The high-resolution backbone network HRB is used to extract features from the target image patch at different resolution scales to obtain features of different resolutions. The features of different resolutions are then stitched together and fused into high-resolution features that preserve high-frequency artifact information. A linear layer is used to linearly process high-resolution features to obtain discriminative feature vectors, and the high-resolution features are standardized to obtain contrast feature vectors. Supervised contrastive loss and cross-entropy classification loss are used to jointly optimize the detection model formed by wavelet transform module, high-resolution backbone network HRB and linear layer cascade. In the optimization process, cross-entropy classification loss is used to optimize the discriminative feature vectors, and supervised contrastive loss is used to optimize the contrast feature vectors to obtain the optimized detection model. The optimized detection model is used to obtain the discrimination result vector of the image to be detected. Based on the discrimination result vector, the softmax function is used to obtain the probability value of the image to be detected as a real generated image. The probability value is used to detect whether the image to be detected is an AI generated image.
2. The AI-generated image detection method according to claim 1, characterized in that, The construction of the energy map includes: Acquire sample images , Indicates the height of the image, This indicates the width of the image; 3 indicates that the image has three channels: RGB. Perform Discrete Wavelet Transform (DWT) decomposition on the sample image to obtain sub-bands. Among them, high-frequency subband The energy map E is used to construct the energy map, and the energy map E is calculated as follows: ; in: This indicates the high-frequency subband of the input image after discrete wavelet transform. Upper passage The coefficient value at that location, Indicates the energy map at location The energy value at that location.
3. The AI-generated image detection method according to claim 2, characterized in that, The acquisition of the target image patch includes: On the energy map E, search for the region with the highest energy accumulation value using a sliding window, and then crop the region with the highest energy accumulation value as a patch for the target image. ; The coordinates of the top left corner of the target image patch are represented as follows: ; in: This represents the coordinates of the top-left corner of the region where the total energy is maximized; The width and height of the energy map are respectively used; a target image patch P with a size of 256×256×3 is obtained.
4. The AI-generated image detection method according to claim 3, characterized in that, The acquisition of the high-resolution features includes: The target image patch P is input into the high-resolution backbone network (HRB) to extract high-resolution features. During feature extraction, the HRB transforms the input patch P into three resolution branches, each corresponding to a different resolution. , and Feature representation, obtaining features at different resolutions; The fusion of features at different resolutions across scales is represented as: ; in: Indicates the first Features of each resolution branch; Indicates branching Feature alignment to branches Spatial resolution operations; Indicates feature concatenation operation; This represents a one-dimensional convolution operation; Indicates the activation function; After the fusion layer, a feature vector with dimensions of 512×64×64 is obtained, and then a high-resolution feature of 512×1 is obtained through average pooling.
5. The AI-generated image detection method according to claim 1, characterized in that, The acquisition of the discrimination result vector includes: The high-resolution features are normalized through a single layer to obtain a contrastive feature vector of size 512×1 for contrastive learning; the high-resolution features are then processed through a linear layer to obtain a discriminative feature vector of size 2×1 for discrimination. The contrastive feature vector is optimized using supervised contrastive loss, as follows: ; in: Represents sample image The embedding vector; Represents sample image The set of positive samples; Indicates the image excluding the sample within the batch. The set of all sample images outside; Indicates temperature parameter; Simultaneously, the cross-entropy classification loss is used to optimize the discriminative feature vector, expressed as: ; in: Indicates the first The true label of each sample image; This indicates the probability that the model predicts the sample image to be a generated image; Indicates the total number of sample images; Furthermore, spatial features are jointly optimized based on supervised contrastive loss and cross-entropy classification loss, expressed as: ; in: and This represents the balancing parameter, used to control the weights of classification loss and contrastive loss; After joint optimization is completed, the linear layer outputs the discrimination result vector.
6. The AI-generated image detection method according to claim 1, characterized in that, The detection of whether the image to be detected is an AI-generated image includes: The probability value that the image to be detected is a real generated image is calculated using the softmax function, and is expressed as: ; in: This represents the linear layer of the classifier for each category. The output score; Indicates that the input image belongs to a category. The predicted probability, and satisfying Among them, categories Represents real images, categories This means that the AI generates the image and uses the class with the highest probability as the final detection result. Specifically, for the output discrimination result vector of size 2×1, the two values correspond to the output scores of categories 0 and 1, respectively.
7. An AI-generated image detection device, characterized in that, include: The acquisition module is used to acquire sample images; The feature extraction module is used to perform Discrete Wavelet Transform (DWT) on the sample image using the wavelet transform module to extract the high-frequency subbands of the sample image to generate an energy map of the sample image; the region with the highest cumulative energy value on the energy map is selected as the target image patch; The high-resolution backbone network HRB is used to extract features from the target image patch at different resolution scales to obtain features of different resolutions. The features of different resolutions are then stitched together and fused into high-resolution features that preserve high-frequency artifact information. The optimization module is used to linearly process high-resolution features to obtain discriminative feature vectors and standardize high-resolution features to obtain contrast feature vectors. Supervised contrastive loss and cross-entropy classification loss are used to jointly optimize the detection model formed by wavelet transform module, high-resolution backbone network HRB and linear layer cascade. In the optimization process, cross-entropy classification loss is used to optimize the discriminative feature vectors and supervised contrastive loss is used to optimize the contrast feature vectors to obtain the optimized detection model. The detection module is used to obtain the discrimination result vector of the image to be detected using the optimized detection model. Based on the discrimination result vector, the softmax function is used to obtain the probability value of the image to be detected as a real generated image. The probability value is used to detect whether the image to be detected is an AI generated image.
8. An electronic device, characterized in that, include: Memory and processor; The memory is used to store computer programs; When the processor executes the computer program stored in the memory, it implements the steps of the AI-generated image detection method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, Used to store a computer program, which, when executed by a processor, implements the steps of an AI-generated image detection method as described in any one of claims 1 to 6.