Artificial intelligence generated image detection method, device, and storage medium

By extracting deep visual features through a forgery detection model trained by cross-modal alignment and combining lightweight linear operations and dynamic thresholds, the problem of difficulty in balancing generalization and efficiency in existing AI-generated image detection methods is solved, achieving efficient and robust image detection results.

CN121837800BActive Publication Date: 2026-05-29PEKING UNIV SHENZHEN GRADUATE SCHOOL
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
PEKING UNIV SHENZHEN GRADUATE SCHOOL
Filing Date
2026-03-13
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Existing AI-generated image detection methods struggle to balance generalization, efficiency, and practicality, especially when faced with unknown generative models and complex post-processing scenarios, where detection performance remains unstable.

Method used

A forgery detection model trained with cross-modal alignment is used to extract deep visual features. It combines lightweight linear operations and Sigmoid mapping, introduces dynamic decision thresholds for efficient inference, accurately captures the essential differences between real and forged images through cross-modal semantic priors, and adaptively adjusts the detection sensitivity.

Benefits of technology

It significantly improves the detection generalization ability for unknown generative models and complex post-processing, reduces computational overhead, has excellent cross-domain adaptability and robustness, meets the requirements of lightweight deployment and real-time response, and enhances robustness and interpretability against diverse forgery methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121837800B_ABST
    Figure CN121837800B_ABST
Patent Text Reader

Abstract

The application discloses an AI generated image detection method and device and a storage medium, comprising: acquiring a to-be-detected image, inputting the to-be-detected image into an image encoder of a forgery detection model; extracting a deep visual feature vector of the to-be-detected image through the image encoder; performing linear operation on the deep visual feature vector and a preset weight parameter matrix, and superimposing a preset bias parameter in the linear operation process to obtain an intermediate scalar value; taking the intermediate scalar value as the input of a Sigmoid function to calculate a scalar confidence score; and determining whether the to-be-detected image is an AI generated image according to the comparison result of the scalar confidence score and a dynamic judgment threshold. The application extracts deep features through cross-modal alignment training, performs linear mapping and efficient reasoning, significantly improves the generalization ability of unknown generated models, and realizes lightweight deployment while ensuring high precision by combining dynamic threshold adaptive adjustment, thereby meeting the actual application requirements.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the fields of computer vision and artificial intelligence security technology, and in particular to an AI-generated image detection method, device and storage medium. Background Technology

[0002] With the rapid development of generative artificial intelligence technology, especially the maturity of technologies such as diffusion models, the quality and realism of AI-generated images have reached a level that is indistinguishable from the real thing. While this has boosted the creative industries, it has also brought a series of security and ethical risks, such as the spread of false information and identity fraud. Therefore, developing efficient and reliable AI-generated image detection technology has become an urgent need to maintain the credibility of digital content.

[0003] In relevant recognition schemes, convolutional neural networks or visual Transformers are mainly used to directly classify input images into true and false categories. These methods (such as CNNSpot and FreDect) excel at capturing statistical anomalies and generation artifacts at low levels, such as texture and frequency domain, and often achieve high accuracy on test sets targeting specific known generation models. However, the performance of these methods is highly dependent on the distribution of training data, making them prone to overfitting to specific generators or image types, resulting in insufficient generalization ability. Once faced with images not seen during training, from new generation models, or with different post-processing procedures, the detection performance drops sharply. Therefore, they suffer from core problems such as weak generalization ability and unstable detection performance for unknown generation models and complex post-processing scenarios, making it difficult to meet the ever-changing security detection requirements in practical applications.

[0004] The above content is only used to help understand the technical solution of this application and does not represent an admission that the above content is prior art. Summary of the Invention

[0005] The main purpose of this application is to provide an AI-generated image detection method, device, and storage medium, aiming to solve the technical problem that existing AI-generated image detection methods are difficult to balance in terms of generalization, efficiency, and practicality.

[0006] To achieve the above objectives, this application proposes an AI-generated image detection method, the method comprising:

[0007] The image to be detected is acquired and input into the image encoder of the forgery detection model, wherein the forgery detection model is obtained through cross-modal alignment training;

[0008] The depth visual feature vector of the image to be detected is extracted by the image encoder;

[0009] A linear operation is performed on the depth visual feature vector and the preset weight parameter matrix, and a preset bias parameter is superimposed during the linear operation to obtain an intermediate scalar value;

[0010] The intermediate scalar value is used as the input to the Sigmoid function to calculate the scalar confidence score;

[0011] Based on the comparison between the scalar confidence score and the dynamic judgment threshold, it is determined whether the image to be detected is an AI-generated image.

[0012] In one embodiment, the step of determining whether the image to be detected is an AI-generated image based on the comparison result of the scalar confidence score and the dynamic determination threshold includes:

[0013] Obtain the source attribute information of the image to be detected;

[0014] In the preset dynamic threshold mapping table, query the dynamic judgment threshold corresponding to the source attribute information;

[0015] If the scalar confidence score is greater than the dynamic determination threshold, then the image to be detected is determined to be an AI-generated image;

[0016] If the scalar confidence score is less than or equal to the dynamic determination threshold, then the image to be detected is determined to be a real image.

[0017] In one embodiment, before the step of querying the dynamic judgment threshold corresponding to the source attribute information in a preset dynamic threshold mapping table, the method further includes:

[0018] Acquire historical detection data, which includes multiple sets of image samples, source attribute information of each image sample, corresponding confidence scores, and true category labels;

[0019] Based on the source attribute information of the historical detection data, the confidence score distribution of AI-generated image samples and real image samples in the corresponding multiple groups of image samples is statistically analyzed.

[0020] Based on the numerical distribution characteristics of the confidence score distribution, calculate the dynamic judgment threshold for each of the source attribute information;

[0021] The source attribute information and the dynamic determination threshold are associated and stored to form the dynamic threshold mapping table.

[0022] In one embodiment, after the step of associating and storing the source attribute information and the dynamic determination threshold to form the dynamic threshold mapping table, the method further includes:

[0023] In response to the threshold update process start command, newly added historical detection data is obtained, and a subset of image sample data with the same source attribute information is filtered from the historical detection data;

[0024] Calculate the dynamic determination threshold of the source attribute information based on the subset of image sample data;

[0025] The calculated dynamic determination data is updated to the historical dynamic threshold of the source attribute information in the dynamic threshold mapping table.

[0026] In one embodiment, before the steps of acquiring the image to be detected and inputting the image to be detected into the image encoder of the forgery detection model, the method further includes:

[0027] Obtain a training image set, which includes real images and AI images;

[0028] The structured reasoning text corresponding to each training image in the training image set is generated using a pre-set multimodal large model.

[0029] A training dataset is constructed based on the image-text pairs consisting of the training images and the corresponding structured reasoning text.

[0030] The visual language base model is jointly optimized and trained using the training dataset and a preset loss function to obtain the forgery detection model, wherein the preset loss function includes contrast loss and classification loss.

[0031] In one embodiment, the step of generating structured inference text corresponding to each training image in the training image set using a preset multimodal large model includes:

[0032] The training image is input into the multimodal large model, and a response text is output, wherein the response text includes at least one analysis conclusion;

[0033] Extract the text content of the analysis conclusion, and add a real image category prefix to the text content to generate the structured reasoning text.

[0034] In one embodiment, the step of inputting the training image into the multimodal large model and outputting response text includes:

[0035] The multimodal large model is used to perform overall semantic consistency analysis on the input training images;

[0036] Identify global semantic contradictions or physical law violations in the analysis results, and generate first-level analysis conclusions based on the identification results;

[0037] Determine whether there are any suspicious semantic anomalies in the first-level analysis conclusions;

[0038] If a suspicious semantic anomaly is found, focus on the target region in the training image that is associated with the suspicious semantic anomaly;

[0039] The target region is subjected to local texture and edge continuity analysis to obtain generated artifacts, and a second-level analysis conclusion is generated based on the generated artifacts;

[0040] The response text is generated and output after the conclusions of the first-level analysis are combined with the conclusions of the second-level analysis.

[0041] In one embodiment, the step of jointly optimizing and training the visual language base model using the training dataset and a preset loss function to obtain the forgery detection model includes:

[0042] Freeze the text encoder of the visual language base model;

