Double-attention-based forged image detection method and device and electronic equipment

Through the combination of the dual attention mechanism and the multi-branch interaction network, the problem of poor detection and positioning of forged images caused by a single fusion of multiple features in the existing technology is solved, and more accurate detection and positioning of forged images are achieved.

CN118570484AActive Publication Date: 2024-08-30NAT UNIV OF DEFENSE TECH

Patent Information

Application Number
CN202410710716.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-04
Publication Date
2024-08-30
Estimated Expiration
2044-06-04

AI Technical Summary

Technical Problem

Due to the single processing method of multi-feature fusion, the existing technology can only obtain a feature map with a single fixed resolution, resulting in poor detection and positioning of forged images.

Method used

A counterfeit image detection method based on dual attention is used to extract image noise features, spatial domain RGB features and image frequency features through the counterfeit feature enhancement module, and the dual attention fusion module is used to perform feature fusion, combined with the multi-scale feature interaction module to perform multi-scale feature interaction at different resolutions. Information interaction between rate features forms a multi-level positioning detection branch to improve the accuracy of detection and positioning.

Benefits of technology

Through adaptive deep fusion and multi-branch interaction network, the detection and positioning effect of forged images is improved, the adverse effects caused by inconsistency in the forged area are overcome, and the performance of detection and positioning is significantly improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118570484A
    Figure CN118570484A
Patent Text Reader

Abstract

The invention belongs to a counterfeited image detection method, and particularly relates to a counterfeited image detection method and device based on double attention and electronic equipment, and the method comprises the steps: inputting a to-be-detected image into a counterfeited feature enhancement module, and carrying out the feature extraction, thereby obtaining an image noise feature, an RGB feature and an image frequency feature; performing feature fusion on the image noise features and the spatial domain RGB features by using a double-attention fusion module, and performing feature cascade with the image frequency features to obtain fusion features; inputting the fused features into a multi-scale feature interaction module, and carrying out information interaction among the features with different resolutions to obtain M feature maps with different resolutions; respectively inputting the M feature maps with different resolutions into the corresponding positioning detection branches; and taking an output result of the positioning detection branch of the (r-1) th level as priori to restrain a result of the rth level, and outputting a prediction mask and a prediction label obtained by the positioning detection branch of each level. The method has good forged image detection and positioning effects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a forged image detection method, and in particular to a forged image detection method, device and electronic equipment based on double attention. Background Art

[0002] With the development of technology, people can use generative models to generate highly realistic images. People cannot distinguish between real images and forged images with the naked eye, and traditional detection models find it difficult to make accurate judgments. The lack of identification means that the false information it carries may cause immeasurable losses to individuals and society. In fact, image forgery detection and positioning has always been one of the key research topics in the field of artificial intelligence security. For a forged image, people not only hope to detect that it is forged, but also hope to further refine and locate which areas in the image are forged. Different from traditional image tampering methods such as copying, splicing and moving, in recent years, large image generation models have been applied to image editing, making the image generation quality higher and higher, and the boundaries of the tampered areas more and more blurred, which significantly increases the difficulty of forgery detection and positioning.

[0003] Artifacts in generated images are mainly concentrated in the frequency domain and the spatial domain. Artifacts in the spatial domain are mainly manifested in two aspects: one is that the forged image has abnormal fluctuations in the color space, and the other is that there are differences in the noise level between the forged area and the real area that can be mined. However, the existing technology is too simplistic in the processing of multi-feature fusion. Since the forged areas of the image often have large differences in position and scale, a feature map with a fixed resolution may ignore the forged features of some areas. Changes in the scale of the forged area will have a negative impact on the performance of the detector, and the existing technology usually only obtains a single fixed resolution feature map.

[0004] It can be seen that the existing technology has poor detection and positioning effects on forged images because the processing method of existing technologies on multi-feature fusion is too simple and only a single feature map with a fixed resolution can be obtained. Summary of the invention

[0005] The technical problem to be solved by the present invention is that the existing technology has a poor effect on the detection and positioning of forged images because the processing method of multi-feature fusion is too single and only a single feature map with a fixed resolution can be obtained. In order to solve the above problem, the present invention provides a forged image detection method, device and electronic device based on dual attention.

[0006] The content of the present invention includes:

[0007] In a first aspect, an embodiment of the present invention provides a forged image detection method based on dual attention, comprising:

[0008] The image to be detected is input into the forgery feature enhancement module for feature extraction to obtain image noise features, spatial domain RGB features and image frequency features;

[0009] The image noise feature and the spatial domain RGB feature are feature-fused by using a dual attention fusion module, and then feature-concatenated with the image frequency feature to obtain a fusion feature, wherein the dual attention fusion module includes a threshold-limited channel attention and a position attention;

[0010] Inputting the fused features into a multi-scale feature interaction module to perform information interaction between features of different resolutions, and obtaining feature maps of M different resolutions, where M is a positive integer;

[0011] The M feature maps with different resolutions are respectively input into their corresponding positioning detection branches, wherein the M positioning detection branches are divided into M levels from low to high according to the resolution of their corresponding feature maps;

[0012] The output result of the positioning detection branch at the r-1th level is used as a priori to constrain the result of the rth level, and the predicted mask and predicted label obtained by the positioning detection branch at each level are output, where r is an integer greater than 1 and less than or equal to M.

[0013] Optionally, the forgery feature enhancement module includes a noise module, an RGB module and a frequency module, and the forgery feature enhancement module inputs the image to be detected to perform feature extraction to obtain image noise features, spatial domain RGB features and image frequency features, including:

[0014] The image to be detected is input into the noise module for feature extraction to obtain the image noise feature, the image to be detected is input into the RGB module for feature extraction to obtain the spatial domain RGB feature, and the image to be detected is input into the frequency module for feature extraction to obtain the image frequency domain feature.

[0015] Optionally, the dual attention fusion module is used to perform feature fusion on the image noise feature and the spatial domain RGB feature, and then feature cascaded with the image frequency feature to obtain the fused feature, including:

[0016] Input the image noise feature and RGB feature into the dual attention fusion module to obtain spatial domain fusion feature;

[0017] The spatial domain fusion feature and the image frequency feature are cascaded to obtain the fusion feature.

[0018] Optionally, the multi-scale feature interaction module includes four extraction branches, and the step of inputting the fused features into the multi-scale feature interaction module to obtain M feature maps with different resolutions includes:

[0019] The fused features are input into the four extraction branches respectively, and the outputs of different feature branches are subjected to feature interaction through full connection to obtain the feature maps of four different resolutions.

[0020] Optionally, the method of using the output result of the positioning detection branch at the r-1th level as a priori to constrain the result at the rth level, and outputting the predicted mask and predicted label obtained by the positioning detection branch at each level, includes:

[0021] Using the output of the positioning detection branch of the first level from bottom to top as a priori input to the positioning detection branch of the second level, to obtain the output result of the second level;

[0022] Using the output of the positioning detection branch of the second level as a priori input to the positioning detection branch of the third level to obtain an output result of the third level;

[0023] The output of the positioning detection branch at the third level is used as a priori input to the positioning detection branch at the fourth level to obtain an output result of the fourth level, wherein the output result includes the prediction mask and the prediction label.

[0024] Optionally, the method further comprises:

[0025] Iteratively training the detection model to be trained using the training data set with the loss function as the optimization target to obtain the detection model, wherein the detection model includes the forgery feature enhancement module, the multi-scale feature interaction module and the progressive detection and positioning module, and the progressive detection and positioning module includes M positioning detection branches;

[0026] The loss function includes classification loss, positioning loss and edge loss. The classification loss is the sum of the classification losses on the M positioning detection branches. The classification loss on the b-th positioning detection branch satisfies:

[0027]

[0028] Where N represents the number of samples, y i represents the true category label, p(y b |X) represents the category prediction probability on the positioning detection branch b;

[0029] The positioning loss is the sum of the positioning losses on the M positioning detection branches, and the positioning loss on the b-th positioning detection branch satisfies:

[0030]

[0031] Among them, H b and W bRespectively represent the length and width of the image on the positioning detection branch b, Represents the label of the true mask position (i, j) on the localization detection branch b, Represents the predicted probability of the input image at position (i, j) on the localization detection branch b;

[0032] The edge loss satisfies:

[0033]

[0034] Among them, w is the hyperparameter to be learned to control the marginal loss, S x and for S y represents the sobel convolution kernel in the x and y directions, M represents the real mask image, and m represents the predicted mask image.

[0035] Optionally, before the detection model to be trained is iteratively trained using the training data set with a loss function as an optimization target to obtain the detection model, the method further includes:

[0036] A first forged image is generated based on an input image and / or input text, and a target image is partially tampered with based on a guided condition to instruct the model to obtain a second forged image, wherein the training data set includes the first forged image and the second forged image.

[0037] In a second aspect, an embodiment of the present invention further provides a forged image detection device based on dual attention, comprising:

[0038] A feature extraction module is used to input the image to be detected into the forgery feature enhancement module for feature extraction to obtain image noise features, spatial domain RGB features and image frequency features;

[0039] A feature fusion module, used to perform feature fusion on the image noise feature and the spatial domain RGB feature using a dual attention fusion module, and then perform feature cascade with the image frequency feature to obtain a fusion feature, wherein the dual attention fusion module includes a threshold-limited channel attention and a position attention;

[0040] A feature interaction module, used for inputting the fused features into a multi-scale feature interaction module to perform information interaction between features of different resolutions, and obtain feature maps of M different resolutions, where M is a positive integer;

[0041] A positioning detection module, used to input the M feature maps of different resolutions into their corresponding positioning detection branches respectively, wherein the M positioning detection branches are divided into M levels from low to high according to the resolution of their corresponding feature maps;

[0042] The output module is used to use the output result of the positioning detection branch of the r-1th level as a priori to constrain the result of the rth level, and output the predicted mask and predicted label obtained by the positioning detection branch of each level, where r is an integer greater than 1 and less than or equal to M.

[0043] In a third aspect, an embodiment of the present invention provides an electronic device, comprising: a memory, a processor, and a program stored in the memory and executable on the processor; the processor is configured to read the program in the memory to implement the steps in the forged image detection method based on dual attention as described in the first aspect.

[0044] In a fourth aspect, an embodiment of the present invention provides a readable storage medium for storing a program, wherein when the program is executed by a processor, the steps in the forged image detection method based on dual attention as described in the first aspect are implemented.

[0045] In an embodiment of the present invention, in order to overcome the adverse effects of inconsistent forged areas, a hierarchical progressive network is used to capture forged artifacts at different scales of the image to achieve detection and positioning. The embodiment of the present application relies on a dual attention mechanism to adaptively deeply fuse multimodal image features, and then a multi-branch interactive network fully interacts image features of different scales, and relies on the dependencies between layers to improve the performance of the detector. In addition, more sensitive noise fingerprints are extracted to obtain more significant artifact features of the forged area. Through the above method, the effect of detecting and locating forged images is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] Attached Figure 1 A flowchart of a forged image detection method based on dual attention provided by an embodiment of the present invention;

