Generalization-oriented generated image authentic identification method and system

By constructing low-level feature alignment between real and AI-synthesized images and training with multiple generators, combined with a category-aware contrastive loss function, the problem of insufficient generalization ability and poor robustness of existing generated image authentication models is solved, achieving stronger cross-generator and image perturbation adaptability.

CN121904456APending Publication Date: 2026-04-21XI AN JIAOTONG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
XI AN JIAOTONG UNIV
Filing Date
2025-12-31
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

Existing image generation authentication techniques exhibit serious problems such as insufficient generalization ability, easy overfitting of models to specific distributions of training data, and poor robustness when faced with unseen image generation models, different image compression formats, resolutions, and post-processing operations.

Method used

By collecting real images and AI-synthesized images for low-level feature alignment, a multi-generator training-evaluation closed loop is constructed. A category-aware contrastive loss function is adopted, combined with various data augmentation strategies and a lightweight classification head, to improve the model's generalization ability.

Benefits of technology

It significantly improves the model's robustness in discriminating against unknown generators and different image perturbations, reduces the risk of the model learning non-causal features due to dataset bias, and enhances its adaptability to diverse forgery patterns.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121904456A_ABST
    Figure CN121904456A_ABST
Patent Text Reader

Abstract

The invention discloses a generalization-oriented generated image authentic identification method and system, and belongs to the technical field of artificial intelligence generation authentic identification. The method comprises the following steps: constructing a training set and a test set which cover a plurality of generators, and realizing low-level feature alignment of real and generated images; generating double non-overlapping views through data enhancement, extracting features through an encoder, and projecting the features to a contrast learning space; comparing a loss training model based on category perception, and iteratively optimizing parameters; and after the encoder is frozen, a classification head is trained, and after test enhancement and feature extraction are performed on the to-be-authenticated image, an authentication result is output. The problems of insufficient generalization, overfitting, performance deviation and the like of an existing model are solved, the authenticity identification robustness and precision of a cross-generator and cross-preprocessing mode are improved, and the method is suitable for detection scenes of various AI generated images.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of artificial intelligence image generation and authentication technology, specifically relating to a generalizable image generation authentication method and system. Background Technology

[0002] In recent years, image generation has made significant progress thanks to the development of deep learning models such as Variational Autoencoders (VAEs), Generative Adversarial Networks (GANs), and diffusion-based systems. Recently, text-to-image generation models, i.e., diffusion-based models, have been widely adopted due to their impressive performance. However, this capability has also been used to create increasingly difficult-to-distinguish fake images from real ones. Therefore, there is an urgent need to develop effective methods for detecting AI-generated images. The convolutional neural network CNNSpot trained a standard CNN model and found that the detector easily identifies synthetic images from visible models, but struggles to generalize to invisible models. UnivFD, using Contrastive Language-Image Pre-training (CLIP) as its backbone, demonstrates improved generalization ability for detecting invisible generators. Subsequent work explores model architecture and image preprocessing to achieve more generalized detection. C2P-CLIP enhances the pre-trained CLIP backbone for Artificial Intelligence Generated Image (AIGI) detection by injecting real and fake concepts. This work utilizes frequency domain artifacts, showing that frequency artifacts can be distinguished well. Neighboring Pixel Relationships (NPR) explores upsampling artifacts in generative models. However, the generalization of these methods is limited by content bias or frequency level bias, potentially exploiting non-causal features such as image format, which may degrade performance on unbiased test sets.

[0003] Advances in AI-generated image detection technology, the rapid development of generative models, and the emergence of new architectures have presented challenges to cross-domain generalization. This is particularly evident in zero-shot scenarios involving previously unseen generative paradigms. Early research has shown that detectors trained on GANs generalize poorly to other types of generators. Currently, AI-generated image detection, even models utilizing large pre-trained visual-language models for feature extraction, often exhibit significant performance degradation when tested with images from previously unseen models. Furthermore, during training, detectors can capture subtle differences between real and fake images in the dataset. Models can exploit these non-causal features to distinguish between real and synthetic images, leading to performance bias and an inability to generalize across different datasets.

[0004] Previous experimental designs primarily revolved around two training and testing strategies: one was single-generator training and multi-generator testing, where the model was trained only on data generated by a specific generator but tested on data generated by all generators; the other was multi-generator training and multi-generator testing, where data from eight generators were introduced during the training phase, and model performance was evaluated on a test set that also covered all generators. Experimental results showed that under the first training strategy, although the model achieved high detection accuracy on the trained generator, its performance significantly declined on samples generated by other, unseen generators, exhibiting severe overfitting and insufficient generalization. This indicates that current anti-spoofing models struggle to effectively identify the generated content of unknown generators, exhibiting a significant domain shift problem. In contrast, under the second training strategy, when the model was trained on data generated by multiple generators, its overall test performance across multiple generators significantly improved. Especially when facing new generators not present in the training phase, the model maintained a high recognition accuracy. This result demonstrates that training with more generator data can effectively enhance the model's ability to generalize to generated image features, thereby improving its robustness in cross-generator discrimination.

[0005] In the experiments, various training and testing combinations were constructed under different compression conditions (generated images): including PNG format (lossless), JPEG85 (medium compression), and compression ratios corresponding to real images (containing multiple unknown compression ratios). Experimental results show that when the compression methods of the training and test sets are consistent, the model achieves good detection performance under the corresponding conditions. For example, under JPEG85 training, the model performs well on the JPEG85 test set. However, this performance is highly "dependent," meaning the model only performs well on data using the compression method used for training. Once the compression method of the test data changes, its performance drops rapidly, demonstrating poor robustness and generalization ability across compression methods. In contrast, when training data is mixed with multiple compression methods consistent with real images, the model maintains relatively stable performance under various compression conditions. This indicates that if the training data's compression method is as close as possible to the distribution of the real world, it helps the model learn more generalized forgery features, thereby improving its adaptability to different compression modes.

[0006] Image resolution is another important low-level factor affecting the performance of image artifact detection models. In practical applications, real-world images often have diverse resolutions and are typically uniformly scaled to a fixed size (e.g., 256×256) for model training or deployment. This process involves different interpolation methods and scaling factors, which can introduce additional artifacts or texture variations. In contrast, most generative models (such as Stable Diffusion 1.4) output images with relatively fixed resolutions (e.g., 512×512), so when scaling them to a uniform size, the scaling factor tends to be consistent. However, when training with both generated and real images and testing on real images, it was found that if the scaling factor used during training is inconsistent with that used for the test images, it leads to a significant drop in model performance. The same conclusion applies to interpolation methods. To mitigate this problem, random scaling should be attempted during training to simulate the diversity of real-world application scenarios. Experimental results show that this enhancement strategy can significantly improve the model's stability at different scaling factors, especially exhibiting stronger adaptability when facing real images. Summary of the Invention

