Image tampering detection method and device, electronic equipment and storage medium
Through the fusion of spatial and frequency domain features of the image tampering detection model, combined with the classification and segmentation network, the problem of poor single image tampering detection in the existing technology is solved, and more accurate and extensive image tampering detection is achieved.
Patent Information
- Application Number
- CN202310632859.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-31
- Publication Date
- 2024-08-30
AI Technical Summary
Existing image tampering detection technology can only detect a single tampering of an image, and the detection effect is poor and cannot be commercialized.
The image tampering detection model is used to extract spatial domain features through the first feature extraction network, and the frequency domain features are extracted through the second feature extraction network, and the decoding module is used for feature fusion, and the classification network and segmentation network are combined to obtain the image tampering detection results.
The accuracy and generalization of image tampering detection are improved, making the image tampering detection model suitable for a wider range of commercial applications.
Smart Images

Figure CN118570514A
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence, and more specifically, to an image tampering detection method, device, electronic device, and computer-readable storage medium. Background Art
[0002] With the development and popularity of powerful image editing software and AI technology, modifying images has become an extremely simple operation. In various fields such as removing copyright watermarks, creating fake news, and tampering with evidence, the danger of tampered or forged images is increasing. At the same time, with the vigorous development of the Internet, social networks have become the main channel for information dissemination, among which images occupy a large part of social network information. Many tampered images are spread through various social networks, affecting people's views on important texts, products, etc. Therefore, it is necessary to provide better image tampering detection technology to help identify image tampering. However, the existing image tampering detection technology can often only detect single image tampering and the detection effect is poor. It has defects in generalization and cannot be commercially applied. Summary of the invention
[0003] A technical problem to be solved by the present disclosure is to provide an effective image tampering detection solution to address the problem that the existing image tampering detection technology can only detect single image tampering and has a poor detection effect.
[0004] According to a first aspect of an embodiment of the present disclosure, a method for detecting image tampering is provided, comprising: obtaining an input image; extracting spatial domain features of the input image using a first feature extraction network of an image tampering detection model; extracting frequency domain features of the input image using a second feature extraction network of the image tampering detection model; performing feature fusion on the spatial domain features and the frequency domain features using a decoding module of the image tampering detection model to obtain fused features of the input image; and obtaining a tampering detection result of the input image using a prediction network of the image tampering detection model based on the fused features of the input image.
[0005] Optionally, the extracting spatial domain features of the input image using the first feature extraction network of the image tampering detection model includes: using the first feature extraction network, performing serialization processing on the input image to obtain a feature block sequence of the input image, performing a spatial reduction attention operation on the feature block sequence, and obtaining the spatial domain features based on a result of the spatial reduction attention operation, wherein the spatial reduction attention operation includes reducing the spatial resolution of each feature block in the feature block sequence and performing an attention operation on the feature block sequence after the spatial resolution is reduced.
[0006] Optionally, the serializing process of the input image to obtain the feature block sequence of the input image comprises: utilizing the overlapping block embedding layer in the first feature extraction network to perform serializing process on the input image to obtain the feature block sequence of the input image; and / or, the spatial reduction attention operation on the feature block sequence comprises: utilizing the spatial reduction attention layer in the first feature extraction network to reduce the spatial resolution of each feature block in the feature block sequence to a predetermined size by average pooling, and performing an attention operation on the feature block sequence after the spatial resolution is reduced; and / or, the spatial domain features are obtained based on the result of the spatial reduction attention operation, comprising: obtaining the spatial domain features based on the result of the spatial reduction attention operation using a feedforward network in the first feature extraction network, wherein the feedforward network comprises a fully connected layer, an activation function layer, and a deep convolutional layer between the fully connected layer and the activation function layer for performing zero-filling position encoding.
[0007] Optionally, the extracting frequency domain features of the input image using the second feature extraction network of the image tampering detection model includes: obtaining a frequency domain transform coefficient map of the input image, converting the frequency domain transform coefficient map into a frequency domain transform volume map, applying a nearest neighbor interpolation algorithm to the frequency domain transform volume map to obtain an interpolated volume map, and obtaining the frequency domain features based on the interpolated volume map.
[0008] Optionally, the spatial domain features include spatial domain features of multiple scales, the frequency domain features include frequency domain features of multiple scales, the decoding module is a self-attention decoding module, and the decoding module of the image tampering detection model is used to perform feature fusion on the spatial domain features and the frequency domain features to obtain the fused features of the input image, including: respectively fusing the spatial domain features and frequency domain features of the same scale to obtain fused feature maps of multiple scales of the input image; respectively based on the fused feature maps of each scale, using the self-attention decoding module to obtain the attention feature map of each scale; and obtaining the fused features based on the attention feature maps of multiple scales.
[0009] Optionally, the number of neural network layers included in the second feature extraction network is smaller than the number of neural network layers included in the first feature extraction network, and / or the number of output channels of the neural network layer of the second feature extraction network is smaller than the number of output channels of the neural network layer of the first feature extraction network.
[0010] Optionally, the prediction network includes a classification network and a segmentation network, wherein the prediction network based on the fusion features of the input image and the image tampering detection model is used to obtain the tampering detection result of the input image, including: obtaining a first prediction result based on the fusion features using the classification network, wherein the first prediction result indicates whether the input image has been tampered with; obtaining a second prediction result based on the fusion features using the segmentation network, wherein the second prediction result indicates the tampered area of the input image.
[0011] Optionally, obtaining the second prediction result based on the fusion feature using the segmentation network includes: obtaining a third prediction result based on the fusion feature using the segmentation network, wherein the third prediction result indicates the tampering probability of each pixel in the input image; and obtaining the second prediction result based on the first prediction result and the third prediction result.
[0012] Optionally, the image tampering detection method also includes: training the image tampering detection model, wherein the training of the image tampering detection model includes: obtaining a training image and tampering mark information of the training image; using a first feature extraction network of the image tampering detection model to extract spatial domain features of the training image, and using a second feature extraction network of the image tampering detection model to extract frequency domain features of the training image; using a decoding module of the image tampering detection model to perform feature fusion on the spatial domain features and the frequency domain features to obtain fused features of the training image; based on the fused features of the training image, using a prediction network of the image tampering detection model to obtain a tampering detection result of the training image; and adjusting parameters of the image tampering detection model based on the tampering mark information and the tampering detection result.
[0013] Optionally, the marking information includes a first mark indicating whether the training image has been tampered with and a second mark indicating an actual tampered area of the training image, and the tampering detection result includes a first prediction result indicating whether the training image has been tampered with and a second prediction result indicating a predicted tampered area of the training image, wherein adjusting the parameters of the image tampering detection model based on the tampering marking information and the tampering detection result includes: calculating a first prediction loss based on the first mark and the first prediction result; calculating a second prediction loss based on the second mark and the second prediction result only when the training image is determined to be tampered with according to the first mark; and adjusting the parameters of the image tampering detection model based on the first prediction loss and the second prediction loss.
[0014] Optionally, the spatial domain features include RGB features, and the frequency domain features include discrete cosine transform DCT features.
[0015] According to a second aspect of an embodiment of the present disclosure, an image tampering detection device is provided, comprising: an image acquisition unit, configured to acquire an input image; a tampering detection unit, configured to perform the following operations: extract spatial domain features of the input image using a first feature extraction network of an image tampering detection model; extract frequency domain features of the input image using a second feature extraction network of the image tampering detection model; perform feature fusion of the spatial domain features and the frequency domain features using a decoding module of the image tampering detection model to obtain fused features of the input image; and obtain a tampering detection result of the input image using a prediction network of the image tampering detection model based on the fused features of the input image.
[0016] Optionally, the extracting spatial domain features of the input image using the first feature extraction network of the image tampering detection model includes: using the first feature extraction network, performing serialization processing on the input image to obtain a feature block sequence of the input image, performing a spatial reduction attention operation on the feature block sequence, and obtaining the spatial domain features based on a result of the spatial reduction attention operation, wherein the spatial reduction attention operation includes reducing the spatial resolution of each feature block in the feature block sequence and performing an attention operation on the feature block sequence after the spatial resolution is reduced.
[0017] Optionally, the serializing process of the input image to obtain the feature block sequence of the input image comprises: utilizing the overlapping block embedding layer in the first feature extraction network to perform serializing process on the input image to obtain the feature block sequence of the input image; and / or, the spatial reduction attention operation on the feature block sequence comprises: utilizing the spatial reduction attention layer in the first feature extraction network to reduce the spatial resolution of each feature block in the feature block sequence to a predetermined size by average pooling, and performing an attention operation on the feature block sequence after the spatial resolution is reduced; and / or, the spatial domain features are obtained based on the result of the spatial reduction attention operation, comprising: obtaining the spatial domain features based on the result of the spatial reduction attention operation using a feedforward network in the first feature extraction network, wherein the feedforward network comprises a fully connected layer, an activation function layer, and a deep convolutional layer between the fully connected layer and the activation function layer for performing zero-filling position encoding.
[0018] Optionally, the extracting frequency domain features of the input image using the second feature extraction network of the image tampering detection model includes: obtaining a frequency domain transform coefficient map of the input image, converting the frequency domain transform coefficient map into a frequency domain transform volume map, applying a nearest neighbor interpolation algorithm to the frequency domain transform volume map to obtain an interpolated volume map, and obtaining the frequency domain features based on the interpolated volume map.
[0019] Optionally, the spatial domain features include spatial domain features of multiple scales, the frequency domain features include frequency domain features of multiple scales, the decoding module is a self-attention decoding module, and the decoding module of the image tampering detection model is used to perform feature fusion on the spatial domain features and the frequency domain features to obtain the fused features of the input image, including: respectively fusing the spatial domain features and frequency domain features of the same scale to obtain fused feature maps of multiple scales of the input image; respectively based on the fused feature maps of each scale, using the self-attention decoding module to obtain the attention feature map of each scale; and obtaining the fused features based on the attention feature maps of multiple scales.
[0020] Optionally, the number of neural network layers included in the second feature extraction network is smaller than the number of neural network layers included in the first feature extraction network, and / or the number of output channels of the neural network layer of the second feature extraction network is smaller than the number of output channels of the neural network layer of the first feature extraction network.
[0021] Optionally, the prediction network includes a classification network and a segmentation network, wherein the prediction network based on the fusion features of the input image and the image tampering detection model is used to obtain the tampering detection result of the input image, including: obtaining a first prediction result based on the fusion features using the classification network, wherein the first prediction result indicates whether the input image has been tampered with; obtaining a second prediction result based on the fusion features using the segmentation network, wherein the second prediction result indicates the tampered area of the input image.
[0022] Optionally, obtaining the second prediction result based on the fusion feature using the segmentation network includes: obtaining a third prediction result based on the fusion feature using the segmentation network, wherein the third prediction result indicates the tampering probability of each pixel in the input image; and obtaining the second prediction result based on the first prediction result and the third prediction result.
[0023] Optionally, the image tampering detection device also includes: a training unit, configured to train the image tampering detection model, wherein the training of the image tampering detection model includes: obtaining a training image and tampering mark information of the training image; using a first feature extraction network of the image tampering detection model to extract spatial domain features of the training image, and using a second feature extraction network of the image tampering detection model to extract frequency domain features of the training image; using a decoding module of the image tampering detection model to perform feature fusion on the spatial domain features and the frequency domain features to obtain fused features of the training image; based on the fused features of the training image, using a prediction network of the image tampering detection model to obtain a tampering detection result of the training image; and adjusting parameters of the image tampering detection model based on the tampering mark information and the tampering detection result.
[0024] Optionally, the marking information includes a first mark indicating whether the training image has been tampered with and a second mark indicating an actual tampered area of the training image, and the tampering detection result includes a first prediction result indicating whether the training image has been tampered with and a second prediction result indicating a predicted tampered area of the training image, wherein adjusting the parameters of the image tampering detection model based on the tampering marking information and the tampering detection result includes: calculating a first prediction loss based on the first mark and the first prediction result; calculating a second prediction loss based on the second mark and the second prediction result only when the training image is determined to be tampered with according to the first mark; and adjusting the parameters of the image tampering detection model based on the first prediction loss and the second prediction loss.
[0025] Optionally, the spatial domain features include RGB features, and the frequency domain features include discrete cosine transform DCT features.
[0026] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, comprising: at least one processor; and at least one memory storing computer executable instructions, wherein the computer executable instructions, when executed by the at least one processor, prompt the at least one processor to execute the image tampering detection method as described above.
[0027] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium storing instructions is provided, wherein when the instructions are executed by at least one processor, the at least one processor is prompted to execute the image tampering detection method as described above.
[0028] According to the image tampering prediction method, device, electronic device and computer-readable storage medium of the embodiments of the present disclosure, the first feature extraction network of the image tampering detection model is used to extract the spatial domain features of the input image, and the second feature extraction network of the image tampering detection model is used to extract the frequency domain features of the input image, and the decoding module of the image tampering detection model is used to perform feature fusion on the spatial domain features and the frequency domain features to obtain the fused features of the input image, and based on the fused features of the input image, the prediction network of the image tampering detection model is used to obtain the tampering detection result of the input image. Therefore, it is not limited to performing a single tampering of the image and improves the accuracy of the tampering detection result, so that the image tampering detection model has better generalization, which is conducive to better commercial applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The accompanying drawings herein are incorporated in and constitute a part of the specification, illustrate exemplary embodiments consistent with the present disclosure, and together with the description, are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.
[0030] Figure 1 is a flow chart of an image tampering detection method according to an embodiment of the present disclosure;
[0031] Figure 2 is a schematic diagram of an image tampering detection model according to an embodiment of the present disclosure;
[0032] Figure 3 is a schematic diagram of a portion of the operation of a first feature extraction network according to an embodiment of the present disclosure;
[0033] Figure 4 is a schematic diagram of the operation of a second feature extraction network according to an embodiment of the present disclosure;
[0034] Figure 5 is a schematic diagram of the operation of a decoding module according to an embodiment of the present disclosure;
[0035] Figure 6 is a flow chart of a training process of an image tampering detection model according to an embodiment of the present disclosure;
[0036] Figure 7 is a block diagram of an image tampering detection device according to an embodiment of the present disclosure;
[0037] Figure 8 is a block diagram of an electronic device according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0038] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.
[0039] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The implementation methods described in the following examples do not represent all implementation methods consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the attached claims.
[0040] It should be noted that the phrase "at least one of the items" in the present disclosure includes three types of parallel situations: "any one of the items", "a combination of any number of the items", and "all of the items". For example, "including at least one of A and B" includes the following three parallel situations: (1) including A; (2) including B; (3) including A and B. Another example is "executing at least one of step 1 and step 2" which means the following three parallel situations: (1) executing step 1; (2) executing step 2; (3) executing step 1 and step 2.
[0041] Figure 1 is a flowchart of an image tampering detection method according to an embodiment of the present disclosure.
[0042] Reference Figure 1 , in step S110, an input image is acquired. For example, the input image may be acquired from a storage device in response to an operation instruction, or the input image may be acquired in real time fully automatically or semi-automatically. According to an embodiment of the present disclosure, the input image may be a compressed image (e.g., a JPEG compressed image), but is not limited thereto. It should be noted that the present disclosure does not impose any restrictions on the type of the input image and the timing and manner of acquiring the input image.
[0043] Subsequently, the input image can be input into the pre-trained image tampering detection model to obtain the tampering detection result of the input image. Figure 1 The steps S120 to S150 shown involve an image tampering detection model, so in order to facilitate a better understanding of the present disclosure, the structure of the image tampering detection model according to an embodiment of the present disclosure is briefly described before describing the steps S120 to S150.
[0044] Figure 2 A schematic diagram of an image tampering detection model according to an embodiment of the present disclosure is shown.
[0045] like Figure 2As shown, the image tampering detection model may include a first feature extraction network 210, a second feature extraction network 220, a decoding module 230 and a prediction network 240. The first feature extraction network 210 is used to extract spatial features of the input image. The second feature extraction network 220 is used to extract frequency domain features of the input image. The decoding module 230 is used to perform feature fusion on the spatial features extracted by the first feature extraction network and the frequency domain features extracted by the second feature extraction network to obtain fused features of the input image. The prediction network 240 is used to obtain a tampering detection result of the input image based on the fused features of the input image. Optionally, according to an embodiment, the decoding module 230 may be a self-attention decoding module. Optionally, according to an embodiment of the present disclosure, the prediction network 240 may include a classification network 241 and a segmentation network 242. The classification network 241 is used to obtain a first prediction result based on the fused features of the input image, wherein the first prediction result indicates whether the input image has been tampered with. The segmentation network 242 is used to obtain a second prediction result based on the fused features of the input image, wherein the second prediction result may indicate a tampered area of the input image.
[0046] In combination Figure 2 After briefly describing the structure of the image tampering detection model, we return to the reference Figure 1 The image tampering detection method according to the embodiment of the present disclosure is further described.
[0047] like Figure 1As shown, after the input image is acquired in step S110, in step S120, the spatial domain features of the input image are extracted using the first feature extraction network of the image tampering detection model. Spatial domain features may also be referred to as pixel domain features. According to an embodiment, the spatial domain features may be features that reflect the characteristics of the input image in the pixel domain or the spatiotemporal domain. For example, the spatial domain features may include color features, such as RGB features, but are not limited thereto. As an example, the first feature extraction network may be any ViT (Vision Transformer) network, for example, a PVT (Pyramid Vision Transformer) network or an improved network of the PVT network (such as a PVTv1 network or a PVTv2 network, etc.), but is not limited thereto. According to an embodiment, step S120 may include: using the first feature extraction network, performing serialization processing on the input image to obtain a feature block sequence of the input image, performing a spatial reduction attention operation on the feature block sequence, and obtaining the spatial domain features based on the result of the spatial reduction attention operation. Here, the spatial reduction attention operation includes reducing the spatial resolution of each feature block in the feature block sequence and performing an attention operation on the feature block sequence after the spatial resolution is reduced. By reducing the spatial resolution (also called "spatial dimension") of each feature block before performing the attention operation, and then performing the attention operation on the feature block sequence after the spatial resolution is reduced, not only the prediction effect but also the prediction efficiency can be improved. This is because the attention operation can help obtain better features and improve the detection effect of image tampering detection, while performing spatial dimension reduction can reduce the amount of calculation and improve the detection efficiency of image tampering detection.
[0048] In the following, the operation of extracting spatial features by the first feature extraction network is described by taking the first feature extraction network as the PVTv2 network as an example. As known to those skilled in the art, the PVTv1 network regards the image as a sequence of non-overlapping blocks, which will lose the local continuity of the image to a certain extent. In order to retain the local continuity of the image, the present disclosure adopts the PVTv2 network to perform serialization processing on the image by using overlapping block embedding. Figure 3 is a schematic diagram of a partial operation of the first feature extraction network according to an embodiment of the present disclosure. As an example, the above-mentioned serialization processing of the input image to obtain the feature block sequence of the input image may include: using the overlapping block embedding layer in the first feature extraction network to perform serialization processing on the input image to obtain the feature block sequence of the input image. Specifically, Figure 3As shown in Figure 1, compared with the original patch embedding of the PVTv1 network, the PVTv2 network has an overlapping patch embedding layer, which enlarges the patch window so that adjacent windows overlap by half the area and pads the feature map with zeros to maintain the resolution. In this work, overlapping patch embedding is implemented using convolution with zero padding. Specifically, given an input image of size h×w×c (h, w, c represent height, width, and number of channels, respectively), it is fed into a convolutional layer with stride S, kernel size 2S-1, padding size S-1, and the number of kernels c′, and the size of the final output feature patch is h / S×w / S×c′.
[0049] As described above, after obtaining the feature block sequence of the input image, a spatial reduction attention operation can be performed on the feature block sequence. As known to those skilled in the art, when processing high-resolution input images, the computational complexity of the PVTv1 network is relatively large. To this end, the present disclosure adopts the PVTv2 network to perform a spatial reduction attention operation on the feature block sequence using linear spatial reduction attention. Specifically, for example, the above-mentioned performing of a spatial reduction attention operation on the feature block sequence may include: utilizing the spatial reduction attention layer in the first feature extraction network, reducing the spatial resolution of each feature block in the feature block sequence to a predetermined size by average pooling, and performing an attention operation on the feature block sequence after the spatial resolution has been reduced. Figure 3 As shown in the figure, unlike the PVTv1 network which uses spatial reduced attention (SRA) for spatial reduction, the PVTv2 network uses linear SRA for spatial reduction, where SRA uses convolution to reduce the spatial dimension (i.e., h×w) to a fixed size (i.e., P×P) before the attention operation, while linear SRA uses average pooling to reduce the spatial dimension (i.e., h×w) to a fixed size (i.e., P×P) before the attention operation. Assuming that an input of size h×w×c is given, the complexity of SRA and linear SRA are:
[0050]
[0051] Ω(Linear SRA)=2hwP 2 c, (2)
[0052] Where R is the spatial reduction ratio of SRA and P is the pooling size of linear SRA.
[0053] Compared with spatial reduced attention, linear spatial reduced attention can further reduce the computational complexity, thereby improving the efficiency of feature extraction, which in turn is beneficial to improving the efficiency of image tampering detection.
[0054] As described above, after performing the spatial reduction attention operation, spatial domain features can be obtained based on the result of the spatial reduction attention operation. As known to those skilled in the art, the position encoding of the PVTv1 network is of fixed size, but this is not flexible for input images of arbitrary sizes. To this end, the present disclosure adopts the PVTv2 network to process the result of the spatial reduction attention operation using a feedforward network including a deep convolutional layer for performing zero-filled position encoding to obtain spatial domain features. Specifically, as an example, spatial domain features can be obtained based on the result of the spatial reduction attention operation using a feedforward network in the first feature extraction network, wherein the feedforward network includes a fully connected layer, an activation function layer, and a deep convolutional layer between the fully connected layer and the activation function layer for performing zero-filled position encoding. As Figure 3 As shown in Figure 1, compared to the original feed-forward network of the PVTv1 network, the feed-forward network of the PVTv2 network adds a deep convolutional layer ( ) between the fully connected layer (FC) and the activation function layer (GELU) for performing zero-filled position encoding. Figure 3 By adding the deep convolutional layer for performing zero-filling position encoding, the first feature extraction network can flexibly extract features from input images of any size.
[0055] Return to reference Figure 1 In step S130, the frequency domain features of the input image may be extracted using the second feature extraction network of the image tampering detection model. According to an embodiment, the frequency domain features may be characteristics that reflect the input image in the frequency domain. For example, the frequency domain features may include discrete cosine transform (DCT) features, but are not limited thereto. As an example, the second feature extraction network may be any ViT (Vision Transformer) network, such as HRNet, but is not limited thereto. According to an embodiment, step S130 may include: obtaining a frequency domain transform coefficient map of the input image, converting the frequency domain transform coefficient map into a frequency domain transform volume map, applying a nearest neighbor interpolation algorithm to the frequency domain transform volume map to obtain an interpolated volume map, and obtaining frequency domain features based on the interpolated volume map. For example, the frequency domain transform coefficient map may be a DCT coefficient map, and the frequency domain transform volume map may be a DCT Volume map.
[0056] Figure 4 FIG. 1 is a schematic diagram of the operation of the second feature extraction network according to an embodiment of the present disclosure. Figure 4 As shown, after obtaining the frequency domain transform coefficient map of the input image (indicated by "1", where 1 is also the number of channels of the input image), it is input into the transform function f(·) to obtain the frequency domain transform volume map (indicated by "21", where 21 is also the number of channels of the frequency domain transform volume map), where the frequency domain transform volume map is the feature map before the position information is lost. f(·) can be expressed as follows:
[0057]
[0058] where M is the input array of DCT coefficients, clip(·) clips the array elements to the interval [-T,T], and abs(·) is the absolute value of the elements.
[0059] Subsequently, the frequency domain transform volume map is processed by applying the nearest neighbor interpolation algorithm. Since resizing will destroy the DCT coefficients, the current frequency domain feature extraction only supports the original image, which is not only not conducive to model fusion, but also not conducive to improving the speed of image tampering detection. To this end, the present disclosure proposes to use the nearest neighbor interpolation algorithm to interpolate the frequency domain transform volume map after obtaining the frequency domain volume map, so that the image tampering detection model can support images that have been resized to any size.
[0060] After applying nearest neighbor interpolation, 8-extended convolution is used to extract features from DCT coefficients derived from the same frequency basis. Next, the extracted features are passed through a normalization layer and a Relu activation function to obtain a 64-channel feature map. Subsequently, the feature map is subjected to a 1×1 convolution, and the number of channels of the feature map is reduced to 4. Next, two paths are performed on the 4-channel feature map. In the first path, a DCT quantization table (e.g., an 8×8 quantization table) is first obtained, and an array is repeated to obtain a quantization array of the same size as the above-mentioned 4-channel feature map, and the 4-channel feature map is element-wise multiplied with the quantization array, that is, each 8×8 array in the quantization array is multiplied with the corresponding block in the 4-channel feature map, and then the 4-channel feature map obtained after multiplication is input into the separation component to separate the frequency components. In the second path, the 4-channel feature map is directly input into the separation component for frequency component separation without the above-mentioned multiplication operation. After the separation components, the 4-channel feature map (H×W×4) is separated into multiple 256-channel feature maps (h / 8×w / 8×256), reducing the resolution. Finally, the features of the two paths are cascaded in the channel dimension and output as the frequency domain features mentioned above.
[0061] According to an embodiment, both the first feature extraction network and the second feature extraction network may include multiple neural network layers. Optionally, the number of neural network layers included in the second feature extraction network may be less than the number of neural network layers included in the first feature extraction network, and / or the number of output channels of the neural network layer of the second feature extraction network is less than the number of output channels of the neural network layer of the first feature extraction network. By using the number of neural network layers included in the second feature extraction network may be less than the number of neural network layers included in the first feature extraction network, and / or the number of output channels of the neural network layer of the second feature extraction network is less than the number of output channels of the neural network layer of the first feature extraction network, so that the weight of the frequency domain features extracted by the second feature extraction network in the entire image tampering detection can be reduced, on the one hand, the amount of calculation can be reduced, and the speed of image tampering detection can be increased. On the other hand, it is also conducive to improving the image tampering detection effect. This is because, research and experiments have shown that image tampering detection mainly relies on spatial domain features, but frequency domain features can play an auxiliary role. Therefore, using frequency domain features in image tampering detection, but at the same time appropriately reducing the role of frequency domain features in image tampering detection, can achieve a balance between image tampering detection effect and efficiency.
[0062] After obtaining the spatial domain features and the frequency domain features, in step S140, the spatial domain features and the frequency domain features can be feature-fused using the decoding module of the image tampering detection model to obtain the fused features of the input image. According to an embodiment, the spatial domain features may include spatial domain features of multiple scales, the frequency domain features may include frequency domain features of multiple scales, the decoding module may be a self-attention decoding module, and step S140 may include: feature-fusion of spatial domain features and frequency domain features of the same scale to obtain fused feature maps of multiple scales of the input image; based on the fused feature maps of each scale, using the self-attention decoding module to obtain the attention feature map of each scale; based on the attention feature maps of multiple scales, obtaining the fused features. Figure 5 FIG. 1 is a schematic diagram of the operation of the decoding module according to an embodiment of the present disclosure. Figure 5As shown in the figure, C2, C3, C4 and C5 respectively represent the fusion feature map of a scale of the input image obtained by fusion of spatial domain features and frequency domain features of the same scale. The fusion feature map of each scale is input into the self-attention decoding module after being spliced with the position encoding information (PE), and the attention feature map of each scale is output through the self-attention operation. By using the self-attention decoding module to perform the self-attention operation on the input fusion feature map, the subtle differences in the features of the tampered area and the non-tampered area can be further learned to improve the image tampering detection effect. The attention feature maps of various scales can be directly used as the fusion features of the input image, or the attention feature maps of various scales can be further upsampled to obtain the fusion features of the input image. For example, the attention feature maps of smaller scales can be gradually upsampled and then spliced with the attention feature maps of larger scales to obtain the fusion features of the input image.
[0063] Finally, in step S150, based on the fusion features of the input image, the prediction network of the image tampering detection model is used to obtain the tampering detection result of the input image. Figure 2 As described, the prediction network may include a classification network and a segmentation network. According to an embodiment, step S150 may include: obtaining a first prediction result based on the fusion feature using the classification network, wherein the first prediction result indicates whether the input image has been tampered with; obtaining a second prediction result based on the fusion feature using the segmentation network, wherein the second prediction result indicates the tampered area of the input image. In order to make the second prediction result more reasonable, the present disclosure further proposes to make the calculation of the second prediction result dependent on the first prediction result, because the premise of the existence of the tampered area of the input image is that the input image is tampered with. Therefore, according to an embodiment, the above-mentioned obtaining the second prediction result based on the fusion feature using the segmentation network may include: obtaining a third prediction result based on the fusion feature using the segmentation network, wherein the third prediction result indicates the tampering probability of each pixel in the input image; obtaining the second prediction result based on the first prediction result and the third prediction result. For example, the first prediction result may be a probability indicating whether the input image has been tampered with, and the third prediction result may be a probability indicating the tampering of each pixel in the input image. The second prediction result can be obtained by multiplying the first prediction result with the third prediction result. By obtaining the second prediction result based on the first prediction result and the third prediction result, the calculation of the second prediction result is made dependent on the first prediction result, thereby obtaining a more reasonable and accurate second prediction result.
[0064] The above has been combined Figures 1 to 5An image tampering detection method according to an embodiment of the present disclosure is described. According to the image tampering detection method according to an embodiment of the present disclosure, two feature extraction networks of an image tampering detection model are used to respectively extract spatial domain features and frequency domain features of an input image, and a decoding module of the image tampering detection model is used to perform feature fusion on the spatial domain features and the frequency domain features to obtain fused features of the input image, and based on the fused features of the input image, a prediction network of the image tampering detection model is used to obtain a tampering detection result of the input image. Therefore, the above-mentioned image tampering detection method is not limited to a single tampering detection of an input image, and can improve the accuracy of the image tampering detection result, so that the image tampering detection model has better generalization, which is conducive to better commercial applications.
[0065] Below, refer to Figure 6 The training process of the above-mentioned image tampering detection model is briefly described. It should be noted that the subject that performs the training of the image tampering detection model and the subject that performs image tampering detection using the image tampering detection model (i.e., the subject that applies the trained image tampering detection model) can be the same or different. If the execution subjects are the same, then optionally, Figure 1 The image tampering detection method shown may also include training steps S610 to S650 of the image tampering detection model to be described below. Otherwise, the training steps S610 to S650 of the image tampering detection model to be described below may independently constitute a training method of the image tampering detection model that can be executed by other entities.
[0066] Specifically, in step S610, a training image and tampering mark information of the training image may be obtained. According to an embodiment, the mark information may include a first mark indicating whether the training image has been tampered with and a second mark indicating the real tampering area of the training image. Optionally, after the training image is obtained, random data enhancement may be performed on the training image, for example, the training image may be randomly inverted and randomly JPEG compressed, etc., so as to increase the diversity of the training image and improve the robustness of the model. In addition, in order to reduce the amount of calculation and improve the training efficiency, the training image may be resized to a predetermined size, for example, 512*512.
[0067] Next, in step S620, the spatial domain features of the training image are extracted using the first feature extraction network of the image tampering detection model, and the frequency domain features of the training image are extracted using the second feature extraction network of the image tampering detection model. For the description of the spatial domain features and the frequency domain features, please refer to the above, which will not be repeated here. In addition, the way the first feature extraction network extracts spatial domain features and the way the second feature extraction network extracts frequency domain features are the same as the way of extracting spatial domain features and frequency domain features mentioned in the image tampering detection method described above. The only difference is that the object for performing feature extraction during training is the training image, and the object for actually performing image tampering detection is an arbitrary input image. Therefore, the extraction method will not be repeated here. During the training process, optionally, the first feature extraction network can be pre-trained using ImageNet, and the second feature extraction network can be randomly initialized.
[0068] Subsequently, in step S630, the decoding module of the image tampering detection model is used to perform feature fusion on the spatial domain features and the frequency domain features to obtain the fused features of the training image. The method of performing feature fusion on the spatial domain features and the frequency domain features to obtain the fused features of the training image using the decoding module of the image tampering detection model is the same as the method of performing feature fusion on the spatial domain features and the frequency domain features to obtain the fused features of the input image using the decoding module of the image tampering detection model described above, so it is not repeated here.
[0069] Next, in step S640, based on the fusion features of the training image, the prediction network of the image tampering detection model is used to obtain the tampering detection result of the training image. According to an embodiment, the prediction network includes a classification network and a segmentation network. For example, step S640 may include: obtaining a first prediction result based on the fusion features using the classification network, wherein the first prediction result indicates whether the training image has been tampered with; obtaining a second prediction result based on the fusion features using the segmentation network, wherein the second prediction result indicates the tampered area of the training image. The tampering detection result includes a first prediction result and a second prediction result.
[0070] Finally, in step S650, based on the tampering mark information and the tampering detection result, the parameters of the image tampering detection model are adjusted. As described above, the mark information obtained in step S610 may include a first mark indicating whether the training image has been tampered with and a second mark indicating the real tampering area of the training image, and the tampering detection result may include a first prediction result indicating whether the training image has been tampered with and a second prediction result indicating the predicted tampering area of the training image. According to an embodiment, step S650 may include: calculating a first prediction loss based on the first mark and the first prediction result; calculating a second prediction loss based on the second mark and the second prediction result only when the training image is determined to be tampered according to the first mark; adjusting the parameters of the image tampering detection model based on the first prediction loss and the second prediction loss. Since the second prediction loss is calculated based on the second mark and the second prediction result only when the training image is determined to be tampered according to the first mark, which is equivalent to using the prediction result of the classification network as the prior probability of the segmentation network, only calculating the segmentation loss of the positive sample (the training image with the tampered area), it can ensure that the segmentation network has a better prediction effect, and it is convenient to optimize the combination of the classification network and the segmentation network during training. In addition, optionally, in order to improve the generalization of the training classification network in image classification, label smoothing can be used for the classification network. For example, in label smooth, the parameter epsilon indicating the degree of label smoothness can be set to 0.1, but is not limited thereto. Optionally, the first prediction loss can use the cross entropy loss of the binary classification, and the second prediction loss can use Focal loss and DICE loss, but is not limited thereto. Generally, the use of Focal loss and DICE loss can better handle the problem of imbalance of positive and negative samples during training. After calculating the first prediction loss and the second prediction loss, the parameters of the image tampering detection model can be adjusted based on the first prediction loss and the second prediction loss until the training is terminated when the predetermined conditions are met. For example, the sum of the first prediction loss and the second prediction loss can be used as the total prediction loss of the image tampering detection model, and the parameters of the image tampering detection model are adjusted based on the total prediction loss until the training is terminated when the predetermined conditions are met.
[0071] In addition, optionally, an Adam optimizer can be used when training the image tampering detection model. The Adam optimizer is an extension of the stochastic gradient descent method, which can adaptively adjust the learning rate of each parameter of the model. For example, the initial learning rate can be set to 1e-4, and the learning rate adjustment strategy can be cosine annealing.
[0072] Already combined Figure 6The training process of the image tampering detection model is described. According to the above training process, an image tampering detection model that can provide more accurate image tampering detection results can be trained.
[0073] Below, refer to Figure 7 The image tampering detection device according to an embodiment of the present disclosure is briefly described.
[0074] Figure 7 is a block diagram of an image tampering detection device according to an embodiment of the present disclosure. Figure 7 , the image tampering detection device 700 may include an image acquisition unit 710 and a tampering detection unit 720. Specifically, the image acquisition unit 710 may be configured to acquire an input image, and the tampering detection unit 720 may be configured to perform the following operations: extract spatial domain features of the input image using a first feature extraction network of the image tampering detection model; extract frequency domain features of the input image using a second feature extraction network of the image tampering detection model; perform feature fusion on spatial domain features and frequency domain features using a decoding module of the image tampering detection model to obtain fused features of the input image; based on the fused features of the input image, obtain a tampering detection result of the input image using a prediction network of the image tampering detection model.
[0075] because Figure 1 The image tampering detection method shown can be Figure 7 The image tampering detection device 700 shown in the figure can be used to perform the image tampering detection, and the image acquisition unit 710 and the tampering detection unit 720 can respectively perform the same Figure 1 Therefore, regarding steps S110 and S120-S150 in Figure 7 Any details on the operations performed by the various units in Figure 1 The corresponding description will not be repeated here.
[0076] Optionally, according to an embodiment, the image tampering detection device 700 may further include a training unit. The training unit may be configured to train an image tampering detection model. Specifically, the training image tampering detection model may include: acquiring a training image and tampering mark information of the training image; extracting spatial domain features of the training image using a first feature extraction network of the image tampering detection model, and extracting frequency domain features of the training image using a second feature extraction network of the image tampering detection model; performing feature fusion on spatial domain features and frequency domain features using a decoding module of the image tampering detection model to obtain fused features of the training image; based on the fused features of the training image, obtaining tampering detection results of the training image using a prediction network of the image tampering detection model; and adjusting parameters of the image tampering detection model based on the tampering mark information and the tampering detection results. In the above, it has been combined with Figure 6The training process of the image tampering detection model has been described, so it will not be repeated here. In addition, optionally, the image tampering detection device 700 may not include a training unit, that is, the image tampering detection model may be trained by a separate training device provided outside the image tampering detection device 700. After the image tampering detection model is trained, the image tampering detection device 700 may obtain the trained image tampering detection model from the training device and use it to perform image tampering detection.
[0077] In addition, it should be noted that, although the image tampering detection device 700 is divided into units for respectively performing corresponding processing when introducing it above, it is clear to those skilled in the art that the processing performed by the above-mentioned units can also be performed without any specific unit division or clear demarcation between the units in the image tampering detection device 700. In addition, the image tampering detection device 700 may also include other units, such as a data preprocessing unit, a storage unit, etc.
[0078] Figure 8 is a block diagram of an electronic device according to an embodiment of the present disclosure.
[0079] Reference Figure 8 The electronic device 800 may include at least one memory 801 storing computer executable instructions and at least one processor 802. When the computer executable instructions are executed by the at least one processor 802, the at least one processor is prompted to execute the image tampering detection method according to the embodiment of the present disclosure.
[0080] As an example, the electronic device may be a PC, a tablet device, a personal digital assistant, a smart phone, or other device capable of executing the above instruction set. Here, the electronic device is not necessarily a single electronic device, but may also be any device or circuit capable of executing the above instruction (or instruction set) individually or in combination. The electronic device may also be part of an integrated control system or system manager, or may be configured as a portable electronic device interconnected with a local or remote (e.g., via wireless transmission) interface.
[0081] In electronic devices, the processor may include a central processing unit (CPU), a graphics processing unit (GPU), a programmable logic device, a dedicated processor system, a microcontroller or a microprocessor. As an example and not limitation, the processor may also include an analog processor, a digital processor, a microprocessor, a multi-core processor, a processor array, a network processor, etc.
[0082] The processor can execute instructions or codes stored in the memory, wherein the memory can also store data. Instructions and data can also be sent and received through the network via the network interface device, wherein the network interface device can adopt any known transmission protocol.
[0083] The memory may be integrated with the processor, for example, RAM or flash memory is arranged within an integrated circuit microprocessor or the like. In addition, the memory may include a separate device, such as an external disk drive, a storage array, or any other storage device that can be used by a database system. The memory and processor may be operatively coupled, or may communicate with each other, such as through an I / O port, a network connection, etc., so that the processor can read text stored in the memory.
[0084] In addition, the electronic device may also include a video display (such as a liquid crystal display) and a user interaction interface (such as a keyboard, a mouse, a touch input device, etc.) All components of the electronic device may be connected to each other via a bus and / or a network.
[0085] According to an embodiment of the present disclosure, a computer-readable storage medium storing instructions may also be provided, wherein when the instructions are executed by at least one processor, the at least one processor is prompted to execute the image tampering detection method according to the embodiment of the present disclosure. Examples of computer-readable storage media here include: read-only memory (ROM), random access programmable read-only memory (PROM), electrically erasable programmable read-only memory (EEPROM), random access memory (RAM), dynamic random access memory (DRAM), static random access memory (SRAM), flash memory, non-volatile memory, CD-ROM, CD-R, CD+R, CD-RW, CD+RW, DVD-ROM, DVD-R, DVD+R, DVD-RW, DVD+RW, DVD-RAM, BD-ROM, BD-R, BD-R LTH, BD-RE, Blu-ray or optical disk storage, hard disk drive (HDD), solid state drive (SSD), card storage (such as, multimedia card, secure digital (SD) card or extreme digital (XD) card), magnetic tape, floppy disk, magneto-optical data storage device, optical data storage device, hard disk, solid state disk and any other device, any other device is configured to store computer programs (or software) and any associated data, data text and data structure in a non-temporary manner and provide the computer program and any associated data, data text and data structure to a processor or computer so that the processor or computer can execute the computer program. The instructions or computer programs in the above-mentioned computer-readable storage medium can be run in an environment deployed in a computer device such as a client, a host, an agent device, a server, etc. In addition, in one example, the computer program and any associated data, data text and data structure are distributed on a networked computer system, so that the computer program and any associated data, data text and data structure are stored, accessed and executed in a distributed manner by one or more processors or computers.
[0086] The above describes the exemplary embodiments of the present application. It should be understood that the above description is only exemplary and not exhaustive, and the present application is not limited to the disclosed exemplary embodiments. Without departing from the scope and spirit of the present application, many modifications and changes are obvious to those of ordinary skill in the art. Therefore, the scope of protection of the present application should be based on the scope of the claims.
Claims
1. A method for detecting image tampering, comprising: Get the input image; Extracting spatial features of the input image using a first feature extraction network of an image tampering detection model; Extracting frequency domain features of the input image using a second feature extraction network of the image tampering detection model; Using the decoding module of the image tampering detection model to perform feature fusion on the spatial domain features and the frequency domain features to obtain fused features of the input image; Based on the fusion features of the input image, a tampering detection result of the input image is obtained by utilizing the prediction network of the image tampering detection model.
2. The image tampering detection method according to claim 1, wherein: The extracting the spatial domain features of the input image using the first feature extraction network of the image tampering detection model includes: Utilizing the first feature extraction network, serializing the input image is performed to obtain a feature block sequence of the input image, a spatial reduction attention operation is performed on the feature block sequence, and the spatial domain features are obtained based on the result of the spatial reduction attention operation, wherein the spatial reduction attention operation includes reducing the spatial resolution of each feature block in the feature block sequence and performing an attention operation on the feature block sequence after the spatial resolution is reduced.
3. The image tampering detection method according to claim 2, wherein: The performing serialization processing on the input image to obtain the feature block sequence of the input image includes: performing serialization processing on the input image using the overlapping block embedding layer in the first feature extraction network to obtain the feature block sequence of the input image; and / or The performing of the spatial reduction attention operation on the feature block sequence comprises: using the spatial reduction attention layer in the first feature extraction network to reduce the spatial resolution of each feature block in the feature block sequence to a predetermined size by average pooling, and performing an attention operation on the feature block sequence after the spatial resolution is reduced; and / or The method of obtaining the spatial domain features based on the result of the spatial reduction attention operation includes: based on the result of the spatial reduction attention operation, obtaining the spatial domain features using a feedforward network in the first feature extraction network, wherein the feedforward network includes a fully connected layer, an activation function layer, and a deep convolutional layer between the fully connected layer and the activation function layer for performing zero-filling position encoding.
4. The image tampering detection method according to claim 1, wherein: The extracting frequency domain features of the input image using the second feature extraction network of the image tampering detection model includes: obtaining a frequency domain transform coefficient map of the input image, converting the frequency domain transform coefficient map into a frequency domain transform volume map, applying a nearest neighbor interpolation algorithm to the frequency domain transform volume map to obtain an interpolated volume map, and obtaining the frequency domain features based on the interpolated volume map.
5. The image tampering detection method according to claim 1, wherein: The spatial domain features include spatial domain features of multiple scales, the frequency domain features include frequency domain features of multiple scales, the decoding module is a self-attention decoding module, and the decoding module using the image tampering detection model performs feature fusion on the spatial domain features and the frequency domain features to obtain the fusion features of the input image, including: Fusing spatial domain features and frequency domain features of the same scale respectively to obtain fused feature maps of multiple scales of the input image; Based on the fused feature maps of each scale, the self-attention decoding module is used to obtain the attention feature maps of each scale; Based on attention feature maps of multiple scales, the fusion feature is obtained.
6. The image tampering detection method according to claim 1, wherein: The number of neural network layers included in the second feature extraction network is smaller than the number of neural network layers included in the first feature extraction network, and / or the number of output channels of the neural network layer of the second feature extraction network is smaller than the number of output channels of the neural network layer of the first feature extraction network.
7. The image tampering detection method according to claim 1, wherein: The prediction network includes a classification network and a segmentation network, wherein the step of obtaining the tampering detection result of the input image by using the prediction network of the image tampering detection model based on the fusion features of the input image includes: Obtaining a first prediction result using the classification network based on the fusion feature, wherein the first prediction result indicates whether the input image has been tampered with; A second prediction result is obtained using the segmentation network based on the fused features, wherein the second prediction result indicates a tampered area of the input image.
8. An image tampering detection device, comprising: An image acquisition unit, configured to acquire an input image; The tamper detection unit is configured to perform the following operations: Extracting spatial features of the input image using a first feature extraction network of an image tampering detection model; Extracting frequency domain features of the input image using a second feature extraction network of the image tampering detection model; Using the decoding module of the image tampering detection model to perform feature fusion on the spatial domain features and the frequency domain features to obtain fused features of the input image; Based on the fusion features of the input image, a tampering detection result of the input image is obtained by utilizing the prediction network of the image tampering detection model.
9. An electronic device, characterized in that: include: at least one processor; at least one memory storing computer executable instructions, Wherein, when the computer executable instructions are executed by the at least one processor, the at least one processor is prompted to execute the image tampering detection method according to any one of claims 1 to 7.
10. A computer-readable storage medium storing instructions, characterized in that: When the instructions are executed by at least one processor, the at least one processor is prompted to perform the image tampering detection method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Face-changing video tampering detection method and system based on multi-domain feature fusion
CN112734696A
Image tampering detection method and device, equipment and storage medium
CN114612411A
Blind forensics method for small target copy-paste tampered image
CN115619639A
Image tampering area detection method and device, electronic equipment and storage medium
CN116109597A
Method, device, and system for testing an image
US20200279358A1
