Training method of image detection model, image detection method and related device
Through self-supervised and fully-supervised image detection models, the problem of inaccurate image tamper detection in the prior art is solved, the accuracy and efficiency of image detection are improved, and business security is ensured.
Patent Information
- Application Number
- CN202411716944.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-03-18
AI Technical Summary
The prior art lacks effective image tamper detection methods, which leads to the tampered images that may pass audits and reduce business security.
A training method for image detection model is provided, by obtaining pre-trained data sets for self-supervised training, and then using the training data set for full-supervised training, to construct an image detection model to identify tampered images.
It improves the recognition accuracy of tampered images, enhances the training efficiency and detection capabilities of the image detection model, and ensures the authenticity of the image and the reliability of the audit.
Smart Images

Figure CN119649200A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and specifically to a training method for an image detection model, an image detection method, and related devices. Background Art
[0002] With the rapid development of image processing technology, image processing tools can be used to modify images in various forms. Malicious modification of information included in an image can be called image tampering. In some scenarios, the authenticity of the image needs to be guaranteed. For example, in scenarios where images need to be used as proof. For example, in banking business, it is necessary to take photos of employees and customers to generate images including employees and customers to prove that the employees provide business services to customers. In the bank's review system, images of employees and customers are reviewed to determine the matching and authenticity of the images to avoid image tampering and false business processing.
[0003] Currently, there is a lack of effective detection methods for image tampering, which makes it easy for tampered images to pass the review, reducing business security. Summary of the invention
[0004] In view of this, the present application provides an image detection model training method, an image detection method and related devices, which can improve the accuracy of identifying tampered images.
[0005] The technical solutions provided by this application are as follows:
[0006] In a first aspect, the present application provides a method for training an image detection model, the method comprising:
[0007] Acquire a pre-training data set, wherein the pre-training data set includes a first training image, and the first training image includes a first original image and a first tampered image;
[0008] Using the pre-training data set, training a pre-training model, wherein the pre-training model includes an encoding network and a prediction network;
[0009] Acquire a training data set, the training data set comprising a second training image and an image label, the second training image comprising a second original image and a second tampered image, the image label comprising a first label and a second label, the first label being used to label the second original image, and the second label being used to label the second tampered image;
[0010] Inputting the second training image into an image detection model to obtain a prediction result output by the image detection model, wherein the image detection model is composed of the encoding network, and the prediction result is used to indicate whether the second training image is a tampered image;
[0011] Based on the prediction result and the image label, the model parameters of the image detection model are adjusted to obtain a trained image detection model.
[0012] In a possible implementation, the pre-trained model includes a first encoding network, a second encoding network, a first prediction network, and a second prediction network;
[0013] The method of training the pre-training model by using the pre-training data set includes:
[0014] Using different random data enhancement methods on the first training image to obtain a first enhanced image and a second enhanced image;
[0015] Inputting the first enhanced image into the first encoding network to obtain a first feature vector output by the first encoding network, and inputting the first feature into the first prediction network to obtain a first output vector output by the first prediction network;
[0016] Inputting the second enhanced image into the second encoding network to obtain a second feature vector output by the second encoding network, and inputting the second feature into the second prediction network to obtain a second output vector output by the second prediction network;
[0017] Determine a loss value of the pre-trained model using the first feature vector, the second feature vector, the first output vector, and the second output vector;
[0018] The model parameters of the pre-trained model are adjusted according to the loss value.
[0019] In a possible implementation, the method further includes:
[0020] Perform image enhancement processing on the second training image included in the training data set.
[0021] In a second aspect, the present application provides an image detection method, the method comprising:
[0022] Obtain an image to be recognized;
[0023] The image to be identified is input into an image detection model to obtain a detection result output by the image detection model, wherein the detection result is used to indicate whether the image to be identified is a tampered image. The image detection model is trained using the image detection model training method described in any embodiment of the first aspect above.
[0024] In a third aspect, the present application provides a training device for an image detection model, the device comprising:
[0025] A first acquisition unit, configured to acquire a pre-training data set, wherein the pre-training data set includes a first training image, and the first training image includes a first original image and a first tampered image;
[0026] A first training unit is used to train a pre-training model using the pre-training data set, wherein the pre-training model includes an encoding network and a prediction network;
[0027] A second acquisition unit is used to acquire a training data set, the training data set includes a second training image and an image label, the second training image includes a second original image and a second tampered image, the image label includes a first label and a second label, the first label is used to mark the second original image, and the second label is used to mark the second tampered image;
[0028] a second training unit, configured to input the second training image into an image detection model to obtain a prediction result output by the image detection model, wherein the image detection model is composed of the encoding network, and the prediction result is used to indicate whether the second training image is a tampered image;
[0029] The third training unit is used to adjust the model parameters of the image detection model based on the prediction result and the image label to obtain a trained image detection model.
[0030] In a possible implementation, the pre-trained model includes a first encoding network, a second encoding network, a first prediction network, and a second prediction network;
[0031] The first training unit is used to:
[0032] Using different random data enhancement devices on the first training image to obtain a first enhanced image and a second enhanced image;
[0033] Inputting the first enhanced image into the first encoding network to obtain a first feature vector output by the first encoding network, and inputting the first feature into the first prediction network to obtain a first output vector output by the first prediction network;
[0034] Inputting the second enhanced image into the second encoding network to obtain a second feature vector output by the second encoding network, and inputting the second feature into the second prediction network to obtain a second output vector output by the second prediction network;
[0035] Determine a loss value of the pre-trained model using the first feature vector, the second feature vector, the first output vector, and the second output vector;
[0036] The model parameters of the pre-trained model are adjusted according to the loss value.
[0037] In a possible implementation manner, the first training unit is further configured to perform image enhancement processing on a second training image included in the training data set.
[0038] In a fourth aspect, the present application provides an image detection device, the device comprising:
[0039] A first acquisition unit, used to acquire an image to be recognized;
[0040] An identification unit is used to input the image to be identified into an image detection model to obtain a detection result output by the image detection model, wherein the detection result is used to indicate whether the image to be identified is a tampered image, and the image detection model is trained using the image detection model training method described in any implementation method of the first aspect above.
[0041] In a fifth aspect, the present application provides a device, including: a processor, a memory, and a system bus;
[0042] The processor and the memory are connected via the system bus;
[0043] The memory is used to store one or more programs, and the one or more programs include instructions. When the instructions are executed by the processor, the processor executes the method described in any implementation of the first aspect, or executes the method described in the second aspect.
[0044] In a sixth aspect, the present application provides a computer-readable storage medium, wherein instructions are stored in the computer-readable storage medium. When the instructions are executed on a terminal device, the terminal device executes the method described in any implementation manner of the first aspect, or executes the method described in the second aspect.
[0045] It can be seen that this application has the following beneficial effects:
[0046] The present application provides a training method for an image detection model and an image detection method, first obtaining a pre-training data set including a first training image, using the pre-training data set to perform self-supervisory training on the pre-training model, and then obtaining a training data set, the training data set including a second training image and an image label, and using the training data set to perform full-supervisory training on the image detection model. The image detection model is composed of an encoding network included in the pre-training model. Before training, the transferable features of the first training image are learned using self-supervised training, which effectively improves the training efficiency of the image detection model. The trained image detection model has a high ability to detect tampered images. The accuracy of detecting tampered images using the trained image detection model is high. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1A flowchart of a method for training an image detection model provided in an embodiment of the present application;
[0048] Figure 2 A schematic diagram of a scenario of model training and model application provided in an embodiment of the present application;
[0049] Figure 3 A schematic diagram of the structure of the pre-training model provided in the embodiment of the present application;
[0050] Figure 4 A schematic diagram of the structure of the image detection model provided in the embodiment of the present application;
[0051] Figure 5 A schematic diagram of a flow chart of an image detection method provided in an embodiment of the present application;
[0052] Figure 6 A schematic diagram of the structure of a training device for an image detection model provided in an embodiment of the present application;
[0053] Figure 7 A schematic diagram of the structure of an image detection device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0054] In order to facilitate the understanding and explanation of the technical solutions provided by the embodiments of the present application, the background technology of the present application will be described below.
[0055] As an important carrier of information, images can convey rich information in a short time with their intuitive and vivid characteristics. With the continuous development of image processing technology, the threshold and cost of image processing are gradually reduced. Image processing technology refers to the technology of making some form of changes to the original image. Image processing technology can include but is not limited to operations such as copying, moving, splicing and repairing. However, in some cases involving the processing of important information in the image, the image may contain false information, affecting the acquisition of normal information. This type of image modification can be called image tampering.
[0056] Image tampering detection for image tampering is a key task in the field of computer vision, and its goal is to determine whether an image has been tampered with or forged. At present, deep learning models have played an important role in the field of image detection. Deep learning models can automatically learn and extract features in images, which are then used to determine whether the image has been tampered with. Existing image detection methods usually use convolutional neural networks to extract tampering information within images. However, image detection methods often focus on visual consistency information at the image level or pixel level. For example, the intrinsic structure of an image is learned through an autoencoder to detect image tampering. For another example, real image samples are generated through a generative adversarial network to improve the accuracy of image tampering detection.
[0057] The above-mentioned use of autoencoders and adversarial networks for image detection has certain drawbacks.
[0058] The disadvantage of autoencoder-based detection is that it uses unsupervised learning, and another method is needed to perform classification detection after feature extraction. If the tampering method is complex and changes the global structure of the image, the autoencoder may not be able to accurately learn and reconstruct the structure of the original image, thus affecting the accuracy of tampering classification. Therefore, although autoencoders have potential in detecting image tampering, their reliance on unsupervised learning and challenges in tampering localization and complex tampering type identification still need to be addressed.
[0059] There are several disadvantages to using adversarial networks to generate real image samples to improve the accuracy of image tampering detection. First, the training process of adversarial networks requires a large amount of data and computing resources, which may make the training process complicated and time-consuming. Second, due to the complexity and diversity of tampering techniques, relying solely on real image samples for training may not cover all possible types of tampering, and therefore may not achieve the desired effect in actual tampering detection. In addition, the generator of the adversarial network may overfit a specific data set, resulting in a decrease in performance when faced with new tampering methods that have not been seen before.
[0060] Based on this, an embodiment of the present application provides a training method for an image detection model and an image detection method, first obtaining a pre-training data set including a first training image, using the pre-training data set to perform self-supervised training on the pre-training model, and then obtaining a training data set, the training data set including a second training image and an image label, and using the training data set to perform full-supervised training on the image detection model. The image detection model is composed of an encoding network included in the pre-training model. Before training, the transferable features of the first training image are learned using self-supervised training, which effectively improves the training efficiency of the image detection model. The trained image detection model has a high ability to detect tampered images. The accuracy of detecting tampered images using the trained image detection model is high.
[0061] In order to facilitate understanding of the technical solution provided by the embodiment of the present application, the training method of the image detection model provided by the embodiment of the present application is described below with reference to the accompanying drawings.
[0062] See also Figure 1 As shown, the figure is a flow chart of a training method for an image detection model provided in an embodiment of the present application.
[0063] S101: Acquire a pre-training data set, where the pre-training data set includes a first training image, where the first training image includes a first original image and a first tampered image.
[0064] See also Figure 2As shown, the figure is a schematic diagram of a scenario of model training and model application provided in an embodiment of the present application.
[0065] The pre-training data set includes a first training image. The first training image includes a first original image and a first tampered image. The first tampered image may be generated by performing image processing on the first original image.
[0066] The embodiment of the present application does not limit the source of the pre-training data set. The pre-training data set is, for example, a public image tampering data set, such as the Casia V1.0 / 2.0 data set. The Casia data set contains a large number of natural scene images and tampered images, which can be used to study image detection algorithms for image tampering.
[0067] S102: Using the pre-training data set, training a pre-training model, where the pre-training model includes an encoding network and a prediction network.
[0068] As an example, the pre-trained model is a self-supervised pre-trained model. The pre-trained model uses the Simsiam self-supervised network as a training framework for contrastive learning.
[0069] Simsiam learns meaningful feature expressions without relying on negative sample pairs, large batches of data, and encoding networks. It does not need to change the model structure, increase the number of training batch samples, or introduce negative samples to increase the amount of computation. Instead, it only needs to add a method to stop gradient backpropagation to solve the problem of training collapse. This simplification makes the Simsiam network more practical and easy to use. In addition, the Simsiam network has only one set of encoding network parameters, and the two branches are used alternately, which further reduces the complexity of the model and improves training efficiency.
[0070] For example, the pre-trained model includes a first encoding network, a second encoding network, a first prediction network, and a second prediction network. Figure 3 As shown, this figure is a schematic diagram of the structure of the pre-training model provided in an embodiment of the present application.
[0071] The compilation network is consistent with the backbone network for downstream task training. The compilation network uses the lightweight network MobileNet. The lightweight network is applied to downstream tasks to reduce the computational burden while ensuring accuracy, and to increase the speed of training and prediction.
[0072] Specifically, using the pre-training data set to train the pre-training model includes the following steps:
[0073] A1: Different random data augmentation methods are used on the first training image to obtain a first enhanced image and a second enhanced image.
[0074] During training, a series of superimposed random data enhancements are performed on the first input training image to obtain the first enhanced image x 1 and the second enhanced image x 2 .
[0075] A2: Input the first enhanced image into the first encoding network to obtain a first feature vector output by the first encoding network, input the first feature into the first prediction network to obtain a first output vector output by the first prediction network.
[0076] A3: Input the second enhanced image into the second encoding network to obtain a second feature vector output by the second encoding network, and input the second feature into the second prediction network to obtain a second output vector output by the second prediction network.
[0077] The first enhanced image x 1 and the second enhanced image x 2 Input into the first encoding network (encoder) and the second encoding network (encoder) for encoding respectively to obtain the first eigenvector z 1 and the second eigenvector z 2 . 1 Send it to the first prediction network (predictor) to get the first output vector p 1 . 2 Send it to the second prediction network (predictor) to get the second output vector p 2 .
[0078] A4: Determine a loss value of the pre-trained model using the first eigenvector, the second eigenvector, the first output vector, and the second output vector.
[0079] The loss value of the pre-trained model is, for example, cosine similarity.
[0080] The loss value calculation formula is, for example, (1) and (2).
[0081]
[0082]
[0083] A5: Adjust the model parameters of the pre-trained model according to the loss value.
[0084] In this way, the pre-trained model can be trained using a public pre-training dataset, so that the pre-trained model learns transferable data representations.
[0085] S103: Acquire a training data set, where the training data set includes a second training image and an image label, where the second training image includes a second original image and a second tampered image, and the image label includes a first label and a second label, where the first label is used to label the second original image, and the second label is used to label the second tampered image.
[0086] The images used for training are obtained to form a training data set. The training data set includes batches of tampered images. If the training data set has problems such as unbalanced sample data and different sizes, the original training images need to be preprocessed. In order to adjust the balance between the training images, the second training image included in the training data set is subjected to image enhancement processing.
[0087] Image enhancement processing includes image mirror flipping, image rotation, image resizing, Joint Photographic Experts Group (JPEG) compression, brightness, contrast and saturation adjustment, etc. Image enhancement processing can improve the robustness and generalization ability of image detection models while expanding images.
[0088] The original data set is divided into training data set, verification data set and test data set according to a certain ratio.
[0089] S104: Input the second training image into the image detection model to obtain a prediction result output by the image detection model, where the image detection model is composed of an encoding network, and the prediction result is used to indicate whether the second training image is a tampered image.
[0090] The image detection model is, for example, a lightweight convolutional neural network (MobileNet). Figure 4 As shown, this figure is a structural schematic diagram of the image detection model provided in an embodiment of the present application.
[0091] The network structure design of MobileNet effectively reduces the amount of calculation and parameters, thereby improving the operating efficiency of the model. This is due to the design of deep convolution and point-by-point convolution, which reduces the amount of calculation. By introducing the inverted residual module, MobileNet reduces the amount of calculation while improving the performance of the model. Due to the lightweight characteristics of MobileNet, the MobileNet network is usually easy to deploy, has a short inference time, and is suitable for environments with limited resources.
[0092] MobileNet uses depthwise separable convolution as the convolution unit. Depthwise separable convolution is decomposed into a combination of depthwise convolution and pointwise convolution for feature extraction. Compared with standard convolution, the accuracy is slightly reduced but the amount of calculation is reduced by 8 to 9 times. Depthwise separable convolution itself does not have the ability to change the number of channels. MobileNet uses pointwise convolution to increase the feature dimension and alleviate the problem that the network can only extract features from low-dimensional feature space due to the small number of channels. The residual structure can effectively transfer gradients and solve the gradient vanishing problem that occurs during training, so that the network converges quickly and improves the generalization ability of the network. MobileNet also uses a residual structure and transforms the structure of the lightweight network into an inverted residual structure, which improves the efficiency and performance of the model.
[0093] S105: Based on the prediction results and the image labels, the model parameters of the image detection model are adjusted to obtain a trained image detection model.
[0094] The training data set is put into the convolutional neural network for training, and then verified on the validation data set to observe the convergence of the image detection model. When the image detection model converges, the images in the test data set are input for prediction to obtain the possibility of image tampering.
[0095] After the image detection model is applied, it is also possible to collect images again to update the training data set, and to train, tune and maintain the image detection model.
[0096] Based on the above training method, self-supervised training is used before training to learn the transferable features of the data, effectively improving the training efficiency of the downstream image detection model. The image detection model can significantly reduce the parameters and computational complexity of the network while maintaining the performance of the neural network, making it easier to deploy, tune and maintain.
[0097] The self-supervised pre-training model is used to train a set of initialization parameters for downstream tasks in advance. Self-supervised pre-training has many advantages. Self-supervised pre-training can significantly reduce the demand for labeled data by training the model with unlabeled data. Through pre-training on large-scale unlabeled data, the model can capture the intrinsic structure and distribution characteristics of the data, and then extract more general and useful feature expressions for the target task, thereby improving the performance of the model on specific tasks. This is especially true when there is less data for the target task or when computing resources are limited. Pre-trained models are also often used for transfer learning. Part or all of the pre-trained model can be applied to new tasks. With the help of the knowledge and features that the pre-trained model has learned, the model performance of the new task can be improved, thereby improving the efficiency and practicality of the model.
[0098] After the image detection model is trained, it can be used to identify whether the image has been tampered with.
[0099] See also Figure 5 As shown, the figure is a flow chart of an image detection method provided in an embodiment of the present application, including S501-S502.
[0100] S501: Acquire an image to be recognized.
[0101] The image to be identified is an image that needs to be detected for image tampering.
[0102] S502: Input the image to be recognized into the image detection model to obtain the detection result output by the image detection model.
[0103] The detection result is used to indicate whether the image to be identified is a tampered image.
[0104] The image detection model can effectively predict the possibility of image tampering and detect whether image tampering technology has been used in business photos, which improves the problem that the naked eye cannot identify traces of image tampering during the manual review process. This image detection model can effectively reduce the missed detection rate of image tampering in marketing photos, limit false marketing behavior, protect consumer rights, and reduce business risks.
[0105] Based on the training method of an image detection model provided in the above method embodiment, the embodiment of the present application also provides a training device for an image detection model, and the training device for the image detection model will be described below in conjunction with the accompanying drawings.
[0106] See also Figure 6 As shown in FIG. 1 , this figure is a schematic diagram of the structure of a training device for an image detection model provided in an embodiment of the present application. Figure 6 As shown, the training device of the image detection model includes:
[0107] A first acquisition unit 601 is used to acquire a pre-training data set, where the pre-training data set includes a first training image, where the first training image includes a first original image and a first tampered image;
[0108] A first training unit 602 is used to train a pre-training model using a pre-training data set, where the pre-training model includes an encoding network and a prediction network;
[0109] A second acquisition unit 603 is used to acquire a training data set, the training data set includes a second training image and an image label, the second training image includes a second original image and a second tampered image, the image label includes a first label and a second label, the first label is used to mark the second original image, and the second label is used to mark the second tampered image;
[0110] A second training unit 604 is used to input the second training image into the image detection model to obtain a prediction result output by the image detection model, the image detection model is composed of an encoding network, and the prediction result is used to indicate whether the second training image is a tampered image;
[0111] The third training unit 605 is used to adjust the model parameters of the image detection model based on the prediction results and the image labels to obtain a trained image detection model.
[0112] In a possible implementation, the pre-trained model includes a first encoding network, a second encoding network, a first prediction network, and a second prediction network;
[0113] The first training unit is used to:
[0114] Using different random data enhancement devices on the first training image to obtain a first enhanced image and a second enhanced image;
[0115] Inputting the first enhanced image into the first encoding network to obtain a first feature vector output by the first encoding network, and inputting the first feature into the first prediction network to obtain a first output vector output by the first prediction network;
[0116] Inputting the second enhanced image into the second encoding network to obtain a second feature vector output by the second encoding network, and inputting the second feature into the second prediction network to obtain a second output vector output by the second prediction network;
[0117] Determine a loss value of the pre-trained model using the first eigenvector, the second eigenvector, the first output vector, and the second output vector;
[0118] Adjust the model parameters of the pre-trained model based on the loss value.
[0119] In a possible implementation manner, the first training unit is further configured to perform image enhancement processing on a second training image included in the training data set.
[0120] Based on an image detection method provided in the above method embodiment, an embodiment of the present application further provides an image detection device, which will be described below in conjunction with the accompanying drawings.
[0121] See also Figure 7 As shown in FIG. 1 , this figure is a schematic diagram of the structure of an image detection device provided in an embodiment of the present application. Figure 7 As shown, the image detection device comprises:
[0122] A first acquisition unit 701 is used to acquire an image to be recognized;
[0123] The recognition unit 702 is used to input the image to be recognized into the image detection model to obtain the detection result output by the image detection model. The detection result is used to indicate whether the image to be recognized is a tampered image. The image detection model is trained using the training method of the above-mentioned image detection model.
[0124] Based on the training method of an image detection model and an image detection method provided by the above method embodiment, the present application provides a device, including: a processor, a memory, and a system bus;
[0125] The processor and memory are connected via a system bus;
[0126] The memory is used to store one or more programs, and the one or more programs include instructions, which, when executed by the processor, enable the processor to execute the image detection model training method or image detection method of any of the above-mentioned embodiments.
[0127] Based on a method for generating a configuration file provided in the above method embodiment, the present application provides a computer-readable storage medium, in which instructions are stored. When the instructions are executed on a terminal device, the terminal device executes the image detection model training method or image detection method of any of the above embodiments.
[0128] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referred to each other. For the system or device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0129] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0130] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0131] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0132] The above description of the disclosed embodiments enables professionals in the field to implement or use the present application. Various modifications to these embodiments will be apparent to professionals in the field, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A training method for an image detection model, characterized in that: The method comprises: Acquire a pre-training data set, wherein the pre-training data set includes a first training image, and the first training image includes a first original image and a first tampered image; Using the pre-training data set, training a pre-training model, wherein the pre-training model includes an encoding network and a prediction network; Acquire a training data set, the training data set comprising a second training image and an image label, the second training image comprising a second original image and a second tampered image, the image label comprising a first label and a second label, the first label being used to label the second original image, and the second label being used to label the second tampered image; Inputting the second training image into an image detection model to obtain a prediction result output by the image detection model, wherein the image detection model is composed of the encoding network, and the prediction result is used to indicate whether the second training image is a tampered image; Based on the prediction result and the image label, the model parameters of the image detection model are adjusted to obtain a trained image detection model.
2. The method according to claim 1, characterized in that The pre-training model includes a first encoding network, a second encoding network, a first prediction network and a second prediction network; The method of training the pre-training model by using the pre-training data set includes: Using different random data enhancement methods on the first training image to obtain a first enhanced image and a second enhanced image; Inputting the first enhanced image into the first encoding network to obtain a first feature vector output by the first encoding network, and inputting the first feature into the first prediction network to obtain a first output vector output by the first prediction network; Inputting the second enhanced image into the second encoding network to obtain a second feature vector output by the second encoding network, and inputting the second feature into the second prediction network to obtain a second output vector output by the second prediction network; Determine a loss value of the pre-trained model using the first feature vector, the second feature vector, the first output vector, and the second output vector; The model parameters of the pre-trained model are adjusted according to the loss value.
3. The method according to claim 1, characterized in that The method further comprises: Perform image enhancement processing on the second training image included in the training data set.
4. An image detection method, characterized in that: The method comprises: Obtain an image to be recognized; The image to be identified is input into an image detection model to obtain a detection result output by the image detection model, wherein the detection result is used to indicate whether the image to be identified is a tampered image. The image detection model is trained using the image detection model training method described in any one of claims 1 to 3.
5. A training device for an image detection model, characterized in that: The device comprises: A first acquisition unit, configured to acquire a pre-training data set, wherein the pre-training data set includes a first training image, and the first training image includes a first original image and a first tampered image; A first training unit is used to train a pre-training model using the pre-training data set, wherein the pre-training model includes an encoding network and a prediction network; A second acquisition unit is used to acquire a training data set, the training data set includes a second training image and an image label, the second training image includes a second original image and a second tampered image, the image label includes a first label and a second label, the first label is used to mark the second original image, and the second label is used to mark the second tampered image; a second training unit, configured to input the second training image into an image detection model to obtain a prediction result output by the image detection model, wherein the image detection model is composed of the encoding network, and the prediction result is used to indicate whether the second training image is a tampered image; The third training unit is used to adjust the model parameters of the image detection model based on the prediction result and the image label to obtain a trained image detection model.
6. The device according to claim 5, characterized in that The pre-training model includes a first encoding network, a second encoding network, a first prediction network and a second prediction network; The first training unit is used to: Using different random data enhancement devices on the first training image to obtain a first enhanced image and a second enhanced image; Inputting the first enhanced image into the first encoding network to obtain a first feature vector output by the first encoding network, and inputting the first feature into the first prediction network to obtain a first output vector output by the first prediction network; Inputting the second enhanced image into the second encoding network to obtain a second feature vector output by the second encoding network, and inputting the second feature into the second prediction network to obtain a second output vector output by the second prediction network; Determine a loss value of the pre-trained model using the first feature vector, the second feature vector, the first output vector, and the second output vector; The model parameters of the pre-trained model are adjusted according to the loss value.
7. The device according to claim 6, characterized in that The first training unit is further configured to perform image enhancement processing on a second training image included in the training data set.
8. An image detection device, characterized in that: The device comprises: A first acquisition unit, used to acquire an image to be recognized; An identification unit is used to input the image to be identified into an image detection model to obtain a detection result output by the image detection model, wherein the detection result is used to indicate whether the image to be identified is a tampered image, and the image detection model is trained using the image detection model training method described in any one of claims 1 to 3.
9. A device, characterized in that: include: Processor, memory, system bus; The processor and the memory are connected via the system bus; The memory is used to store one or more programs, and the one or more programs include instructions, which, when executed by the processor, enable the processor to execute the method according to any one of claims 1 to 3, or execute the method according to claim 4.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed on a terminal device, the terminal device executes the method according to any one of claims 1 to 3, or executes the method according to claim 4.