[0047] Attached Figure 2a A DA-HFNet network structure view provided by an embodiment of the present invention;

[0048] Attached Figure 2b For attachment Figure 2a Schematic diagram of the structure of the forged feature enhancement module;

[0049] Attached Figure 2c For attachment Figure 2a Schematic diagram of the structure of the multi-scale feature interaction module;

[0050] Attached Figure 2d For attachment Figure 2a The structural diagram of the progressive detection and positioning module;

[0051] Attached Figure 3 A schematic diagram of the structure of a dual-attention feature fusion module provided in an embodiment of the present invention;

[0052] Attached Figure 4 Part of the forged area positioning results provided by the embodiment of the present invention;

[0053] Attached Figure 5 A schematic diagram of a forged image detection device based on dual attention provided by an embodiment of the present invention;

[0054] Attached Figure 6 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0055] In the embodiments of the present application, the term "and / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent three situations: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. In the embodiments of the present application, the term "plurality" refers to two or more than two, and other quantifiers are similar.

[0056] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0057] See also Figure 1 , Figure 1 The present invention provides a flowchart of a forged image detection method based on dual attention, which specifically includes the following steps:

[0058] Step 101: input the image to be detected into the forgery feature enhancement module for feature extraction to obtain image noise features, spatial domain RGB features and image frequency domain features.

[0059] Step 102 is used to use a dual attention fusion module to perform feature fusion on the image noise feature and the spatial domain RGB feature, and then perform feature cascade with the image frequency feature to obtain a fusion feature. The dual attention fusion module includes threshold-limited channel attention and position attention.

[0060] Step 103 is used to input the fused features into a multi-scale feature interaction module to perform information interaction between features of different resolutions to obtain feature maps of M different resolutions, where M is a positive integer.

[0061] Step 104: input the M feature maps with different resolutions into their corresponding positioning detection branches respectively, wherein the M positioning detection branches are divided into M levels from low to high according to the resolution of their corresponding feature maps.

[0062] Step 105, using the output result of the r-1th level positioning detection branch as a priori to constrain the result of the rth level, outputting the predicted mask and predicted label obtained by the positioning detection branch of each level, where r is an integer greater than 1 and less than or equal to M.

[0063] In an embodiment of the present application, in order to overcome the adverse effects of inconsistent forged areas, a hierarchical progressive network is used to capture forged artifacts at different scales of the image to achieve detection and positioning. The embodiment of the present application relies on a dual attention mechanism to adaptively deeply fuse multimodal image features, and then a multi-branch interactive network fully interacts image features of different scales, and relies on the dependencies between layers to improve the performance of the detector. In addition, a more sensitive noise fingerprint is extracted to obtain more significant artifact features of the forged area. Through the above method, the effect of detecting and locating forged images is improved.

[0064] The detection model provided in the embodiment of the present invention may also be referred to as a DA-HFNet model. Figure 2a-Figure 3 ,DA-HFNet model includes a forged feature enhancement module, a multi-scale feature interaction module and a progressive detection and localization module, wherein the progressive detection and localization module includes M localization detection branches.

[0065] Different from the prior art method of obtaining image noise residual using a Steganalysis Rich Model (SRM), the present application uses a forged feature enhancement module to extract features to obtain image noise features and spatial domain RGB features.

[0066] Optionally, the forgery feature enhancement module includes a noise module, an RGB module and a frequency module, and step 101 includes:

[0067] Input the image to be detected into the noise module for feature extraction to obtain the image noise feature, input the image to be detected into the RGB module for feature extraction to obtain the spatial domain RGB feature, and input the image to be detected into the frequency module for feature extraction to obtain the image frequency domain feature;

[0068] The step 102 includes:

[0069] Input the image noise feature and RGB feature into the dual attention fusion module to obtain spatial domain fusion feature;

[0070] The spatial domain fusion feature and the image frequency feature are cascaded to obtain the fusion feature.

[0071] In this embodiment, more significant artifact features of the forged area can be obtained by extracting a more sensitive noise fingerprint.

[0072] Because there are obvious frequency inconsistencies in images generated by different methods, this application adds an image frequency domain feature extraction branch to obtain image frequency domain features, and uses a combination of multiple features to obtain a stronger feature representation of the image forgery area.

[0073] Optionally, in some embodiments, step 103 includes:

[0074] The fusion feature is cascaded with the image frequency domain feature and then input into the multi-scale feature interaction module to obtain M feature maps with different resolutions.

[0075] In the feature fusion stage, see Figure 2a-Figure 3 This application uses the dual attention fusion (DAM) module to deeply fuse the RGB features and noise features in the spatial domain. Figure 3 As shown in the figure, the DAM module consists of two parts: threshold-limited channel attention (CA) and position attention (PA). CA focuses on the relationship between all channels and sets a threshold-limited mechanism to adjust the channel weights, which helps to achieve more accurate segmentation results. PA uses the association between two point features to enhance the expressiveness of features by establishing rich contextual relationships on local features.

[0076] This application sets up a learnable weighted fusion method to fuse the output features of CA and PA, and establish a connection between the context of the image and the features between different positions. Figure 2a and Figure 2b As shown in FIG. 1 , the fusion features obtained by fusion of the DAM module are further fused with the image frequency domain features and then input into the multi-scale feature interaction module.

[0077] Since the tampered areas of the generated model differ in size, and using a feature map with a fixed resolution may result in information loss, this application uses feature maps with different resolutions to capture richer local and global features. Ordinary network structures connect different resolutions in series, while this application provides a parallel feature interaction method.