[0007] The technical problem to be solved by the present invention is to provide a generalizable generated image authentication method and system to address the shortcomings of the prior art. This method solves the problems of insufficient generalization ability, easy overfitting of the model to a specific distribution of the training data, and poor robustness of the existing methods when faced with image generation models that have not been seen during training, different image compression formats, resolutions, and post-processing operations.

[0008] The present invention adopts the following technical solution: A generalization-oriented method for detecting fake images generated from images includes the following steps: S1. Collect real images, design text prompts based on the real images, and use various text-driven image generation models to generate AI-synthesized images, so that the real images and AI-synthesized images are aligned on low-level features, and obtain training sets and test sets. S2. Initialize an initial model containing a preset encoder and a projection layer. During the training phase, introduce AI-synthesized image data generated by multiple generators and iteratively train the initial model. After each iteration of training, use a test set covering the multiple generators to evaluate the generalization performance of the intermediate model obtained in the current iteration and obtain the detection performance index of the intermediate model on test samples corresponding to different generators. S3. Perform two independent and random enhancement transformations on each input image in the training set to generate two image views with no overlapping regions; input the two image views into the preset encoder of the initial model to extract feature vectors, and project the feature vectors onto the contrast learning space through the projection layer of the initial model to obtain projected features; S4. Based on the projection features, calculate the training loss using the category-aware contrastive loss function, adjust the training parameters in combination with the obtained detection performance index, update the parameters of the encoder and projection layer in the initial model using the backpropagation algorithm, iteratively execute steps S2 to S4 until the detection performance index meets the preset generalization requirements, and obtain the pre-trained model. S5. Freeze the encoder parameters in the pre-trained model, add a classification head and train it. After performing test enhancement processing on the input image to be identified, extract features through the encoder and output the identification result using the classification head.

[0009] Preferably, in step S1, the low-level feature alignment includes at least one of image format alignment, image compression rate alignment, and image resolution alignment for the real image and the AI-synthesized image.

[0010] Preferably, in step S2, the preset encoder is a ResNet-50 or a Vision Transformer, the encoder removes the last classification layer and outputs a 2048-dimensional feature vector; the projection layer is a two-layer MLP structure, which includes linear transformation, batch normalization, ReLU activation and linear transformation in sequence, and the projection layer projects the 2048-dimensional feature vector onto a 128-dimensional contrastive learning space; the encoder is initialized with ImageNet pre-trained weights, and the projection layer is initialized randomly.

[0011] Preferably, in step S2, the detection performance indicators include accuracy, precision, and recall.

[0012] Preferably, in step S3, the enhancement transformation includes: Directional blurring: Apply a slight Gaussian blur that matches the artifact features of the generated image; Standard geometric transformations include random cropping, horizontal flipping, and small-angle rotation. Moderate color adjustment: Employ a larger color dithering effect than the generated image; The enhancement transformation does not include JPEG compression.

[0013] Preferably, in step S4, the calculation process of the category-aware contrastive loss function includes: Define a positive sample pair as: two enhanced views of the same image, or all image views of the same category; Define a negative sample pair as: a pair of images representing all distinct categories; Calculate the cosine similarity between projected features to form a similarity matrix; Construct a binary mask matrix, where a value of 1 corresponds to a positive sample pair and a value of 0 corresponds to a negative sample pair; The training loss is calculated using the InfoNCE loss formula.

[0014] Preferably, in step S4, the SGD optimizer is used to update the parameters of the encoder and projection layer in the initial model, and the learning rate adopts a cosine annealing strategy; after each training cycle, the generalization performance of the intermediate model is evaluated through the test set, and the change of the validation loss is monitored. When the validation loss no longer decreases and the detection performance index meets the preset generalization requirements, training is stopped and the current model weights are saved as a pre-trained model.

[0015] Preferably, in step S5, the test enhancement process is a center clipping and standardization process.

[0016] Preferably, in step S5, the classification head consists of 1-2 fully connected layers, outputting a 2D vector, and using 0.5 as a threshold to determine whether the image to be identified is a real image or an AI-synthesized image.

[0017] Secondly, embodiments of the present invention provide a generalizable generated image authentication system, comprising: Data module: used to collect real images, design text prompts based on the real images, generate AI-synthesized images using multiple text-driven image generation models, align the real images and AI-synthesized images at low-level features, and obtain training and test sets, both of which cover the image data corresponding to the multiple generators; Initialization module: used to initialize an initial model containing a preset encoder and projection layer, introduce AI-synthesized image data generated by multiple generators during the training phase, and iteratively train the initial model; after each iteration of training, the generalization performance of the intermediate model obtained in the current iteration is evaluated using a test set covering the multiple generators, and the detection performance index of the intermediate model on the test samples corresponding to different generators is obtained. Feature module: used to perform two independent and random enhancement transformations on each input image in the training set to generate two image views with non-overlapping regions; input the two image views into the preset encoder of the initial model to extract feature vectors, and project the feature vectors to the contrast learning space through the projection layer of the initial model to obtain projected features; Training module: Based on the projection features, calculate the training loss using the category-aware contrastive loss function, adjust the training parameters in combination with the obtained detection performance index, update the parameters of the encoder and projection layer in the initial model using the backpropagation algorithm, iteratively execute steps S2 to S4 until the detection performance index meets the preset generalization requirements, and obtain the pre-trained model. The fake detection module is used to freeze the encoder parameters in the pre-trained model, add a classification head and train it, perform test enhancement processing on the input image to be faked, extract features through the encoder, and output the fake detection result using the classification head.

[0018] Thirdly, a computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the steps of the generalized image generation authentication method described above.

[0019] Fourthly, embodiments of the present invention provide a computer-readable storage medium including a computer program, which, when executed by a processor, implements the steps of the above-described generalized image generation authentication method.

[0020] Fifthly, a chip includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the steps of the generalizable image generation authentication method described above.

[0021] In a sixth aspect, embodiments of the present invention provide an electronic device including a computer program, which, when executed by the electronic device, implements the steps of the above-described generalized image generation authentication method.

