Training data generation method and device

By merging the attribute information of the tampered layer and the background layer, a new tampered image is generated as training data, which solves the problems of insufficient diversity and accuracy of training data in the existing technology and achieves more efficient model training.

CN120599409APending Publication Date: 2025-09-05TAIKANG ONLINE HEALTH TECH (WUHAN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510742447.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-04
Publication Date
2025-09-05

AI Technical Summary

Technical Problem

The existing image tampering detection model training data is expensive to obtain and the quantity is limited. The generated training data cannot cover a variety of scenarios, resulting in low data diversity and accuracy.

Method used

By obtaining the attribute information of the background layer and the tampered layer of the tampered image set, the background layer and the tampered layer to be merged are selected, and they are merged to generate a new tampered image as training data, thereby improving the accuracy and diversity of the training data.

Benefits of technology

The generated training data covers a variety of scenarios more accurately and is suitable for image compression caused by uploading to social software, which improves the effect of model training.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120599409A_ABST
    Figure CN120599409A_ABST
Patent Text Reader

Abstract

The invention provides a training data generation method and device. The method comprises the following steps: acquiring a tampered image set; according to the tampered image set, extracting a background image layer of the tampered image set and attribute information of a tampered image layer; selecting a to-be-merged background image layer and a to-be-merged tampered image layer according to attribute information of the background image layer and the tampered image layer of the tampered image set; and merging the background image layer and the tampering image layer, and adding a first tampering image obtained by merging into training data. According to the scheme, the accuracy of training data generation is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the fields of machine learning and artificial intelligence, and in particular to a method and apparatus for generating training data. Background Art

[0002] With the rapid development of digital image processing technology, image tampering has become increasingly common. To detect and identify these tampering attempts, deep learning-based image tampering detection models have been widely researched. However, training such models requires a large amount of high-quality tampered image data and its corresponding true labels. Given the high cost and limited availability of authentic tampered data, generating realistic synthetic tampered data has become a key technology for training image tampering detection models.

[0003] Currently, some solutions use cropping, scaling, and other transformations on tampered images to obtain training images as training data for the model. However, the training data obtained using this method cannot cover a variety of scenarios and is inaccurate. Summary of the Invention

[0004] The present application provides a method and apparatus for generating training data to improve the accuracy of training data generation.

[0005] In a first aspect, the present application provides a training data generation method, comprising: obtaining a tampered image set; extracting attribute information of the background layer and the tampered layer of the tampered image set based on the tampered image set; selecting the background layer and the tampered layer to be merged based on the attribute information of the background layer and the tampered layer of the tampered image set; merging the background layer and the tampered layer, and adding the merged first tampered image to the training data.

[0006] In one possible implementation, based on the attribute information of the background layer and the tampered layer of the tampered image set, the background layer and the tampered layer to be merged are selected, including: combining the background layer with different attribute information and the tampered layer with different attribute information to determine the background layer and the tampered layer to be merged.

[0007] In one possible implementation, the tampered image set includes a second tampered image; selecting the background layer and the tampered layer to be merged based on the attribute information of the background layer and the tampered layer of the tampered image set, further comprising: obtaining the attribute information of the background layer and the tampered layer of the second tampered image; obtaining the first tampered layer by adjusting the attribute information of the tampered layer of the second tampered image based on the attribute information of the background layer of the second tampered image; and using the background layer of the second tampered image and the first tampered layer as the background layer and the tampered layer to be merged.

[0008] In one possible implementation, obtaining attribute information of the background layer and the tampered layer of the second tampered image includes: parsing the second tampered image to obtain attribute information of each layer in the second tampered image; determining the background layer and the tampered layer of the second tampered image based on the attribute information of each layer in the second tampered image; and extracting the attribute information of the background layer and the tampered layer of the second tampered image.

[0009] In one possible implementation, the background layer of the second tampered image and the first tampered layer are used as the background layer and tampered layer to be merged, including: generating a random number; if the random number is not greater than a preset threshold, the background layer of the second tampered image and the first tampered layer are used as the background layer and tampered layer to be merged.

[0010] In a possible implementation, the method further includes: if the random number is greater than a preset threshold, obtaining attribute information of the background layer of the untampered image; and using the background layer of the untampered image and the first tampered layer as the background layer and tampered layer to be merged.

[0011] In a possible implementation, merging the background layer and the tampered layer specifically includes: merging pixel values ​​of the background layer and the tampered layer.

[0012] In a possible implementation, the method further includes: generating mask labels for the training data.

[0013] In one possible implementation, generating a mask label for training data includes: creating an image for a tampered image in the training data; the size of the image is the same as the size of a background layer of the tampered image; the initial pixel values ​​of the image are all first values; setting the pixel values ​​of an overlay area in the image to a second value to obtain a mask label for the training data; the overlay area represents an overlapping area between the tampered layer and the background layer.

[0014] In a possible implementation, the method further includes: determining a quality range of the training data; and performing image compression on the training data within the quality range to obtain enhanced training data.

[0015] In a second aspect, the present application provides a training data generation device, comprising: an acquisition module for acquiring a tampered image set; an extraction module for extracting attribute information of a background layer and a tampered layer of the tampered image set based on the tampered image set;

[0016] The selection module is used to select the background layer and the tampered layer to be merged according to the attribute information of the background layer and the tampered layer of the tampered image set; the processing module is used to merge the background layer and the tampered layer, and add the first tampered image obtained by the merger to the training data.

[0017] In a third aspect, the present application provides an electronic device comprising: a processor, and a memory communicatively connected to the processor; the memory stores computer-executable instructions; and the processor executes the computer-executable instructions stored in the memory to implement the above method.

[0018] In a fourth aspect, the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the above method.

[0019] In a fifth aspect, the present application provides a computer program product, comprising a computer program, which is used to implement the above method when executed by a processor.

[0020] In the training data generation method and device provided by the present application, an initial tampered image set is obtained; based on the tampered image set, attribute information of the background layer and the tampered layer of the tampered image set is extracted; based on the attribute information of the background layer and the tampered layer of the tampered image set, the background layer and the tampered layer to be merged are selected; the selected background layer and the tampered layer are merged, and the new tampered image obtained by the merger is added to the training data as a training image; the scheme of the present application improves the accuracy of training data generation by merging the tampered layer with the background layer to obtain a new tampered image, and then using the new tampered image as training data. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0022] Figure 1 A flowchart of a training data generation method is exemplified;

