Image tampering detection method and device, electronic equipment and readable storage medium

By training the image tamper detection model and using the multi-loss value function to detect images, the problems of inaccurate detection and inability to identify tampered areas in the prior art are solved, and higher detection accuracy and specific tampered areas are achieved.

CN120279392APending Publication Date: 2025-07-08SHENZHEN XUMI YUNTU SPACE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510188594.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-20
Publication Date
2025-07-08

AI Technical Summary

Technical Problem

The existing image tamper detection technology has problems such as inaccurate detection and the inability to identify specific tampered areas.

Method used

The image tamper detection model obtained by training detects the image to be detected, and uses a loss function based on the first loss value and the second loss value to train the model. The first loss value measures the difference in sample tamper detection sub-results at different resolutions, the second loss value measures the difference in the overall tamper detection results, and updates the model parameters in combination with the loss value at different resolutions.

Benefits of technology

The accuracy of image tamper detection is improved, and specific tampering areas can be identified, avoiding the problems of inaccurate detection and inability to identify tampering areas.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120279392A_ABST
    Figure CN120279392A_ABST
Patent Text Reader

Abstract

The invention relates to the field of image detection, and provides an image tampering detection method and device, electronic equipment and a readable storage medium. The method comprises the following steps: acquiring a to-be-detected image; detecting a tampering area of the to-be-detected image through the trained image tampering detection model to obtain a tampering detection result; wherein the image tampering detection model is obtained based on training of a training set, the training set comprises a plurality of sample detection images, a loss value of the image tampering detection model is based on a first loss value and a second loss value, the first loss value represents loss corresponding to sample tampering detection sub-results of the sample detection images under different resolutions, and the second loss value represents loss corresponding to sample tampering detection sub-results of the sample detection images under different resolutions. The second loss value represents loss corresponding to the sample tampering detection result. According to the method, the loss values of different positions can be used for updating the model, the detection accuracy of the image tampering detection model is improved, and meanwhile, the specific tampering region can be accurately identified.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image detection, and in particular, to an image tampering detection method, apparatus, electronic device, and readable storage medium. Background Art

[0002] With the rapid development of the Internet, social networks have become the main channels for information dissemination, and images account for a considerable proportion of the information in social networks. A large number of tampered images are widely spread through various social networks, thus affecting people's cognition and judgment of important texts, products, etc. Traditional image tampering detection algorithms often only detect a specific image attribute, such as color filter array and JPEG compression characteristics, resulting in inaccurate detection results and being unable to detect the specific tampered areas.

[0003] It can be seen that the existing image tampering detection technologies have problems of inaccurate detection and inability to detect the specific tampered areas when detecting whether an image has been tampered. Summary of the Invention

[0004] In view of this, embodiments of this application provide an image tampering detection method, apparatus, electronic device, and readable storage medium to solve the problems of inaccurate detection and inability to detect the specific tampered areas in the prior art when detecting whether an image has been tampered.

[0005] In the first aspect of the embodiments of this application, an image tampering detection method is provided. The method includes:

[0006] Obtain an image to be detected; detect the tampered area of the image to be detected through a trained image tampering detection model to obtain a tampering detection result; wherein the image tampering detection model is trained based on a training set, the training set includes a plurality of sample detection images, and the loss value of the image tampering detection model is obtained based on a first loss value and a second loss value. The first loss value represents the loss corresponding to the sample tampering detection sub-results of the sample detection images at different resolutions, and the second loss value represents the loss corresponding to the sample tampering detection results.

[0007] In the second aspect of the embodiments of this application, an image tampering detection apparatus is provided. The apparatus includes:

[0008] An obtaining module configured to obtain an image to be detected;

[0009] A detection module, configured to detect a tampered area of an image to be detected through a trained image tampering detection model, and obtain a tampering detection result; wherein the image tampering detection model is trained based on a training set, the training set includes a plurality of sample detection images, and the loss value of the image tampering detection model is obtained based on a first loss value and a second loss value. The first loss value represents the loss corresponding to the sample tampering detection sub-results of the sample detection images at different resolutions, and the second loss value represents the loss corresponding to the sample tampering detection result.

[0010] In a third aspect of the embodiments of the present application, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the above method are implemented.

[0011] In a fourth aspect of the embodiments of the present application, a readable storage medium is provided. The readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.

[0012] The beneficial effects of the embodiments of the present application compared with the prior art are as follows:

[0013] In the embodiments of the present application, an image to be detected is obtained; the tampered area of the image to be detected is detected through a trained image tampering detection model to obtain a tampering detection result; since the image tampering detection model is trained based on a training set, the training set includes a plurality of sample detection images, and the loss value of the image tampering detection model is obtained based on a first loss value and a second loss value. The first loss value represents the loss corresponding to the sample tampering detection sub-results of the sample detection images at different resolutions, and the second loss value represents the loss corresponding to the sample tampering detection result. In this way, by hierarchically obtaining the losses corresponding to the sample tampering detection sub-results at different resolutions, and combining the sample tampering detection sub-results at different resolutions to obtain the loss corresponding to the sample tampering detection result, the loss values at different positions can be used to update the model, improving the detection accuracy of the image tampering detection model. At the same time, the specific tampered area can be identified, avoiding the problems of inaccurate detection and inability to detect the specific tampered area in the prior art when detecting whether an image has been tampered. Description of the Drawings