[0022] Compared with the prior art, the present invention has at least the following beneficial effects: A generalized generative image forgery detection method is proposed, which utilizes multiple generative models to construct synthetic images and aligns them with low-level features of real images. This fundamentally reduces the risk of the model learning non-causally related features due to dataset bias, forcing the model to learn more essential forgery traces. It employs multi-generator training and evaluation using a test set encompassing multiple generators during iterations. Simulating the challenge of the proliferation of generative models in the real world, it forces the model to be exposed to highly diverse forgery patterns during learning, rather than overfitting to specific artifacts of a single generator. This directly improves its zero-shot or few-shot adaptability when facing unknown generators. A category-aware contrastive loss is introduced for pre-training. Compared to traditional binary cross-entropy loss, this loss function constructs positive and negative sample pairs at the image view level, bringing the model closer to features of all real images and all generated images in the feature space, while simultaneously distancing these two categories of features. This allows the encoder to learn more essential and robust representations of real and synthetic features, rather than simply fitting a shallow decision boundary. Finally, by freezing the pre-trained encoder and fine-tuning the lightweight classification head, the learned powerful generalization features are preserved, enabling efficient adaptation to specific anti-spoofing tasks.

[0023] Furthermore, the real images are sourced from public datasets such as COCO and CC3M, with a total number of no less than 380k images. The generated images employ 16 mainstream models to ensure data diversity and representativeness, avoiding model bias caused by a single data source. The ratio of training to test sets balances training sufficiency and evaluation accuracy. Low-level feature alignment eliminates non-essential differences between real and generated images in the dataset, preventing the model from mistakenly using non-causal features such as format and resolution as identification criteria. This reduces the risk of performance bias from the data source and provides unbiased data support for the subsequent model to learn general forgery features, significantly improving training effectiveness and model generalization potential.

[0024] Furthermore, ResNet-50 or Vision Transformer is selected as the encoder, utilizing their pre-trained weights on large-scale image datasets to quickly extract high-quality visual features, avoiding insufficient feature learning caused by training from scratch; the 2048-dimensional feature vector output of the final classification layer is removed, retaining rich low-level and high-level feature information; two MLP projection layers use a linear transformation-batch normalization-ReLU activation-linear transformation structure to accurately project high-dimensional features onto a 128-dimensional contrastive learning space, simplifying computational complexity while ensuring feature discriminativeness; the initialization strategies of the encoder and projection layers are adapted to their respective functional positioning, accelerating training convergence and improving feature quality, providing high-quality input for category-aware contrastive loss calculation, and directly supporting the improvement of model generalization and discrimination accuracy.

[0025] Furthermore, the detection performance metrics are limited to accuracy, precision, and recall, comprehensively covering the core evaluation dimensions of the counterfeit detection task and avoiding the one-sidedness of evaluation caused by a single metric. Accuracy reflects the overall counterfeit detection effect, precision ensures the accuracy of generated image recognition, and recall ensures the comprehensive capture of generated images. The combination of the three can objectively reflect the model's performance in different scenarios. Using these metrics as feedback during iterative training can accurately determine whether the model has problems such as overfitting or insufficient generalization, guide the adjustment of training parameters, and ensure that the model training moves towards the goal of improving generalization, avoiding the waste of resources and performance deviation caused by blind training.

[0026] Furthermore, targeted blurring is used to match artifact features in the generated image, simulating slight blurring interference in real-world scenes without obscuring core discriminative features. Standard geometric transformations enrich data diversity, allowing the model to adapt to images with different poses and viewpoints. Moderate color adjustments employ a larger jitter amplitude than the generated image, matching the high tolerance of real images to color changes and preventing the model from learning biased color-related features. JPEG compression is explicitly excluded because compression artifacts in real images differ from those in generated images, preventing the model from mistakenly using compression traces as a basis for discrimination. Expanding the distribution of training data and focusing on essential discriminative features significantly improves the model's resistance to preprocessing perturbations.

[0027] Furthermore, by expanding the range of positive samples, the model not only learns the view invariance of a single image but also grasps the common features at the category level of real / generated images; negative samples clearly define the boundaries of different classes, enhancing feature discrimination; cosine similarity calculation combined with a binary mask matrix accurately quantifies the similarity relationship between samples, avoiding noise interference; the InfoNCE loss formula and temperature parameter adjustment balance the effects of feature aggregation and dispersion, guiding the model to learn more generalizable discriminative features. This shift from a result-oriented to a feature-oriented approach effectively improves the model's ability to recognize diverse artifact patterns in generated images, which is the core technical support for improving the model's generalization ability.

[0028] Furthermore, the SGD optimizer is used to update parameters, combined with a cosine annealing learning rate strategy. This not only allows for rapid convergence to a high-quality parameter space but also avoids parameter oscillations caused by excessively high learning rates in the later stages. The training termination condition is set at the point where the validation loss no longer decreases and the detection performance metric meets the target, forming a dual constraint that prevents overfitting while ensuring that the model's generalization meets the requirements. Generalization performance evaluation after each training cycle captures performance changes during model training in a timely manner, providing real-time feedback for parameter adjustment. The model weights with the lowest validation loss are saved as pre-trained models to ensure that the optimal model is used for subsequent inference, avoiding the impact of insufficiently trained or overfitted models on the false detection effect, and significantly improving the reliability and practicality of the model.

[0029] Furthermore, the test enhancement is limited to center cropping and standardization, which eliminates feature interference caused by inconsistent image sizes while maintaining the integrity of information in the core image region. Standardization unifies the pixel value distribution of the image, keeping it consistent with the preprocessing in the training stage and avoiding feature extraction bias caused by differences in data distribution. This processing strategy is simple and efficient, does not introduce additional artifacts or information loss, and ensures that the features extracted by the encoder can truly reflect the essential attributes of the image, providing reliable input for the classification head and directly improving the anti-spoofing accuracy in the inference stage. This allows the model to maintain stable performance when faced with diverse input images in real-world scenarios.

[0030] Furthermore, the structure of 1-2 fully connected layers is simple, with low computational complexity, and will not significantly increase inference time, ensuring the efficiency of counterfeit detection; the output is a 2D vector that directly corresponds to the binary classification target of the counterfeit detection task, with clear logic; the classification is judged with a threshold of 0.5, which is simple, intuitive and easy to operate, avoiding judgment delays or errors caused by complex decision rules; the classification head is trained separately after the encoder is frozen, which utilizes the generalized features learned by the encoder and adapts to the binary classification task through targeted training, achieving a balance between feature generalization and task specificity. While improving the counterfeit detection accuracy, it also takes into account real-time requirements, making it suitable for deployment and application on various terminal devices.