[0023] Figure 2 A flowchart of a training data generation method is exemplified;

[0024] Figure 3 A flowchart of a training data generation method is exemplified;

[0025] Figure 4 This is a flowchart of a training data generation method according to an example of the present application;

[0026] Figure 5 A schematic diagram of generating training data and training data labels for an example of this application;

[0027] Figure 6 The following is a schematic diagram showing the structure of a training data generating device;

[0028] Figure 7 Schematic diagram of the structure of an electronic device is shown in FIG.

[0029] The above drawings illustrate specific embodiments of the present application, which will be described in more detail below. These drawings and the textual description are not intended to limit the scope of the present application in any way, but rather to illustrate the concepts of the present application to those skilled in the art by reference to specific embodiments. DETAILED DESCRIPTION

[0030] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.

[0031] It should be noted that the brief description of terms in this application is only for the convenience of understanding the embodiments described below, and is not intended to limit the embodiments of this application. Unless otherwise specified, these terms should be understood according to their ordinary and usual meanings. The terms "first", "second", etc. in the specification and claims and the above-mentioned drawings in this application are used to distinguish similar or similar objects or entities, and do not necessarily mean to limit a specific order or precedence, unless otherwise indicated. It should be understood that the terms used in this way can be interchangeable where appropriate, for example, they can be implemented in an order other than those given in the diagrams or descriptions of the embodiments of this application. The terms "including" and "having" in the specification and claims and the above-mentioned drawings in this application and any variations thereof are intended to cover but not exclude inclusion, for example, a product or device containing a series of components is not necessarily limited to those components clearly listed, but may include other components that are not clearly listed or inherent to these products or devices. The term "module" used in this application refers to any known or later developed hardware, software, firmware, artificial intelligence, fuzzy logic or combination of hardware and / or software code that can perform the functions associated with the element.

[0032] With the rapid development of digital image processing technology, image tampering has become increasingly common. To detect and identify these tampering attempts, deep learning-based image tampering detection models have been widely researched. However, training such models requires a large amount of high-quality tampered image data and its corresponding true labels. Given the high cost and limited availability of authentic tampered data, generating realistic synthetic tampered data has become a key technology for training image tampering detection models.

[0033] Currently, some solutions involve cropping, scaling, and other transformations on tampered images to obtain training images as training data for the model. However, the training data obtained using this method cannot cover a variety of scenarios, and is not applicable to the real situation of image compression caused by uploading through social software. As a result, the generated training data cannot include data from a variety of scenarios, and the data diversity and accuracy are low. Using these inaccurate training data to train the model will also result in an inaccurate training model.

[0034] The technical content provided by this application is intended to solve some of the technical problems mentioned above in the related technologies. In the training data generation method and device provided by this application, an initial tampered image set is obtained; based on the tampered image set, the attribute information of the background layer and the tampered layer of the tampered image set is extracted; based on the attribute information of the background layer and the tampered layer of the tampered image set, the background layer and the tampered layer to be merged are selected; the selected background layer and the tampered layer are merged, and the new tampered image obtained by merging is added to the training data as a training image; the scheme of this application improves the accuracy of training data generation by merging the tampered layer with the background layer to obtain a new tampered image, and then using the obtained new tampered image as training data.

[0035] The following specific embodiments describe in detail the technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0036] Figure 1 A flow chart of a training data generation method is shown as an example; Figure 1 As shown, the method includes:

[0037] Step 101: Obtain a set of tampered images;

[0038] Step 102: extracting attribute information of the background layer and the tampered layer of the tampered image set according to the tampered image set;

[0039] Step 103: Select the background layer and the tampered layer to be merged according to the attribute information of the background layer and the tampered layer of the tampered image set;

[0040] Step 104: merge the background layer and the tampered layer, and add the merged first tampered image to the training data.

[0041] Specifically, a tampered image set is first obtained; the tampered image set represents an initial set of images that have been tampered with but not tampered with again. Based on the obtained tampered image set, attribute information of the background layer and tampered layer of the tampered image set is extracted; based on the extracted attribute information of the background layer and tampered layer of the tampered image set, the background layer and tampered layer to be merged are selected. Specifically, the background layer and tampered layer of each tampered image in the tampered image set are extracted; illustratively, a document of the tampered image can be loaded to extract attribute information of each layer of the tampered image; wherein the attribute information of the image represents the basic features and structure of the image on the corresponding layer, such as the size of the layer, the layer type, etc.; based on the extracted attribute information, the background layer and tampered layer of the tampered image set are identified and confirmed. Based on the attribute information of the background layer and tampered layer of the tampered image set, the background layer and tampered layer to be merged are selected. Thereafter, the background layer and tampered layer are merged to obtain a new first tampered image, and the merged first tampered image is added to the training data. In this example, the background layer and the tampered layer to be merged are determined from the initial set of tampered images to be processed; the background layer and the tampered layer to be merged are merged to obtain a first tampered image, and the first tampered image is added to the training data; the accuracy of the generated training data and the diversity of the training data are improved.

[0042] Furthermore, to generate accurate and diverse training data, it is necessary to improve the diversity of the background layer and the tampering layer; accordingly, as an example, based on any example, step 103 includes:

[0043] The background layers with different attribute information and the tampered layers with different attribute information are combined to determine the background layers and tampered layers to be merged.

[0044] Specifically, for each tampered image in the tampered image set, the attribute information of the background layer and the tampered layer can be extracted first; then, based on the attribute information of each layer of each image extracted, the background layers corresponding to different attribute information and the tampered layers corresponding to different attribute information are combined to determine the background layers and tampered layers to be merged. Subsequently, multiple groups of determined background layers and tampered layers to be merged are merged to obtain a large amount of diverse and rich training data. In this example, by combining background layers with different attribute information and tampered layers with different attribute information, the tampered layers and background layers to be merged are determined, thereby improving the diversity of the background layers and tampered layers.