[0014] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for the embodiments or the description of the prior art. Obviously, the following drawings are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0015] Figure 1It is a schematic flowchart of an image tampering detection method provided by an embodiment of the present application;

[0016] Figure 2 It is a schematic flowchart of another image tampering detection method provided by an embodiment of the present application;

[0017] Figure 3 It is a schematic structural diagram of an encoder and a decoder provided by an embodiment of the present application;

[0018] Figure 4 It is a schematic structural diagram of an image tampering detection device provided by an embodiment of the present application;

[0019] Figure 5 It is a schematic structural diagram of an electronic device provided by an embodiment of the present application. Detailed implementation manners

[0020] In the following description, for the purpose of illustration rather than limitation, specific details such as specific system architectures, technologies, etc. are presented to thoroughly understand the embodiments of the present application. However, those skilled in the art should clearly understand that the present application can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid unnecessary details from interfering with the description of the present application.

[0021] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, rather than to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are usually of the same category, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims means at least one of the connected objects, and the character " / ", generally represents an "or" relationship between the associated objects before and after.

[0022] In addition, it should be noted that the term "comprising", "including" or any other variant thereof is intended to cover non-exclusively, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. Without further limitation, the elements defined by the statement "including..." do not exclude the existence of additional identical elements in the process, method, article or device including the elements.

[0023] Next, a detailed description will be given of an image tampering detection method, device, electronic device, and readable storage medium according to an embodiment of the present application with reference to the accompanying drawings.

[0024] Figure 1 It is a schematic flowchart of an image tampering detection method provided by an embodiment of the present application. As Figure 1 shown, the method includes:

[0025] S101, obtain the image to be detected;

[0026] S102, detect the tampered area of the image to be detected through the trained image tampering detection model to obtain the tampering detection result.

[0027] Specifically, the image to be detected is an image that needs to be detected by the image tampering detection model to determine whether it has been tampered with; the area of the image to be detected may be completely tampered with, or only partially tampered with.

[0028] It can be understood that the image tampering detection model is trained based on a training set, the training set includes multiple sample detection images, and the loss value of the image tampering detection model is obtained based on the first loss value and the second loss value.

[0029] The first loss value represents the loss corresponding to the sample tampering detection sub-results of the sample detection image at different resolutions, that is, the first loss value is used to measure the difference between the sample tampering detection sub-results and the sample tampering labels. The second loss value represents the loss corresponding to the sample tampering detection result. It should be noted that the sample tampering detection result is obtained by fusing each sample tampering detection sub-result, and the second loss value is used to measure the difference between the sample tampering detection result and the sample tampering labels.

[0030] It can be understood that in order to enable the model to learn the features of the image more comprehensively, the sample detection images are processed at different resolutions, and the corresponding sample tampering detection sub-results are obtained. Since the sample detection images are at different resolutions, that is, there are sample detection images at multiple resolutions, the number of corresponding sample tampering detection sub-results is also multiple, that is, each sample detection image at each resolution corresponds to a sample tampering detection sub-result, and the corresponding first loss value is also multiple. Each first loss value is used to measure the difference between these sub-results at different resolutions and the real situation. In this way, considering different resolutions can enable the model to capture the feature information of the image at different scales, avoid missing some tampering features due to only focusing on a single resolution, and thus improve the detection ability of the model. At the same time, by hierarchically obtaining the losses corresponding to the sample tampering detection sub-results at different resolutions, the image tampering detection model can be updated using the loss values at different positions, improving the detection accuracy of the image tampering detection model, and being able to identify the specific tampered areas of the sample detection image, improving the detection accuracy of the image to be detected. The specific steps for obtaining the sample detection images at different resolutions will be described in detail in subsequent embodiments and will not be elaborated here.

[0031] It can be understood that the second loss value measures the difference between the tampering detection result of the model for the overall sample detection image and the true tampering label. The second loss value comprehensively considers the degree of deviation between the final judgment of the model on the sample detection image (whether it is tampered and the tampering location, etc.) and the actual situation, and is a measure of the overall detection effect of the model. By combining the first loss value and the second loss value, the prediction results of the model are evaluated from different perspectives, enabling the model to more comprehensively and accurately learn the features of image tampering during the training process, thereby improving its detection performance in practical applications.