[0031] It is understood that the beneficial effects of the second to sixth aspects mentioned above can be found in the relevant descriptions in the first aspect mentioned above, and will not be repeated here.

[0032] In summary, the method of this invention improves the model's cross-generator generalization ability, enhances the model's robustness to various image perturbations in practical applications, and solves the pain points of poor generalization and dependence on specific data distribution in existing anti-spoofing techniques.

[0033] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description

[0034] Figure 1 This is a graph showing the statistical results of the deviation between the dataset of this invention and existing datasets; Figure 2 A graph showing the relationship between image format and anti-counterfeiting accuracy; Figure 3 A graph showing the relationship between image size, interpolation method, and anti-counterfeiting accuracy. Figure 4 This is a model architecture diagram; Figure 5 A graph showing the relationship between different training settings and the authentication results is provided. (a) is the authentication result graph for single generator training and multi-generator testing, and (b) is the authentication result graph for multi-generator training and multi-generator testing. Figure 6 A diagram showing the impact of loss on counterfeit detection; Figure 7 A diagram showing the impact of loss on robustness; Figure 8 A schematic diagram of a computer device provided in an embodiment of the present invention; Figure 9 This is a block diagram of a chip according to an embodiment of the present invention; Figure 10 This is a flowchart of the method of the present invention.

[0035] Among them, 60. Computer equipment; 61. Processor; 62. Memory; 63. Computer program; 600. Electronic device; 610. Processing unit; 620. Storage unit; 6201. Random access memory unit; 6202. Cache memory unit; 6203. Read-only memory unit; 6204. Program / utility; 6205. Program module; 630. Bus; 640. Display unit; 650. Input / output interface; 660. Network adapter; 700. External device. Detailed Implementation

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

[0037] In the description of this invention, it should be understood that the terms "comprising" and "including" indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.

[0038] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the invention. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.

[0039] It should also be further understood that the term "and / or" as used in this specification and the appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes such combinations. For example, A and / or B can represent three cases: A alone, A and B simultaneously, and B alone. Additionally, the character " / " in this invention generally indicates that the preceding and following objects have an "or" relationship.

[0040] It should be understood that although terms such as first, second, third, etc., may be used in the embodiments of the present invention to describe the preset range, these preset ranges should not be limited to these terms. These terms are only used to distinguish the preset ranges from one another. For example, without departing from the scope of the embodiments of the present invention, the first preset range may also be referred to as the second preset range, and similarly, the second preset range may also be referred to as the first preset range.

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

[0042] The accompanying drawings illustrate various structural schematic diagrams according to embodiments disclosed in this invention. These drawings are not to scale, and some details have been enlarged for clarity, and some details may have been omitted. The shapes of the various regions and layers shown in the drawings, as well as their relative sizes and positional relationships, are merely exemplary and may deviate from reality due to manufacturing tolerances or technical limitations. Furthermore, those skilled in the art can design regions / layers with different shapes, sizes, and relative positions as needed.

[0043] This invention provides a generalization-oriented method for detecting fake images generated from images. Addressing the shortcomings of existing methods, such as insufficient generalization, reliance on non-causal features, and weak robustness, this invention proposes a core innovative solution. It constructs an unbiased dataset aligned with low-level features of real and AI-synthesized images, covering data from 16 mainstream generators, thus mitigating bias at the source. A multi-generator training-evaluation closed loop is employed, dynamically adjusting parameters based on accuracy, precision, and recall to resolve cross-generator domain bias. Targeted data augmentation is designed to match generated image artifacts and eliminate JPEG compression interference. ResNet-50 / VisionTransformer combined with two MLP projection layers optimizes feature extraction and adaptation. An innovative category-aware contrast loss expands the range of positive samples to enhance category-level feature learning. A frozen encoder and lightweight classification head are used for staged inference, balancing generalization and efficiency. This invention significantly improves the robustness and accuracy of fake image detection across generators and preprocessing methods, making it suitable for real-world applications.

[0044] Please see Figure 10 The present invention provides a generalizable image generation authentication method, comprising the following steps: S1. Construction of the dataset Please see Figure 1This work involved constructing datasets for both generated and real images. Over 380k real images were collected from multiple public datasets (COCO, CC3M, etc.), and various levels of detail-based text prompts were designed to guide the generative model in generating corresponding AI-synthesized images. To ensure the quality and diversity of the generated images, 16 mainstream text-driven image generation models, including SDXL, FLUX.1-dev, and SD3, were used, and prompt engineering techniques were employed to optimize the generation results. Ultimately, a training set of 380k*6 AI-generated images and a test set of 160k AI-generated images were obtained. Simultaneously, low-level alignment was achieved between the collected real images and the generated images, such as JPEG compression and resolution adjustments.

[0045] Please see Figure 2 and Figure 3 Detectors trained on datasets containing these discrepancies are prone to learning biased features, incorrectly associating realism with format, image size, or semantics. Our dataset avoids learning these biased features as much as possible.

[0046] S2, multi-generator training, multi-generator testing The experimental design mainly revolves around two training and testing strategies: one is single generator training and multi-generator testing, where the model is trained on data generated by only one specific generator, but tested on data generated by all generators; the other is multi-generator training and multi-generator testing, where data from 8 generators are introduced during the training phase, and the model performance is evaluated on a test set that also covers all generators.

[0047] S3, Model Structure S301, Data augmentation The same input image is subjected to two independent and random enhancement transformations to generate two "views"—that is, two different small images displayed in the image, where the two small images come from different regions and cannot overlap.

[0048] Directional blurring: Apply a slight Gaussian blur, but adjust the parameters to match the blur effect with the artifact features of the generated image, avoiding obscuring key discriminative features.

[0049] Standard geometric transformations: Apply conventional random cropping, horizontal flipping, and small-angle rotation to maintain the diversity of natural images.

[0050] Moderate color adjustment: Allows for greater color jitter than the generated image, because real images are more tolerant of color variations.

[0051] Avoid compression enhancement: Do not apply JPEG compression, because real images typically do not produce artifacts similar to those in the generated images after compression.

[0052] S302, encoder and project layer Build a deep learning model that can learn to distinguish between real and generated images, including the components required for feature extraction and contrastive learning.

[0053] Encoder Selection: A powerful visual encoder, such as ResNet-50 or VisionTransformer, is chosen as the base network. These networks are pre-trained on large-scale image datasets and are capable of extracting high-quality visual features. The final classification layer of the encoder is removed, retaining only the feature extraction part, outputting a 2048-dimensional feature vector.