[0043] A low-rank adaptive strategy is adopted to efficiently fine-tune the parameters of the image encoder and forgery detection head of the visual language basic model.

[0044] The visual features output by the fine-tuned image encoder and the forgery detection head are input into a binary classifier;

[0045] Calculate the overall objective function of the contrast loss and the classification loss, and use the overall objective function to simultaneously optimize the low-rank adaptive parameters of the image encoder and the model parameters of the binary classifier;

[0046] The forgery detection model is obtained based on the optimization results.

[0047] In addition, to achieve the above objectives, this application also proposes an AI-generated image detection device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the AI-generated image detection method as described above.

[0048] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the AI-generated image detection method described above.

[0049] One or more technical solutions proposed in this application have at least the following technical effects:

[0050] The technical solution of this application involves acquiring an image to be detected, inputting the image to be detected into an image encoder of a forgery detection model, wherein the forgery detection model is obtained through cross-modal alignment training; extracting the depth visual feature vector of the image to be detected through the image encoder; performing a linear operation on the depth visual feature vector and a preset weight parameter matrix, and superimposing a preset bias parameter during the linear operation to obtain an intermediate scalar value; using the intermediate scalar value as the input of the Sigmoid function to calculate a scalar confidence score; and determining whether the image to be detected is an AI-generated image based on the comparison result of the scalar confidence score and a dynamic judgment threshold.

[0051] This application employs a cross-modal aligned training model forgery detection to extract deep visual features. Leveraging cross-modal semantic priors, it accurately captures the essential differences between real and forged images, significantly improving detection generalization capabilities against unknown generative models and complex post-processing. Simultaneously, it achieves efficient inference through lightweight linear operations and sigmoid mapping, combined with dynamic threshold adaptive adjustment of detection sensitivity. This ensures high detection accuracy while significantly reducing computational overhead, meeting the requirements for lightweight deployment and real-time response, and demonstrating excellent cross-domain adaptability and practical application value. Furthermore, this method does not rely on large-scale multimodal models for complex inference; stable confidence scores can be obtained solely through feature linear mapping, further enhancing robustness and interpretability against diverse forgery methods. This provides a comprehensive performance that balances detection accuracy and speed for the reliable verification of digital content authenticity. Attached Figure Description

[0052] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0053] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0054] Figure 1 This is a flowchart illustrating the first embodiment of the AI-generated image detection method of this application;

[0055] Figure 2 This is a detailed step diagram of step S50 in the first embodiment above;

[0056] Figure 3 This is a flowchart illustrating the second embodiment of the AI-generated image detection method of this application;

[0057] Figure 4This is a detailed flowchart of step S70 in the second embodiment described above;

[0058] Figure 5 This is a detailed step diagram of step S90 in the second embodiment above;

[0059] Figure 6 A schematic diagram of the ForgeCLIP model training framework;

[0060] Figure 7 This is a schematic diagram of the device structure of the hardware operating environment involved in the AI-generated image detection method in the embodiments of this application.

[0061] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0062] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.

[0063] Among related technologies, AI-generated image detection technology mainly follows two completely different technical paths, but each has its own inherent defects, making it difficult to meet the reliable detection needs of digital content authenticity in an open environment.

[0064] The first category of methods is represented by classification models based on texture / frequency domain features, including schemes such as CNNSpot and FreDect. These methods extract low-level statistical features of images through convolutional neural networks or visual Transformers, utilizing artifacts in the generated images' frequency domain distribution and local texture consistency for classification. However, these models are highly dependent on the distribution characteristics of the training data, and their decision boundaries often severely overfit the specific generator architecture seen during the training phase (such as a specific version of GAN or diffusion model). Experiments show that when faced with novel generative models not seen during training, unknown post-processing procedures (such as compression, scaling, and filtering), or images spanning different data domains, the detection accuracy of these methods drops precipitously, indicating a serious deficiency in generalization ability. Furthermore, these models only output binary labels, lacking interpretability of the judgment criteria, making it difficult to support the reliability requirements of decisions in highly security-sensitive scenarios.

[0065] The second type of approach attempts to introduce multimodal large models (such as CLIP and BLIP) for semantic-level forgery detection. These methods leverage the powerful cross-modal alignment capabilities of vision-language pre-trained models, distinguishing between images and textual prompts (such as "real photo" and "AI-generated image") by calculating semantic similarity, or by performing logical reasoning based on image understanding. While these methods possess some cross-domain generalization ability and interpretability, their deployment cost is extremely high: large-scale vision-language models often contain hundreds of millions or even billions of parameters, and the reasoning process requires expensive computational resources and storage overhead, making them difficult to implement on edge devices or in real-time detection scenarios. Furthermore, these methods are insensitive to fine-grained forgery traces—semantic understanding easily overlooks local pixel-level statistical anomalies, resulting in insufficient robustness against forged images that have undergone adversarial perturbations or local editing.

[0066] A comprehensive analysis reveals that the core dilemma faced by both types of methods lies in the following: methods based on shallow statistical features, while computationally efficient, suffer from poor generalization; methods based on multimodal semantics, while possessing strong inference capabilities, are computationally expensive. Both struggle to achieve a balance between detection accuracy, cross-domain generalization ability, and deployment efficiency. More importantly, existing solutions generally rely on performance evaluation using closed test sets. When faced with real-world images that have undergone multiple post-processing, cross-model transfer, or deliberate adversarial perturbations, the false positive rate increases significantly, and adaptability is severely insufficient. This results in a common technical problem in existing AI-generated image detection methods: an inability to simultaneously achieve generalization, efficiency, and practicality.

[0067] Based on the aforementioned shortcomings of related technologies, this application proposes an AI-generated image detection method. This method addresses the core pain points of existing methods, such as weak generalization ability, low computational efficiency, and difficulty in adapting to open real-world scenarios. It extracts deep visual features through a forgery detection model trained via cross-modal alignment and performs lightweight and efficient inference based on linear operations and dynamic thresholds. Specifically, during the training phase, this method utilizes a cross-modal alignment mechanism to learn the semantic differences between real and forged images, enabling the model to capture deep forgery features with cross-domain transfer capabilities, overcoming the overfitting problem of traditional methods to specific generators. During the inference phase, only a single linear transformation and sigmoid mapping are needed on the deep feature vector output by the image encoder to obtain the confidence score, avoiding the complex computational overhead of large multimodal models. Simultaneously, a dynamic threshold mechanism is introduced to adapt to the detection sensitivity requirements of different application scenarios. Through these technical means, this application significantly improves cross-domain generalization ability and deployment practicality while maintaining high detection accuracy, providing an effective technical solution to the comprehensive technical challenge of balancing generalization, efficiency, and practicality in existing technologies.

[0068] To better understand the technical solution of this application, the following embodiments will be used to illustrate the implementation of the technical solution provided by this application in conjunction with the accompanying drawings.

[0069] Reference Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the AI-generated image detection method of this application. In this embodiment, the AI-generated image detection method includes steps S10 to S50:

[0070] Step S10: Obtain the image to be detected and input the image to be detected into the image encoder of the forgery detection model, wherein the forgery detection model is obtained through cross-modal alignment training;

[0071] In this embodiment, after receiving the image to be detected but before inputting it into the forgery detection model, the image is preprocessed before input. Preprocessing includes a normalization operation, specifically scaling the image size to a fixed resolution specified by the model's input layer, such as 224 x 224 pixels or 336 x 336 pixels. This scaling operation is typically achieved through bilinear interpolation or nearest neighbor sampling algorithms, while the fixed target resolution is derived from the input size preset by the image encoder network structure during the construction of the forgery detection model. This size is usually recorded in the model configuration file or determined by the pre-trained weights. Subsequently, the values ​​of each pixel channel are normalized. Normalization aims to make the mean and variance of the pixel values ​​conform to the data distribution used during model pre-training, for example, converting the original pixel values ​​in the range of 0 to 255 into floating-point numbers that conform to a specific mean and standard deviation.

[0072] After preprocessing to obtain a normalized image tensor, this normalized image tensor is transmitted to the image encoder of the forgery detection model. This image encoder is a specialized component trained through cross-modal alignment, and its parameters are specifically trained to align its output visual feature space with a high-quality semantic text space.