[0032] According to the technical solution provided by the embodiments of the present application, the tampering area of the image to be detected is detected by the image tampering detection model obtained through training, and a tampering detection result is obtained; since the image tampering detection model is obtained by training based on a training set, the training set includes multiple sample detection images, and the loss value of the image tampering detection model is derived from the first loss value and the second loss value. The first loss value represents the loss corresponding to the sample tampering detection sub-results of the sample detection image at different resolutions, and the second loss value represents the loss corresponding to the sample tampering detection result. In this way, by hierarchically obtaining the losses corresponding to the sample tampering detection sub-results at different resolutions and combining the sample tampering detection sub-results at different resolutions to obtain the loss corresponding to the sample tampering detection result, the loss values at different positions can be used to update the model, improving the detection accuracy of the image tampering detection model, and at the same time being able to identify the specific tampering area, avoiding the problems of inaccurate detection and inability to detect the specific tampering area in the prior art when detecting whether an image is tampered.

[0033] In some embodiments, before the tampering area of the image to be detected is detected by the image tampering detection model obtained through training, it further includes:

[0034] Performing feature encoding on the sample detection image at different scales to obtain encoding results at different resolutions; performing feature decoding on the encoding results at different resolutions to obtain decoding results at different resolutions; determining the first loss value corresponding to each sample tampering detection sub-result according to each decoding result, and determining the second loss value corresponding to the sample tampering detection result according to each sample tampering detection sub-result; obtaining a loss value according to the first loss value and the second loss value, and using the loss value to update the parameters of the image tampering detection model to be trained, to obtain a trained image tampering detection model.

[0035] Specifically, before using the image tampering detection model to detect the tampered area of the image to be detected, it is necessary to train the image tampering detection model to be trained, and then obtain the image tampering detection model. That is, after the image tampering detection model to be trained obtains the sample detection image, it performs feature encoding on the sample detection image at different scales to obtain encoding results with different resolutions.

[0036] It can be understood that since image tampering may present different features at different scales, from macroscopic image structure changes to microscopic pixel-level modifications, all may contain clues of tampering. Therefore, the encoding results with different resolutions can contain the feature information of the sample detection image at different scales, from low-resolution global features to high-resolution local detail features, aiming to extract the multi-level features of the image, enhance the representation ability of the model, and fully train the shallow features.

[0037] Furthermore, feature decoding is performed on the encoding results with different resolutions to obtain decoding results with different resolutions. Feature decoding is the reverse operation of the encoding results, remapping the encoding results with different resolutions back to the image or feature space to obtain decoding results with different resolutions. In this way, it helps to restore part of the information of the image, and at the same time, the decoding results also provide a basis for subsequent loss calculation.

[0038] Furthermore, the first loss value corresponding to each sample tampering detection sub-result is determined according to each decoding result, and the second loss value corresponding to the sample tampering detection result is determined according to each sample tampering detection sub-result; specifically, the first loss value corresponding to the sample tampering detection sub-result is the tampering judgment of the image at different resolutions, and the second loss value is the loss evaluation of the tampering detection result of the entire sample detection image obtained by combining these sub-results. The second loss value focuses on the accuracy of the overall tampering judgment, ensuring that the model can achieve good performance not only in local details but also in the tampering judgment of the overall image.

[0039] Furthermore, the first loss value and the second loss value are added together to obtain the final loss value. Using the obtained loss value, the parameters of the image tampering detection model to be trained are updated using an optimization algorithm (such as stochastic gradient descent). Through the backpropagation algorithm, the gradient information of the loss value is transmitted back to each parameter of the model, so that the model knows how to adjust its internal weights and biases to gradually reduce the loss value. After multiple iterations, the parameters of the model are continuously updated, and finally, the model reaches good performance on the training set, thus obtaining a trained image tampering detection model.

[0040] According to the technical solution provided by the embodiments of the present application, feature encoding is performed on the sample detection image at different scales to obtain encoding results with different resolutions; feature decoding is performed on the encoding results with different resolutions to obtain decoding results with different resolutions; a first loss value corresponding to each sample tampering detection sub-result is determined according to each decoding result, and a second loss value corresponding to the sample tampering detection result is determined according to each sample tampering detection sub-result; a loss value is obtained according to the first loss value and the second loss value, and the parameters of the image tampering detection model to be trained are updated by using the loss value to obtain a trained image tampering detection model. In this way, the trained image tampering detection model can more accurately detect the tampered area in the image and improve the accuracy of image tampering because it considers both the features at different resolutions and the judgment accuracy of overall tampering.

[0041] In some embodiments, performing feature encoding on the sample detection image at different scales to obtain encoding results with different resolutions includes:

[0042] Input the sample detection image into the feature encoding module, where the feature encoding module includes at least two encoders connected in sequence. The first encoder is used to encode the received sample detection image to obtain the encoding result corresponding to the first encoder; the encoding result is downsampled and used as the input to the next connected encoder for encoding until the last encoder in the feature encoding module obtains the corresponding encoding result.

[0043] Specifically, for better understanding of this embodiment, the following is combined with Figure 2 to illustrate this embodiment. As shown in Figure 2 : The specific process of performing feature encoding on the sample detection image at different scales to obtain encoding results with different resolutions is to input the sample detection image into the feature encoding module, where the feature encoding module includes at least two encoders connected in sequence.