[0045] Furthermore, a new tampered layer can be obtained by changing the attribute information of the tampered layer; Figure 2A flowchart of a training data generation method is exemplified; based on any example, the tampered image set includes a second tampered image; step 103 further includes:

[0046] Step 201: Obtain attribute information of the background layer and the tampered layer of the second tampered image;

[0047] Step 202: Based on the attribute information of the background layer of the second tampered image, the attribute information of the tampered layer of the second tampered image is adjusted to obtain the first tampered layer;

[0048] Step 203: Use the background layer of the second tampered image and the first tampered layer as the background layer and tampered layer to be merged.

[0049] Specifically, the tampered layer and background layer to be merged are selected, and any second tampered image can also be selected from the set of tampered images to be processed; then, the attribute information of the background layer and the tampered layer of the second tampered image is obtained; based on the attribute information of the background layer of the second image obtained, the attribute information of the tampered layer of the second tampered image is adjusted to obtain the tampered first tampered layer; exemplarily, the attribute information includes: the size information (width and height) of the layer; the position information of the layer, wherein the position information of the background layer can represent the position information of the background layer in the image, and the attribute information of the tampered layer can represent the position information of the tampered layer relative to the background layer; exemplarily, the position of the layer can be represented by the coordinates of the upper left corner of the layer; in actual application, when the coordinates of any point of the layer and the size of the layer are known, the position information of the layer can be determined. This example does not specifically limit the representation method of the layer position information. Furthermore, the attribute information of the layer also includes the layer type, image pixel data, etc. When it comes to text-type layers, the attribute information of the layer also includes: text content, font, font size, rotation angle, color, etc.

[0050] Specifically, the attribute information of the tampered layer of the second tampered image is adjusted. Any adjustments can be made to the aforementioned attribute information of the tampered layer, but adjustments must be made based on the background layer. As an example, the position of the tampered layer is updated: within the size range of the background layer, the tampered layer is moved to a new coordinate position, and the position coordinate attributes of the tampered layer are updated. As another example, within the size range of the background layer, the size of the tampered layer is adjusted: first, the new width and height of the tampered layer are determined, the tampered layer is enlarged or reduced at a fixed or random ratio, and the width and height attribute information of the current tampered layer is updated to obtain a new tampered layer. As yet another example, within the size range of the background layer, the rotation angle of the tampered layer is adjusted: the tampered layer is rotated around the center of the tampered layer at a fixed or random angle to obtain an updated tampered layer. It should be noted that during the rotation process, the tampered layer must not exceed the size range of the background layer. When the tampered layer contains text, the text content, font, size, and color can be randomly changed, and the attribute information of the adjusted layer is updated. Furthermore, the principle of adjustment must ensure that the tampered layer does not exceed the size range of the background layer. The aforementioned adjustments can be made individually or simultaneously. The resulting tampered layer is the first tampered layer. The background layer of the second tampered image and the first tampered layer are used as the background layer and tampered layer to be merged. In this example, by adjusting the attribute information of the tampered layer to obtain a new first tampered layer, the first tampered layer and the background layer of the second tampered image are used as the tampered layer and background layer to be merged, thereby increasing the diversity of the tampered layers. Subsequently, training data is generated based on the highly diverse tampered layers, thereby increasing the diversity and accuracy of the generated training data.

[0051] Furthermore, it is necessary to accurately obtain the attribute information of the background layer and the attribute information of the tampered layer; accordingly, as an example, Figure 3 A flowchart of a training data generation method is exemplified. Based on any example, step 201 includes:

[0052] Step 301: parse the second tampered image to obtain attribute information of each layer in the second tampered image;

[0053] Step 302: Determine the background layer and the tampered layer of the second tampered image based on the attribute information of each layer in the second tampered image;

[0054] Step 303: Extract attribute information of the background layer and the tampered layer of the second tampered image.

[0055] Specifically, the second tampered image is parsed to obtain attribute information of each layer of the second tampered image; based on the attribute information of each layer obtained from the parsing, the background layer and the tampered layer of the second tampered layer are identified and determined; accordingly, the attribute information of the background layer and the tampered layer of the second tampered image is extracted from the attribute information of each layer obtained from the parsing. In this example, by parsing the second tampered image, obtaining the attribute information of each layer of the tampered image, identifying the tampered layer and the background layer, and extracting the attribute information of the tampered layer and the background layer, the accuracy of identifying the tampered layer and the background layer of the tampered image and the accuracy of extracting the attribute information of the tampered layer and the background layer are improved.

[0056] In order to further improve the diversity of the acquired tampering layers and background layers, it is necessary to determine whether the background layer needs to be replaced; accordingly, as an example, step 203 includes:

[0057] Generate random numbers;

[0058] If the random number is not greater than the preset threshold, the background layer of the second tampered image and the first tampered layer are used as the background layer and the tampered layer to be merged.

[0059] Specifically, a random number is generated; the random number is compared with a preset threshold. It should be noted that this example does not specifically limit the method of generating random numbers; illustratively, a random function can be used to generate random numbers. If the generated random number is not greater than the preset threshold, then there is no need to replace the background layer, and the background layer of the second tampered image and the first tampered layer are used as the background layer and tampered layer to be merged. In this example, by generating a random number, it is determined whether the background layer needs to be replaced before generating training data, thereby improving the diversity and accuracy of the generated training data.

[0060] Furthermore, the method further comprises:

[0061] If the random number is greater than the preset threshold, the attribute information of the background layer of the untampered image is obtained;

[0062] The background layer of the untampered image and the first tampered layer are used as the background layer and tampered layer to be merged.