[0073] As one implementation, the image encoder is built on the pre-trained CLIP-ViT architecture. CLIP-ViT is a specific architecture of the Visual Transformer in a contrastive language-image pre-training mode, and is defined as a "contrastive language-image pre-trained model based on Visual Transformer." During the model training phase, this image encoder, together with the forgery detection head, is jointly fine-tuned on a dataset using image text generated by a large multimodal model. This image text dataset is rich in semantic analysis descriptions of image authenticity. During training, optimization is performed using a contrastive loss function, the purpose of which is to force the image encoder to map real images and AI-generated images to vector regions similar to the features of "real" and "forged" semantic description texts, respectively, thereby achieving recognition. This process essentially distills the semantic discriminative and generalization capabilities of the large language model into the visual encoder. Therefore, inputting the image to be detected into this encoder is the starting point for injecting the visual signal to be analyzed into a deep representation network that has been shaped to be highly sensitive to semantic anomalies related to forgery.

[0074] Step S20: Extract the depth visual feature vector of the image to be detected using the image encoder;

[0075] After receiving the preprocessed image tensor, the image encoder performs the core visual feature extraction function, transforming the input pixel data into a high-dimensional and dense numerical vector, i.e., a depth visual feature vector. This transformation process is completed by the image encoder, which typically employs a Vision Transformer or a deep convolutional network architecture. Taking the Vision Transformer as an example, its data processing logic follows a series of hierarchical transformations.

[0076] First, the preprocessed image is segmented into a series of fixed-size image patches. Each patch is transformed into a corresponding feature vector through a linear projection layer; this feature vector is called a patch embedding. Simultaneously, a learnable classification token vector is added, and positional encoding information is injected into all patch embeddings to preserve their spatial structure. This sequence of feature vectors is then fed into the main body of the image encoder, a series of stacked Transformer encoding layers. Within each Transformer encoding layer, a self-attention mechanism is used to compute all feature vectors, allowing the features of each image patch to be updated based on global context information, thereby capturing different levels of information from local texture to global semantics. Subsequent multi-layer feedforward neural networks further perform nonlinear transformations on these features.

[0077] After sequential processing through all encoding layers, the feature vector output by the classification token in the last layer is finally extracted as the aggregated representation of the entire input image, i.e., the required deep visual feature vector. This deep visual feature vector is represented as a fixed-dimensional floating-point array, such as a 768-dimensional or 1024-dimensional vector. Its key characteristic is that, due to the aforementioned cross-modal alignment training, the geometric structure of its vector space has been optimized. Specifically, in this vector space, the distribution of feature vectors from different images is not arbitrary, but implicitly aligned with a text feature subspace generated by semantic descriptions such as "real" and "fake." Therefore, the output of the image encoder is not only a general image feature, but also a core representation that already contains semantic alignment and discriminative enhancement information, specifically for subsequent authenticity determination.

[0078] Step S30: Perform linear operation on the depth visual feature vector and the preset weight parameter matrix, and superimpose a preset bias parameter during the linear operation to obtain an intermediate scalar value;

[0079] Subsequently, the extracted depth visual feature vectors are converted into one-dimensional scalar signals for final binary probability determination. This data processing logic is a typical linear transformation operation, performed by a linear classification layer immediately following the image encoder in the forgery detection model; this layer is usually called a fully connected layer.

[0080] The specific implementation process is as follows: The depth visual feature vector is defined as v, with a dimension of d. This linear classification layer encapsulates two key learnable parameters: a weight parameter matrix W and a bias parameter b. The weight parameter matrix W has a dimension of 1 row and d columns, meaning it contains d weight coefficients, each corresponding to a dimension in the depth visual feature vector; the bias parameter b is a scalar value. These learnable parameters, along with some parameters of the image encoder, such as the LoRA adapter parameters, and the forgery detection head, are optimized using a joint objective function that includes contrastive loss and classification loss during the final training phase of the model.

[0081] During computation, vector-matrix multiplication is performed: First, the depth visual feature vector v is multiplied by the weight parameter matrix W, i.e., a dot product is performed. Since the weight parameter matrix W is a row vector, this operation is equivalent to calculating the weighted sum of each dimension of v and its corresponding weight coefficient in W. The result of this operation is a single scalar value. Next, the bias parameter b is added to this calculated scalar value, completing the addition operation. The final result, z, is the intermediate scalar value.

[0082] Geometrically, this linear operation defines a hyperplane in the depth visual feature space. The depth visual feature vector v is projected onto the normal direction of this hyperplane, which is defined by the weight parameter matrix W, and an offset determined by the bias parameter b is added to obtain a scalar value z. This scalar value z represents the "distance" or "predisposition" of the feature vector of the image to be detected to one side of the hyperplane. Typically, a positive value indicates that the feature vector is located on the side that tends to be judged as "forgery," while a negative value indicates that it tends to be judged as "real." This completes the dimensionality reduction and projection process from the high-dimensional abstract feature space to a one-dimensional decision axis.

[0083] Step S40: Use the intermediate scalar value as input to the Sigmoid function to calculate the scalar confidence score;

[0084] Subsequently, the obtained intermediate scalar value z needs to be converted into a confidence score with a clear probabilistic meaning. This step achieves nonlinear activation and mapping by applying a monotonic sigmoid function, also known as the Sigmoid function.

[0085] Specifically, the mathematical definition of the Sigmoid function is σ(z) = 11 + e zσ(z)=1+e z1. In the specific calculation process, the system receives the intermediate scalar value z as input and substitutes it into the above formula. The entire calculation is executed by the processor or a dedicated tensor arithmetic unit, which performs a series of basic arithmetic operations such as exponentiation, addition, and division.

[0086] The core technique of this calculation lies in the mathematical properties of the Sigmoid function. This Sigmoid function can compress and map any real value z, ranging from negative infinity to positive infinity, into an interval between 0 and 1. The output value s=σ(z) obtained after mapping is the desired scalar confidence score.

[0087] The significance of this scalar confidence score can be interpreted as follows: the closer the scalar confidence score s is to 1, the higher the probability that the forgery detection model determines the input image to be an AI-generated image based on the extracted visual features; conversely, the closer the scalar confidence score s is to 0, the higher the probability that the image is a real image. A value of 0.5 is generally considered the theoretical decision neutral point.

[0088] This transformation process converts the geometrically meaningful propensity scalar z obtained from the previous linear projection into a confidence metric that is more easily understood and used in probability theory. This scalar confidence score not only directly serves the final binary decision but also provides an indicator of the overall system's decision uncertainty. For example, a confidence score of 0.9 means the model has a higher degree of confidence in its false judgment than a score of 0.6.

[0089] Step S50: Based on the comparison result between the scalar confidence score and the dynamic determination threshold, determine whether the image to be detected is an AI-generated image.

[0090] Finally, the generated continuous confidence score s needs to be converted into a clear binary classification decision. By introducing a dynamic decision mechanism, the scalar confidence score is finally determined based on a variable threshold.

[0091] In the specific implementation process, the first step is to obtain a dynamic judgment threshold. The system queries a pre-built dynamic threshold mapping table based on the source attribute information attached to the image to be detected or inferred through analysis, such as the image upload channel, shooting device model, or image format, to obtain the corresponding dynamic judgment threshold. This mapping table is stored in key-value pairs, where the key is a different combination of source attributes, and the value is the statistically optimized dynamic judgment threshold Tdynamic. For example, for the source "compressed images from social media platforms," ​​the threshold might be set to 0.55; while for "professional RAW format" images, the threshold might be set to 0.48.

[0092] After obtaining the corresponding dynamic threshold Tdynamic, the core comparison operation is performed: the scalar confidence score s is directly compared with Tdynamic. The judgment logic follows these rules: if s > Tdynamic, the final judgment result is the AI-generated image; if s ≤ Tdynamic, the final judgment result is the real image.

[0093] By introducing a dynamic threshold, the probability distribution of confidence scores in the model output may differ between real images and AI-generated images due to variations in imaging quality, post-processing procedures, and inherent noise patterns. The dynamic thresholding mechanism adaptively adjusts the decision boundary by setting statistically optimized thresholds for different sources, such as aiming to maximize F1 scores on historical data. This mechanism significantly improves the robustness and overall classification performance of the detection method in the face of diverse and complex real-world scenarios, thereby ensuring high accuracy, high efficiency, and reliable applicability in complex real-world environments at a higher level.