[0054] Projection layer design: A two-layer MLP projection head is added after the encoder to project the 2048-dimensional features onto a 128-dimensional contrastive learning space. The projection layer includes: linear transformation → batch normalization → ReLU activation → linear transformation. The last layer has no activation function to ensure that the output can be used to calculate cosine similarity.

[0055] Model Combination: The encoder and projection layer are combined into a unified model that takes an image as input and outputs two results: the original feature vector (used for subsequent classification tasks) and the projected features (used for contrastive loss calculation).

[0056] Parameter initialization: The encoder is initialized with ImageNet pre-trained weights to speed up training and improve feature quality; the projection layer is initialized randomly because it is a task-specific component.

[0057] S303, Calculation of Category-Aware Contrast Loss We design a novel contrastive loss function that enables the model to learn to distinguish between real and generated images, rather than just learning view invariance for a single image.

[0058] Positive sample definition: Positive sample pairs are defined as two classes: 1) Two enhanced views of the same image; 2) All image views of the same category (e.g., all views of generated images).

[0059] This expands the range of positive samples for standard contrastive learning, enabling the model to learn class-level similarity.

[0060] Negative sample definition: All image view pairs of different categories are defined as negative samples (such as real image view and generated image view).

[0061] Similarity calculation: Calculate the cosine similarity between all projected features to form a similarity matrix. The similarity value ranges from [-1, 1], with larger values ​​indicating greater feature similarity.

[0062] Category mask construction: A binary mask matrix is ​​created, where a value of 1 represents a positive sample pair (samples of the same class), and a value of 0 represents a negative sample pair. This mask combines the "same image" mask of standard contrastive learning with the "same image" mask of category-aware learning.

[0063] Loss Calculation: The final loss is calculated using the InfoNCE loss formula. For each sample, the sum of its similarity to all positive samples is calculated, divided by the sum of its similarity to all samples (including both positive and negative samples), and then the negative logarithm is taken. The temperature parameter controls the sharpness of the distribution, initially set to 0.2, and gradually decreased to 0.05 during training.

[0064] S304, Model Training Process The model is trained by category-aware contrastive learning, enabling it to effectively distinguish between real and generated images.

[0065] Data Loading: Build a data loader that retrieves one batch of images and labels from the training set at a time. For each image in the batch, apply the appropriate augmentation strategy based on its category, generating two views.

[0066] Forward propagation: Input two views into the model to obtain projected features. Note that it's important to maintain the consecutive positions of the two views of the same image within the batch to facilitate subsequent loss calculation.

[0067] Loss Calculation: The loss value for the current batch is calculated using a category-aware contrastive loss function. The loss considers both the similarity of samples of the same class and the differences between samples of different classes.

[0068] Parameter update: Gradients are calculated via backpropagation, and the parameters of the encoder and projection layers are updated using the SGD optimizer. A cosine annealing strategy is used for the learning rate.

[0069] Validation monitoring: After each training epoch, evaluate the model performance on the validation set. Monitor changes in the validation loss, and stop training when the loss stops decreasing to prevent overfitting.

[0070] Model saving: Save the model weights with the lowest validation loss and use them as a pre-trained model for subsequent classification tasks.

[0071] S305, Reasoning Stage The pre-trained model is adapted to a binary classification task to enable the determination of whether a single image is real or generated.

[0072] Freeze the encoder: Load the pre-trained encoder weights and freeze all parameters to ensure they are no longer updated. This preserves the discriminative features learned by the encoder.

[0073] Add a classification head: Add a lightweight classification head after the encoder, usually consisting of 1-2 fully connected layers, which outputs a 2D vector (scores for the real class and the generated class).

[0074] Classifier training: The classifier head is trained using the training set, while the encoder remains frozen. Since the encoder has learned high-quality features, the classifier typically converges in just 10-20 epochs.

[0075] Inference process: Test-time augmentation (center cropping and normalization only) is applied to the input image, features are extracted by the encoder, and then the prediction result is obtained by the classification head. The output is the probability value of the generated image, usually with a threshold of 0.5 to determine the category.

[0076] S306, Evaluation Phase Metrics Calculation: Calculate multiple evaluation metrics, including accuracy, precision, and recall. Pay particular attention to the accuracy of generated images.

[0077] Confusion Matrix Analysis: A detailed analysis of the confusion matrix identifies sample types that the model is prone to confuse. For example, it examines which real images are misclassified as generated images (potentially low-quality or real images from specific scenes) and which generated images are misclassified as real images (potentially high-quality generated images).

[0078] In another embodiment of the present invention, a generalizable generated image authentication system is provided. This system can be used to implement the above-mentioned generalizable generated image authentication method. Specifically, the generalizable generated image authentication system includes a data module, an initialization module, a feature module, a training module, and an authentication module.

[0079] The data module is used to collect real images, design text prompts based on the real images, generate AI-synthesized images using multiple text-driven image generation models, align the real images and AI-synthesized images at low-level features, and obtain training and test sets. Both training and test sets cover the image data corresponding to the multiple generators. Initialization module: used to initialize an initial model containing a preset encoder and projection layer, introduce AI-synthesized image data generated by multiple generators during the training phase, and iteratively train the initial model; after each iteration of training, the generalization performance of the intermediate model obtained in the current iteration is evaluated using a test set covering the multiple generators, and the detection performance index of the intermediate model on the test samples corresponding to different generators is obtained. Feature module: used to perform two independent and random enhancement transformations on each input image in the training set to generate two image views with non-overlapping regions; input the two image views into the preset encoder of the initial model to extract feature vectors, and project the feature vectors to the contrast learning space through the projection layer of the initial model to obtain projected features; Training module: Based on the projection features, calculate the training loss using the category-aware contrastive loss function, adjust the training parameters in combination with the obtained detection performance index, update the parameters of the encoder and projection layer in the initial model using the backpropagation algorithm, iteratively execute steps S2 to S4 until the detection performance index meets the preset generalization requirements, and obtain the pre-trained model. The fake detection module is used to freeze the encoder parameters in the pre-trained model, add a classification head and train it, perform test enhancement processing on the input image to be faked, extract features through the encoder, and output the fake detection result using the classification head.