[0063] Specifically, if the generated random number is greater than a preset threshold, the attribute information of the background layer of an untampered image is obtained. Exemplarily, the untampered image is any original image that has not been tampered with. In actual applications, a file corresponding to an untampered original image can be loaded, and this file is a complete original file; the obtained untampered image is parsed to obtain the attribute information of the corresponding background layer. Afterwards, the background layer of the untampered image and the first tampered layer obtained above are used as the background layer and tampered layer to be merged. Subsequently, if the background layer of the untampered image is used as the background layer to be merged, when adjusting the tampered layer, it is necessary to adjust it based on the background layer of the untampered image. For example, the adjusted size cannot exceed the size range of the background layer of the untampered image; when the tampered layer is rotated or scaled, it cannot exceed the background layer of the untampered image. As an example, when the background layer of the untampered image is used as the background layer to be merged, the position coordinates of the tampered layer can be initialized on the background layer of the untampered image; specifically, if the coordinates of the tampered layer equivalent to the position of the background layer of the tampered image are expressed as (x, y), then the position of the tampered layer relative to the background layer of the untampered image is also adjusted to the coordinate expression (x, y); and then the tampered layer and the background layer are superimposed. In this example, by comparing the random number with the preset threshold; when the random number is greater than the preset threshold, the background layer of the tampered image is replaced with the background layer of the untampered image, so that the subsequently generated training data is more diverse, and the accuracy of the generated training data is further improved.

[0064] Furthermore, it is necessary to merge the determined background layer and the tampered layer to obtain a new tampered image, and use the new tampered image as training data; accordingly, as an example, the background layer and the tampered layer are merged, specifically including:

[0065] Merge the pixel values ​​of the background layer and the tampered layer.

[0066] Specifically, after determining the background layer and the tampered layer to be merged, the pixel values ​​of the background layer and the background layer are merged to obtain a new tampered image. This new tampered image is added to the training data for subsequent training of the tampering detection model. In this example, by merging the pixel values ​​of the tampered layer and the background layer to obtain a new tampered image, and using this new tampered image as training data, the accuracy of the generated training data is improved.

[0067] Furthermore, after generating the training data, it is necessary to generate corresponding labels for the training data so as to subsequently train the model; accordingly, as an example, the method further includes:

[0068] Generate mask labels for training data.

[0069] Generate mask labels for training data, including:

[0070] For the tampered image in the training data, create an image; the size of the image is the same as the size of the background layer of the tampered image; the initial pixel values ​​of the image are all the first value;

[0071] The pixel value of the superimposed area in the image is set to the second value to obtain the mask label of the training data; the superimposed area represents the overlapping area of ​​the tampered layer and the background layer.

[0072] Specifically, training data labels are generated to enable subsequent training data to accurately train the corresponding tampering detection model. For the tampered image in the training data, an image with the same dimensions as the background layer of the tampered image is first created, with the initial pixel values ​​of this image all being the first value. Next, the pixel values ​​of the overlay region in the created image are set to the second value. The resulting image is the mask image, which serves as the mask label for the tampered image in the training data. The overlay region is the overlap between the tampered and background layers. For example, the pixel values ​​of the initial image can be set to 0, resulting in a black image. The pixel values ​​of the overlay region of the tampered and background layers are then set to 255, resulting in a white overlap. In practical applications, generating mask labels for training images can clearly indicate which image regions the model should focus on or ignore. This helps the model learn key features more quickly during training, thereby improving training efficiency. Mask labels contain rich information, such as the location, shape, and size of the target object. This helps the model learn a more comprehensive feature representation during training, thereby enhancing the model's generalization ability and enabling accurate object detection in diverse scenarios. Mask labels precisely identify the location of target objects within an image, helping the model more accurately learn the characteristics of the target object during training. By using a large amount of training data with mask labels, the model can gradually improve its recognition accuracy. Generating mask labels for training images makes data management and use more convenient. Label information can be stored in a structured manner, facilitating subsequent data processing and analysis.

[0073] Furthermore, after the background layer and the tampered layer are combined to generate training data, the training data can be compressed to obtain data of different qualities for better model training. Accordingly, as an example, the method further includes:

[0074] Determine the quality range of training data;

[0075] The training data is compressed within a quality range to obtain enhanced training data.

[0076] Specifically, after generating the training data, the tampered images can be compressed according to a certain quality range to obtain enhanced training data. First, the quality range of the training data is determined. Then, the training data is compressed according to random qualities within the determined quality range to obtain enhanced training data. In this example, the training data is compressed according to the determined quality range to obtain training data of different image qualities. This allows the training data to cover more real-world scenes and lower-quality images compressed by social software, further increasing the accuracy and diversity of the training data.

[0077] In one example, when a tampered image is determined in the tampered image set, and the tampered layer of the tampered image is adjusted to obtain a variety of tampered layers, when generating training data, it can be performed according to Figure 4 The process shown is carried out. Figure 4 This is a flow chart of a training data generation method according to an example of the present application; Figure 4 As shown, first, a tampered image is parsed to obtain the attribute information of each layer, the background layer and the tampered layer are identified and determined, and the attribute information of the tampered layer and the tampered layer is extracted; a random number is generated and compared with a preset threshold. If the random number exceeds the preset threshold, any untampered image is parsed to obtain the background layer of the untampered image; at this time, the background layer of the untampered image is selected as the new background layer; the tampered layer of the tampered image is then adjusted to obtain a new tampered layer, the new tampered layer and the background layer of the untampered image are merged to obtain a new tampered image, and the new tampered image is added to the training data; the training data is then masked and labeled. If the random number does not exceed the preset threshold, the adjusted new tampered layer and the background layer of the tampered image are merged to obtain a new tampered image, and the new tampered image is added to the training data; and the data labels of the training data are generated.

[0078] Figure 5 A schematic diagram of generating training data and training data labels for an example of this application; Figure 5 As shown, the upper left corner shows the first untampered image of any example, and the tampered image is obtained after tampering; the upper right corner is the second untampered image of any example; the tampered layer of the tampered image is adjusted to obtain a new tampered layer, and then the new tampered layer and the background layer of the second untampered image are merged by pixel values ​​to obtain a new tampered image in the lower left corner, and the new tampered image is the training data; the lower right corner is the mask label of the corresponding training data.

[0079] The training data generation method provided by this embodiment obtains an initial tampered image set; extracts attribute information of the background layer and the tampered layer of the tampered image set based on the tampered image set; selects the background layer and the tampered layer to be merged based on the attribute information of the background layer and the tampered layer of the tampered image set; merges the selected background layer and the tampered layer, and adds the merged new tampered image as a training image to the training data; the solution of the present application improves the accuracy of training data generation by merging the tampered layer and the background layer to obtain a new tampered image, and then using the obtained new tampered image as training data.