[0094] Furthermore, you can also view Figure 2 , Figure 2 This is a detailed step diagram of step S50 in the first embodiment described above, based on the shown... Figure 2 The step of determining whether the image to be detected is an AI-generated image based on the comparison result of the scalar confidence score and the dynamic determination threshold includes S51~54:

[0095] Step S51: Obtain the source attribute information of the image to be detected;

[0096] Step S52: In the preset dynamic threshold mapping table, query the dynamic judgment threshold corresponding to the source attribute information;

[0097] Step S53: If the scalar confidence score is greater than the dynamic determination threshold, then the image to be detected is determined to be an AI-generated image.

[0098] Step S54: If the scalar confidence score is less than or equal to the dynamic determination threshold, then the image to be detected is determined to be a real image.

[0099] In the dynamic determination phase, the first step is to obtain the source attribute information of the image to be detected. This source attribute information is derived by parsing the input image data stream or file-related metadata, and can characterize the image's generation or circulation background. The specific representation can be predefined category labels or structured data, such as the device manufacturer and model field extracted from the image's EXIF ​​metadata, user claims or channel labels like "social media upload" obtained from the upload interface, or the format type inferred by analyzing the image file header, compression features, and noise patterns, such as "JPEG high compression rate." By calling the corresponding metadata reading interface or running a lightweight analysis model, the source attribute information is obtained and normalized, and then converted into standardized key-value pairs for subsequent queries. The key to this conversion is ensuring that the source attribute information remains consistent with the keys in a pre-built dynamic threshold mapping table to achieve accurate retrieval.

[0100] Next, based on the standardized source attribute keys, a query operation is performed in a pre-defined dynamic threshold mapping table to obtain the corresponding dynamic judgment threshold. This dynamic threshold mapping table is stored in memory or cache, and its data structure is a hash table or dictionary. The keys are various possible standardized source attributes, and the values ​​are the optimal thresholds calculated through offline statistical analysis. In specific implementations, the source attribute key is used as the query key to call the lookup function of the mapping table, thereby obtaining the floating-point threshold value Tdynamic. If the query key does not exist in the mapping table, it can be configured to return the global default threshold or execute a specific exception handling process. By pre-calculating and storing optimized thresholds for different scenarios, the complex decision boundary selection problem is transformed into an efficient constant-time query, thus achieving adaptive judgment capability without increasing online computational overhead.

[0101] Finally, after obtaining the dynamic decision threshold, the scalar confidence score *s* is compared with the dynamic decision threshold *Tdynamic*, and mapped to a discrete category according to a predetermined rule. The decision rule is clearly stated: if *s* > *Tdynamic*, the image to be detected is determined to be an AI-generated image; if *s* ≤ *Tdynamic*, it is determined to be a real image. This Boolean comparison and its corresponding conditional branch are basic operations at the processor level, ensuring the efficiency of the decision-making process.

[0102] In this embodiment, by adaptively acquiring a dynamic judgment threshold, the system can flexibly adapt to the inherent differences in feature score distribution of images from different sources, ultimately improving the overall classification accuracy and robustness in cross-domain scenarios.

[0103] In addition, based on the above Figure 2 The content of step S52, as recorded, before the step of querying the dynamic determination threshold corresponding to the source attribute information in the preset dynamic threshold mapping table, further includes:

[0104] Acquire historical detection data, which includes multiple sets of image samples, source attribute information of each image sample, corresponding confidence scores, and true category labels;

[0105] Based on the source attribute information of the historical detection data, the confidence score distribution of AI-generated image samples and real image samples in the corresponding multiple groups of image samples is statistically analyzed.

[0106] Based on the numerical distribution characteristics of the confidence score distribution, calculate the dynamic judgment threshold for each of the source attribute information;

[0107] The source attribute information and the dynamic determination threshold are associated and stored to form the dynamic threshold mapping table.

[0108] When constructing a dynamic threshold mapping table, offline data collection and computational optimization are required. The core logic of this process is to calculate the optimal classification decision threshold for images of different source attributes based on historical feedback data accumulated during system operation through statistical analysis, and to persistently store the calculation results for efficient retrieval during online detection.

[0109] The specific implementation process includes the following steps: First, historical detection data is retrieved from a designated data storage area, which can be a database or log files. Historical detection data is a structured collection of records, each containing four key fields: a unique identifier or feature hash of the image sample, the source attribute information corresponding to the image, a scalar confidence score calculated by the model in previous detection processes, and a true category label confirmed after manual review or authoritative verification, i.e., "AI-generated image" or "real image." This data originates from feedback accumulated during previous system operation, based on user or administrator confirmation of the detection results.

[0110] After acquiring historical detection data, for each unique source attribute, all records belonging to that source attribute are filtered out. Then, based on the true category labels in the records, the filtered data is divided into two independent subsets: an AI-generated image sample set and a real image sample set. For each subset, the confidence scores of all records are extracted, and distribution statistics are performed. Distribution statistics may include calculating kernel density estimates to depict a smooth probability density curve, or directly calculating the empirical cumulative distribution function. The aim is to accurately quantify the distribution of confidence scores for real images and AI-generated images within a numerical range under a specific source, as well as the overlapping area between the two distributions.

[0111] Based on the above statistical analysis results, the threshold calculation stage begins. According to the numerical characteristics of the confidence score distribution, an optimization algorithm is used to determine the dynamic decision threshold that best distinguishes the categories. Specifically, the calculation process aims to maximize a pre-defined evaluation metric, such as the F1 score on the validation set, accuracy, or the Youden index calculated based on two distributions. A common implementation is to perform a step-by-step search within the possible threshold range of 0 to 1, or to use a more efficient optimization algorithm to calculate the corresponding classification performance metric for each candidate threshold, and finally select the threshold that optimizes this performance metric as the dynamic decision threshold for this source attribute.

[0112] Finally, the calculated correspondence between each set of source attribute information and the dynamic judgment threshold, i.e., key-value pairs, is written or updated to a centralized storage structure to form the final dynamic threshold mapping table. This mapping table is typically persisted in the form of a JSON or XML file, or a database table, ensuring that it can be fully loaded into memory when the online detection service starts, thereby providing efficient query services for the real-time judgment process.

[0113] Furthermore, after the step of associating and storing the source attribute information and the dynamic determination threshold to form the dynamic threshold mapping table, the method further includes:

[0114] In response to the threshold update process start command, newly added historical detection data is obtained, and a subset of image sample data with the same source attribute information is filtered from the historical detection data;

[0115] Calculate the dynamic determination threshold of the source attribute information based on the subset of image sample data;

[0116] The calculated dynamic determination data is updated to the historical dynamic threshold of the source attribute information in the dynamic threshold mapping table.

[0117] To ensure that the detection system can adapt to slow changes in data distribution, i.e. concept drift, and achieve continuous self-improvement, this method designs an online update and iterative optimization mechanism for the dynamic threshold mapping table.

[0118] The specific implementation process of this online update and iterative optimization mechanism is as follows: First, the system update process is triggered by a specific start command. This start command follows a preset strategy, typically with two parallel conditions: one is time-driven, meaning it is automatically triggered when a preset update cycle is reached, such as every 24 hours or weekly; the other is data-driven, meaning it is triggered when the amount of newly added and labeled historical detection data reaches a preset trigger threshold, such as when 1000 new valid records are added. When either condition is met, the system scheduler automatically initiates the threshold update process start command.

[0119] After the process starts, the system will retrieve the newly added historical detection data accumulated since the last update. Next, it will perform a crucial data filtering operation. The core of this operation is to group all the newly added data according to the source attribute information, and for each source attribute already existing in the dynamic threshold mapping table, filter out a subset of image sample data with the same source attribute information.

[0120] Subsequently, for each source attribute to be updated, the system recalculates the dynamic judgment threshold using its corresponding subset of image sample data. The algorithm used for recalculation is the same as the initialization time of the mapping table, that is, based on the confidence score distribution of AI-generated images and real images in the image sample subset, a new optimal threshold is determined by optimizing specific evaluation metrics. To ensure the reliability of the new threshold, a minimum data requirement can be set during this process; if the amount of new data for a certain source attribute is insufficient, the update operation for that source attribute is skipped.