[0044] In some examples, as a preference, this example uses a feature encoding module including four encoders connected in sequence for exemplary illustration. After the first encoder receives the sample detection image, it will encode the received sample detection image to obtain the encoding result corresponding to the first encoder. Immediately afterwards, the encoding result will be downsampled to change the resolution of the sample detection image. The obtained downsampling result will be input to the next encoder connected to the current encoder for encoding, and at the same time, the encoding result output by the next encoder will be downsampled. Such an operation will be repeated for each encoder until the fourth encoder in the feature encoding module obtains the corresponding encoding result, so that encoding results with different resolutions can be obtained.

[0045] In some examples, the sampling step of the present example's downsampling is preferably 2, and other steps can also be used. The present example does not limit this.

[0046] It can be understood that through this cascaded method, each encoder can further extract and transform the input data based on the previous encoder. Due to the existence of downsampling, the data processed by subsequent encoders will gradually decrease in resolution, but the degree of feature abstraction will gradually increase, that is, it gradually transitions from local detailed features to more global and abstract features. The encoding result obtained by the last encoder contains the image features after multiple abstractions and dimensionality reductions, including the overall structure of the image, high-level semantic information, etc. At the same time, such a cascaded method can also fully integrate deep and shallow feature information and improve the model's sensitivity to shallow texture and edge information.

[0047] According to the technical solution provided by the embodiment of the present application, the sample detection image is input into the feature encoding module. The feature encoding module includes at least two encoders connected in sequence. The first encoder is used to encode the received sample detection image to obtain the encoding result corresponding to the first encoder; the encoding result is downsampled and used as the input to the next connected encoder for encoding until the last encoder in the feature encoding module obtains the corresponding encoding result. Using at least two encoders and cascading them through downsampling can enable the model to extract features from different levels and scales of the image. Starting from local details, through downsampling and the processing of subsequent encoders, it gradually transitions to the extraction of more global and abstract features of the image, providing more comprehensive and rich feature information for image forgery detection, which helps the subsequent processing steps to better judge whether the image has been forged and determine the forged area.

[0048] In some embodiments, feature decoding is performed on the encoding results of different resolutions to obtain decoding results of different resolutions, including:

[0049] The encoding result output by the feature encoding module is downsampled and then encoded again, and the downsampling result obtained by downsampling and the encoding result obtained by re-encoding are used as the initial decoding features; the initial decoding features are input into the feature decoding module. The feature encoding module includes at least two decoders connected in sequence. Each decoder corresponds to the encoder in the feature encoding module. The first decoder is used to decode the received initial decoding features to obtain the decoding result corresponding to the first decoder; the decoding result is upsampled and used as the first input, and the encoding result obtained by the corresponding encoder is downsampled and used as the second input. The first input and the second input are input into the next connected decoder so that the next decoder can perform fusion decoding on the first input and the second input until the last decoder in the feature decoding module obtains the corresponding decoding result.

[0050] Specifically, referring to Figure 2 , in the decoding stage, first, the encoding result output by the feature encoding module is downsampled and then encoded again. The downsampling result obtained by downsampling and the encoding result obtained by re-encoding are used as the initial decoding features and input into the feature decoding module to ensure that after passing through the feature decoding module, the decoded result can have the same resolution as the sample detection image.

[0051] It can be understood that the feature encoding module also includes at least two decoders connected in sequence. Each decoder corresponds to an encoder in the feature encoding module, forming a symmetric structure. Thus, following the previous example, this example also uses four encoders connected in sequence in the feature decoding module for illustrative purposes.

[0052] It can be understood that after receiving the initial decoding features, the first decoder decodes the received initial decoding features to obtain the decoding result corresponding to the first decoder. Further, the decoding result of the first decoder is upsampled to restore the resolution of the decoding result. Upsampling is the opposite of the previous downsampling and aims to restore the detailed information of the data. At the same time, the encoding result obtained by the encoder in the corresponding stage is downsampled to make it match the upsampled decoding result to some extent for fusion.

[0053] In some examples, the specific upsampling method uses bilinear interpolation with a sampling step of 2. This method can maximize the integrity of edge information during the upsampling process. By upsampling, the size of the feature map is enlarged and finally restored to the same size as the sample detection image.

[0054] Further, the decoded result after upsampling is used as the first input, and the encoded result after downsampling is used as the second input, which are input into the next decoder. Specifically, the first input and the second input can be concatenated and then input into the next decoder. The next decoder will perform fusion decoding on these two inputs, enabling the decoder to integrate information from different sources, utilize both the result of the previous decoding step (partially restored information) and the information of the corresponding encoder (feature information during original encoding), thereby leveraging more useful information to enhance the learning ability of the network, fully integrating deep and shallow feature information, and improving the sensitivity of the model to the texture and edge information of the shallow layer. Further, the processing steps of each decoder are repeatedly executed. Each decoder will use the decoded result after upsampling of the previous connected decoder as the first input, and downsample the encoded result obtained by the encoder at the corresponding stage as the second input, and perform the fusion decoding operation until the fourth decoder in the feature decoding module obtains the corresponding encoded result. In this way, the decoded result is gradually refined until the final decoder obtains the final decoded result. Such an iterative process makes the decoded result increasingly close to the feature representation of the original image. The final decoded result will include the restoration of image information at different resolutions and can obtain decoded results at different resolutions.