[0078] It should be understood that the number of extraction branches included in the multi-scale feature interaction module (i.e., the value of M) is not limited here. Each extraction branch can extract a feature map of a fixed resolution. The number of extraction branches can extract the number of feature maps with different resolutions.

[0079] In this embodiment, multimodal image features are adaptively deeply fused by relying on a dual attention mechanism, and then image features of different scales are fully interacted by a multi-branch interactive network, and the performance of the detector is improved by relying on the dependencies between the layers. Specifically, this embodiment also utilizes multiple features of the image and performs enhanced processing on feature fusion. In order to learn a richer feature representation, this embodiment performs dual attention adaptive fusion processing on features of different categories. Specifically, this embodiment utilizes the RGB features and noise features of the image spatial domain for fusion, and uses the features of the frequency domain as a supervisory branch, and weightedly fuses the spatial domain features and frequency domain features of the image to enhance the expressiveness of the features.

[0080] Optionally, as a specific embodiment, Figure 2c As shown, the multi-scale feature interaction module includes four extraction branches, and the fusion feature is input into the multi-scale feature interaction module to obtain M feature maps with different resolutions, including:

[0081] The fused features are input into the four extraction branches respectively, and the outputs of different feature branches are subjected to feature interaction through full connection to obtain the feature maps of four different resolutions.

[0082] In this embodiment, the extraction branch is represented as θ b , b∈(1...4). Each extraction branch can extract feature maps of a specific resolution, and fully interact features between different extraction branches by establishing full connections. The output of each scale extraction branch is obtained by fusion of the outputs of all extraction branches. For example, the extraction branch θ3 downsampled by 4 times is obtained by adding the output of the extraction branch θ1 downsampled by 4 times, the extraction branch θ2 downsampled by 2 times, the extraction branch θ4 upsampled by 2 times, and the output of θ3 itself.

[0083] In this embodiment, a hierarchical network is used to achieve coarse-to-fine image-level forgery detection and pixel-level forgery localization. Specifically, in the previous steps, M feature maps of different resolutions are obtained, and then the category prediction and region prediction of this level are performed in a detection module and a localization module respectively starting from the feature map with the lowest resolution. In the detection module, we use a simple linear classifier, and the localization module uses a self-attention mechanism to map the feature map of this level to a mask. b .

[0084] After obtaining the results of the current level, the classification and positioning prediction results of the previous level are introduced as a priori constraints on the results of this level in the prediction process of the next level. In this embodiment, a progressive network is used to improve our detection and positioning results layer by layer. For detection tasks, considering that features with lower resolution may have missing information and cannot achieve fine classification, a relatively coarse classification category is set for it in this embodiment. Similarly, for positioning tasks, this embodiment uses the roughly estimated forged area obtained by the low-resolution branch to guide the next layer to improve the positioning effect.

[0085] Since the forged regions of an image often have large differences in position and scale, a feature map with a fixed resolution may ignore the forged features of some regions. The change in the scale of the forged region will have a negative impact on the performance of the detector, and most existing works have ignored this point. Therefore, this embodiment uses a hierarchical network to fully exchange information between features of different resolutions, and then detects and locates the image at different scales from the image features of different resolutions. In addition, this embodiment also uses an edge loss to correct the positioning of the forged region, so that the model performance is further improved.

[0086] Optionally, in some embodiments, the value of M is 4, and the output result of the positioning detection branch of the r-1th level is used as a priori to constrain the result of the rth level, and the predicted mask and predicted label obtained by the positioning detection branch of each level are output, including:

[0087] Using the output of the positioning detection branch of the first level from bottom to top as a priori input to the positioning detection branch of the second level, to obtain the output result of the second level;

[0088] Using the output of the positioning detection branch of the second level as a priori input to the positioning detection branch of the third level to obtain an output result of the third level;

[0089] The output of the positioning detection branch at the third level is used as a priori input to the positioning detection branch at the fourth level to obtain an output result of the fourth level, wherein the output result includes the prediction mask and the prediction label.

[0090] In the specific implementation, the output result of the highest-level positioning detection branch is the final predicted mask and predicted label. Specifically, the above process can be described as follows:

[0091] Given an image The features extracted by the above four extraction branches are expressed as Then we have the positioning fake area as:

[0092]

[0093] mask b+1 =softmax(F b+1 +Γ(mask b ·F b+1 / 2)).

[0094] in, represents the localization head of the extraction branch b, Γ(·) represents a linear interpolator, and the category prediction results and prediction probabilities of different extraction branches are represented as θ b and p(y b |X), the probability prediction satisfies:

[0095]

[0096] p(y b+1 |X)=softmax(θ b+1 (X)⊙(1+p(y b |X))).

[0097] in, represents the category detection head on the extraction branch b.

[0098] In order to train the DA-HFNet model, in this embodiment, different loss functions are set as optimization targets for the detection task and the positioning task on each positioning detection branch. Optionally, the method further includes:

[0099] Iteratively training a detection model to be trained using a training data set with a loss function as an optimization target to obtain the detection model, wherein the detection model includes the forgery feature enhancement module, the multi-scale feature interaction module and the progressive detection and positioning module;

[0100] The loss function includes classification loss, positioning loss and edge loss.

[0101] Specifically, for the detection task of the forged category, the optimization objective of each branch is expressed as follows, that is, the classification loss on the b-th localization detection branch satisfies:

[0102]

[0103] Where N represents the number of samples, y i represents the true category label, p(y b |X) represents the category prediction probability on the positioning detection branch b; the classification loss is the sum of the classification losses on the M positioning detection branches, Figure 2a and Figure 2d In the embodiment shown, the classification loss of the four branches is expressed as:

[0104]

[0105] For the task of locating the forged area, the binary cross entropy loss function is used to express the optimization objective of each branch as follows, that is, the positioning loss on the b-th positioning detection branch satisfies:

[0106]

[0107] Among them, H b and W b Respectively represent the length and width of the image on branch b, Represents the label of the true mask position (i, j) on branch b, represents the predicted probability of the input image at position (i, j) on branch b; the positioning loss is the sum of the positioning losses on the M positioning detection branches. Figure 2a and Figure 2d In the illustrated embodiment, the positioning loss of the four branches is expressed as:

[0108]

[0109] The location of the forged area belongs to the category of image segmentation. Considering that the segmentation task is often prone to misjudgment of forged pixels and real pixels at the boundary position, and the AI-edited image has unclear traces of the edited area boundary, a learnable edge loss is set in this embodiment. Since this embodiment focuses more on the final forged area location result, the edge loss of all branches is not calculated, but only the edge loss under the highest resolution branch is calculated.

[0110] The edge loss satisfies:

[0111]

[0112] Among them, w is the hyperparameter to be learned to control the marginal loss, S x and for S y represents the sobel convolution kernel in the x and y directions, M represents the real mask image, and m represents the predicted mask image.

[0113] In this embodiment, the sum of classification loss, positioning loss and edge loss is used as the final loss function, and the loss function Loss in the iterative training process satisfies:

[0114]

[0115] Optionally, before the detection model to be trained is iteratively trained using the training data set with a loss function as an optimization target to obtain the detection model, the method further includes:

[0116] A first forged image is generated based on an input image and / or input text, and a target image is partially tampered with based on a guided condition to instruct the model to obtain a second forged image, wherein the training data set includes the first forged image and the second forged image.

[0117] The first forged image is a forged image generated in the whole image generation mode. As an optional implementation, a model such as CycleGAN, LinkGAN, DDPM, etc. is used to generate a complete forged image using an image as input. As another optional implementation, a model such as StyleGAN, GigaGAN, GLIDE, StableDiffusion, etc. is used to generate a complete forged image using text as input.

[0118] The second forged image is a forged image generated in the partial editing mode. The partial editing mode only tampered with a part of the image. The image can be used as a guiding condition to guide the model to partially tamper with the target image, such as EditGAN, DragGAN, HD-painter, Paint-byexample, etc., and the text can be used as a guide to tamper with part of the input image, such as StyleCLIP, Imagic, Ranni, etc.

[0119] These generative models generate highly realistic forged images that are difficult for detection models to accurately identify. In particular, image tampering based on generative models is different from traditional splicing modes because real pixels and forged pixels coexist in one image and the forged boundaries are more hidden, so such images are more difficult for the model to successfully detect and locate. The first forged image and the second forged image are obtained by the above method. Using the first forged image and the second forged image to train the detection model to be trained can improve the training effect, so that the trained detection model has better performance.

[0120] In this embodiment, in view of the diversity of generative models and the diversity of generation modes, a DA-HFNet forged image training dataset covering the current mainstream generative models is constructed, including text-guided image editing and image-guided image editing, etc., which solves the problem that the current AI-generated image dataset lacks generation content related to image editing methods, improves the completeness of the training dataset, and thus improves the effect of model training.

[0121] In order to verify the positioning and detection effect of the present method on forged images, an experimental test was carried out in this embodiment, and the specific instructions are as follows.

[0122] First, in order to solve the current lack of corresponding datasets for some advanced image editing methods, this embodiment constructs an image generation and editing dataset based on GANs and DMs, which includes two modes of image and text in the guidance method. The DA-HFNet dataset is constructed in this embodiment mainly for two reasons: 1) Forged images based on generative models are not only becoming more and more realistic in generation quality, but also the generation methods are becoming more diverse, especially some image editing methods no longer have obvious editing boundaries, but the existing datasets in the prior art have not studied this aspect. 2) The detection and location of forged images requires the study of various types of forgery methods, and datasets containing various methods are necessary for research.

[0123] The relevant composition structure of the data set in this embodiment is shown in Table 1. Among them, the generated images guided by images come from BigGAN, DDPM, and PaintbyExample respectively. BigGAN is a representative whole-image generation method based on GAN; DDPM is a representative whole-image generation method based on diffusion model; PaintbyExample can use the diffusion model to draw a given image to a specified area in another image. The generated images guided by text come from FuseDream, GLIDE, InpaintAnything, and StyleCLIP respectively. FuseDream can generate an image that meets the description from a given text by relying on GAN; GLIDE can generate an image that meets the description from a given text by relying on the diffusion model; InpaintAnything uses the diffusion model to change the specified area in the real image into an image that meets the text description; StyleCLIP relies on GAN to edit the image into an image that meets the text description. For real images, 10k and 10k images are randomly selected from COCO2017 and ImageNet respectively.

[0124] In this example, the accuracy score (ACC) and F1 score (F1) are selected as the evaluation indicators of our experiment. The basic experimental settings are as follows: DA-HFNet is implemented on pytorch and trained on two NVIDIA3090 GPUs. The image input size is set to 256×256, the initial learning rate is set to 0.0002 and periodically decays to 1e-08, and the training rounds are set to 50. We apply conventional data enhancement methods to the training process, including rotation, inversion, etc.

[0125] Table 1 Composition structure of DA-HFNet dataset

[0126]