[0121] After calculating the updated dynamic threshold, the system accesses the dynamic threshold mapping table, finds the entry corresponding to the specific source attribute information, and replaces the stored historical threshold with the newly calculated threshold. In practical applications, to avoid the online detection service reading inconsistent thresholds at the moment of update, mechanisms such as double buffering or versioning are used to ensure the smoothness of threshold switching and the continuity of service operation.

[0122] Through this update mechanism, the dynamic threshold mapping table can be iteratively optimized using the latest feedback data, ensuring that the judgment rules of the online detection system always maintain the best match with the current data distribution, thereby improving the adaptability and overall accuracy of the system in long-term operation.

[0123] Furthermore, refer to Figure 3 In the second embodiment of the AI-generated image detection method proposed in this application, the AI-generated image detection method includes steps S60-90:

[0124] Step S60: Obtain a training image set, which includes real images and AI images;

[0125] Step S70: Generate structured reasoning text corresponding to each training image in the training image set using a preset multimodal large model;

[0126] Step S80: Construct a training dataset based on the image-text pairs formed by the training images and the corresponding structured reasoning text;

[0127] Step S90: The visual language basic model is jointly optimized and trained using the training dataset and the preset loss function to obtain the forgery detection model, wherein the preset loss function includes contrast loss and classification loss.

[0128] The training method for the forgery detection model aims to construct a lightweight, efficient visual encoder with strong cross-domain generalization capabilities. Specifically, a reinforced expert model is used to generate high-quality semantic supervision signals. Then, through cross-modal alignment learning, high-level semantic discrimination capabilities are transferred to a lightweight base visual model, thereby training the final forgery detection model.

[0129] The entire training process comprises four main stages: data preparation, supervision signal generation, dataset construction, and joint optimization training. This training process can also be viewed... Figure 6 , Figure 6 This is a schematic diagram of the ForgeCLIP model training framework.

[0130] The first stage is data preparation. In this stage, a broad and diverse initial training image set is constructed. This training image set includes two main categories: real images and AI-generated images. To ensure the model can adapt to the complex imaging characteristics of the real world, this embodiment uses a dedicated dataset containing a large number of real images. In this dedicated dataset, the real image portion not only includes general real photo libraries from the internet, but also focuses on including original real images taken from various mainstream devices without any third-party deep post-processing, to cover the complex imaging characteristics of the real world. The number of original images shown is greater than or equal to 5000. The acquisition method for the real images shown is targeted, including not only general real photo libraries from the internet, but also specifically real images taken from various mainstream devices without any third-party deep post-processing, to cover the complex imaging characteristics of the real world. The number of original images shown is greater than or equal to 5000. For the AI-generated images, it is necessary to collect images from various generative models with different architectures and versions, such as the Stable Diffusion series, DALL-E series, Midjourney, and closed-source models such as GPT-4o or Gemini, to ensure the diversity of generation patterns. All collected images need to undergo preprocessing such as uniform size adjustment and format standardization to form the initial training sample pool.

[0131] The second stage involves generating high-quality semantic supervision signals. The data processing logic in this stage involves using a specially optimized multimodal large-scale model to generate structured diagnostic reports, i.e., structured inference text, for each training image. This multimodal large-scale model is a large-scale visual-language model trained using Group Relative Policy Optimization (GRPO), such as the GLAI model optimized based on the DeepSeek-R1 paradigm. GRPO optimization ensures that the generated text not only contains true / false conclusions but also includes detailed and interpretable reasoning processes for forgery traces, greatly improving the quality of the supervision signal. In practice, each training image is input into this large-scale model along with a preset system prompt. This system prompt can be designed as: "Please carefully analyze this image and determine whether it was generated by AI or is a real photograph taken by a camera." "Please think..." <think>The labels detail all observed visual evidence and logical reasoning supporting the judgment. Furthermore, based on the application of these system prompts, the large model outputs response text containing the reasoning chain and the final conclusion. From this response text, the relevant information is extracted. <think>The content within the tags will yield the required structured inference text. This structured inference text contains a detailed analysis by the large model of potential semantic inconsistencies, object structural anomalies, or low-level texture artifacts in the image.

[0132] The third stage involves constructing a pairing dataset for alignment learning. In this stage, the original output structured inference text needs to be cleaned, formatted, and paired to generate training samples that can be directly used by the visual language foundation model. The specific implementation process is as follows: First, each extracted structured inference text is manually verified or automatically verified based on rules to correct obvious errors or irrelevant content, ensuring text quality. Next, based on the real category labels of the training images, a uniform category prefix is ​​added to the beginning of the inference text, such as "This is a real image: [Inference Text]" or "This is an AI-generated image: [Inference Text]", thus explicitly encoding category information into the text and strengthening semantic association. Finally, the standardized structured inference text with the added prefix is ​​paired with the corresponding original training images to form complete "image-text" pairs. Combining all such pairs constitutes the image-text pairing training dataset.

[0133] The fourth stage is joint optimization training. In this stage, the pre-trained visual-language base model is fine-tuned using the constructed paired dataset to align the feature space of its image encoder with the text feature space, while preserving and enhancing its classification ability. The core of this step is to distill the generalization ability of a large model into a lightweight small model through a joint optimization strategy, ultimately enabling this lightweight model to achieve generalization results close to those of the large model and further improve inference efficiency. Specifically, the visual-language base model is initialized first, and all parameters of its text encoder are frozen, using this text encoder as a fixed, high-quality text feature extractor to output a target-aligned text semantic space. Second, a low-rank adaptive strategy is used to efficiently fine-tune the parameters of the image encoder of this base model. By injecting a small number of low-rank matrices during training, the number of trainable parameters is significantly reduced, thereby mitigating the risk of overfitting. Then, a lightweight binary classification head, typically a multilayer perceptron, is connected after the visual feature vector output by the image encoder. During training, for a batch of image-text pairs, visual feature vectors and text feature vectors are obtained through both the image encoder and the frozen text encoder.

[0134] Joint optimization is achieved through a combined loss function that combines contrastive learning loss and detection loss, i.e., classification loss. Specifically, the contrastive loss is calculated as follows: For N image-text pairs in a batch, image features v_i are first obtained through an image encoder, and text features t_i are obtained through a frozen text encoder. Then, the similarity matrix S between the image features and the text features is calculated, where S_ij = v_i · t_j (usually normalized and scaled with a temperature coefficient). The contrastive loss aims to maximize the similarity of positive sample pairs (i,i) while minimizing the similarity of negative sample pairs (i,j≠i). A common implementation is symmetric cross-entropy loss, which calculates the image-to-text cross-entropy loss and the text-to-image cross-entropy loss and takes the average. This loss function forces the feature space learned by the image encoder to align with the semantic text feature space generated by the large model, thereby distilling the large model's deep understanding of image authenticity (such as semantic contradictions, violations of physical laws, etc.) into visual features.

[0135] The classification loss directly affects the detection task itself: image features v_i are input into the binary classifier head to obtain the predicted probability p_i = σ(MLP(v_i)), where σ is the Sigmoid function. The classification loss uses binary cross-entropy loss: L_cls = -[y_i log(p_i) + (1-y_i) log(1-p_i)], where y_i is the true label of the image (1 indicates AI-generated, 0 indicates real). This loss ensures that the model does not deviate from the final detection target while optimizing feature alignment, and can directly optimize detection performance.

[0136] During joint optimization, the total loss L_total = L_contrastive + α L_cls, where α is a weighted hyperparameter balancing the two losses. Through backpropagation, the LoRA parameters in the image encoder and the parameters in the binary classifier head are updated simultaneously. This joint optimization strategy allows the model to absorb rich semantic knowledge from a large model during learning (through contrastive loss) while maintaining end-to-end detection capability (through classification loss), thus achieving generalization capabilities on a lightweight model that surpass those of traditional large-model methods. After multiple rounds of iterative training until the loss converges, the retained, finely tuned image encoder and classifier head together constitute the final forgery detection model.

[0137] In this embodiment, the forgery detection model obtained by jointly optimizing the visual language basic model inherits the deep semantic generalization ability of the text generated by the large model through GRPO optimization. On the other hand, through the joint optimization strategy, this ability is distilled into a lightweight model, so that while maintaining lightweight and efficient reasoning, it achieves a powerful cross-domain generalization effect, thereby effectively solving the technical contradiction that it is difficult to balance generalization and efficiency.