[0055] According to the technical solution provided by the embodiment of the present application, the encoded result output by the feature encoding module is downsampled and then re-encoded, and the downsampling result obtained by downsampling and the encoded result obtained by re-encoding are used as the initial decoding features; the initial decoding features are input into the feature decoding module. The feature encoding module includes at least two decoders connected in sequence. Each decoder corresponds to an encoder in the feature encoding module. The first decoder is used to decode the received initial decoding features to obtain the decoded result corresponding to the first decoder; the decoded result is upsampled as the first input, and the encoded result obtained by the corresponding encoder is downsampled as the second input. The first input and the second input are input into the next connected decoder, so that the next decoder performs fusion decoding on the first input and the second input until the last decoder in the feature decoding module obtains the corresponding decoded result. In this way, through the iterative processing of at least two decoders, the information in the encoding stage is fully utilized, and the image information at different resolutions can be gradually restored from the abstract features, which helps to more comprehensively analyze and understand the feature information of the image at different levels and resolutions in tasks such as image forgery detection, and improves the processing ability of the model for image features and the analysis ability for forgery information. At the same time, the corresponding relationship between the decoder and the encoder ensures the consistency and coherence of the encoding and decoding processes, which helps to improve the performance and stability of the entire model.

[0056] In some embodiments, the encoder includes: a first convolutional layer, a first group normalization layer, a first activation function layer, a second convolutional layer, and a second group normalization layer connected in sequence; the decoder includes: a third convolutional layer, a third group normalization layer, a second activation function layer, a fourth convolutional layer, and a fourth group normalization layer connected in sequence.

[0057] Specifically, Figure 3 , the structure of each encoder in the feature encoding module includes a first convolutional layer, a first group normalization layer, a first activation function layer, a second convolutional layer, and a second group normalization layer connected in sequence; the structure of each decoder in the feature decoding module also includes a third convolutional layer, a third group normalization layer, a second activation function layer, a fourth convolutional layer, and a fourth group normalization layer connected in sequence;

[0058] Specifically, after receiving the input data, the encoder will use its first convolutional layer, first group normalization layer, first activation function layer, second convolutional layer, and second group normalization layer to process the input data in sequence to obtain an encoding result. Similarly, after receiving the input data, the decoder will use its third convolutional layer, third group normalization layer, second activation function layer, fourth convolutional layer, and fourth group normalization layer to process the input data in sequence to obtain a decoding result.

[0059] Among them, the first convolutional layer, the second convolutional layer, the third convolutional layer, and the fourth convolutional layer preferably use 3*3 convolutional layers, and the first activation function layer and the second activation function layer preferably use ReLU functions. In addition, Sigmoid functions, etc. can also be used. This embodiment does not make specific limitations here.

[0060] It should be noted that in this embodiment, the group normalization method in the first group normalization layer, the second group normalization layer, the third group normalization layer, and the fourth group normalization layer is used to replace the traditional batch normalization method. The idea is to group the data matrix by channels, calculate the normalized mean and variance within each group, and do not use the data in the batch dimension. The calculation size is independent of the batch size. It solves the problem that batch normalization is closely related to the training batch size, and the mean and variance calculated when the batch is small are unstable and cannot represent the entire data. In this way, using the group normalization method can avoid the influence of the batch size on the model, make the deep neural network easier to converge, and reduce the risk of model overfitting.

[0061] In some examples, determining a first loss value corresponding to each sample tampering detection sub-result according to each decoding result includes: performing convolutional processing on each decoding result using a fifth convolutional layer to obtain convolutional features; activating the convolutional features using a third activation function layer to obtain a sample tampering detection sub-result corresponding to each decoding result; calculating the difference between each sample tampering detection sub-result and the true tampering label using a binary cross-entropy loss function to obtain the first loss value.

[0062] Specifically, referring to Figure 2 , after obtaining decoding results with different resolutions, continuing with the above example, if the feature decoding module includes four sequentially connected decoders, then four decoding results with different resolutions will be obtained. For each decoding result, use the fifth convolutional layer to perform convolutional processing on each decoding result to obtain convolutional features; use the third activation function layer to activate the convolutional features to obtain a sample tampering detection sub-result corresponding to each decoding result. Finally, use the binary cross-entropy loss function to calculate the difference between each sample tampering detection sub-result and the true tampering label to obtain a first loss value. In this example, the third activation function layer preferably uses the Sigmoid function. In addition, the ReLU function etc. can also be used, and this implementation does not make specific limitations here.