[0127] This embodiment tests the model on the DA-HFNet dataset constructed in this article. First, the method of this embodiment is compared with the baseline method in image-level classification and pixel-level positioning. Table 2 reports the results of different methods in image-level attribute category classification. Specifically, it can be observed in Table 2 that the performance of the pre-trained detector on our dataset is generally low, which is directly related to the feature expression ability of the parameters learned by the detector. Among them, Trufor uses features including noise features and RGB features; PSCC-Net uses the RGB features of the image and uses a hierarchical structure. HIFI-IFDL uses RGB features and frequency domain features, and also uses a hierarchical structure. PSCC-Net and HIFI-IFDL are both representative methods on hierarchical networks. The detector trained on our dataset, our method shows the best ACC score on both GAN-based and Diffusionmodel-based forged images, and the F1 score is also very competitive. Then we report the performance of different detectors in pixel-level forged area positioning in Table 3. Our baseline model continues to use the detector in image-level forged category classification. From Table 3, we can observe that the pre-trained detectors do not work well on our dataset. On the one hand, this is because the segmentation objects performed by the pre-trained PSCC-Net and HIFI-IFDL are mostly from manually edited forged images, which have large fingerprint differences from the forged images edited by AIGC. We then used our DA-HFNet dataset to train the PSCC and IFDL detectors, which have significant improvements in both ACC and F1 scores. At the same time, we observed that for forged region localization, our method achieved the best results in both ACC and F1 scores, with an average ACC score that is 3.93% higher than the second place, and an average F1 score that is 2.72% higher than the second place. We Figure 4 The comparison of our forged region localization performance and contrast methods is shown in .

[0128] Table 2 Experimental results of image-level forgery detection

[0129]

[0130] Table 3 Experimental results of pixel-level forged area positioning

[0131]

[0132] This embodiment further conducts an ablation experiment. This embodiment performs an ablation comparison on the multi-feature dual attention interaction module in the method. Table 4 reports the results of the ablation experiment. First, this embodiment eliminates the dual attention feature fusion module in the method and only uses the feature cascade method to fuse features. The ACC and F1 of the method in forged category detection are reduced by 2.84% and 6.2% respectively, and the ACC in forged area positioning is reduced by 3.08%, and the F1 score is slightly reduced. This embodiment believes that this is caused by insufficient feature fusion after eliminating the dual attention fusion module. Subsequently, this embodiment ablates the features used in the method respectively. It can be observed from the 2nd to 4th rows in Table 4 that eliminating the image features of a branch will cause different degrees of decline in the performance of the method. The most serious is the elimination of the frequency branch. The ACC of the method in forged category classification is reduced by 7.68%, and the ACC in forged area positioning is reduced by 5.75%. Therefore, this embodiment believes that the features of each branch have a positive effect on the performance of the method. Finally, this embodiment also uses SRM filtering to obtain noise residuals to replace the noise features of this embodiment. The results are shown in the fifth row of Table 4. Compared with the method of this embodiment, the detector trained using SRM filtering has decreased in both ACC and F1 indicators.

[0133] Table 4 Ablation experiment results

[0134]

[0135] In the subsequent experiments, this embodiment studies the impact of edge loss on the experiment, and reports the corresponding experimental results in Table 5. It can be seen from Table 5 that when we remove the edge loss, the ACC score and F1 score of the model in the forged category classification task decrease by 6.47% and 4.88% respectively, and the CC score and F1 score in the forged region localization task decrease by 4.35% and 5.79% respectively. This proves the positive impact of the edge loss we set in the experiment.

[0136] Table 5 Ablation experiment results of the impact of edge loss on model detection performance

[0137]

[0138] In this embodiment, a forged image detection method based on dual attention is proposed. This method proposes a multi-feature fusion progressive network for the detection and positioning of AIGC high-quality forged images. This method uses noise features that are more sensitive to noise and combines the RGB and frequency features of the image to obtain richer forgery traces. The multi-modal image features are adaptively fused through the dual attention fusion mechanism, and the information interaction between features of different resolutions is realized using a multi-branch feature interaction network. In addition, in this embodiment, a high-quality forged image dataset generated using text guidance or image guidance is constructed, including GAN and Diffusionmodel. A large number of experiments on this dataset prove the effectiveness of the method provided in this embodiment for high-quality forged image detection and positioning. Using ACC and F1 as evaluation indicators, the method provided in this embodiment is compared with the existing forged image detection and positioning methods. In the forged attribute recognition task, the ACC score of this method is 3.93% higher than that of the advanced forged image detection method, and the F1 reaches 98.37%, which is also very competitive. In the forged area positioning task, the ACC score and F1 score of this method are 2.49% and 2.72% higher than the most advanced methods, respectively.

[0139] See also Figure 5 The embodiment of the present invention further provides a forged image detection device 500 based on dual attention, comprising:

[0140] The feature extraction module 501 is used to input the image to be detected into the forgery feature enhancement module for feature extraction to obtain image noise features, spatial domain RGB features and image frequency features;

[0141] A feature fusion module 502 is used to perform feature fusion on the image noise feature and the spatial domain RGB feature using a dual attention fusion module, and then perform feature cascade with the image frequency feature to obtain a fusion feature, wherein the dual attention fusion module includes a threshold-limited channel attention and a position attention;

[0142] A feature interaction module 503 is used to input the fused features into a multi-scale feature interaction module to perform information interaction between features of different resolutions, and obtain feature maps of M different resolutions, where M is a positive integer;

[0143] A positioning detection module 504 is used to input the M feature maps with different resolutions into their corresponding positioning detection branches respectively, wherein the M positioning detection branches are divided into M levels from low to high according to the resolution of the corresponding feature maps;