[0138] Furthermore, you can also view Figure 4 , Figure 4 This is a detailed flowchart of step S70 in the second embodiment described above, based on the above... Figure 4 The step of generating structured inference text corresponding to each training image in the training image set using a preset multimodal large model includes S71~72:

[0139] Step S71: Input the training image into the multimodal large model and output response text, wherein the response text includes at least one analysis conclusion;

[0140] Step S72: Extract the text content of the analysis conclusion, and add a real image category prefix to the text content to generate the structured reasoning text.

[0141] This embodiment describes the process of automatically generating and formatting text descriptions rich in discriminative information for training images. This process aims to provide adapted structured supervision signals for subsequent cross-modal alignment training. Its implementation includes two core steps: generating initial response text and performing text formatting.

[0142] First, the initial response text is generated. Specifically, the preprocessed training image is loaded into memory and concatenated with a preset system instruction prompt to form the complete model input. The multimodal large model used is a model that has been pre-trained on a large scale and optimized for visual language tasks. It is an LLM model optimized by Group Relative Policy Optimization (GRPO), defined as a GLAI model. GLAI is used to generate high-quality text representations, and GRPO optimization makes the generated text more inferential and detailed. After receiving a mixed input containing visual and textual information, the large model initiates internal forward inference computation. This computation process involves encoding the image into a sequence of visual features and inputting it along with the embedding vector of the text instruction into the Transformer decoder network, generating text output word by word through autoregression. The final output response text is structured and contains one or more independent analytical conclusions. Each analytical conclusion points to potential signs of forgery in the training image, such as "the outline of the person's left ear has an unnatural smooth transition and lacks the subtle wrinkles of biological tissue," or "the texture of the clouds in the background shows a repetitive pattern, which does not conform to the randomness of the natural atmosphere." By leveraging the powerful visual understanding and language generation capabilities of large models, this step transforms fine-grained visual anomalies into textual descriptions that can be processed by computers and semantically aligned, thus providing high-quality supervision signals for subsequent distillation learning.

[0143] Next, text formatting is performed. In this step, the generated raw response text undergoes information extraction and standardization to construct data units that can be directly used for training. Specifically, the system identifies structured markers or natural language patterns in the response text, locates and extracts the plain text content of one or more analytical conclusions. For example, if the large model output follows... <think> Conclusion 1; Conclusion 2; Conclusion 3< / think> If the format is "...", then all content within that tag is extracted. Next, a crucial text formatting operation is performed. Based on the known true categories of the current training image—either "real" or "AI-generated"—a unified category prefix is ​​added to the extracted analysis conclusion text. For example, for a real image, the generated prefixed text is "This is a real image: [Conclusion 1; Conclusion 2]"; for an AI-generated image, it is "This is an AI-generated image: [Conclusion 1; Conclusion 2]". This operation explicitly establishes a strong semantic association between visual features and high-level category concepts. Finally, the prefixed complete text string is identified as the structured inference text corresponding to the training image and bound to the original image, awaiting subsequent steps to form paired data.

[0144] First, the initial response text is generated. In this step, the preprocessed training image is loaded into memory and concatenated with a pre-defined system instruction prompt to form the complete model input. The multimodal large model used is a model that has been pre-trained on a large scale and optimized for visual language tasks, such as Qwen2.5-VL or a GLAI model optimized with Group Relative Policy Optimization (GRPO). GRPO optimization makes the generated text more inferential and detailed. After receiving a mixed input containing visual and textual information, the large model initiates internal forward inference computation. This computation involves encoding the image into a sequence of visual features and inputting it along with the embedding vector of the text instruction into the Transformer decoder network to generate text output word by word through autoregression. The final output response text is structured and contains one or more independent analytical conclusions. Each analytical conclusion points to potential signs of forgery in the training image, such as "the outline of the person's left ear has an unnatural smooth transition and lacks the subtle wrinkles of biological tissue," or "the texture of the clouds in the background exhibits a repetitive pattern, which does not conform to the randomness of natural atmosphere." By leveraging the powerful visual understanding and language generation capabilities of large models, this step transforms fine-grained visual anomalies into textual descriptions that can be processed by computers and semantically aligned, thus providing high-quality supervision signals for subsequent distillation learning.

[0145] Next, text formatting is performed. In this step, the generated raw response text undergoes information extraction and standardization to construct data units that can be directly used for training. Specifically, the system identifies structured markers or natural language patterns in the response text, locates and extracts the plain text content of one or more analytical conclusions. For example, if the large model output follows... <think> Conclusion 1; Conclusion 2; Conclusion 3< / think> If the format is "...", then all content within that tag is extracted. Next, a crucial text formatting operation is performed. Based on the known true categories of the current training image—either "real" or "AI-generated"—a unified category prefix is ​​added to the extracted analysis conclusion text. For example, for a real image, the generated prefixed text is "This is a real image: [Conclusion 1; Conclusion 2]"; for an AI-generated image, it is "This is an AI-generated image: [Conclusion 1; Conclusion 2]". This operation explicitly establishes a strong semantic association between visual features and high-level category concepts. Finally, the prefixed complete text string is identified as the structured inference text corresponding to the training image and bound to the original image, awaiting subsequent steps to form paired data.

[0146] In this embodiment, through rule-based post-processing, the freely generated, potentially loosely formatted outputs of the multimodal large model are transformed into standardized, structured supervision signals, ensuring the consistency of the training data format and enhancing the injection of category semantics.

[0147] Based on the above Figure 4 The content described in step S71 is further refined to include the step of inputting the training image into the multimodal large model and outputting the response text, specifically steps S71-1 to S71-6:

[0148] Step S71-1: Perform overall semantic consistency analysis on the input training images using the multimodal large model;

[0149] Step S71-2: Identify global semantic contradictions or physical law violations in the analysis results, and generate first-level analysis conclusions based on the identification results;

[0150] Step S71-3: Determine whether there are any suspicious semantic anomalies in the first-level analysis conclusion;

[0151] Step S71-4: If a suspicious semantic anomaly exists, focus on the target region in the training image that is associated with the suspicious semantic anomaly;

[0152] Step S71-5: Perform local texture and edge continuity analysis on the target area to obtain generated artifacts, and generate a second-level analysis conclusion based on the generated artifacts;

[0153] Step S71-6: Combine the first-level analysis conclusions with the second-level analysis conclusions to generate and output the response text.

[0154] This embodiment details the internal reasoning mechanism for generating response text using a multimodal large model. This mechanism simulates a hierarchical, coarse-to-fine analysis strategy, employing a multi-stage review process with progressively shifting focus to ultimately generate a logically rigorous analysis report with clearly defined levels of evidence. Its specific implementation follows these six steps.

[0155] First, a comprehensive semantic consistency analysis is performed. The multimodal large model globally encodes the input training images through its visual encoder and utilizes the world knowledge embedded in its language model to conduct a preliminary assessment of the overall plausibility of the scene. This assessment process includes checking whether the spatial relationships between objects in the image are reasonable, such as whether objects are floating in mid-air; judging whether the scene conforms to basic physical laws, such as whether the lighting and shadows are uniform; and verifying whether the content conforms to common sense, such as whether modern objects appear in historical scenes. The model compares the global image features with an implicit common sense knowledge base to form a preliminary perception of the overall naturalness of the image, providing context for subsequent fine-grained anomaly localization.

[0156] Next, pattern recognition and preliminary conclusion generation are performed. Based on the above preliminary perception, the multimodal large model identifies features in the analysis results that violate global consistency, such as architectural structures that do not conform to the principles of perspective or objects that appear to float in a way that clearly violates the law of gravity. Based on these identified abnormal features, the multimodal large model generates first-level analysis conclusions. These conclusions are usually high-level and general, such as "the consistency of lighting and shadow in the scene is questionable" or "the size ratio of objects in the image is abnormal."

[0157] Next, the first-level conclusions are evaluated and suspicious points are identified. The multimodal large model evaluates the generated first-level analysis conclusions to determine whether they contain sufficiently clear "suspicious semantic anomalies" pointing to potential forgery. If no such anomalies are found or the signs are weak, the model proceeds directly to the final conclusion synthesis process. If clear suspicious points are found, the model will perform visual attention focusing processing.