[0080] This invention provides a terminal device comprising a processor and a memory. The memory stores a computer program, which includes program instructions. The processor executes the program instructions stored in the computer storage medium. The processor may be a Central Processing Unit (CPU), or other general-purpose processors, graphics processing units (GPUs), tensor processing units (TPUs), digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. It is the computing and control core of the terminal, suitable for implementing one or more instructions, specifically suitable for loading and executing one or more instructions to implement a corresponding method flow or corresponding function. The processor described in this embodiment can be used for the operation of a generalized image authentication method, including: Real images are collected, and text prompts are designed based on these images. Multiple text-driven image generation models are used to generate AI-synthesized images, aligning the real images with the AI-synthesized images at low-level features to obtain training and testing sets. An initial model containing a preset encoder and projection layer is initialized. During the training phase, AI-synthesized image data generated by multiple generators is introduced, and the initial model is iteratively trained. After each iteration, the generalization performance of the intermediate model obtained in the current iteration is evaluated using a test set covering the multiple generators, obtaining the detection performance index of the intermediate model on test samples corresponding to different generators. Each input image in the training set undergoes two independent and random enhancement transformations to generate two images with non-overlapping regions. The process involves: inputting the two image views into the preset encoder of the initial model to extract feature vectors; projecting these feature vectors onto the contrast learning space through the projection layer of the initial model to obtain projected features; calculating the training loss using a category-aware contrastive loss function based on the projected features; adjusting the training parameters by combining the obtained detection performance index; updating the parameters of the encoder and projection layer in the initial model using the backpropagation algorithm based on the training loss; iterating until the detection performance index meets the preset generalization requirement to obtain a pre-trained model; freezing the encoder parameters in the pre-trained model; adding a classification head and training the model; performing test enhancement processing on the input image to be identified; extracting features through the encoder; and outputting the identification result using the classification head.

[0081] Please see Figure 8 The terminal device is a computer device. In this embodiment, the computer device 60 includes a processor 61, a memory 62, and a computer program 63 stored in the memory 62 and executable on the processor 61. When executed by the processor 61, the computer program 63 implements the generalized generated image authentication method described in this embodiment. To avoid repetition, these details are not elaborated here. Alternatively, when executed by the processor 61, the computer program 63 implements the functions of each model / unit in the generalized generated image authentication system described in this embodiment. To avoid repetition, these details are not elaborated here.

[0082] Computer device 60 can be a desktop computer, laptop, handheld computer, cloud server, or other computing device. Computer device 60 may include, but is not limited to, a processor 61 and a memory 62. Those skilled in the art will understand that... Figure 8 This is merely an example of computer device 60 and does not constitute a limitation on computer device 60. It may include more or fewer components than shown, or combine certain components, or different components. For example, computer device may also include input / output devices, network access devices, buses, etc.

[0083] The processor 61 may be a Central Processing Unit (CPU), or other general-purpose processors, graphics processing units (GPUs), tensor processing units (TPUs), digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.

[0084] The memory 62 can be an internal storage unit of the computer device 60, such as a hard disk or memory of the computer device 60. The memory 62 can also be an external storage device of the computer device 60, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc. equipped on the computer device 60.

[0085] Furthermore, the memory 62 may include both internal storage units and external storage devices of the computer device 60. The memory 62 is used to store computer programs and other programs and data required by the computer device. The memory 62 can also be used to temporarily store data that has been output or will be output.

[0086] Please see Figure 9 The terminal device is an electronic device 600, which is manifested in the form of a general-purpose computing device. The components of the electronic device may include, but are not limited to: at least one processing unit 610, at least one storage unit 620, a bus 630 connecting different platform components (including storage unit 620 and processing unit 610), a display unit 640, etc.

[0087] The storage unit stores program code, which can be executed by the processing unit 610 to perform the steps described in the method section of this specification according to various exemplary embodiments of the present invention. For example, the processing unit 610 can perform actions such as... Figure 1 The steps are shown in the figure.

[0088] Storage unit 620 may include a readable medium in the form of a volatile storage unit, such as random access memory (RAM) 6201 and / or cache memory 6202, and may further include a read-only memory (ROM) 6203.

[0089] Storage unit 620 may also include a program / utility 6204 having a set (at least one) program module 6205, such program module 6205 including but not limited to: operating system, one or more application programs, other program modules and program data, each or some combination of these examples may include an implementation of a network environment.

[0090] Bus 630 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the multiple bus structures.

[0091] Electronic device 600 can also communicate with one or more external devices 700 (e.g., keyboard, pointing device, Bluetooth device, etc.), and with one or more devices that enable a user to interact with electronic device 600, and / or with any device that enables electronic device 600 to communicate with one or more other computing devices (e.g., router, modem). This communication can be performed via input / output interface 650. Furthermore, electronic device 600 can also communicate with one or more networks (e.g., local area network, wide area network, and / or public network, such as the Internet) via network adapter 660. Network adapter 660 can communicate with other modules of electronic device 600 via bus 630. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 600, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage platforms.

[0092] Example 4 This invention also provides a storage medium, specifically a computer-readable storage medium, which is a memory device in a terminal device for storing programs and data. It is understood that the computer-readable storage medium here can include both built-in storage media in the terminal device and extended storage media supported by the terminal device; it can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. The computer-readable storage medium provides storage space that stores the terminal's operating system. Furthermore, the storage space also stores one or more instructions suitable for loading and execution by a processor, which can be one or more computer programs (including program code). More specific examples of the computer-readable storage medium include: an electrical connection with one or more wires, a portable disk, a hard disk, random access memory, read-only memory, erasable programmable read-only memory, optical fiber, portable compact disk read-only memory, optical storage device, magnetic storage device, or any suitable combination thereof.

[0093] Computer-readable storage media also include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable storage medium can also be any readable medium other than a readable storage medium that can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the readable storage medium can be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, radio frequency, etc., or any suitable combination thereof.