[0080] Example 2

[0081] The following is a specific example to illustrate the specific application of using this solution in the aforementioned example to adjust the tampered layer of the tampered image to obtain a new tampered layer and merge it with the corresponding background layer to be merged to generate training data.

[0082] Step 1: For example, using a document of tampered images, load the image file PSD1 to be processed, extract the background layer name Layer.name = 'background', that is, the background layer (Layer_background1), extract the layer type Layer.kind = 'type'; extract the tampered layer name Layer.name = 'tamper', that is, the tampered layer (Layer_tamper1); obtain the size of the background layer: B_W1×B_H1; obtain the tampered layer size T_W1×T_H1, the position of the tampered layer in the background layer Layer.position: (x1, y1), the text content Layer.text: "xxx", the font Layer.font: "Simsun", the font size Layer.fontsize: 100, the rotation angle Layer.rotate: 0, and the color Lyaer.color: (100, 100, 100);

[0083] Step 2: Use the random function to generate a random number rand_num = random.randint (0, 100). Set it to jump to step 3 to replace the background layer when the random number exceeds the threshold T = 50, otherwise jump to step 5;

[0084] Step 3: Load a PSD file (PSD2) corresponding to an unmodified image, extract the layer name Layer.name = "background", which is the background layer (Layer_background2), and obtain the size of the background layer: B_W2×B_H2;

[0085] Step 4: Get Layer_background2 from step 3 as the new background layer, initialize the coordinates of the tampered layer, for example, set the coordinates of the upper left corner of the tampered layer relative to the background layer to (0, 0), superimpose the tampered layer Layer_tamper1 on the Layer_background2 layer, and update the position attribute of the tampered layer to (0, 0);

[0086] Step 5: Make the following adjustments to the tampered layer Layer_tamper1 and update the adjusted attribute values ​​to the corresponding attributes of Layer_tamper1 to increase the diversity of the final synthetic training data:

[0087] Optional operation 1: Update the position of the Layer_tamper1 layer to ensure that it is within the background size range. Set x2 = random.randint(0, B_W2-1), y2 = random.randint(0, B_H2-1), move the layer to the new coordinate position (x2, y2), and update the current layer's position coordinate properties Layer.position = (x2, y2);

[0088] Optional operation 2: Adjust the size of the Layer_tamper1 layer to determine the new width and height T_W2 × T_H2, scale the tamper layer to the new size, and update the width and height properties of the current layer Layer.size = (T_W2, T_H2);

[0089] Optional operation 3: Adjust the rotation angle of the Layer_tamper1 layer. Rotate the Layer_tamper1 layer around the layer center at a fixed angle θ, and update the layer's rotation angle property, Layer.rotate = θ.

[0090] Optional operation 4: Randomly select a text from the text list to change the text content and update the corresponding layer properties, Layer.text = random.choice(text_list);

[0091] Optional operation 5: Randomly select a font from the font list to change the text font and update the corresponding layer properties, Layer.font = random.choice(font_list);

[0092] Optional operation 6: Change the text font size and update the corresponding layer properties, Layer.fontsize = random.randint(50,200);

[0093] Optional operation 7: Change the text color and update the corresponding layer properties, Layer.color = (random.randint(0,255),random.randint(0,255),random.randint(0,255));

[0094] Step 6: Merge the pixel values ​​of the background layer and the tampered layer to generate a new image and save it in uncompressed PNG format as the initial data for training; generate labels for the corresponding training data: create a blank image of the same size as the background layer, with all initial pixel values ​​set to 0. On this blank image, assign the pixel values ​​of the corresponding areas of the tampered layer that fall within the size range of the background layer to 255, generate training data labels, and save them;

[0095] Step 7: By looping steps 1-6, a small amount of tampered image files can be used to generate a large amount of diverse and accurate training data, and automatically generate labels; after the generated initial training data and the corresponding mask label set are prepared, when training the tampering detection model, every two training cycles, the training images are adjusted based on the initial training set (uncompressed PNG images), and the initial training data is compressed according to the random quality q within a certain image quality range q = random.randint(60, 100) and saved in JPEG format for data enhancement to obtain enhanced training data.

[0096] Example 3

[0097] Figure 6 A schematic diagram of the structure of a training data generating device is shown as an example. Figure 6 As shown, the device includes:

[0098] An acquisition module 21 is used to acquire a set of tampered images;

[0099] An extraction module 22 is used to extract attribute information of a background layer and a tampered layer of the tampered image set based on the tampered image set;

[0100] A selection module 23 is used to select the background layer and the tampered layer to be merged according to the attribute information of the background layer and the tampered layer of the tampered image set;

[0101] The processing module 24 is configured to merge the background layer and the tampered layer, and add the merged first tampered image to the training data.

[0102] Specifically, a tampered image set is first obtained; the tampered image set represents an initial set of images that have been tampered with but not tampered with again. Based on the obtained tampered image set, attribute information of the background layer and tampered layer of the tampered image set is extracted; based on the extracted attribute information of the background layer and tampered layer of the tampered image set, the background layer and tampered layer to be merged are selected. Specifically, the background layer and tampered layer of each tampered image in the tampered image set are extracted; illustratively, a document of the tampered image can be loaded to extract attribute information of each layer of the tampered image; wherein the attribute information of the image represents the basic features and structure of the image on the corresponding layer, such as the size of the layer, the layer type, etc.; based on the extracted attribute information, the background layer and tampered layer of the tampered image set are identified and confirmed. Based on the attribute information of the background layer and tampered layer of the tampered image set, the background layer and tampered layer to be merged are selected. Thereafter, the background layer and tampered layer are merged to obtain a new first tampered image, and the merged first tampered image is added to the training data. In this example, the background layer and the tampered layer to be merged are determined from the initial set of tampered images to be processed; the background layer and the tampered layer to be merged are merged to obtain a first tampered image, and the first tampered image is added to the training data; the accuracy of the generated training data and the diversity of the training data are improved.

