Generated content detection method and related device
Through the pre-trained content classification model, the characteristics of different content generation algorithms are extracted and fused, and the generalization of the generated content detection method is solved, ensuring the accuracy and adaptability of the detection.
Patent Information
- Application Number
- CN202411278636.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-12
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2044-09-12
AI Technical Summary
The existing generated content detection methods have decreased generalization when the content generation algorithm is updated, resulting in a significant reduction in detection accuracy, and it is impossible to effectively identify the content generated by the new and old content generation algorithm.
The pre-trained content classification model is adopted to extract the content features of different content generation algorithms through feature extraction layer, feature fusion network and classification header to ensure that the model has high generalization and accuracy in both new and old algorithms.
It realizes the detection accuracy when the content generation algorithm is updated, ensures the generalization and accuracy of the generated content detection, and avoids the decline in the performance of the detection model on new and old algorithms.
Smart Images

Figure CN118799715B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of software technology, and in particular to a generated content detection method and related devices. Background Art
[0002] At present, generative AI has developed rapidly in the fields of content creation such as images and videos. The generated content (such as images generated by image generation algorithms and videos generated by video generation algorithms) can be so realistic that they are indistinguishable from the real thing.
[0003] When detecting generated content, we can often only target specific content generation algorithms. Once the content generation algorithm is updated, its generalization will be greatly reduced, which will lead to a significant drop in detection accuracy. Summary of the invention
[0004] In view of the above problems, the present application provides a generated content detection method and related devices to achieve the purpose of effectively identifying generated content without losing generalization. The specific scheme is as follows:
[0005] A first aspect of the present application provides a generated content detection method, the generated content detection method comprising:
[0006] Obtain the target content to be detected;
[0007] Retrieve a pre-trained content classification model, the content classification model can extract content features of different content generation algorithms and classify through feature fusion; wherein the training process of the content classification model includes constructing a basic model, the model includes a feature extraction layer, a feature fusion network and a classification head, the feature extraction layer includes multiple pre-trained feature extractors, and one feature extractor corresponds to one content generation algorithm; obtain a training data set, the training data set includes real content and generated content generated by the content generation algorithm corresponding to each feature extractor; select sample content for this training from the real content and the generated content, annotate the sample content with a classification label, and input the sample content into the basic model to train the basic model until the loss function value meets the corresponding convergence condition, and then terminate the training; use the basic model after the training as the content classification model;
[0008] The target content is input into the content classification model, and a target classification result of the target content is predicted by the content classification model, where the target classification result is used to indicate whether the target content belongs to generated content.
[0009] In a possible implementation, the target content is a target image, the content classification model is an image classification model, the content generation algorithm is an image generation algorithm, the content feature is an image feature, and the generated content is a generated image;
[0010] The training process of the image classification model includes:
[0011] Constructing a first basic model, wherein the first basic model includes a first feature extraction layer, a first feature fusion network and a first classification head, wherein the first feature extraction layer includes a plurality of pre-trained first feature extractors, and one first feature extractor corresponds to one image generation algorithm;
[0012] Acquire a first training data set, wherein the first training data set includes a first real image and a first generated image generated by an image generation algorithm corresponding to each first feature extractor;
[0013] A first sample image for this training is selected from the first real image and the first generated image, a first classification label is annotated on the first sample image, and the first sample image is input into the first basic model to achieve:
[0014] Extracting the first image features of the first sample image through each first feature extractor; splicing the first image features extracted by each first feature extractor and adding a learnable first feature variable; performing fusion learning based on the self-attention mechanism on the first image features added with the first feature variable through the first feature fusion network to obtain a second image feature; extracting features corresponding to the first feature variable from the second image features, and outputting the extracted features to the first classification head; performing classification prediction on the features obtained by the first classification head to obtain a first classification result of the first sample image, the first classification result being used to characterize whether the first sample image belongs to the generated image; calculating a first loss function value of the first sample image according to the first classification result and the first classification label, updating the weight parameters of the first feature fusion network and the first classification head according to the first loss function value, and returning to execute the step of selecting the first sample image for this training from the first real image and the first generated image until the first loss function value satisfies the corresponding first convergence condition, and then terminating the training;
[0015] The first basic model after training is used as the image classification model.
[0016] In a possible implementation, the training process of each first feature extractor includes:
[0017] Constructing a second basic model, wherein the second basic model includes a first original feature extractor and a second classification head, and the first original feature extractor includes a single first feature extraction network;
[0018] Acquire a second training data set, where the second training data set includes a second real image and a second generated image generated by a target image generation algorithm, where the target image generation algorithm is an image generation algorithm corresponding to the first feature extractor to be trained;
[0019] A second sample image for this training is selected from the second real image and the second generated image, a second classification label is marked on the second sample image, and the second sample image is input into the second basic model to achieve:
[0020] Extracting a third image feature of the second sample image through the first feature extraction network; performing classification prediction on the third image feature through the second classification head to obtain a second classification result of the second sample image, wherein the second classification result is used to characterize whether the second sample image belongs to the generated image; calculating a second loss function value of the second sample image according to the second classification result and the second classification label, updating weight parameters of the first feature extraction network and the second classification head according to the second loss function value, and returning to execute the step of selecting the second sample image for this training from the second real image and the second generated image until the second loss function value satisfies the corresponding second convergence condition, and then terminating the training;
[0021] The first original feature extractor after training is used as the first feature extractor corresponding to the target image generation algorithm.
[0022] In a possible implementation, obtaining the first training data set includes:
[0023] According to the number of the plurality of first feature extractors in the first feature extraction layer, sampling the third generated image generated by the image generation algorithm corresponding to each first feature extractor;
[0024] Using the sampled third generated image as the first generated image;
[0025] The first real images are captured, where the number of the first real images is the same as the number of the first generated images.
[0026] In a possible implementation, the training process of the image classification model further includes:
[0027] In response to the image generation algorithm update instruction, the step of constructing the first basic model is returned to be executed.
[0028] In a possible implementation, the target content is a target video, the content classification model is a video classification model, the content generation algorithm is a video generation algorithm, the content feature is a video feature, and the generated content is a generated video;
[0029] The training process of the video classification model includes:
[0030] Constructing a third basic model, wherein the third basic model includes a second feature extraction layer, a second feature fusion network and a third classification head, wherein the second feature extraction layer includes a plurality of pre-trained second feature extractors, and one second feature extractor corresponds to one video generation algorithm;
[0031] Acquire a third training data set, wherein the third training data set includes a first real video and a first generated video generated by a video generation algorithm corresponding to each second feature extractor;
[0032] A first sample video for this training is selected from the first real video and the first generated video, a third classification label is marked on the first sample video, and the first sample video is input into the third basic model to achieve:
[0033] Extracting the first video features of the first sample video through each second feature extractor, wherein some features of the first video features belong to the learnable second feature variables; performing fusion learning based on the cross-attention mechanism on the first video features extracted by each second feature extractor through the second feature fusion network to obtain second video features; extracting features corresponding to the second feature variables from the second video features, and outputting the extracted features to the third classification head; performing classification prediction on the features obtained by the third classification head to obtain a third classification result of the first sample video, wherein the third classification result is used to characterize whether the first sample video belongs to the generated video; calculating the third loss function value of the first sample video according to the third classification result and the third classification label, updating the weight parameters of the second feature fusion network and the third classification head according to the third loss function value, and returning to execute the step of selecting the first sample video for this training from the first real video and the first generated video until the third loss function value satisfies the corresponding third convergence condition, and then terminating the training;
[0034] The third basic model that has completed training is used as the video classification model.
[0035] In a possible implementation, the training process of each second feature extractor includes:
[0036] Constructing a fourth basic model, wherein the fourth basic model includes a second original feature extractor and a fourth classification head, wherein the second original feature extractor includes a plurality of second feature extraction networks and a third feature fusion network;
[0037] Acquire a fourth training data set, wherein the fourth training data set includes a second real video and a second generated video generated by a target video generation algorithm, wherein the target video generation algorithm is a video generation algorithm corresponding to the second feature extractor to be trained;
[0038] A second sample video for this training is selected from the second real video and the second generated video, a fourth classification label is marked on the second sample video, and the second sample video is output to the fourth basic model to achieve:
[0039] Extract the third video feature of the second sample video through each second feature extraction network; splice the third video feature extracted by each second feature extraction network, and add a learnable third feature variable; perform fusion learning based on the self-attention mechanism on the third video feature added with the third feature variable through the third feature fusion network to obtain a fourth video feature; extract the feature corresponding to the third feature variable from the fourth video feature, and output the extracted feature to the fourth classification head; perform classification prediction on the features obtained by the fourth classification head to obtain a fourth classification result of the second sample video, and the fourth classification result is used to characterize whether the second sample video belongs to the generated video; calculate the fourth loss function value of the second sample video according to the fourth classification result and the fourth classification label, update the weight parameters of the multiple second feature extraction networks, the third feature fusion network and the fourth classification head according to the fourth loss function value, and return to execute the step of selecting the second sample video for this training from the second real video and the second generated video until the fourth loss function value meets the corresponding fourth convergence condition, and then end the training;
[0040] The second original feature extractor after training is used as the second feature extractor corresponding to the target video generation algorithm.
[0041] In a possible implementation, obtaining the third training data set includes:
[0042] According to the number of the plurality of second feature extractors in the second feature extraction layer, sampling the third generated video generated by the video generation algorithm corresponding to each second feature extractor;
[0043] Using the sampled third generated video as the first generated video;
[0044] The first real videos are captured, where the number of the first real videos is the same as the number of the first generated videos.
[0045] In a possible implementation, the training process of the video classification model further includes:
[0046] In response to the video generation algorithm update instruction, return to execute the construction of the third basic model.
[0047] A second aspect of the present application provides a generated content detection device, the generated content detection device comprising:
[0048] A content acquisition module, used to acquire target content to be detected;
[0049] The content detection module is used to call a pre-trained content classification model, which can extract content features of different content generation algorithms and classify them through feature fusion; input the target content into the content classification model, and predict the target classification result of the target content through the content classification model, and the target classification result is used to characterize whether the target content belongs to generated content.
[0050] A third aspect of the present application provides a computer program product, including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements the generated content detection method of the first aspect or any implementation of the first aspect.
[0051] A fourth aspect of the present application provides an electronic device, comprising at least one processor and a memory connected to the processor, wherein:
[0052] The memory is used to store computer programs;
[0053] The processor is used to execute the computer program so that the electronic device can implement the generated content detection method of the first aspect or any implementation manner of the first aspect.
[0054] In a fifth aspect, the present application provides a computer storage medium, which carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement the generated content detection method of the first aspect or any implementation method of the first aspect.
[0055] By means of the above technical solution, the present application provides a generated content detection method and related devices, which pre-trains a content classification model, and the content classification model can extract content features of different content generation algorithms and classify them through feature fusion. The target content to be detected is obtained, and then the content classification model is retrieved, and the target content is further input into the content classification model. The target classification result of the target content is predicted by the content classification model, and the target classification result is used to characterize whether the target content belongs to generated content. The present application can fuse the content features of different content generation algorithms to train the content classification model, which makes the content classification model highly generalizable and accurate in both new and old content generation algorithms, thereby ensuring the accuracy of generated content detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
[0057] Figure 1 A method flow chart of a method for generating content detection provided in an embodiment of the present application;
[0058] Figure 2 A partial method flow chart of a method for generating content detection provided in an embodiment of the present application;
[0059] Figure 3 A schematic diagram of the structure of the first basic model provided in an embodiment of the present application;
[0060] Figure 4 A flowchart of another part of a method for generating content detection provided in an embodiment of the present application;
[0061] Figure 5 A flowchart of another part of a method for generating content detection provided in an embodiment of the present application;
[0062] Figure 6 A flowchart of another part of a method for generating content detection provided in an embodiment of the present application;
[0063] Figure 7 A schematic diagram of the structure of the third basic model provided in the embodiment of the present application;
[0064] Figure 8 A flowchart of another part of a method for generating content detection provided in an embodiment of the present application;
[0065] Fig. 9 A flowchart of another part of a method for generating content detection provided in an embodiment of the present application;
[0066] Fig.10 A schematic diagram of the structure of a generated content detection device provided in an embodiment of the present application;
[0067] Fig.11 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0068] The following describes the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. The terms used in the implementation method section of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application.
[0069] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0070] Taking the case where the content is an image and the content generation algorithm is an image generation algorithm as an example, the existing detection method of the image generation algorithm has the following disadvantages:
[0071] According to different image generation algorithms, the detection methods are also targeted. The detection methods of generated images can be divided into two schools, namely active recognition and passive recognition. Active recognition refers to actively implanting invisible watermarks in the generated image after the image is generated. The impact of this watermark on the image quality is basically invisible. When the generated image is detected, if the implanted watermark can be restored, it is a generated image; passive recognition refers to not implanting watermarks and identifying any given image indiscriminately. Since the active recognition method requires the implantation of invisible watermarks in advance, it is insufficient in applicability.
[0072] Existing passive recognition solutions basically rely on image generation algorithms, which use the images generated by the image generation algorithm to form a training data set to train an image classification model to determine whether it is a generated image. The detection rate of new image generation algorithms will be quite low. In addition, the image generation algorithm is updated very quickly, and the generated images are increasingly difficult to detect accurately, which poses a huge challenge to the detection of generated images.
[0073] Previous generative image detection methods do not generalize well to images generated by increasingly updated image generation algorithms. In other words, whenever an image generation algorithm makes a breakthrough, the detection rate of previous generative image detection methods for the images generated by it will drop significantly. Moreover, after adding images generated by new image generation algorithms to the training data set for retraining, the performance on previous image generation methods will often decline. In general, in the face of increasingly updated image generation algorithms, there is currently no effective solution to overcome the challenges they bring. Even if the image classification model is retrained, it cannot effectively solve the problem of the model's performance decline on images generated by previous image generation algorithms.
[0074] Of course, the same is true for the problems with video generation algorithms. In this regard, the present application aims to solve the problem that when content generation algorithms such as image generation algorithms and video generation algorithms are updated, the generalization of the detection model will be greatly reduced, resulting in a significant drop in accuracy. The embodiment of the present application provides a generated content detection method and related devices, so that the generated content detection can be updated following the content generation algorithm. The present application can supplement the intelligent detection means of generated content such as images and videos, and form a standardized review system for generated content. In addition, the present application can help companies and brands prevent the occurrence of copyright-infringing content, thereby protecting corporate reputation and brand image. The generated content detection method of the embodiment of the present application is described in detail below in conjunction with the accompanying drawings.
[0075] See also Figure 1 , Figure 1 A method flow chart of a method for generating content detection provided in an embodiment of the present application. Figure 1 As shown, a generated content detection method provided in an embodiment of the present application may include the following steps S101 to S103, and these steps are described in detail below.
[0076] S101, obtaining target content to be detected.
[0077] In an embodiment of the present application, the target content may be text, sound, image or video, etc., to be detected as generated content. The number may be one or more, which is specifically specified by the user and is not limited in this embodiment of the present application.
[0078] S102, retrieve a pre-trained content classification model, the content classification model can extract content features of different content generation algorithms and classify them through feature fusion; wherein the training process of the content classification model includes constructing a basic model, the model includes a feature extraction layer, a feature fusion network and a classification head, the feature extraction layer includes multiple pre-trained feature extractors, and one feature extractor corresponds to one content generation algorithm; obtain a training data set, the training data set includes real content and generated content generated by the content generation algorithm corresponding to each feature extractor; select sample content for this training from the real content and the generated content, annotate the sample content with a classification label, and input the sample content into the basic model to train the basic model until the loss function value meets the corresponding convergence condition, and then terminate the training; use the basic model after the training as the content classification model.
[0079] In the embodiment of the present application, the content classification model is a model trained in a supervised manner, which can extract content features of each content generation algorithm, and then perform feature fusion and classification based on the fused features.
[0080] Different content classification models can be set for different content generation algorithms. For example, an image generation algorithm can be trained to obtain an image classification model, while a video generation algorithm can be trained to obtain a video classification model.
[0081] Taking the image classification model as an example, the image generation algorithm that the image classification model can use to extract image features may include different types of image generation algorithms, and may also include different versions of image generation algorithms of the same type, which is not limited in the embodiments of the present application.
[0082] S103, inputting the target content into the content classification model, and predicting the target classification result of the target content through the content classification model, where the target classification result is used to indicate whether the target content belongs to generated content.
[0083] In an embodiment of the present application, taking the target content as an image as an example, the target content is input into an image classification model, and the image classification model is used to predict whether the target content is a generated image; taking the target content as a video as an example, the target content is input into a video classification model, and the video classification model is used to predict whether the target content is a generated video.
[0084] In a possible implementation, the image classification model may include first feature extractors corresponding to different image generation algorithms, and each first feature extractor can accurately extract image features of the generated image generated by the corresponding image generation algorithm. In this scenario, the target content is the target image, the content classification model is the image classification model, the content generation algorithm is the image generation algorithm, the content features are the image features, and the generated content is the generated image.
[0085] See also Figure 2 , Figure 2 This is a partial method flow chart of a method for generating content detection provided in an embodiment of the present application. Figure 2 As shown, an embodiment of the present application provides a method for generating content detection, wherein the training process of the image classification model may include the following steps S201 to S204, and these steps are described in detail below.
[0086] S201, constructing a first basic model, the first basic model comprising a first feature extraction layer, a first feature fusion network and a first classification head, the first feature extraction layer comprising a plurality of pre-trained first feature extractors, and one first feature extractor corresponds to one image generation algorithm.
[0087] S202, obtaining a first training data set, where the first training data set includes a first real image and a first generated image generated by an image generation algorithm corresponding to each first feature extractor.
[0088] S203, selecting a first sample image for this training from the first real image and the first generated image, annotating a first classification label on the first sample image, and inputting the first sample image into the first basic model to achieve:
[0089] Extract the first image features of the first sample image through each first feature extractor; splice the first image features extracted by each first feature extractor and add the learnable first feature variable; perform fusion learning based on the self-attention mechanism on the first image features added with the first feature variable through the first feature fusion network to obtain the second image features; extract the features corresponding to the first feature variable from the second image features, and output the extracted features to the first classification head; perform classification prediction on the features obtained by the first classification head to obtain the first classification result of the first sample image, and the first classification result is used to characterize whether the first sample image belongs to the generated image; calculate the first loss function value of the first sample image according to the first classification result and the first classification label, update the weight parameters of the first feature fusion network and the first classification head according to the first loss function value, and return to execute the step of selecting the first sample image for this training from the first real image and the first generated image until the first loss function value meets the corresponding first convergence condition, and then end the training.
[0090] S204, using the first basic model after training as an image classification model.
[0091] Specifically, in the embodiment of the present application, a first basic model corresponding to the image classification model is first constructed. Figure 3 , Figure 3This is a schematic diagram of the structure of the first basic model provided in the embodiment of the present application. Figure 3 As shown, the first basic model includes a first feature extraction layer A-1, a first feature fusion network A-2 and a first classification head A-3 connected in sequence. The first feature extraction layer A-1 includes n pre-trained first feature extractors (i.e. Figure 3 In the first feature extractor 1, the first feature extractor 2, the first feature extractor 3, ..., the first feature extractor n), one first feature extractor corresponds to an image generation algorithm, that is, a certain version of an image generation algorithm under a certain type, and the corresponding first feature extractor can accurately extract the image features of the generated image. In addition, the first classification head A-3 can be a multilayer perceptron network (also called MLP, Multilayer Perceptron).
[0092] Furthermore, a first training data set for training the image classification model is obtained, wherein the first training data set includes a collected first real image and a first generated image generated by an image generation algorithm corresponding to each first feature extractor, wherein the first real image can be captured from a database.
[0093] In a possible implementation, the number of first generated images corresponding to each first feature extractor in the first training data set is the same, and the total number of first generated images corresponding to all first feature extractors is the same as the number of first real images. Figure 4 , Figure 4 This is another part of the method flow chart of a method for generating content detection provided in an embodiment of the present application. Figure 4 As shown, an embodiment of the present application provides a method for generating content detection, wherein "obtaining a first training data set" in step S202 may include the following steps S2021 to S2023, and these steps are described in detail below.
[0094] S2021: Sample the third generated image generated by the image generation algorithm corresponding to each first feature extractor according to the number of the multiple first feature extractors in the first feature extraction layer.
[0095] S2022: Use the sampled third generated image as the first generated image.
[0096] S2023, capturing first real images, where the number of the first real images is the same as the number of the first generated images.
[0097] Specifically, in the embodiment of the present application, it is assumed that when training a single first feature extractor, the image generation algorithm corresponding to each first feature extractor generates 500,000 generated images (i.e., third generated images). Based on this, the 500,000 third generated images corresponding to each first feature extractor are sampled, and the sampling number is 500,000 / k, where k is the total number of first feature extractors in the first feature extraction layer. The sampled 500,000 third generated images are used as the first generated images.
[0098] In addition, first real images are collected, for example, 500,000 first real images are captured from a database, and the number of first real images is ensured to be the same as the number of first generated images, thereby constructing a first training data set containing 1 million images.
[0099] In the process of multiple iterations of training the first basic model, a first sample image for this training can be selected from the first training data set, and the first sample image is composed of the selected first real image and the first generated image, and the number of the two is the same. In addition, the first sample image is annotated with a corresponding first classification label, wherein the first classification label of the first real image in the first sample image can be 1, and the first classification label of the first generated image in the first sample image can be 0. The first sample image is input into the first basic model to achieve:
[0100] The first image features corresponding to the first sample image are extracted by each first feature extractor. Specifically, for the first sample image, each first feature extractor can extract its first image features under the corresponding image generation algorithm respectively; the first image features extracted by each first feature extractor are spliced and added with a learnable first feature variable; the first image features added with the first feature variable are fused and learned based on the self-attention mechanism by the first feature fusion network to obtain the second image features, and the first feature fusion network can include a Transformer structure; the features corresponding to the first feature variable are extracted from the second image features, and the extracted features are output to the first classification head, and the first classification head can specifically be a multi-layer perceptron network; the first classification head classifies and predicts the features obtained by the first classification head to obtain the first classification result corresponding to the first sample image, and the first classification result is used to characterize whether the first sample image belongs to the generated image; the first classification label is taken as the target, and the first loss function value corresponding to the first sample image is calculated in combination with the first classification result, and the weight parameters of the first feature fusion network and the first classification head are reversely adjusted according to the first loss function value, and the next iterative training is entered until the first loss function value converges, and the training is terminated.
[0101] The first basic model that has completed training is used as the image classification model.
[0102] For example, the image input size is 512×512. After passing through k first feature extractors, k 2048-dimensional first image features are extracted. The k 2048-dimensional first image features are concatenated and then a learnable first feature variable cls token is added to form a [B,k+1,2048]-dimensional feature and input it into the Transfomer structure, where B is the batchsize, that is, the number of first sample images in this training.
[0103] In order to integrate the learning between different image features, the Transformer structure is composed of three multi-head self-attention networks in series, and the multi-head hyperparameter is 8. The Transformer structure integrates the features obtained through three multi-head self-attention networks and outputs the integrated learned second image features. According to the self-attention mechanism, k+1 features (i.e., k 2048-dimensional first image features and 1 feature variable) aggregate global information to a certain extent, but they are mainly self-features. In order to avoid bias towards a certain feature, the features corresponding to the first feature variable cls token are extracted from the second image features. The dimension of the extracted features is [B, 2048], and the extracted features are input into the multi-layer perceptron network.
[0104] The multi-layer perceptron network can contain 2 fully connected layers. The first fully connected layer compresses the extracted features from 2048 dimensions to 512 dimensions, and then sends them to the second fully connected layer after a relu function. The output dimension of the second fully connected layer is 2, one dimension is the probability of belonging to the generated image, and the other dimension is the probability of not belonging to the generated image. The sum of the probabilities of the two dimensions is 1.
[0105] After training, the embodiment of the present application can obtain an overall image classification model, which has good adaptability to the images generated by the currently existing k image generation algorithms.
[0106] On this basis, when a new image generation algorithm with very good performance is generated, the first basic model can be rebuilt, its unique first feature extractor can be trained, and the image classification model can be retrained. In this regard, in the embodiment of the present application, the training process of the image classification model also includes the following steps:
[0107] In response to the image generation algorithm update instruction, the process returns to execute construction of the first basic model.
[0108] In an embodiment of the present application, the image generation algorithm update instruction is used to instruct a new image generation algorithm to be added to the training. To this end, the first basic model is reconstructed, and a first feature extractor corresponding to the new image generation algorithm is added. After the training of the first feature extractor is completed, the first basic model is retrained to obtain a new image classification model.
[0109] In a possible implementation, the first feature extractor corresponding to each image generation algorithm can be trained specifically to ensure the generalization of new image generation algorithms. Figure 5 , Figure 5 This is another part of the method flow chart of a method for generating content detection provided in an embodiment of the present application. Figure 5 As shown, an embodiment of the present application provides a method for generating content detection, wherein the training process of each first feature extractor may include the following steps S301 to S304, and these steps are described in detail below.
[0110] S301, constructing a second basic model, wherein the second basic model includes a first original feature extractor and a second classification head, and the first original feature extractor includes a single first feature extraction network.
[0111] S302, obtaining a second training data set, where the second training data set includes a second real image and a second generated image generated by a target image generation algorithm, where the target image generation algorithm is an image generation algorithm corresponding to the first feature extractor to be trained.
[0112] S303, selecting a second sample image for this training from the second real image and the second generated image, marking a second classification label on the second sample image, and inputting the second sample image into the second basic model to achieve:
[0113] The third image feature of the second sample image is extracted through the first feature extraction network; the third image feature is classified and predicted through the second classification head to obtain a second classification result of the second sample image, and the second classification result is used to characterize whether the second sample image belongs to the generated image; the second loss function value of the second sample image is calculated according to the second classification result and the second classification label, the weight parameters of the first feature extraction network and the second classification head are updated according to the second loss function value, and the step of selecting the second sample image for this training from the second real image and the second generated image is returned to execute until the second loss function value meets the corresponding second convergence condition, and the training is terminated.
[0114] S304: Use the first original feature extractor after training as the first feature extractor corresponding to the target image generation algorithm.
[0115] Specifically, in the embodiment of the present application, for each existing image generation algorithm, it is necessary to train its corresponding first feature extractor. Taking a certain image generation algorithm as an example, a corresponding second basic model is constructed, and the second basic model includes a first original feature extractor, wherein the first original feature extractor includes a single first feature extraction network. In practical applications, the second basic model can be a resnet50 classification network.
[0116] Furthermore, a second training data set is obtained for training the first feature extractor, wherein the second training data set includes a collected second real image and a second generated image generated by an image generation algorithm (i.e., a target image generation algorithm) corresponding to the first feature extractor to be trained, and the second real image can be captured from a database.
[0117] In the process of multiple iterations of training the second basic model, a second sample image for this training can be selected from the second training data set, and the second sample image is composed of the selected second real image and the second generated image, and the number of the two is the same. In addition, the second sample image is annotated with a corresponding second classification label, wherein the second classification label of the second real image in the second sample image can be 1, and the second classification label of the second generated image in the second sample image can be 0. The second sample image is input into the second basic model to achieve:
[0118] The second image features corresponding to the second sample image are extracted through the first feature extraction network; the second image features are classified and predicted through the second classification head to obtain a second classification result corresponding to the second sample image, and the second classification result is used to characterize whether the second sample image belongs to the generated image. The second classification head can specifically be a multi-layer perceptron network; taking the second classification label as the target, the second loss function value corresponding to the second sample image is calculated in combination with the second classification result, and the weight parameters of the first feature extraction network and the second classification head are reversely adjusted according to the second loss function value, and the next iterative training is entered until the second loss function value converges, and the training is terminated.
[0119] The first original feature extractor that has finished training is used as the first feature extractor corresponding to the target image generation algorithm.
[0120] In a possible implementation, the video classification model may include second feature extractors corresponding to different video generation algorithms, and each second feature extractor can accurately extract the video features of the generated video generated by the corresponding video generation algorithm. In this scenario, the target content is the target video, the content classification model is the video classification model, the content generation algorithm is the video generation algorithm, the content features are the video features, and the generated content is the generated video.
[0121] See also Figure 6 , Figure 6 This is another part of the method flow chart of a method for generating content detection provided in an embodiment of the present application. Figure 6 As shown, an embodiment of the present application provides a method for generating content detection, wherein the training process of the video classification model may include the following steps S401 to S404, and these steps are described in detail below.
[0122] S401, constructing a third basic model, the third basic model includes a second feature extraction layer, a second feature fusion network and a third classification head, the second feature extraction layer includes a plurality of pre-trained second feature extractors, and one second feature extractor corresponds to one video generation algorithm.
[0123] S402, obtaining a third training data set, where the third training data set includes a first real video and a first generated video generated by a video generation algorithm corresponding to each second feature extractor.
[0124] S403, selecting a first sample video for this training from the first real video and the first generated video, marking a third classification label on the first sample video, and inputting the first sample video into the third basic model to achieve:
[0125] The first video features of the first sample video are extracted by each second feature extractor, and some features in the first video features belong to the learnable second feature variables; the first video features extracted by each second feature extractor are fused and learned based on the cross-attention mechanism by the second feature fusion network to obtain the second video features; the features corresponding to the second feature variables are extracted from the second video features, and the extracted features are output to the third classification head; the features obtained by the third classification head are classified and predicted to obtain the third classification result of the first sample video, and the third classification result is used to characterize whether the first sample video belongs to the generated video; the third loss function value of the first sample video is calculated according to the third classification result and the third classification label, the weight parameters of the second feature fusion network and the third classification head are updated according to the third loss function value, and the step of selecting the first sample video for this training from the first real video and the first generated video is returned to execute until the third loss function value meets the corresponding third convergence condition, and the training is terminated.
[0126] S404: Use the third basic model that has finished training as a video classification model.
[0127] Specifically, in the embodiment of the present application, a third basic model corresponding to the video classification model is first constructed. Figure 7 , Figure 7 This is a schematic diagram of the structure of the third basic model provided in the embodiment of the present application. Figure 7 As shown, the third basic model includes a second feature extraction layer B-1, a second feature fusion network B-2 and a third classification head B-3 connected in sequence. Among them, the second feature extraction layer B-1 includes m second feature extractors (i.e. Figure 7In the second feature extractor 1, the second feature extractor 2, the second feature extractor 3, ..., the second feature extractor m), one second feature extractor corresponds to one video generation algorithm, that is, a video generation algorithm of a certain type and a certain version, and the corresponding second feature extractor can accurately extract the video features of the generated video. In addition, the third classification head B-3 can be a multi-layer perceptron network (also called MLP, MultilayerPerceptron).
[0128] Furthermore, a third training data set is obtained for training the video classification model, wherein the third training data set includes the collected first real video and the first generated video generated by the video generation algorithm corresponding to each second feature extractor, wherein the first real video can be captured from the database.
[0129] In a possible implementation, the number of first generated videos corresponding to each second feature extractor in the third training data set is the same, and the total number of first generated videos corresponding to all second feature extractors is the same as the number of first real videos. Figure 8 , Figure 8 This is another part of the method flow chart of a method for generating content detection provided in an embodiment of the present application. Figure 8 As shown, an embodiment of the present application provides a method for generating content detection, wherein "obtaining a third training data set" in step S402 may include the following steps S4021 to S4023, and these steps are described in detail below.
[0130] S4021, sampling the third generated video generated by the video generation algorithm corresponding to each second feature extractor according to the number of the plurality of second feature extractors in the second feature extraction layer.
[0131] S4022: Use the sampled third generated video as the first generated video.
[0132] S4023, capture the first real video, the number of the first real video is the same as the number of the first generated video.
[0133] Specifically, in the embodiment of the present application, it is assumed that when training a single second feature extractor, the video generation algorithm corresponding to each second feature extractor generates 500,000 generated videos (i.e., third generated videos). Based on this, the 500,000 third generated videos corresponding to each second feature extractor are sampled, and the sampling number is 500,000 / k, where k is the total number of second feature extractors in the second feature extraction layer. The sampled 500,000 third generated videos are used as the first generated videos.
[0134] In addition, first real videos are collected, for example, 500,000 first real videos are captured from the database, and the number of first real videos is ensured to be the same as the number of first generated videos. Thus, a third training data set containing 1 million videos can be constructed.
[0135] In the process of multiple iterations of training the third basic model, a first sample video for this training can be selected from the third training data set, and the first sample video is composed of the selected first real video and the first generated video, and the number of the two is the same. In addition, the first sample video is annotated with a corresponding third classification label, wherein the first classification label of the first real video in the first sample video can be 1, and the first classification label of the first generated video in the first sample video can be 0. The first sample video is input into the third basic model to achieve:
[0136] The first video features corresponding to the first sample video are extracted by each second feature extractor. Specifically, for the first sample video, each second feature extractor can respectively extract its first video features under the corresponding video generation algorithm, wherein some features of the first video features belong to the image contained in the first sample video, and another part of the features belong to the learnable second feature variable; the first video features extracted by each second feature extractor are subjected to fusion learning based on the cross attention mechanism by the second feature fusion network to obtain the second video features, and the second feature fusion network may contain a Transfomer structure; the features corresponding to the second feature variable are extracted from the second video features, and the extracted features are output to the third classification head, which may specifically be a multi-layer perceptron network; the features obtained by the third classification head are classified and predicted to obtain the third classification result corresponding to the first sample video, and the third classification result is used to characterize whether the first sample video belongs to the generated video; the third classification label is taken as the target, and the third loss function value corresponding to the first sample video is calculated in combination with the third classification result, and the weight parameters of the second feature fusion network and the third classification head are reversely updated according to the third loss function value, and the next iterative training is entered until the third loss function value converges, and the training is terminated.
[0137] The third basic model that has finished training is used as the video classification model.
[0138] For example, the image size of a video is 512×512 and the total number of frames is 30. After passing through k second feature extractors, k [B, 30+1, 1512]-dimensional features are extracted, where each [B, 30+1, 1512]-dimensional feature contains the features of 30 images and the features corresponding to the second feature variable cls token, where B is the batch size, that is, the number of first sample videos in this training; for the fusion learning between different video features, each feature in the k [B, 30+1, 1512] dimensions is combined with other features in pairs and sent to the Transfomer structure, which performs fusion learning based on the cross-attention mechanism and outputs the learned second video features. The Transfomer structure is composed of 3 multi-head self-attention networks in series, and the multi-head hyperparameter is 8.
[0139] The feature corresponding to the second feature variable cls token is extracted from the second video feature. The feature has integrated the information of k features and its dimension is [B, k×kk,1512]. The extracted feature is input into the multi-layer perceptron network.
[0140] The multi-layer perceptron network can include 1 pooling layer and 2 fully connected layers. The pooling layer compresses the extracted features into [B, 1512]. The first fully connected layer compresses the extracted features from 1512 dimensions to 512 dimensions. After a relu function, it is sent to the second fully connected layer. The output dimension of the second fully connected layer is 2, one dimension is the probability of belonging to the generated video, and the other dimension is the probability of not belonging to the generated video. The sum of the probabilities of the two dimensions is 1.
[0141] After training, the embodiment of the present application can obtain an overall video classification model, which has good adaptability to the videos generated by the currently existing k video generation algorithms.
[0142] On this basis, when a new video generation algorithm with very good performance is generated, the third basic puppet show can be reconstructed, its unique second feature extractor can be trained, and the video classification model can be retrained. In this regard, in the embodiment of the present application, the training process of the video classification model also includes the following steps:
[0143] In response to the video generation algorithm update instruction, the process returns to execute the construction of the third basic model.
[0144] In an embodiment of the present application, the video generation algorithm update instruction is used to instruct a new video generation algorithm to join the training. In this regard, the third basic model is reconstructed, and a second feature extractor corresponding to the new video generation algorithm is added. After the training of the second feature extractor is completed, the third basic model is retrained to obtain a new video classification model.
[0145] In a possible implementation, the second feature extractor corresponding to each video generation algorithm can be trained specifically to ensure the generalization of new video generation algorithms. Fig. 9 , Fig. 9 This is another part of the method flow chart of a method for generating content detection provided in an embodiment of the present application. Fig. 9 As shown, an embodiment of the present application provides a method for generating content detection, wherein the training process of each second feature extractor includes the following steps S501 to S504, and these steps are described in detail below.
[0146] S501, constructing a fourth basic model, wherein the fourth basic model includes a second original feature extractor and a fourth classification head, and the second original feature extractor includes a plurality of second feature extraction networks and a third feature fusion network.
[0147] S502, obtaining a fourth training data set, where the fourth training data set includes a second real video and a second generated video generated by a target video generation algorithm, where the target video generation algorithm is a video generation algorithm corresponding to the second feature extractor to be trained.
[0148] S503, selecting a second sample video for this training from the second real video and the second generated video, marking the second sample video with a fourth classification label, and outputting the second sample video to the fourth basic model to achieve:
[0149] The third video feature of the second sample video is extracted through each second feature extraction network; the third video feature extracted by each second feature extraction network is spliced, and a learnable third feature variable is added; the third video feature with the third feature variable added is fused and learned based on the self-attention mechanism through the third feature fusion network to obtain a fourth video feature; the feature corresponding to the third feature variable is extracted from the fourth video feature, and the extracted feature is output to the fourth classification head; the fourth classification head is used to classify and predict the features obtained to obtain a fourth classification result of the second sample video, and the fourth classification result is used to characterize whether the second sample video belongs to the generated video; the fourth loss function value of the second sample video is calculated according to the fourth classification result and the fourth classification label, the weight parameters of multiple second feature extraction networks, the third feature fusion network and the fourth classification head are updated according to the fourth loss function value, and the step of selecting the second sample video for this training from the second real video and the second generated video is returned to execute until the fourth loss function value meets the corresponding fourth convergence condition, and the training is terminated.
[0150] S504: Use the second original feature extractor after training as the second feature extractor corresponding to the target video generation algorithm.
[0151] Specifically, in the embodiment of the present application, for each existing video generation algorithm, it is necessary to train its corresponding second feature extractor. Taking a certain video generation algorithm as an example, a corresponding fourth basic model is constructed, and the fourth basic model includes a second original feature extractor and a fourth classification head, wherein the second original feature extractor includes multiple second feature extraction networks and a third feature fusion network. In practical applications, the second original feature extractor may include two second feature extraction networks (resnet50 classification network and clip-vit classification network, respectively), and the two second feature extraction networks can extract different semantic information, and the third feature fusion network may include a Transfomer structure, which is composed of 3 multi-head self-attention networks connected in series, and the multi-head hyperparameter is 8.
[0152] Furthermore, a fourth training data set is obtained for training the second feature extractor, wherein the fourth training data set includes the collected second real video and the second generated video generated by the video generation algorithm (i.e., the target video generation algorithm) corresponding to the second feature extractor to be trained, and the second real video can be captured from the database.
[0153] In the process of multiple iterations of training the fourth basic model, a second sample video for this training can be selected from the fourth training data set, the second sample video consisting of the selected second real video and the second generated video, the number of which is the same. In addition, the second sample video is annotated with a corresponding fourth classification label, wherein the fourth classification label of the second real video in the second sample video can be 1, and the fourth classification label of the second generated video in the second sample video can be 0. The second sample video is input into the fourth basic model to achieve:
[0154] The third video feature of the second sample video is extracted by each second feature extraction network. Specifically, for the second sample video, the third video feature extracted by each second feature extraction network contains semantic information in different directions. The third video features extracted by each second feature extraction network are spliced, and a learnable third feature variable is added. The third video features added with the third feature variable are fused and learned based on the self-attention mechanism by the third feature fusion network to obtain a fourth video feature. The features corresponding to the third feature variable are extracted from the fourth video features, and the extracted features are output to the fourth classification head, which can be a multi-layer perceptron network. The fourth classification head is used to classify and predict the features obtained by the fourth classification head to obtain a fourth classification result of the second sample video, and the fourth classification result is used to characterize whether the second sample video belongs to the generated video. The fourth classification label is used as a target, and the fourth loss function value corresponding to the second sample video is calculated in combination with the fourth classification result. The weight parameters of multiple second feature extraction networks, the third feature fusion network and the fourth classification head are reversely adjusted according to the fourth loss function value, and the next iterative training is entered until the fourth loss function value converges, and the training is terminated.
[0155] The second original feature extractor after training is used as the second feature extractor corresponding to the target video generation algorithm.
[0156] For example, the image size of a video is 512×512 and the total number of frames is 30. After passing through the resnet50 classification network and the clip-vit classification network, two third video features are obtained. The two third video features are spliced and the learnable third feature variable cls token is added to obtain the [B, 30, 1512]-dimensional feature and input it into the Transfomer structure, where B is the batch size, that is, the number of second sample videos in this training, and 1512 is the splicing dimension of the two third video features.
[0157] The Transformer structure uses three multi-head self-attention networks to fuse the acquired features and output the fused learned fourth video features. The features corresponding to the third feature variable cls token are extracted from the fourth video features. The dimension of the extracted features is [B, 1512] and the extracted features are input into the multi-layer perceptron network.
[0158] The multi-layer perceptron network can contain 2 fully connected layers. The first fully connected layer compresses the extracted features from 1512 dimensions to 512 dimensions, and then sends them to the second fully connected layer after a relu function. The output dimension of the second fully connected layer is 2, one dimension is the probability of belonging to the generated video, and the other dimension is the probability of not belonging to the generated video. The sum of the probabilities of the two dimensions is 1.
[0159] After training, the embodiment of the present application can obtain an overall video classification model, which has good adaptability to the videos generated by the currently existing k video generation algorithms.
[0160] Through the above description, the generated content detection method provided in the embodiment of the present application solves the problem of poor performance when encountering a new content generation algorithm during generated content detection, greatly improves the generalization and usability of generated content detection, ensures the accuracy of generated content detection, and ensures the safe operation of related project applications.
[0161] A generated content detection method provided in an embodiment of the present application is introduced above, and a device for executing the generated content detection method will be introduced below.
[0162] See also Fig.10 , Fig.10 This is a schematic diagram of a structure of a content detection device provided in an embodiment of the present application. Fig. 9 As shown, the generated content detection device includes:
[0163] The content acquisition module 10 is used to acquire the target content to be detected;
[0164] The content detection module 20 is used to retrieve a pre-trained content classification model, which can extract content features of different content generation algorithms and classify them through feature fusion; wherein the training process of the content classification model includes constructing a basic model, the model includes a feature extraction layer, a feature fusion network and a classification head, the feature extraction layer includes multiple pre-trained feature extractors, and one feature extractor corresponds to one content generation algorithm; obtaining a training data set, the training data set includes real content and generated content generated by the content generation algorithm corresponding to each feature extractor; selecting sample content for this training from the real content and the generated content, marking the sample content with a classification label, and inputting the sample content into the basic model to train the basic model until the loss function value meets the corresponding convergence condition, and then the training is terminated; the basic model after the training is used as the content classification model; inputting the target content into the content classification model, and predicting the target classification result of the target content through the content classification model, and the target classification result is used to characterize whether the target content belongs to the generated content.
[0165] In a possible implementation, the target content is a target image, the content classification model is an image classification model, the content generation algorithm is an image generation algorithm, the content feature is an image feature, and the generated content is a generated image;
[0166] The process of training the image classification model by the content detection module 20 includes:
[0167] Construct a first basic model, the first basic model includes a first feature extraction layer, a first feature fusion network and a first classification head, the first feature extraction layer includes multiple pre-trained first feature extractors, and one first feature extractor corresponds to an image generation algorithm; obtain a first training data set, the first training data set includes a first real image, and a first generated image generated by the image generation algorithm corresponding to each first feature extractor; select a first sample image for this training from the first real image and the first generated image, annotate the first sample image with a first classification label, and input the first sample image into the first basic model to achieve: extract the first image features of the first sample image through each first feature extractor; splice the first image features extracted by each first feature extractor, and add a learnable first feature variable; add the first feature fusion network to the first feature features. The first image feature of the first feature variable is input for fusion learning based on the self-attention mechanism to obtain the second image feature; the feature corresponding to the first feature variable is extracted from the second image feature, and the extracted feature is output to the first classification head; the first classification head performs classification prediction on the obtained feature to obtain the first classification result of the first sample image, and the first classification result is used to characterize whether the first sample image belongs to the generated image; the first loss function value of the first sample image is calculated according to the first classification result and the first classification label, the weight parameters of the first feature fusion network and the first classification head are updated according to the first loss function value, and the step of selecting the first sample image for this training from the first real image and the first generated image is returned to execute until the first loss function value meets the corresponding first convergence condition, and the training is terminated; the first basic model after the training is used as the image classification model.
[0168] In a possible implementation, the process of training each first feature extractor by the content detection module 20 includes:
[0169] A second basic model is constructed, wherein the second basic model includes a first original feature extractor and a second classification head, and the first original feature extractor includes a single first feature extraction network; a second training data set is obtained, wherein the second training data set includes a second real image and a second generated image generated by a target image generation algorithm, and the target image generation algorithm is an image generation algorithm corresponding to the first feature extractor to be trained; a second sample image for this training is selected from the second real image and the second generated image, a second classification label is annotated on the second sample image, and the second sample image is input into the second basic model to achieve: extracting a third image feature of the second sample image through the first feature extraction network; feature; classify and predict the third image feature through the second classification head to obtain a second classification result of the second sample image, and the second classification result is used to characterize whether the second sample image belongs to the generated image; calculate the second loss function value of the second sample image according to the second classification result and the second classification label, update the weight parameters of the first feature extraction network and the second classification head according to the second loss function value, and return to execute the step of selecting the second sample image for this training from the second real image and the second generated image until the second loss function value meets the corresponding second convergence condition, and end the training; use the first original feature extractor after the training as the first feature extractor corresponding to the target image generation algorithm.
[0170] In a possible implementation, the content detection module 20 for acquiring the first training data set is specifically configured to:
[0171] According to the number of multiple first feature extractors in the first feature extraction layer, the third generated images generated by the image generation algorithm corresponding to each first feature extractor are sampled; the sampled third generated images are used as the first generated images; and the first real images are captured, and the number of the first real images is the same as the number of the first generated images.
[0172] In a possible implementation, the process of training the image classification model by the content detection module 20 further includes:
[0173] In response to the image generation algorithm update instruction, the process returns to execute construction of the first basic model.
[0174] In a possible implementation, the target content is a target video, the content classification model is a video classification model, the content generation algorithm is a video generation algorithm, the content feature is a video feature, and the generated content is a generated video;
[0175] The process of training the video classification model by the content detection module 20 includes:
[0176] A third basic model is constructed, wherein the third basic model includes a second feature extraction layer, a second feature fusion network and a third classification head, wherein the second feature extraction layer includes a plurality of pre-trained second feature extractors, and one second feature extractor corresponds to one video generation algorithm; a third training data set is obtained, wherein the third training data set includes a first real video and a first generated video generated by the video generation algorithm corresponding to each second feature extractor; a first sample video of this training is selected from the first real video and the first generated video, a third classification label is annotated on the first sample video, and the first sample video is input into the third basic model to achieve: extracting the first video features of the first sample video through each second feature extractor, wherein some features of the first video features belong to the learnable second feature variables; extracting the first video features of each second feature extractor through the second feature fusion network The first video features are obtained and fusion learning based on the cross-attention mechanism is performed to obtain the second video features; the features corresponding to the second feature variables are extracted from the second video features, and the extracted features are output to the third classification head; the features obtained by the third classification head are classified and predicted to obtain the third classification result of the first sample video, and the third classification result is used to characterize whether the first sample video belongs to the generated video; the third loss function value of the first sample video is calculated according to the third classification result and the third classification label, the weight parameters of the second feature fusion network and the third classification head are updated according to the third loss function value, and the step of selecting the first sample video for this training from the first real video and the first generated video is returned to execute until the third loss function value meets the corresponding third convergence condition, and the training is terminated; the third basic model that has completed the training is used as the video classification model.
[0177] In a possible implementation, the process of training each second feature extractor by the content detection module 20 includes:
[0178] Construct a fourth basic model, wherein the fourth basic model includes a second original feature extractor and a fourth classification head, wherein the second original feature extractor includes multiple second feature extraction networks and a third feature fusion network; obtain a fourth training data set, wherein the fourth training data set includes a second real video and a second generated video generated by a target video generation algorithm, wherein the target video generation algorithm is a video generation algorithm corresponding to the second feature extractor to be trained; select a second sample video for this training from the second real video and the second generated video, annotate the second sample video with a fourth classification label, and output the second sample video to the fourth basic model to achieve: extract the third video feature of the second sample video through each second feature extraction network; splice the third video features extracted by each second feature extraction network, and add a learnable third feature variable; and train the third video with the third feature variable added through the third feature fusion network. The features are fused and learned based on the self-attention mechanism to obtain a fourth video feature; the features corresponding to the third feature variables are extracted from the fourth video features, and the extracted features are output to the fourth classification head; the features obtained by the fourth classification head are classified and predicted to obtain a fourth classification result of the second sample video, and the fourth classification result is used to characterize whether the second sample video belongs to the generated video; the fourth loss function value of the second sample video is calculated according to the fourth classification result and the fourth classification label, the weight parameters of multiple second feature extraction networks, the third feature fusion network and the fourth classification head are updated according to the fourth loss function value, and the step of selecting the second sample video for this training from the second real video and the second generated video is returned to execute, until the fourth loss function value meets the corresponding fourth convergence condition, the training is terminated; the second original feature extractor after the training is used as the second feature extractor corresponding to the target video generation algorithm.
[0179] In a possible implementation, the content detection module 20 for acquiring the third training data set is specifically configured to:
[0180] According to the number of multiple second feature extractors in the second feature extraction layer, the third generated videos generated by the video generation algorithm corresponding to each second feature extractor are sampled; the sampled third generated videos are used as the first generated videos; and the first real videos are captured, and the number of the first real videos is the same as the number of the first generated videos.
[0181] In a possible implementation, the process of the content detection module 20 training the video classification model further includes:
[0182] In response to the video generation algorithm update instruction, the process returns to execute the construction of the third basic model.
[0183] It should be noted that the detailed functions of each module in the embodiment of the present application can be found in the corresponding disclosed part of the above-mentioned content image detection method embodiment, and will not be repeated here.
[0184] The present application also provides an electronic device in an embodiment. Fig.11 , Fig.11 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device in the embodiment of the present application may include but is not limited to fixed terminals such as mobile phones, notebook computers, PDAs (personal digital assistants), PADs (tablet computers), desktop computers, etc. Fig.11 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0185] like Fig.11 As shown, the electronic device may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 1101, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1102 or a program loaded from a storage device 1108 to a random access memory (RAM) 1103. When the electronic device is powered on, various programs and data required for the operation of the electronic device are also stored in the RAM 1103. The processing device 1101, the ROM 1102, and the RAM 1103 are connected to each other via a bus 1104. An input / output (I / O) interface 1105 is also connected to the bus 1104.
[0186] Typically, the following devices may be connected to the I / O interface 1105: an input device 1106 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 1107 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 1108 including, for example, a memory card, a hard disk, etc.; and a communication device 1109. The communication device 1109 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although Fig.11 An electronic device having various devices is shown, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0187] An embodiment of the present application also provides a computer program product including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements any one of the generated content detection methods provided in the embodiments of the present application.
[0188] A computer-readable storage medium is also provided in an embodiment of the present application. The storage medium carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any of the generated content detection methods provided in the embodiments of the present application.
[0189] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.
[0190] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0191] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0192] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.
Claims
1. A method for detecting generated content, characterized in that: The generated content detection method comprises: Obtain the target content to be detected; Retrieve a pre-trained content classification model, the content classification model can extract content features of different content generation algorithms and classify through feature fusion; wherein the training process of the content classification model includes constructing a basic model, the model includes a feature extraction layer, a feature fusion network and a classification head, the feature extraction layer includes multiple pre-trained feature extractors, and one feature extractor corresponds to one content generation algorithm; obtain a training data set, the training data set includes real content and generated content generated by the content generation algorithm corresponding to each feature extractor; select sample content for this training from the real content and the generated content, annotate the sample content with a classification label, and input the sample content into the basic model to train the basic model until the loss function value meets the corresponding convergence condition, and then terminate the training; use the basic model after the training as the content classification model; Inputting the target content into the content classification model, and predicting a target classification result of the target content by using the content classification model, wherein the target classification result is used to indicate whether the target content belongs to generated content; The target content is a target video, the content classification model is a video classification model, the content generation algorithm is a video generation algorithm, the content feature is a video feature, and the generated content is a generated video; The training process of the video classification model includes: Constructing a third basic model, wherein the third basic model includes a second feature extraction layer, a second feature fusion network and a third classification head, wherein the second feature extraction layer includes a plurality of pre-trained second feature extractors, and one second feature extractor corresponds to one video generation algorithm; Acquire a third training data set, wherein the third training data set includes a first real video and a first generated video generated by a video generation algorithm corresponding to each second feature extractor; A first sample video for this training is selected from the first real video and the first generated video, a third classification label is marked on the first sample video, and the first sample video is input into the third basic model to achieve: Extracting the first video features of the first sample video through each second feature extractor, wherein some features of the first video features belong to the learnable second feature variables; performing fusion learning based on the cross-attention mechanism on the first video features extracted by each second feature extractor through the second feature fusion network to obtain second video features; extracting features corresponding to the second feature variables from the second video features, and outputting the extracted features to the third classification head; performing classification prediction on the features obtained by the third classification head to obtain a third classification result of the first sample video, wherein the third classification result is used to characterize whether the first sample video belongs to the generated video; calculating the third loss function value of the first sample video according to the third classification result and the third classification label, updating the weight parameters of the second feature fusion network and the third classification head according to the third loss function value, and returning to execute the step of selecting the first sample video for this training from the first real video and the first generated video until the third loss function value satisfies the corresponding third convergence condition, and then terminating the training; Using the third basic model that has finished training as the video classification model; The training process of each second feature extractor includes: Constructing a fourth basic model, wherein the fourth basic model includes a second original feature extractor and a fourth classification head, wherein the second original feature extractor includes a plurality of second feature extraction networks and a third feature fusion network; Acquire a fourth training data set, wherein the fourth training data set includes a second real video and a second generated video generated by a target video generation algorithm, wherein the target video generation algorithm is a video generation algorithm corresponding to the second feature extractor to be trained; A second sample video for this training is selected from the second real video and the second generated video, a fourth classification label is marked on the second sample video, and the second sample video is output to the fourth basic model to achieve: Extract the third video feature of the second sample video through each second feature extraction network; splice the third video feature extracted by each second feature extraction network, and add a learnable third feature variable; perform fusion learning based on the self-attention mechanism on the third video feature added with the third feature variable through the third feature fusion network to obtain a fourth video feature; extract the feature corresponding to the third feature variable from the fourth video feature, and output the extracted feature to the fourth classification head; perform classification prediction on the features obtained by the fourth classification head to obtain a fourth classification result of the second sample video, and the fourth classification result is used to characterize whether the second sample video belongs to the generated video; calculate the fourth loss function value of the second sample video according to the fourth classification result and the fourth classification label, update the weight parameters of the multiple second feature extraction networks, the third feature fusion network and the fourth classification head according to the fourth loss function value, and return to execute the step of selecting the second sample video for this training from the second real video and the second generated video until the fourth loss function value meets the corresponding fourth convergence condition, and then end the training; The second original feature extractor after training is used as the second feature extractor corresponding to the target video generation algorithm.
2. The generated content detection method according to claim 1, characterized in that: The obtaining of the third training data set comprises: According to the number of the plurality of second feature extractors in the second feature extraction layer, sampling the third generated video generated by the video generation algorithm corresponding to each second feature extractor; Using the sampled third generated video as the first generated video; The first real videos are captured, where the number of the first real videos is the same as the number of the first generated videos.
3. The generated content detection method according to claim 1, characterized in that: The training process of the video classification model also includes: In response to the video generation algorithm update instruction, return to execute the construction of the third basic model.
4. A generated content detection device, characterized in that: The generated content detection device comprises: A content acquisition module, used to acquire target content to be detected; The content detection module is used to retrieve a pre-trained content classification model, wherein the content classification model can extract content features of different content generation algorithms and classify them through feature fusion; wherein the training process of the content classification model includes constructing a basic model, wherein the model includes a feature extraction layer, a feature fusion network and a classification head, wherein the feature extraction layer includes multiple pre-trained feature extractors, and one feature extractor corresponds to one content generation algorithm; obtaining a training data set, wherein the training data set includes real content and generated content generated by the content generation algorithm corresponding to each feature extractor; selecting sample content for this training from the real content and the generated content, annotating the sample content with a classification label, and inputting the sample content into the basic model to train the basic model until the loss function value meets the corresponding convergence condition, and then terminating the training; using the basic model after the training as the content classification model; inputting the target content into the content classification model, and predicting the target classification result of the target content through the content classification model, wherein the target classification result is used to characterize whether the target content belongs to the generated content; The target content is a target video, the content classification model is a video classification model, the content generation algorithm is a video generation algorithm, the content feature is a video feature, and the generated content is a generated video; The training process of the video classification model includes: Constructing a third basic model, wherein the third basic model includes a second feature extraction layer, a second feature fusion network and a third classification head, wherein the second feature extraction layer includes a plurality of pre-trained second feature extractors, and one second feature extractor corresponds to one video generation algorithm; Acquire a third training data set, wherein the third training data set includes a first real video and a first generated video generated by a video generation algorithm corresponding to each second feature extractor; A first sample video for this training is selected from the first real video and the first generated video, a third classification label is marked on the first sample video, and the first sample video is input into the third basic model to achieve: Extracting the first video features of the first sample video through each second feature extractor, wherein some features of the first video features belong to the learnable second feature variables; performing fusion learning based on the cross-attention mechanism on the first video features extracted by each second feature extractor through the second feature fusion network to obtain second video features; extracting features corresponding to the second feature variables from the second video features, and outputting the extracted features to the third classification head; performing classification prediction on the features obtained by the third classification head to obtain a third classification result of the first sample video, wherein the third classification result is used to characterize whether the first sample video belongs to the generated video; calculating the third loss function value of the first sample video according to the third classification result and the third classification label, updating the weight parameters of the second feature fusion network and the third classification head according to the third loss function value, and returning to execute the step of selecting the first sample video for this training from the first real video and the first generated video until the third loss function value satisfies the corresponding third convergence condition, and then terminating the training; Using the third basic model that has finished training as the video classification model; The training process of each second feature extractor includes: Constructing a fourth basic model, wherein the fourth basic model includes a second original feature extractor and a fourth classification head, wherein the second original feature extractor includes a plurality of second feature extraction networks and a third feature fusion network; Acquire a fourth training data set, wherein the fourth training data set includes a second real video and a second generated video generated by a target video generation algorithm, wherein the target video generation algorithm is a video generation algorithm corresponding to the second feature extractor to be trained; A second sample video for this training is selected from the second real video and the second generated video, a fourth classification label is marked on the second sample video, and the second sample video is output to the fourth basic model to achieve: Extract the third video feature of the second sample video through each second feature extraction network; splice the third video feature extracted by each second feature extraction network, and add a learnable third feature variable; perform fusion learning based on the self-attention mechanism on the third video feature added with the third feature variable through the third feature fusion network to obtain a fourth video feature; extract the feature corresponding to the third feature variable from the fourth video feature, and output the extracted feature to the fourth classification head; perform classification prediction on the features obtained by the fourth classification head to obtain a fourth classification result of the second sample video, and the fourth classification result is used to characterize whether the second sample video belongs to the generated video; calculate the fourth loss function value of the second sample video according to the fourth classification result and the fourth classification label, update the weight parameters of the multiple second feature extraction networks, the third feature fusion network and the fourth classification head according to the fourth loss function value, and return to execute the step of selecting the second sample video for this training from the second real video and the second generated video until the fourth loss function value meets the corresponding fourth convergence condition, and then end the training; The second original feature extractor after training is used as the second feature extractor corresponding to the target video generation algorithm.
Citation Information
Patent Citations
Identification method and device of deep forgery algorithm, electronic equipment and storage medium
CN114841340A
Cross-domain deep forgery detection model training method, deep forgery detection method and system
CN116385817A