[0144] The output module 505 is used to use the output result of the r-1th level positioning detection branch as a priori to constrain the result of the rth level, and output the predicted mask and predicted label obtained by the positioning detection branch of each level, where r is an integer greater than 1 and less than or equal to M.

[0145] Optionally, the forgery feature enhancement module includes a noise module, an RGB module and a frequency module, and the feature extraction module 501 is specifically used for:

[0146] The image to be detected is input into the noise module for feature extraction to obtain the image noise feature, and the image to be detected is input into the RGB module for feature extraction to obtain the spatial domain RGB feature, and the image to be detected is input into the frequency module for feature extraction to obtain the image frequency domain feature.

[0147] Optionally, the feature fusion module 502 is specifically used for:

[0148] Input the image noise feature and RGB feature into the dual attention fusion module to obtain spatial domain fusion feature;

[0149] The spatial domain fusion feature and the image frequency feature are cascaded to obtain the fusion feature.

[0150] Optionally, the multi-scale feature interaction module includes four extraction branches, and the feature interaction module 503 is specifically used for:

[0151] The fused features are input into the four extraction branches respectively, and the outputs of different feature branches are subjected to feature interaction through full connection to obtain the feature maps of four different resolutions.

[0152] Optionally, the output module 505 is specifically used for:

[0153] Using the output of the positioning detection branch of the first level from bottom to top as a priori input to the positioning detection branch of the second level, to obtain the output result of the second level;

[0154] Using the output of the positioning detection branch of the second level as a priori input to the positioning detection branch of the third level to obtain an output result of the third level;

[0155] The output of the positioning detection branch at the third level is used as a priori input to the positioning detection branch at the fourth level to obtain an output result of the fourth level, wherein the output result includes the prediction mask and the prediction label.

[0156] Optionally, the dual-attention based forged image detection device 500 further includes:

[0157] A training module, used for iteratively training a detection model to be trained using a training data set with a loss function as an optimization target to obtain the detection model, wherein the detection model includes the forgery feature enhancement module, the multi-scale feature interaction module and a progressive detection and positioning module, and the progressive detection and positioning module includes M positioning detection branches;

[0158] The loss function includes classification loss, positioning loss and edge loss. The classification loss is the sum of the classification losses on the M positioning detection branches. The classification loss on the b-th positioning detection branch satisfies:

[0159]

[0160] Where N represents the number of samples, y i represents the true category label, p(y b |X) represents the category prediction probability on the positioning detection branch b;

[0161] The positioning loss is the sum of the positioning losses on the M positioning detection branches, and the positioning loss on the b-th positioning detection branch satisfies:

[0162]

[0163] Among them, H b and W b Respectively represent the length and width of the image on the positioning detection branch b, Represents the label of the true mask position (i, j) on the localization detection branch b, Represents the predicted probability of the input image at position (i, j) on the localization detection branch b;

[0164] The edge loss satisfies:

[0165]

[0166] Among them, w is the hyperparameter to be learned to control the marginal loss, S x and for S y represents the sobel convolution kernel in the x and y directions, M represents the real mask image, and m represents the predicted mask image.

[0167] Optionally, the dual-attention based forged image detection device 500 further includes:

[0168] A generation module is used to generate a first forged image based on an input image and / or input text, and to partially tamper with the target image based on a guided condition to guide the model to obtain a second forged image, wherein the training data set includes the first forged image and the second forged image.

[0169] The dual-attention-based forged image detection device 500 provided in the embodiment of the present application can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated in this embodiment.

[0170] It should be noted that the division of units in the embodiments of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, each functional unit in each embodiment of the present application may be integrated into a processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0171] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a processor-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) or a processor (processor) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program codes.

[0172] like Figure 6 As shown, an embodiment of the present application provides an electronic device 600, including: a memory 602, a processor 601, and a program stored in the memory 602 and executable on the processor 601; the processor 601 is used to read the program in the memory 602 to implement the steps in the forged image detection method based on dual attention as described above.

[0173] The embodiment of the present application also provides a readable storage medium, on which a program is stored. When the program is executed by a processor, the various processes of the forged image detection method embodiment based on dual attention are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here. Among them, the readable storage medium can be any available medium or data storage device that can be accessed by the processor, including but not limited to magnetic storage (such as floppy disk, hard disk, magnetic tape, magneto-optical disk (MO), etc.), optical storage (such as compact disk (CD), digital video disc (DVD), Blu-ray Disc (BD), high-definition versatile disc (HVD), etc.), and semiconductor memory (such as read-only memory (ROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read only memory (EEPROM), non-volatile memory (NAND FLASH), solid-state drive (Solid State Disk or Solid State Drive, SSD)), etc.

[0174] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0175] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, disk, CD), and includes a number of instructions for a terminal (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0176] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. A forged image detection method based on dual attention, characterized in that: include: The image to be detected is input into the forgery feature enhancement module for feature extraction to obtain image noise features, spatial domain RGB features and image frequency features; The image noise feature and the spatial domain RGB feature are feature-fused by using a dual attention fusion module, and then feature-concatenated with the image frequency feature to obtain a fusion feature, wherein the dual attention fusion module includes a threshold-limited channel attention and a position attention; Inputting the fused features into a multi-scale feature interaction module to perform information interaction between features of different resolutions, and obtaining feature maps of M different resolutions, where M is a positive integer; The M feature maps with different resolutions are respectively input into their corresponding positioning detection branches, wherein the M positioning detection branches are divided into M levels from low to high according to the resolution of their corresponding feature maps; The output result of the positioning detection branch at the r-1th level is used as a priori to constrain the result of the rth level, and the predicted mask and predicted label obtained by the positioning detection branch at each level are output, where r is an integer greater than 1 and less than or equal to M.