[0103] Furthermore, to generate accurate and diverse training data, it is necessary to improve the diversity of the background layer and the tampering layer; accordingly, as an example, the selection module 23 is used to:

[0104] The background layers with different attribute information and the tampered layers with different attribute information are combined to determine the background layers and tampered layers to be merged.

[0105] Specifically, for each tampered image in the tampered image set, the attribute information of the background layer and the tampered layer can be extracted first; then, based on the attribute information of each layer of each image extracted, the background layers corresponding to different attribute information and the tampered layers corresponding to different attribute information are combined to determine the background layers and tampered layers to be merged. Subsequently, multiple groups of determined background layers and tampered layers to be merged are merged to obtain a large amount of diverse and rich training data. In this example, by combining background layers with different attribute information and tampered layers with different attribute information, the tampered layers and background layers to be merged are determined, thereby improving the diversity of the background layers and tampered layers.

[0106] Furthermore, a new tampered layer can be obtained by changing the attribute information of the tampered layer; the selection module 23 is further used to:

[0107] Obtaining attribute information of the background layer and the tampered layer of the second tampered image;

[0108] Based on the attribute information of the background layer of the second tampered image, the first tampered layer is obtained by adjusting the attribute information of the tampered layer of the second tampered image;

[0109] The background layer of the second tampered image and the first tampered layer are used as the background layer and the tampered layer to be merged.

[0110] Specifically, the tampered layer and background layer to be merged are selected, and any second tampered image can also be selected from the set of tampered images to be processed; then, the attribute information of the background layer and the tampered layer of the second tampered image is obtained; based on the attribute information of the background layer of the second image obtained, the attribute information of the tampered layer of the second tampered image is adjusted to obtain the tampered first tampered layer; exemplarily, the attribute information includes: the size information (width and height) of the layer; the position information of the layer, wherein the position information of the background layer can represent the position information of the background layer in the image, and the attribute information of the tampered layer can represent the position information of the tampered layer relative to the background layer; exemplarily, the position of the layer can be represented by the coordinates of the upper left corner of the layer; in actual application, when the coordinates of any point of the layer and the size of the layer are known, the position information of the layer can be determined. This example does not specifically limit the representation method of the layer position information. Furthermore, the attribute information of the layer also includes the layer type, image pixel data, etc. When it comes to text-type layers, the attribute information of the layer also includes: text content, font, font size, rotation angle, color, etc.

[0111] Specifically, the attribute information of the tampered layer of the second tampered image is adjusted. Any adjustments can be made to the aforementioned attribute information of the tampered layer, but adjustments must be made based on the background layer. As an example, the position of the tampered layer is updated: within the size range of the background layer, the tampered layer is moved to a new coordinate position, and the position coordinate attributes of the tampered layer are updated. As another example, within the size range of the background layer, the size of the tampered layer is adjusted: first, the new width and height of the tampered layer are determined, the tampered layer is enlarged or reduced at a fixed or random ratio, and the width and height attribute information of the current tampered layer is updated to obtain a new tampered layer. As yet another example, within the size range of the background layer, the rotation angle of the tampered layer is adjusted: the tampered layer is rotated around the center of the tampered layer at a fixed or random angle to obtain an updated tampered layer. It should be noted that during the rotation process, the tampered layer must not exceed the size range of the background layer. When the tampered layer contains text, the text content, font, size, and color can be randomly changed, and the attribute information of the adjusted layer is updated. Furthermore, the principle of adjustment must ensure that the tampered layer does not exceed the size range of the background layer. The aforementioned adjustments can be made individually or simultaneously. The resulting tampered layer is the first tampered layer. The background layer of the second tampered image and the first tampered layer are used as the background layer and tampered layer to be merged. In this example, by adjusting the attribute information of the tampered layer to obtain a new first tampered layer, the first tampered layer and the background layer of the second tampered image are used as the tampered layer and background layer to be merged, thereby increasing the diversity of the tampered layers. Subsequently, training data is generated based on the highly diverse tampered layers, thereby increasing the diversity and accuracy of the generated training data.

[0112] Furthermore, it is necessary to accurately obtain the attribute information of the background layer and the attribute information of the tampered layer; accordingly, as an example, the selection module 23 is further used to:

[0113] parsing the second tampered image to obtain attribute information of each layer in the second tampered image;

[0114] determining a background layer and a tampered layer of the second tampered image according to attribute information of each layer in the second tampered image;

[0115] Attribute information of the background layer and the tampered layer of the second tampered image is extracted.

[0116] Specifically, the second tampered image is parsed to obtain attribute information of each layer of the second tampered image; based on the attribute information of each layer obtained from the parsing, the background layer and the tampered layer of the second tampered layer are identified and determined; accordingly, the attribute information of the background layer and the tampered layer of the second tampered image is extracted from the attribute information of each layer obtained from the parsing. In this example, by parsing the second tampered image, obtaining the attribute information of each layer of the tampered image, identifying the tampered layer and the background layer, and extracting the attribute information of the tampered layer and the background layer, the accuracy of identifying the tampered layer and the background layer of the tampered image and the accuracy of extracting the attribute information of the tampered layer and the background layer are improved.

[0117] In order to further improve the diversity of the acquired tampering layers and background layers, it is necessary to determine whether the background layer needs to be replaced; accordingly, as an example, the selection module 23 is further used to:

[0118] Generate random numbers;

[0119] If the random number is not greater than the preset threshold, the background layer of the second tampered image and the first tampered layer are used as the background layer and the tampered layer to be merged.

[0120] Specifically, a random number is generated; the random number is compared with a preset threshold. It should be noted that this example does not specifically limit the method of generating random numbers; illustratively, a random function can be used to generate random numbers. If the generated random number is not greater than the preset threshold, then there is no need to replace the background layer, and the background layer of the second tampered image and the first tampered layer are used as the background layer and tampered layer to be merged. In this example, by generating a random number, it is determined whether the background layer needs to be replaced before generating training data, thereby improving the diversity and accuracy of the generated training data.

[0121] Furthermore, if the random number is greater than a preset threshold, the attribute information of the background layer of the untampered image is obtained;