[0063] It can be understood that the binary cross-entropy loss function is commonly used in binary classification problems. In this embodiment, it will be used to measure the difference between the sample tampering detection sub-result and the true tampering label. For each sample tampering detection sub-result, it is regarded as a prediction result, and the true tampering label is known (usually 0 or 1, indicating not tampered or tampered). When the prediction result exactly matches the true label, the loss value is close to 0; when the two differ greatly, the loss value is large. This can guide the model to adjust its parameters in the correct direction to make the prediction result closer to the true label.

[0064] In some examples, for the four decoding results with different resolutions, after convolutional processing and activation processing, four sample tampering detection sub-results will be obtained, and at the same time, 4 first loss values will be obtained. The total first loss value is obtained by adding the 4 first loss values.

[0065] According to the technical solution provided by the embodiment of the present application, use the fifth convolutional layer to perform convolutional processing on each decoding result to obtain convolutional features; use the third activation function layer to activate the convolutional features to obtain a sample tampering detection sub-result corresponding to each decoding result; use the binary cross-entropy loss function to calculate the difference between each sample tampering detection sub-result and the true tampering label to obtain a first loss value. Through convolutional and activation operations, the decoding results are converted into sample tampering detection sub-results that can be used for loss calculation, and the binary cross-entropy loss function is used to evaluate the difference between the sample tampering detection sub-results and the true tampering labels, providing a basis for optimizing the image tampering detection model. It helps the model continuously adjust its own parameters during training to reduce the difference between the prediction result and the true result and improve the accuracy of image tampering detection.

[0066] In some embodiments, determining a second loss value corresponding to the sample tampering detection result according to each sample tampering detection sub-result includes:

[0067] Fuse the tampering detection sub-results of each sample to obtain a fusion result; perform convolution processing on the fusion result using the sixth convolutional layer to obtain target convolutional features; use the fourth activation function layer to activate the target convolutional features to obtain a tampering detection result; calculate the difference between the sample tampering detection result and the true tampering label to obtain a second loss value.

[0068] Specifically, refer to Figure 2 , four sample tampering detection sub-results are obtained, and these sub-results are obtained from feature processing at different scales. Fusing them can integrate information from multiple aspects to obtain a more comprehensive and integrated fusion result.

[0069] Furthermore, perform convolution processing on the fusion result using the sixth convolutional layer to obtain target convolutional features; in this example, the sixth convolutional layer preferably uses a 1*1 convolutional layer. Further use the fourth activation function layer to activate the target convolutional features to obtain a tampering detection result; then calculate the difference between the sample tampering detection result and the true tampering label to obtain a second loss value. In this example, the third activation function layer preferably uses the Sigmoid function, and other functions such as the ReLU function can also be used. This implementation does not make specific limitations here.

[0070] According to the technical solution provided by the embodiment of the present application, perform convolution processing on the fusion result using the sixth convolutional layer to obtain target convolutional features; use the fourth activation function layer to activate the target convolutional features to obtain a tampering detection result; calculate the difference between the sample tampering detection result and the true tampering label to obtain a second loss value. Through convolution and activation operations, the fusion result is converted into a sample tampering detection result that can be used for loss calculation, and by evaluating the difference between the sample tampering detection result and the true tampering label, a basis is provided for optimizing the image tampering detection model. Help the model continuously adjust its own parameters during the training process to reduce the difference between the prediction result and the true result and improve the accuracy of image tampering detection.

[0071] It should be understood that the magnitudes of the sequence numbers of the steps in the above embodiments do not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation to the process of the embodiment of the present application.

[0072] All the above optional technical solutions can be combined arbitrarily to form optional embodiments of the present application, which will not be elaborated here one by one.

[0073] The following is an embodiment of the apparatus of the present application, which can be used to execute the method embodiment of the present application. For the details not disclosed in the embodiment of the apparatus of the present application, please refer to the method embodiment of the present application.

[0074] Figure 4 is a schematic structural diagram of an image tampering detection device provided by an embodiment of the present application. AsFigure 4 As shown, the device includes:

[0075] An acquisition module 401, configured to acquire an image to be detected;

[0076] A detection module 402, configured to detect a tampered area of the image to be detected through a trained image tampering detection model to obtain a tampering detection result; wherein the image tampering detection model is trained based on a training set, the training set includes a plurality of sample detection images, and the loss value of the image tampering detection model is derived from a first loss value and a second loss value. The first loss value represents the loss corresponding to the sample tampering detection sub-results of the sample detection image at different resolutions, and the second loss value represents the loss corresponding to the sample tampering detection result.

[0077] In some embodiments, the image tampering detection device of this embodiment further includes a training module 403. The training module 403 is configured to perform feature encoding on the sample detection image at different scales to obtain encoding results at different resolutions; perform feature decoding on the encoding results at different resolutions to obtain decoding results at different resolutions; determine a first loss value corresponding to each sample tampering detection sub-result according to each decoding result, and determine a second loss value corresponding to the sample tampering detection result according to each sample tampering detection sub-result; obtain a loss value according to the first loss value and the second loss value, and use the loss value to update the parameters of the image tampering detection model to be trained to obtain a trained image tampering detection model.