[0158] Subsequently, visual attention focusing is performed. During this process, the multimodal large model, based on the suspicious semantic anomalies indicated in the first-level analysis conclusions, such as "unnatural lighting on a person's face," guides computational resources and analysis focus to the target region in the training image associated with the anomaly, such as the person's face, through its internal self-attention mechanism or visual localization module. This step achieves the association mapping from "global semantic anomalies" to "local visual regions."

[0159] Next, a microscopic-level local inspection is performed. For the focused target area, the model performs high-resolution local texture analysis and edge continuity analysis to check for unnatural repetitive patterns in the texture, excessive smoothness with insufficient noise, color transitions with breaks, or typical generation artifacts such as blurred, broken, or abnormally blended edges with the background. Based on this visual analysis, the model generates specific and conclusive secondary analysis conclusions, such as "the skin texture in the facial cheek area exhibits a grid-like repetitive pattern" or "there is obvious pixel aliasing at the boundary between the hair and the background."

[0160] Finally, the multimodal model logically connects and synthesizes evidence from different levels, integrating the general first-level analytical conclusions with the second-level analytical conclusions that provide specific visual evidence, forming a complete chain of reasoning. For example, the synthesis might be "There is inconsistency in the overall lighting, specifically manifested in the conflict between the direction of the highlight on the person's face and the direction of the background light source." Ultimately, based on this synthesized chain of reasoning, the model generates and outputs a formatted response text containing the complete analytical process.

[0161] Furthermore, you can also view Figure 5 , Figure 5 This is a detailed step diagram of step S90 in the second embodiment described above, based on the shown... Figure 5 The steps for jointly optimizing and training the visual language base model using the training dataset and a preset loss function to obtain the forgery detection model include S91-95:

[0162] Step S91: Freeze the text encoder of the visual language base model;

[0163] Step S92: A low-rank adaptive strategy is adopted to efficiently fine-tune the parameters of the image encoder and the forgery detection head of the visual language basic model.

[0164] Step S93: The visual features output by the fine-tuned image encoder and the forgery detection head are input into a binary classifier;

[0165] Step S94: Calculate the overall objective function of the contrast loss and the classification loss, and use the overall objective function to simultaneously optimize the low-rank adaptive parameters of the image encoder and the model parameters of the binary classifier;

[0166] Step S95: Obtain the forgery detection model based on the optimization results.

[0167] This embodiment defines the specific execution flow of the joint optimization training of the forgery detection model. The data processing logic of this execution flow reshapes the image encoder of the general vision-language base model in a parameter-efficient manner, aligning its visual feature space with the highly discriminative semantic space defined by high-quality inference text, while simultaneously optimizing its end-to-end classification performance. The core of this embodiment lies in distilling the generalization ability of a large model into a lightweight small model by jointly optimizing the contrastive loss and the detection loss (i.e., classification loss). This allows the small model to achieve generalization effects close to those of the large model during inference, while maintaining extremely high computational efficiency.

[0168] In training preparation, the text semantic space of the visual language base model is locked and used as a stable and reliable optimization target anchor. Specifically, a pre-trained visual language base model, such as OpenAI's CLIP model, is loaded. The visual language base model includes two independent encoder branches: an image encoder and a text encoder. Before training begins, all weight parameters of the text encoder are set to an untrainable state by setting the "requires_grad" attribute or an equivalent interface of the model parameters of the visual language base model; this is a freeze operation. Through this freeze operation, in all subsequent training iterations, regardless of the input text, the text feature vectors generated by the text encoder are determined by the original pre-trained weights, and the representation space remains unchanged. This freeze operation maps the structured inference text rich in discriminative information generated by the GRPO-optimized multimodal large model to a stable target semantic space through a fixed text encoder; thereby significantly reducing the total number of trainable parameters, preventing the visual language base model from overfitting on limited paired data, and ensuring that the optimization process focuses on the transfer and alignment of the visual feature space.

[0169] Subsequently, the image encoder of the visual language foundation model is efficiently and adaptively modified. A low-rank adaptive strategy is adopted to achieve efficient fine-tuning of the parameters of the image encoder. Specifically, a set of trainable low-rank decomposition matrices is injected into the self-attention module and feedforward network module of each Transformer layer inside the image encoder. Based on this, the image editor can flexibly adjust its visual feature extraction behavior to align with the text space, while preserving its pre-trained basic visual representation capabilities to the greatest extent, and achieving efficient domain adaptation with minimal parameter overhead. Furthermore, the fine-tuning of the forgery detection head further enhances the model's initial response to forgery traces, laying a more solid foundation for subsequent accurate classification.

[0170] During training, the visual features output by the image editor and the forgery detection head are simultaneously used for two parallel supervisory signals: On one hand, the visual features output by the image encoder are compared with the high-quality text features output by the frozen text encoder to calculate a contrastive loss. By narrowing the feature distance between matching image-text pairs and widening mismatched pairs, the image encoder learns the semantic understanding of images from a larger model, achieving alignment in the visual-semantic space. On the other hand, the enhanced visual features output by the forgery detection head are fed into a binary classifier to calculate a classification loss, directly optimizing the authenticity discrimination capability through binary cross-entropy. Through the joint optimization of contrastive and classification losses, the LoRA parameters in the image encoder and the forgery detection head are updated synchronously, so that the visual features they learn possess both the generalization ability to align with strong discriminative text semantics and rich discriminative information sensitive to forgery traces.

[0171] Based on this, the image encoder can flexibly adjust its visual feature extraction behavior to align with the text space, while preserving its pre-trained basic visual representation capabilities to the greatest extent possible, and achieving efficient domain adaptation with minimal parameter overhead. Furthermore, fine-tuning the forgery detection head further enhances the model's initial response to forgery traces, laying a more solid foundation for subsequent accurate classification.

[0172] At the end of the modified visual feature extraction pipeline, a lightweight module dedicated to final decision-making is connected. Specifically, based on the visual feature vectors output by the fine-tuned image encoder and the forgery detection head, a binary classifier is connected to construct a parallel classification path directly facing downstream tasks. Specifically, the input image sequentially passes through an image encoder injected with LoRA and a forgery detection head. The image encoder outputs a basic visual feature vector v_base, which is then input to the forgery detection head to obtain an enhanced high-level semantic feature vector v_enhanced. The basic visual feature vector v_base is mainly used for comparison and alignment with text features, while the high-level semantic feature vector v_enhanced carries richer forgery discrimination information and is sent to the subsequent classifier. Furthermore, after the feature vector, the binary classifier is connected. The binary classifier is characterized by one or more fully connected layers, with the last layer using a sigmoid activation function to output a scalar value between 0 and 1. The binary classifier can be randomly initialized and is fully trainable, providing direct supervision signals in parallel with contrastive learning. This ensures that the visual language base model does not lose and strengthens its core ability to perform real / fake binary classification while striving to align with the text semantic space.

[0173] Throughout the training process, a general objective function combining two different supervision signals is defined, and all trainable parameters are updated synchronously using the gradient descent algorithm. Specifically, in each training batch, the following steps are performed: First, for a batch of image-text pairs, a set of text feature vectors {t_i} and a set of basic visual feature vectors {v_i} are obtained using a frozen text encoder and an image encoder injected with LoRA, respectively. The contrastive loss L_contrastive is then calculated. This loss aims to narrow the feature distance between matching image-text pairs (e.g., a real image and its "real" descriptive text) while widening the feature distance between mismatched pairs. This is crucial for knowledge distillation, enabling the image encoder to learn how the large model understands the semantics of images.

[0174] Simultaneously, the basic visual features {v_base_i} of the same batch of images are input into the LoRA forgery detection head to obtain an enhanced visual feature set {v_enhanced_i}, which is then fed into the binary classifier to obtain the predicted probability {p_i}. The classification loss L_classification is calculated, which is the difference between the predicted probability and the real image label calculated using the binary cross-entropy function, directly optimizing the final detection performance of the model. Finally, the total objective function is constructed as a weighted sum of the contrastive loss and the classification loss, and is represented as: L_total = L_contrastive + α·L_classification, where α is a hyperparameter balancing the weights of the contrastive loss and the classification loss. Using the backpropagation algorithm, the gradient of the total objective function with respect to all trainable parameters, i.e., the parameters of all LoRA matrices in the image encoder and forgery detection head, and all parameters of the binary classifier, is calculated. An optimizer (such as AdamW) is used to synchronously update the parameters of all LoRA matrices in the image encoder and forgery detection head, as well as all parameters of the binary classifier. Through this joint optimization, the contrastive loss guides the visual features of the image encoder to align with the frozen text space, and the classification loss drives the forgery detection head to enhance discriminative representations. The model's learning process is precisely guided toward an optimal solution, which can not only deeply understand the semantic authenticity of the image content (from the generalization ability of the large model), but also make accurate judgments of authenticity based on this understanding (from the proprietary ability of the classification task).