[0122] The background layer of the untampered image and the first tampered layer are used as the background layer and tampered layer to be merged.

[0123] Specifically, if the generated random number is greater than a preset threshold, the attribute information of the background layer of an untampered image is obtained. Exemplarily, the untampered image is any original image that has not been tampered with. In actual applications, a file corresponding to an untampered original image can be loaded, and this file is a complete original file; the obtained untampered image is parsed to obtain the attribute information of the corresponding background layer. Afterwards, the background layer of the untampered image and the first tampered layer obtained above are used as the background layer and tampered layer to be merged. Subsequently, if the background layer of the untampered image is used as the background layer to be merged, when adjusting the tampered layer, it is necessary to adjust it based on the background layer of the untampered image. For example, the adjusted size cannot exceed the size range of the background layer of the untampered image; when the tampered layer is rotated or scaled, it cannot exceed the background layer of the untampered image. As an example, when the background layer of the untampered image is used as the background layer to be merged, the position coordinates of the tampered layer can be initialized on the background layer of the untampered image; specifically, if the coordinates of the tampered layer equivalent to the position of the background layer of the tampered image are expressed as (x, y), then the position of the tampered layer relative to the background layer of the untampered image is also adjusted to the coordinate expression (x, y); and then the tampered layer and the background layer are superimposed. In this example, by comparing the random number with the preset threshold; when the random number is greater than the preset threshold, the background layer of the tampered image is replaced with the background layer of the untampered image, so that the subsequently generated training data is more diverse, and the accuracy of the generated training data is further improved.

[0124] Furthermore, it is necessary to merge the determined background layer and the tampered layer to obtain a new tampered image, and use the new tampered image as training data; accordingly, as an example, the background layer and the tampered layer are merged, specifically including:

[0125] Merge the pixel values ​​of the background layer and the tampered layer.

[0126] Specifically, after determining the background layer and the tampered layer to be merged, the pixel values ​​of the background layer and the background layer are merged to obtain a new tampered image. This new tampered image is added to the training data for subsequent training of the tampering detection model. In this example, by merging the pixel values ​​of the tampered layer and the background layer to obtain a new tampered image, and using this new tampered image as training data, the accuracy of the generated training data is improved.

[0127] Furthermore, after generating the training data, it is necessary to generate corresponding labels for the training data so as to subsequently train the model. Accordingly, as an example, the apparatus further includes a generating module 25, which is used to:

[0128] Generate mask labels for training data.

[0129] Generate mask labels for training data, including:

[0130] For the tampered image in the training data, create an image; the size of the image is the same as the size of the background layer of the tampered image; the initial pixel values ​​of the image are all the first value;

[0131] The pixel value of the superimposed area in the image is set to the second value to obtain the mask label of the training data; the superimposed area represents the overlapping area of ​​the tampered layer and the background layer.

[0132] Specifically, training data labels are generated to enable subsequent training data to accurately train the corresponding tampering detection model. For the tampered image in the training data, an image with the same dimensions as the background layer of the tampered image is first created, with the initial pixel values ​​of this image all being the first value. Next, the pixel values ​​of the overlay region in the created image are set to the second value. The resulting image is the mask image, which serves as the mask label for the tampered image in the training data. The overlay region is the overlap between the tampered and background layers. For example, the pixel values ​​of the initial image can be set to 0, resulting in a black image. The pixel values ​​of the overlay region of the tampered and background layers are then set to 255, resulting in a white overlap. In practical applications, generating mask labels for training images can clearly indicate which image regions the model should focus on or ignore. This helps the model learn key features more quickly during training, thereby improving training efficiency. Mask labels contain rich information, such as the location, shape, and size of the target object. This helps the model learn a more comprehensive feature representation during training, thereby enhancing the model's generalization ability and enabling accurate object detection in diverse scenarios. Mask labels precisely identify the location of target objects within an image, helping the model more accurately learn the characteristics of the target object during training. By using a large amount of training data with mask labels, the model can gradually improve its recognition accuracy. Generating mask labels for training images makes data management and use more convenient. Label information can be stored in a structured manner, facilitating subsequent data processing and analysis.

[0133] Furthermore, after the background layer and the tampered layer are combined to generate training data, the training data can also be compressed to obtain data of different qualities for better training the model. Accordingly, as an example, the device further includes an enhancement module 25, which is further configured to:

[0134] Determine the quality range of training data;

[0135] The training data is compressed within a quality range to obtain enhanced training data.

[0136] Specifically, after generating the training data, the tampered images can be compressed according to a certain quality range to obtain enhanced training data. First, the quality range of the training data is determined. Then, the training data is compressed according to random qualities within the determined quality range to obtain enhanced training data. In this example, the training data is compressed according to the determined quality range to obtain training data of different image qualities. This allows the training data to cover more real-world scenes and lower-quality images compressed by social software, further increasing the accuracy and diversity of the training data.

[0137] The training data generation device provided by this embodiment obtains an initial tampered image set; extracts attribute information of the background layer and the tampered layer of the tampered image set based on the tampered image set; selects the background layer and the tampered layer to be merged based on the attribute information of the background layer and the tampered layer of the tampered image set; merges the selected background layer and the tampered layer, and adds the merged new tampered image as a training image to the training data; the solution of the present application improves the accuracy of training data generation by merging the tampered layer and the background layer to obtain a new tampered image, and then using the obtained new tampered image as training data.

[0138] Example 4

[0139] Figure 7 exemplarily shows a structural diagram of an electronic device, the device comprising:

[0140] The device includes a processor 291 and a memory 292; a communication interface 293, and a bus 294. The processor 291, memory 292, and communication interface 293 can communicate with each other via bus 294. Communication interface 293 can be used for information transmission. Processor 291 can invoke logic instructions in memory 292 to execute the method described above.

[0141] In addition, the logic instructions in the memory 292 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product.

[0142] Memory 292, as a computer-readable storage medium, can be used to store software programs and computer-executable programs, such as program instructions / modules corresponding to the methods in the embodiments of the present application. Processor 291 executes the software programs, instructions, and modules stored in memory 292 to execute functional applications and data processing, thereby implementing the methods in the above-mentioned method examples.