[0078] In some embodiments, the training module 403 is further configured to input the sample detection image into a feature encoding module. The feature encoding module includes at least two encoders connected in sequence. The first encoder is used to encode the received sample detection image to obtain an encoding result corresponding to the first encoder; the encoding result is downsampled and used as an input, and is input into the next connected encoder for encoding until the last encoder in the feature encoding module obtains the corresponding encoding result.

[0079] In some embodiments, the training module 403 is further configured to downsample the encoding result output by the feature encoding module and then perform re-encoding, and use the downsampling result obtained by downsampling and the encoding result obtained by re-encoding as the initial decoding features; input the initial decoding features into the feature decoding module. The feature encoding module includes at least two decoders connected in sequence, and each decoder corresponds to an encoder in the feature encoding module. The first decoder is configured to decode the received initial decoding features to obtain a decoding result corresponding to the first decoder; upsample the decoding result as the first input, and downsample the encoding result obtained by the corresponding encoder as the second input, and input the first input and the second input into the next connected decoder, so that the next decoder performs fusion decoding on the first input and the second input until the last decoder in the feature decoding module obtains the corresponding decoding result.

[0080] In some embodiments, the training module 403 is further configured that the encoder includes: a first convolutional layer, a first group normalization layer, a first activation function layer, a second convolutional layer, and a second group normalization layer connected in sequence. The decoder includes: a third convolutional layer, a third group normalization layer, a second activation function layer, a fourth convolutional layer, and a fourth group normalization layer connected in sequence.

[0081] In some embodiments, the training module 403 is further configured to perform convolution processing on each decoding result using a fifth convolutional layer to obtain convolution features; activate the convolution features using a third activation function layer to obtain a sample tampering detection sub-result corresponding to each decoding result; calculate the difference between each sample tampering detection sub-result and the true tampering label using a binary cross-entropy loss function to obtain a first loss value.

[0082] In some embodiments, the training module 403 is further configured to fuse each sample tampering detection sub-result to obtain a fusion result; perform convolution processing on the fusion result using a sixth convolutional layer to obtain target convolution features; activate the target convolution features using a fourth activation function layer to obtain a tampering detection result; calculate the difference between the sample tampering detection result and the true tampering label to obtain a second loss value.

[0083] The device provided by the embodiment of the present application obtains a to-be-detected image, and detects a tampered area of the to-be-detected image through a trained image tampering detection model to obtain a tampering detection result. Since the image tampering detection model is trained based on a training set, the training set includes multiple sample detection images, and the loss value of the image tampering detection model is obtained based on a first loss value and a second loss value. The first loss value represents the loss corresponding to the sample tampering detection sub-results of the sample detection images at different resolutions, and the second loss value represents the loss corresponding to the sample tampering detection result. In this way, by hierarchically obtaining the losses corresponding to the sample tampering detection sub-results at different resolutions and combining the sample tampering detection sub-results at different resolutions to obtain the loss corresponding to the sample tampering detection result, the loss values at different positions can be used to update the model, improving the detection accuracy of the image tampering detection model. At the same time, the specific tampered area can be identified, avoiding the problems in the prior art of inaccurate detection and inability to detect the specific tampered area when detecting whether an image has been tampered with.

[0084] Figure 5 is a schematic diagram of the electronic device 5 provided by the embodiment of the present application. As Figure 5 shown, the electronic device 5 of this embodiment includes: a processor 501, a memory 502, and a computer program 503 stored in the memory 502 and executable on the processor 501. When the processor 501 executes the computer program 503, the steps in each of the above method embodiments are implemented. Alternatively, when the processor 501 executes the computer program 503, the functions of each module / unit in each of the above device embodiments are implemented.

[0085] The electronic device 5 can be a desktop computer, a notebook, a palm computer, a cloud server, and other electronic devices. The electronic device 5 may include, but is not limited to, the processor 501 and the memory 502. Those skilled in the art can understand that Figure 5 merely examples of the electronic device 5, which do not constitute a limitation to the electronic device 5, and may include more or fewer components than those shown in the figure, or different components.

[0086] The processor 501 may be a central processing unit (CPU), or may be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.

[0087] The memory 502 can be an internal storage unit of the electronic device 5, for example, the hard disk or memory of the electronic device 5. The memory 502 can also be an external storage device of the electronic device 5, for example, a plug-in hard disk equipped on the electronic device 5, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. The memory 502 can also include both the internal storage unit and the external storage device of the electronic device 5. The memory 502 is used to store computer programs and other programs and data required by the electronic device.

[0088] Those skilled in the art can clearly understand that, for the convenience and conciseness of description, only the above division of each functional unit and module is used as an example for illustration. In practical applications, the above functions can be allocated to different functional units and modules according to needs, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.