[0094] Program code for performing the operations of this invention can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java and C++, and conventional procedural programming languages ​​such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0095] One or more instructions stored in a computer-readable storage medium can be loaded and executed by a processor to implement the corresponding steps of the generalization-oriented generated image authentication method in the above embodiments; one or more instructions in the computer-readable storage medium are loaded and executed by the processor in the following steps: Real images are collected, and text prompts are designed based on these images. Multiple text-driven image generation models are used to generate AI-synthesized images, aligning the real images with the AI-synthesized images at low-level features to obtain training and testing sets. An initial model containing a preset encoder and projection layer is initialized. During the training phase, AI-synthesized image data generated by multiple generators is introduced, and the initial model is iteratively trained. After each iteration, the generalization performance of the intermediate model obtained in the current iteration is evaluated using a test set covering the multiple generators, obtaining the detection performance index of the intermediate model on test samples corresponding to different generators. Each input image in the training set undergoes two independent and random enhancement transformations to generate two images with non-overlapping regions. The process involves: inputting the two image views into the preset encoder of the initial model to extract feature vectors; projecting these feature vectors onto the contrast learning space through the projection layer of the initial model to obtain projected features; calculating the training loss using a category-aware contrastive loss function based on the projected features; adjusting the training parameters by combining the obtained detection performance index; updating the parameters of the encoder and projection layer in the initial model using the backpropagation algorithm based on the training loss; iterating until the detection performance index meets the preset generalization requirement to obtain a pre-trained model; freezing the encoder parameters in the pre-trained model; adding a classification head and training the model; performing test enhancement processing on the input image to be identified; extracting features through the encoder; and outputting the identification result using the classification head.

[0096] The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0097] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.

[0098] Regarding datasets: The generalizability of AIGI detectors is hampered by dataset bias. Existing datasets often exhibit systematic differences in attributes unrelated to authority. For example, word frequency analysis illustrates semantic bias, and image size bias models can utilize these non-causal features to distinguish between real and synthetic images, leading to biased detector performance and an inability to generalize across different datasets. Dataset alignment, by ensuring that synthetic images are highly similar to real images, promises to address dataset bias, eliminate factors related to authenticity, and guide the detector to focus on clues related to forgery. For example, real images are JPEG-encoded and vary in size, while synthetic images are uniformly PNG-encoded and have a fixed size.

[0099] In terms of the model: the core advantage of category-aware contrastive learning methods lies in the fact that they not only solve the "what" problem (distinguishing between real and generated images) but also the "why" problem (understanding the essential features of the generated images). Ordinary binary classification detectors act like a result-oriented judge, focusing only on the final judgment; while category-aware contrastive learning acts like a feature-oriented expert, deeply understanding the inherent feature patterns of the generated images. This difference is particularly crucial in the following scenarios: in the real world, images may undergo various processing methods, and the robustness of contrastive learning methods makes them more reliable.

[0100] Analysis of the impact of the Generator level on the performance of the anti-counterfeiting algorithm Please see Figure 5Experimental results show that, under the first training strategy, although the model achieves high detection accuracy on the trained generator, its performance drops significantly on samples generated by other unseen generators, exhibiting severe overfitting and insufficient generalization ability. This indicates that the current anti-spoofing model struggles to effectively identify the generated content when faced with unknown generators, exhibiting a significant domain shift problem. In contrast, under the second training strategy, after training the model on data generated by multiple generators, its overall test performance across multiple generators significantly improves. Especially when facing new generators not present in the training phase, the model maintains high recognition accuracy. This result demonstrates that incorporating data from more generators during training can effectively enhance the model's generalization learning ability towards generated image features, thereby improving its robustness in cross-generator discrimination.

[0101] Analysis of the impact of category-aware contrast loss on the performance of counterfeit detection algorithms Please see Figure 6 This experiment systematically evaluated the performance of three different pre-training strategies in the generated image detection task, based on CLIP-L / 14, frozen CLIP-B / 32, and CLIP-B / 32 model fine-tuned by category-aware contrastive learning. Experimental results show that CLIP-L / 14 (left column) performs robustly on most generators, achieving an average accuracy (ACC) of 69.32%. Its detection accuracy exceeds 97% for mainstream diffusion models such as SD 1.4 and SD 1.5. However, its detection capability for older or specific architectures like GR-GAN and PG 2.5 is significantly insufficient (Fake_Acc is only 21.85% and 31.81%, respectively), indicating that its generalization ability is limited by the distribution of pre-training data. The most significant performance leap is reflected in the right column—after fine-tuning CLIP-B / 32 in the orange area (i.e., the category-aware contrastive learning framework), the model's detection performance on all generators is greatly improved, with an average ACC as high as 74.07%, and the average Fake_Acc jumping from 35.44% to 61.39%, especially for the most difficult-to-detect GR-GAN and PG models. For generators of type 2.5, the Fake_Acc rate surged from 5.21% and 19.37% to 14.38% and 73.32%, respectively, demonstrating that this method effectively enhances the model's ability to learn diverse artifact patterns. Category-aware contrastive learning, by combining general visual representations with task-specific artifact learning, not only significantly improves the detection capability for various generators but also enhances the model's robustness and generalization when faced with new and old, high and low quality generated images, validating its great potential as a next-generation paradigm for generated image detection.

[0102] Analysis of the impact of category-aware contrast loss on robustness Please see Figure 7The core purpose of this experimental table is to verify the effect of class-aware contrastive learning on improving model robustness. It compares the performance differences between the frozen CLIP-V / 14 baseline model and the CLIP-B / 32 model fine-tuned with class-aware contrastive learning under different test settings. The two columns on the left show the results for the frozen CLIP-V / 14 model: when the test settings are consistent with training (crop 224 only), the average accuracy (ACC) reaches 75.71%. However, once the test settings are changed to "resize 256 + crop 224", the ACC drops sharply to 58.22%, and Fake_Acc plummets from 54.95% to 38.84%, indicating that the model is highly sensitive to the preprocessing method and lacks cross-setting generalization ability. In contrast, the two columns on the right show the performance of the CLIP-B / 32 model after fine-tuning with category-aware contrastive learning: Under the same test settings (crop 224), its ACC is as high as 71.09%, slightly lower than CLIP-V / 14. However, after changing the test settings (resize 256 + crop 224), the ACC only slightly decreases to 71.03%, Fake_Acc decreases slightly from 53.87% to 53.87%, almost without loss, while Real_Acc remains stable above 89.99%, demonstrating extremely strong robustness. This proves that category-aware contrastive learning not only improves the model's ability to learn the essential artifact features of generated images, but more importantly, it enhances its resistance to preprocessing perturbations such as input scale and cropping methods—even when the training and testing settings are inconsistent, the model can still maintain high performance. This has significant practical value for real-world deployment scenarios where image sources are diverse and preprocessing is uncontrollable.

[0103] In summary, this invention presents a generalizable generative image authentication method and system. Through core designs such as multi-generator training and testing, low-level feature alignment, and category-aware contrastive loss, it significantly improves the generalization and robustness of generative image authentication. Experiments show that the model achieves a substantial improvement in detection accuracy on unseen generators, with an average ACC of 74.07%, and a significant improvement in Fake_Acc for difficult-to-detect generators. Its performance remains stable across compression formats, resolutions, and interpolation methods, avoiding performance drops caused by inconsistent training and testing conditions. It effectively reduces dependence on non-causal features, lowers the risk of overfitting, and exhibits strong adaptability to real-world scenarios. This invention balances authentication accuracy and efficiency, providing a reliable solution for AI-generated image detection. It can be widely applied in media verification, content moderation, and other scenarios, and has significant practical value.