[0143] Memory 292 may include a program storage area and a data storage area. The program storage area may store an operating system and at least one application required for a function; the data storage area may store data generated based on the use of the terminal device. Memory 292 may also include high-speed random access memory and non-volatile memory.

[0144] An embodiment of the present application further provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the method in any embodiment.

[0145] An embodiment of the present application further provides a computer program product, including a computer program, which is used to implement the method in any embodiment when executed by a processor.

[0146] It should be noted that for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all optional embodiments, and the actions and modules involved are not necessarily required by this application.

[0147] It should be further noted that, although the various steps in the flowchart are shown in sequence as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps may be executed in other orders. Moreover, at least a portion of the steps in the flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed in the same time period, but may be executed in different time periods. The execution order of these sub-steps or stages is not necessarily sequential, but may be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.

[0148] It should be understood that the above-described device embodiments are merely illustrative, and the device of the present application may also be implemented in other ways. For example, the division of units / modules in the above-described embodiments is merely a logical functional division, and actual implementations may employ other division methods. For example, multiple units, modules, or components may be combined or integrated into another system, or some features may be omitted or not implemented.

[0149] In addition, unless otherwise specified, the functional units / modules in the various embodiments of the present application may be integrated into a single unit / module, each unit / module may exist physically separately, or two or more units / modules may be integrated together. The aforementioned integrated units / modules may be implemented in the form of hardware or software program modules.

[0150] If the integrated unit / module is implemented in hardware, the hardware may be digital circuits, analog circuits, etc. The physical implementation of the hardware structure includes, but is not limited to, transistors, memristors, etc. Unless otherwise specified, the processor may be any appropriate hardware processor, such as a CPU, GPU, FPGA, DSP, and ASIC. Unless otherwise specified, the storage unit may be any appropriate magnetic storage medium or magneto-optical storage medium, such as resistive random access memory (RRAM), dynamic random access memory (DRAM), static random access memory (SRAM), enhanced dynamic random access memory (EDRAM), high-bandwidth memory (HBM), hybrid memory cube (HMC), etc.

[0151] If the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a memory and includes a number of instructions for enabling a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned memory includes various media that can store program codes, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.

[0152] In the above embodiments, the description of each embodiment has its own emphasis. For parts not described in detail in a particular embodiment, please refer to the relevant description of other embodiments. The technical features of the above embodiments can be combined in any way. To keep the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0153] Those skilled in the art will readily appreciate other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present invention that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only.

[0154] It will be understood that the present application is not limited to the exact construction that has been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof.

[0155] Finally, it should be noted that other embodiments of the present invention will readily occur to those skilled in the art after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses, or adaptations of the present invention that follow the general principles of the present invention and include common knowledge or customary techniques in the art not disclosed herein, and is not limited to the precise structure described above and shown in the drawings. Various modifications and variations may be made without departing from the scope of the present invention.

Claims

1. A training data generation method, characterized in that: include: Obtaining a set of tampered images; Extracting attribute information of a background layer and a tampered layer of the tampered image set according to the tampered image set; Selecting the background layer and the tampered layer to be merged according to the attribute information of the background layer and the tampered layer of the tampered image set; The background layer and the tampered layer are merged, and a first tampered image obtained by merging is added to the training data.

2. The method according to claim 1, characterized in that The step of selecting the background layer and the tampered layer to be merged according to the attribute information of the background layer and the tampered layer of the tampered image set includes: The background layer with different attribute information and the tampered layer with different attribute information are combined to determine the background layer and the tampered layer to be merged.

3. The method according to claim 1, characterized in that The tampered image set includes a second tampered image; and selecting the background layer and the tampered layer to be merged according to the attribute information of the background layer and the tampered layer of the tampered image set further includes: Obtaining attribute information of the background layer and the tampered layer of the second tampered image; obtaining a first tampered layer by adjusting the attribute information of the tampered layer of the second tampered image based on the attribute information of the background layer of the second tampered image; The background layer of the second tampered image and the first tampered layer are used as the background layer and tampered layer to be merged.

4. The method according to claim 3, characterized in that The acquiring of attribute information of the background layer and the tampered layer of the second tampered image includes: parsing the second tampered image to obtain attribute information of each layer in the second tampered image; determining a background layer and a tampered layer of the second tampered image according to attribute information of each layer in the second tampered image; Attribute information of the background layer and the tampered layer of the second tampered image is extracted.

5. The method according to claim 3, characterized in that The step of using the background layer of the second tampered image and the first tampered layer as the background layer and the tampered layer to be merged includes: Generate random numbers; If the random number is not greater than a preset threshold, the background layer of the second tampered image and the first tampered layer are used as the background layer and the tampered layer to be merged.

6. The method according to claim 5, characterized in that The method further comprises: If the random number is greater than a preset threshold, obtaining attribute information of the background layer of the untampered image; The background layer of the untampered image and the first tampered layer are used as the background layer and tampered layer to be merged.

7. The method according to any one of claims 1 to 6, characterized in that The merging of the background layer and the tampered layer specifically includes: Merge the pixel values ​​of the background layer and the tampered layer.

8. The method according to any one of claims 1 to 6, characterized in that The method further comprises: generating mask labels for the training data; Generating the mask label of the training data includes: For the tampered image in the training data, create an image; the size of the image is the same as the size of the background layer of the tampered image; and the initial pixel values ​​of the image are all the first value; The pixel value of the superimposed area in the image is set to a second value to obtain a mask label of the training data; the superimposed area represents the overlapping area of ​​the tampered layer and the background layer.

9. The method according to any one of claims 1 to 6, characterized in that The method further comprises: determining a quality interval of the training data; The training data is subjected to image compression within the quality range to obtain enhanced training data.

10. A training data generating device, characterized in that: include: An acquisition module, used to acquire a set of tampered images; An extraction module, configured to extract attribute information of a background layer and a tampered layer of the tampered image set based on the tampered image set; A selection module, configured to select a background layer and a tampered layer to be merged according to attribute information of the background layer and the tampered layer of the tampered image set; The processing module is used to merge the background layer and the tampered layer, and add the merged first tampered image to the training data.