[0089] If the integrated module / 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 readable storage medium. Based on this understanding, to implement all or part of the processes in the above method embodiments of the present application, it can also be completed by instructing relevant hardware through a computer program. The computer program can be stored in the readable storage medium. When the computer program is executed by a processor, the steps of the above method embodiments can be implemented. The computer program can include computer program code, and the computer program code can be in the form of source code, object code, executable file or some intermediate form, etc. The readable storage medium can include: any entity or device that can carry computer program code, a recording medium, a USB flash drive, a mobile hard disk, a magnetic disk, an optical disc, a computer memory, a Read-Only Memory (ROM), a Random Access Memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc.

[0090] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the various embodiments of the present application, and should all be included within the protection scope of the present application.

Claims

1. An image forgery detection method, characterized in that, Including: Obtain the image to be detected; Detect the tampered area of the image to be detected through the trained image tampering detection model to obtain a tampering detection result; Wherein the image tampering detection model is obtained by training based on a training set, the training set includes a plurality of sample detection images, and the loss value of the image tampering detection model is obtained based on a first loss value and a second loss value. The first loss value represents the loss corresponding to the sample tampering detection sub-results of the sample detection image at different resolutions, and the second loss value represents the loss corresponding to the sample tampering detection result.

2. The method according to claim 1, wherein Before the tampered area of the image to be detected is detected by the trained image tampering detection model, it further includes: Perform feature encoding on the sample detection image at different scales to obtain encoding results at different resolutions; Perform feature decoding on the encoding results at different resolutions to obtain decoding results at different resolutions; Determine the first loss value corresponding to each sample tampering detection sub-result according to each decoding result, and determine the second loss value corresponding to the sample tampering detection result according to each sample tampering detection sub-result; Obtain the loss value according to the first loss value and the second loss value, and update the parameters of the image tampering detection model to be trained by using the loss value to obtain a trained image tampering detection model.

3. The method according to claim 2, wherein The performing feature encoding on the sample detection image at different scales to obtain encoding results at different resolutions includes: Input the sample detection image into a feature encoding module, the feature encoding module includes at least two encoders connected in sequence, and the first encoder is used to encode the received sample detection image to obtain the encoding result corresponding to the first encoder; Use the encoding result after downsampling as an input, and input it into the next connected encoder for encoding until the last encoder in the feature encoding module obtains the corresponding encoding result.

4. The method according to claim 3, characterized in that, The performing feature decoding on the encoding results at different resolutions to obtain decoding results at different resolutions includes: Perform downsampling on the encoding result output by the feature encoding module and then perform re-encoding, and use the downsampling result obtained by downsampling and the encoding result obtained by re-encoding as initial decoding features; Input the initial decoding features into a feature decoding module, the feature encoding module includes at least two decoders connected in sequence, and each decoder corresponds to the encoder in the feature encoding module. The first decoder is used to decode the received initial decoding features to obtain the decoding result corresponding to the first decoder; Use the decoding result after upsampling as the first input, and use the encoding result obtained by downsampling the corresponding encoder as the second input, and input the first input and the second input into the next connected decoder so that the next decoder performs fusion decoding on the first input and the second input until the last decoder in the feature decoding module obtains the corresponding decoding result.

5. The method according to claim 4, wherein The encoder includes: a first convolutional layer, a first group normalization layer, a first activation function layer, a second convolutional layer, and a second group normalization layer connected in sequence; The decoder includes: a third convolutional layer, a third group normalization layer, a second activation function layer, a fourth convolutional layer, and a fourth group normalization layer connected in sequence.

6. The method according to claim 2, characterized in that, The determining the first loss value corresponding to each sample tampering detection sub-result according to each decoding result includes: Performing convolutional processing on each of the decoding results by using a fifth convolutional layer to obtain convolutional features; Activating the convolutional features by using a third activation function layer to obtain the sample tampering detection sub-result corresponding to each of the decoding results; Calculating the difference between each of the sample tampering detection sub-results and the true tampering label by using a binary cross-entropy loss function to obtain the first loss value.

7. The method according to claim 2, wherein The determining the second loss value corresponding to the sample tampering detection result according to each sample tampering detection sub-result includes: Fusing each of the sample tampering detection sub-results to obtain a fusion result; Performing convolutional processing on the fusion result by using a sixth convolutional layer to obtain target convolutional features; Activating the target convolutional features by using a fourth activation function layer to obtain the tampering detection result; Calculating the difference between the sample tampering detection result and the true tampering label to obtain the second loss value.

8. An image tampering detection device, characterized in that, Includes: An acquisition module configured to acquire an image to be detected; A detection module configured to detect the tampering area of the image to be detected through a trained image tampering detection model to obtain a tampering detection result; wherein the image tampering detection model is trained based on a training set, the training set includes a plurality of sample detection images, and the loss value of the image tampering detection model is derived from the first loss value and the second loss value, the first loss value represents the loss corresponding to the sample tampering detection sub-results of the sample detection images at different resolutions, and the second loss value represents the loss corresponding to the sample tampering detection result.

9. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, the steps of the method according to any one of claims 1 to 7 are implemented.