[0104] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0105] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0106] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed in this invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0107] In the embodiments provided by this invention, it should be understood that the disclosed devices / terminals and methods can be implemented in other ways. For example, the device / terminal embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0108] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0109] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0110] If the integrated module / unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random-access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electrical carrier signals and telecommunication signals.

[0111] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus, and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0112] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0113] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0114] The above content is only for illustrating the technical concept of the present invention and should not be construed as limiting the scope of protection of the present invention. Any modifications made to the technical solution based on the technical concept proposed in this invention shall fall within the scope of protection of the claims of this invention.

Claims

1. A generalizable generative image authentication method, characterized in that, Includes the following steps: S1. Collect real images, design text prompts based on the real images, and use various text-driven image generation models to generate AI-synthesized images, so that the real images and AI-synthesized images are aligned on low-level features, and obtain training sets and test sets. S2. Initialize an initial model containing a preset encoder and a projection layer. During the training phase, introduce AI-synthesized image data generated by multiple generators and iteratively train the initial model. After each iteration of training, the generalization performance of the intermediate model obtained in the current iteration is evaluated using a test set covering the multiple generators, and the detection performance index of the intermediate model on the test samples corresponding to different generators is obtained. S3. Perform two independent and random enhancement transformations on each input image in the training set to generate two image views with no overlapping regions. The two image views are input into the preset encoder of the initial model to extract feature vectors. The feature vectors are then projected onto the contrast learning space through the projection layer of the initial model to obtain projected features. S4. Based on the projection features, calculate the training loss using the category-aware contrastive loss function, adjust the training parameters in combination with the obtained detection performance index, update the parameters of the encoder and projection layer in the initial model using the backpropagation algorithm, iteratively execute steps S2 to S4 until the detection performance index meets the preset generalization requirements, and obtain the pre-trained model. S5. Freeze the encoder parameters in the pre-trained model, add a classification head and train it. After performing test enhancement processing on the input image to be identified, extract features through the encoder and output the identification result using the classification head.

2. The generalization-oriented generative image authentication method according to claim 1, characterized in that, In step S1, the low-level feature alignment includes at least one of image format alignment, image compression rate alignment, and image resolution alignment for the real image and the AI-synthesized image.

3. The generalization-oriented generative image authentication method according to claim 1, characterized in that, In step S2, the preset encoder is either ResNet-50 or Vision Transformer. The encoder removes the last classification layer and outputs a 2048-dimensional feature vector. The projection layer is a two-layer MLP structure, which includes linear transformation, batch normalization, ReLU activation, and linear transformation in sequence. The projection layer projects the 2048-dimensional feature vector onto a 128-dimensional contrastive learning space. The encoder is initialized with ImageNet pre-trained weights, and the projection layer is initialized randomly.

4. The generalization-oriented image generation anti-counterfeiting method according to claim 1, characterized in that, In step S2, the detection performance indicators include accuracy, precision, and recall.

5. The generalization-oriented generative image authentication method according to claim 1, characterized in that, In step S3, the enhancement transformation includes: Directional blurring: Apply a slight Gaussian blur that matches the artifact features of the generated image; Standard geometric transformations include random cropping, horizontal flipping, and small-angle rotation. Moderate color adjustment: Employ a larger color dithering effect than the generated image; The enhancement transformation does not include JPEG compression.

6. The generalization-oriented generative image authentication method according to claim 1, characterized in that, In step S4, the calculation process of the category-aware contrastive loss function includes: Define a positive sample pair as: two enhanced views of the same image, or all image views of the same category; Define a negative sample pair as: a pair of images representing all distinct categories; Calculate the cosine similarity between projected features to form a similarity matrix; Construct a binary mask matrix, where a value of 1 corresponds to a positive sample pair and a value of 0 corresponds to a negative sample pair; The training loss is calculated using the InfoNCE loss formula.

7. The generalization-oriented generative image authentication method according to claim 1, characterized in that, In step S4, the SGD optimizer is used to update the parameters of the encoder and projection layer in the initial model, and the learning rate adopts the cosine annealing strategy. After each training cycle, the generalization performance of the intermediate model is evaluated through the test set, and the change of the validation loss is monitored. When the validation loss no longer decreases and the detection performance index meets the preset generalization requirements, training is stopped and the current model weights are saved as a pre-trained model.

8. The generalization-oriented generative image authentication method according to claim 1, characterized in that, In step S5, the test enhancement process consists of center clipping and standardization.

9. The generalization-oriented generative image authentication method according to claim 1, characterized in that, In step S5, the classification head consists of 1-2 fully connected layers, outputting a 2D vector, and using 0.5 as a threshold to determine whether the image to be identified is a real image or an AI-synthesized image.

10. A generalizable generative image authentication system, characterized in that, include: Data module: used to collect real images, design text prompts based on the real images, generate AI-synthesized images using multiple text-driven image generation models, align the real images and AI-synthesized images at low-level features, and obtain training and test sets, both of which cover the image data corresponding to the multiple generators; Initialization module: used to initialize an initial model containing a preset encoder and projection layer, introduce AI-synthesized image data generated by multiple generators during the training phase, and iteratively train the initial model; After each iteration of training, the generalization performance of the intermediate model obtained in the current iteration is evaluated using a test set covering the multiple generators, and the detection performance index of the intermediate model on the test samples corresponding to different generators is obtained. Feature module: used to perform two independent and random enhancement transformations on each input image in the training set to generate two image views with non-overlapping regions; The two image views are input into the preset encoder of the initial model to extract feature vectors. The feature vectors are then projected onto the contrast learning space through the projection layer of the initial model to obtain projected features. Training module: Used to calculate training loss based on the projection features using a category-aware contrastive loss function, adjust training parameters in combination with the obtained detection performance index, update the parameters of the encoder and projection layer in the initial model using the backpropagation algorithm, and iterate until the detection performance index meets the preset generalization requirements to obtain a pre-trained model; The fake detection module is used to freeze the encoder parameters in the pre-trained model, add a classification head and train it, perform test enhancement processing on the input image to be faked, extract features through the encoder, and output the fake detection result using the classification head.