2. The method according to claim 1, characterized in that: The forgery feature enhancement module includes a noise module, an RGB module and a frequency module. The forgery feature enhancement module inputs the image to be detected to extract features, and obtains image noise features, spatial domain RGB features and image frequency features, including: The image to be detected is input into the noise module for feature extraction to obtain the image noise feature, the image to be detected is input into the RGB module for feature extraction to obtain the spatial domain RGB feature, and the image to be detected is input into the frequency module for feature extraction to obtain the image frequency domain feature.

3. The method according to claim 2, characterized in that: The dual attention fusion module is used to perform feature fusion on the image noise feature and the spatial domain RGB feature, and then feature cascaded with the image frequency feature to obtain the fusion feature, including: Input the image noise feature and RGB feature into the dual attention fusion module to obtain spatial domain fusion feature; The spatial domain fusion feature and the image frequency feature are cascaded to obtain the fusion feature.

4. The method according to any one of claims 1 to 3, characterized in that: The multi-scale feature interaction module includes four extraction branches. The fusion feature is input into the multi-scale feature interaction module to obtain M feature maps with different resolutions, including: The fused features are input into the four extraction branches respectively, and the outputs of different feature branches are subjected to feature interaction through full connection to obtain the feature maps of four different resolutions.

5. The method according to claim 4, characterized in that: The method uses the output result of the positioning detection branch at the r-1th level as a priori to constrain the result at the rth level, and outputs the predicted mask and predicted label obtained by the positioning detection branch at each level, including: Using the output of the positioning detection branch of the first level from bottom to top as a priori input to the positioning detection branch of the second level, to obtain the output result of the second level; Using the output of the positioning detection branch of the second level as a priori input to the positioning detection branch of the third level to obtain an output result of the third level; The output of the positioning detection branch at the third level is used as a priori input to the positioning detection branch at the fourth level to obtain an output result of the fourth level, wherein the output result includes the prediction mask and the prediction label.

6. The method according to claim 1, characterized in that: The method further comprises: Iteratively training the detection model to be trained using the training data set with the loss function as the optimization target to obtain the detection model, wherein the detection model includes the forgery feature enhancement module, the multi-scale feature interaction module and the progressive detection and positioning module, and the progressive detection and positioning module includes M positioning detection branches; The loss function includes classification loss, positioning loss and edge loss. The classification loss is the sum of the classification losses on the M positioning detection branches. The classification loss on the b-th positioning detection branch satisfies: Where N represents the number of samples, y i represents the true category label, p(y b |X) represents the category prediction probability on the positioning detection branch b; The positioning loss is the sum of the positioning losses on the M positioning detection branches, and the positioning loss on the b-th positioning detection branch satisfies: Among them, H b and W b Respectively represent the length and width of the image on the positioning detection branch b, Represents the label of the true mask position (i, j) on the localization detection branch b, Represents the predicted probability of the input image at position (i, j) on the localization detection branch b; The edge loss satisfies: Among them, w is the hyperparameter to be learned to control the marginal loss, S x and for S y represents the sobel convolution kernel in the x and y directions, M represents the real mask image, and m represents the predicted mask image.

7. The method according to claim 6, characterized in that: Before the detection model is obtained by iteratively training the detection model to be trained using the training data set with the loss function as the optimization target, the method further comprises: A first forged image is generated based on an input image and / or input text, and a target image is partially tampered with based on a guided condition to instruct the model to obtain a second forged image, wherein the training data set includes the first forged image and the second forged image.

8. A forged image detection device based on dual attention, characterized in that: include: A feature extraction module is used to input the image to be detected into the forgery feature enhancement module for feature extraction to obtain image noise features, spatial domain RGB features and image frequency features; A feature fusion module, used to perform feature fusion on the image noise feature and the spatial domain RGB feature using a dual attention fusion module, and then perform feature cascade with the image frequency feature to obtain a fusion feature, wherein the dual attention fusion module includes a threshold-limited channel attention and a position attention; A feature interaction module, used for inputting the fused features into a multi-scale feature interaction module to perform information interaction between features of different resolutions, and obtain feature maps of M different resolutions, where M is a positive integer; A positioning detection module, used to input the M feature maps of different resolutions into their corresponding positioning detection branches respectively, wherein the M positioning detection branches are divided into M levels from low to high according to the resolution of their corresponding feature maps; The output module is used to use the output result of the positioning detection branch of the r-1th level as a priori to constrain the result of the rth level, and output the predicted mask and predicted label obtained by the positioning detection branch of each level, where r is an integer greater than 1 and less than or equal to M.

9. An electronic device, comprising: A memory, a processor, and a program stored in the memory and executable on the processor; wherein the processor is used to read the program in the memory to implement the steps in the forged image detection method based on dual attention as described in any one of claims 1 to 7.

10. A readable storage medium for storing a program, characterized in that: When the program is executed by a processor, the steps of the forged image detection method based on dual attention are implemented as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Face image forgery detection method and related equipment

    CN115909445A

  • Remote sensing image target detection method and system based on multi-scale semantic features

    CN117079139A

  • Social network deep counterfeit video detection method and system based on deep learning

    CN118097502A

  • Person Re-Identification Method Combining Random Batch Mask and Multi-Scale Representation Learning

    JP6830707B1

  • Medical image interpretation method and apparatus, computer device and storage medium

    WO2020215557A1

Cited By

  • Counterfeit positioning method based on attention enhancement and adaptive frequency selection

    CN121937453A

  • Artificial intelligence generated image detection method and device, terminal equipment and storage medium

    CN122415621A