[0175] The training process is monitored and optimized, and training is terminated when preset conditions are met, and the final model is encapsulated. In specific implementation, the model performance is continuously evaluated on an independent validation set. Training terminates when the overall performance metric (such as average accuracy) on the validation set no longer improves, or when the preset maximum number of training epochs is reached. Subsequently, the weights of the image encoder and the forgery detection head (including the optimized LoRA adapter) and the weights of the binary classifier are saved, which together constitute the forgery detection model that can be used for independent inference. This forgery detection model is a lightweight small model, but because the semantic generalization ability of a large model is successfully distilled into itself through the joint optimization of contrastive loss and classification loss during training, it can achieve the powerful generalization effect originally possessed by large models in practical applications, perfectly balancing high accuracy and high efficiency.

[0176] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the AI-generated image detection method of this application. Any simple modifications based on this technical concept are within the protection scope of this application.

[0177] This application provides an AI-generated image detection device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the AI-generated image detection method in Embodiment 1 above.

[0178] The following is for reference. Figure 7 The diagram illustrates a structural schematic suitable for implementing the AI-generated image detection device in the embodiments of this application. The AI-generated image detection device in the embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The AI-generated image detection device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.

[0179] like Figure 7 As shown, the AI-generated image detection device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1003 into a random access memory (RAM) 1004. The RAM 1004 also stores various programs and data required for the operation of the AI-generated image detection device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touchscreen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 1003 including, for example, magnetic tape, hard disk, etc.; and communication devices 1009. The communication device 1009 allows the AI-generated image detection device to communicate wirelessly or wiredly with other devices to exchange data. While the figure shows AI-generated image detection devices with various systems, it should be understood that implementing or possessing all of the systems shown is not required. More or fewer systems may be implemented alternatively.

[0180] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.

[0181] The AI-generated image detection device provided in this application, employing the AI-generated image detection method described in the above embodiments, can solve the technical problem that existing AI-generated image detection methods struggle to balance generalization, efficiency, and practicality. Compared with the prior art, the beneficial effects of the AI-generated image detection device provided in this application are the same as those of the AI-generated image detection method provided in the above embodiments, and other technical features in this AI-generated image detection device are the same as those disclosed in the previous embodiment method, and will not be repeated here.

[0182] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.

[0183] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0184] This application provides a storage medium, which is a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, which are used to execute the AI-generated image detection method in the above embodiments.

[0185] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.

[0186] The aforementioned computer-readable storage medium may be included in the AI-generated image detection device; or it may exist independently and not be assembled into the AI-generated image detection device.

[0187] The aforementioned computer-readable storage medium carries one or more programs, which, when executed by the AI-generated image detection device, enable the AI-generated image detection device to implement the technical content of the AI-generated image detection method embodiment shown above.

[0188] Computer program code for performing the operations of this application can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as "C" or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0189] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0190] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.

[0191] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described AI-generated image detection method. This solves the technical problem that existing AI-generated image detection methods struggle to balance generalization, efficiency, and practicality. Compared to the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the AI-generated image detection method provided in the above embodiments, and will not be elaborated upon here.< / think> < / think>

Claims

1. An AI-generated image detection method, characterized in that, The AI-generated image detection method includes the following steps: The image to be detected is acquired and input into the image encoder of the forgery detection model, wherein the forgery detection model is obtained through cross-modal alignment training; The depth visual feature vector of the image to be detected is extracted by the image encoder; A linear operation is performed on the depth visual feature vector and the preset weight parameter matrix, and a preset bias parameter is superimposed during the linear operation to obtain an intermediate scalar value; The intermediate scalar value is used as the input to the Sigmoid function to calculate the scalar confidence score; Obtain the source attribute information of the image to be detected; In the preset dynamic threshold mapping table, query the dynamic judgment threshold corresponding to the source attribute information; If the scalar confidence score is greater than the dynamic determination threshold, then the image to be detected is determined to be an AI-generated image; If the scalar confidence score is less than or equal to the dynamic determination threshold, then the image to be detected is determined to be a real image; Prior to the step of acquiring the image to be detected and inputting the image to be detected into the image encoder of the forgery detection model, the method further includes: Obtain a training image set, which includes real images and AI images; Using a pre-defined multimodal large model, structured inference text corresponding to each training image in the training image set is generated. The training images are input into the multimodal large model, and response text is output. The response text includes at least one analysis conclusion. The text content of the analysis conclusion is extracted, and a real image category prefix is ​​added to the text content to generate the structured inference text. A training dataset is constructed based on the image-text pairs consisting of the training images and the corresponding structured reasoning text. The visual language base model is jointly optimized and trained using the training dataset and the preset loss function to obtain the forgery detection model, wherein the text encoder of the visual language base model is frozen, and the preset loss function includes contrastive loss and classification loss. In addition, before the step of querying the dynamic judgment threshold corresponding to the source attribute information in the preset dynamic threshold mapping table, the method further includes: Acquire historical detection data, which includes multiple sets of image samples, source attribute information of each image sample, corresponding confidence scores, and true category labels; Based on the source attribute information of the historical detection data, the confidence score distribution of AI-generated image samples and real image samples in the corresponding multiple groups of image samples is statistically analyzed. Based on the numerical distribution characteristics of the confidence score distribution, calculate the dynamic judgment threshold for each of the source attribute information; The source attribute information and the dynamic determination threshold are associated and stored to form the dynamic threshold mapping table.

2. The AI-generated image detection method as described in claim 1, characterized in that, After the step of associating and storing the source attribute information and the dynamic determination threshold to form the dynamic threshold mapping table, the method further includes: In response to the threshold update process start command, newly added historical detection data is obtained, and a subset of image sample data with the same source attribute information is filtered from the historical detection data; Calculate the dynamic determination threshold of the source attribute information based on the subset of image sample data; The calculated dynamic determination data is updated to the historical dynamic threshold of the source attribute information in the dynamic threshold mapping table.

3. The AI-generated image detection method as described in claim 1, characterized in that, The step of inputting the training image into the multimodal large model and outputting response text includes: The multimodal large model is used to perform overall semantic consistency analysis on the input training images; Identify global semantic contradictions or physical law violations in the analysis results, and generate first-level analysis conclusions based on the identification results; Determine whether there are any suspicious semantic anomalies in the first-level analysis conclusions; If a suspicious semantic anomaly is found, focus on the target region in the training image that is associated with the suspicious semantic anomaly; The target region is subjected to local texture and edge continuity analysis to obtain generated artifacts, and a second-level analysis conclusion is generated based on the generated artifacts; The response text is generated and output after the conclusions of the first-level analysis are combined with the conclusions of the second-level analysis.

4. The AI-generated image detection method as described in claim 1, characterized in that, The steps for jointly optimizing and training the visual language base model using the training dataset and a preset loss function to obtain the forgery detection model include: A low-rank adaptive strategy is adopted to efficiently fine-tune the parameters of the image encoder and forgery detection head of the visual language basic model. The visual features output by the fine-tuned image encoder and the forgery detection head are input into a binary classifier; Calculate the overall objective function of the contrast loss and the classification loss, and use the overall objective function to simultaneously optimize the low-rank adaptive parameters of the image encoder and the model parameters of the binary classifier; The forgery detection model is obtained based on the optimization results.

5. An AI-generated image detection device, characterized in that, The AI-generated image detection device stores a computer program, which, when executed by a processor, implements the AI-generated image detection method as described in any one of claims 1-4.

6. A storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the AI-generated image detection method as described in any one of claims 1-4.

Citation Information

Patent Citations

  • Multi-image forgery detection method and system based on cross-modal visual large language model

    CN120355985A

  • Method and apparatus for processing image, electronic device, and storage medium

    US20260045086A1