Training method of image detection model, image detection method and device

By alternately training the generator and discriminator of the GAN model, generating and detecting fake images with watermarks, and dynamically updating the training set, the problem of insufficient training set samples is solved, the generalization ability and robustness of the image detection model are improved, and the recognition accuracy is increased.

CN116486199BActive Publication Date: 2025-12-23ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310386130.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-04
Publication Date
2025-12-23
Estimated Expiration
2043-04-04

AI Technical Summary

Technical Problem

Existing image recognition models suffer from weak generalization ability and poor robustness due to insufficient training set samples, which in turn affects the accuracy of recognition results.

Method used

By alternately training the generator and discriminator of the GAN model based on the training set, fake images with watermarks are generated and detected. The training set is dynamically updated until the optimization conditions are met, and the discriminator is determined to be the target image detection model.

Benefits of technology

It improves the generalization ability and robustness of the image detection model, enhances the accuracy of image authenticity detection results, and strengthens robustness against attacks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116486199B_ABST
    Figure CN116486199B_ABST
Patent Text Reader

Abstract

The embodiment of the specification provides a training method of an image detection model, an image detection method and device, wherein the training method comprises: performing alternating training processing on a generator and a discriminator of a to-be-trained GAN model based on a training set to obtain a trained GAN model; if it is determined that a preset verification condition is met, inputting a plurality of first false images generated by the generator of the current GAN model into the discriminator of the current GAN model in sequence for image detection processing to obtain a detection result; determining whether the current GAN model meets an optimization condition according to the detection result; if the optimization condition is met, updating the training set according to the detection result and performing alternating training processing based on the updated training set; and if the optimization condition is not met, determining the discriminator of the current GAN model as a target image detection model.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present document relates to the technical field of image processing, and particularly relates to a training method of an image detection model, an image detection method and device BACKGROUND

[0002] Biological feature recognition is widely used in many fields, such as payment field, security field, etc. With the continuous development of artificial intelligence technology, in order to avoid the attack operation of attackers to cause loss to users, biological feature recognition processing by using a recognition model has become a mainstream biological feature recognition method. At present, the training method of the recognition model is usually to use a fixed training set for training processing, and when the model converges, the recognition model is obtained. However, in this training method, the generalization ability and robustness of the obtained recognition model may be weak due to insufficient samples in the fixed training set, and thus the recognition result accuracy of the model is poor. SUMMARY

[0003] One or more embodiments of the present specification provide a training method of an image detection model. The method comprises alternately training a generator and a discriminator of a to-be-trained GAN model based on a training set to obtain a trained GAN model. The generator is configured to generate a false image containing a watermark. The discriminator is configured to detect the authenticity of an input image. If it is determined that a preset verification condition is met, a plurality of first false images generated by the generator of the current GAN model are sequentially input into the discriminator of the current GAN model for image detection processing to obtain a detection result. It is determined whether the current GAN model meets an optimization condition according to the detection result. If the optimization condition is met, the training set is updated according to the detection result, and the alternately training is performed based on the updated training set. If the optimization condition is not met, the discriminator of the current GAN model is determined as a target image detection model.

[0004] One or more embodiments of the present specification provide an image detection method. The method comprises obtaining a to-be-detected image. An image detection model is used to perform image detection processing on the to-be-detected image to obtain a detection result. The detection result represents the authenticity of the to-be-detected image. The image detection model is obtained by training a to-be-trained GAN model based on a training set. The training processing comprises updating the training set and training based on the updated training set when it is determined that an optimization condition is met.

[0005] One or more embodiments of the present specification provide a training device of an image detection model. The device comprises a training module, which performs alternating training processing on a generator and a discriminator of a to-be-trained GAN model based on a training set, to obtain a trained GAN model. The generator is configured to generate a false image containing a watermark. The discriminator is configured to detect the authenticity of an input image. The device further comprises a detection module, which, if it is determined that a preset verification condition is met, sequentially inputs a plurality of first false images generated by the generator of a current GAN model into the discriminator of the current GAN model for image detection processing, to obtain a detection result. The device further comprises a determination module, which determines whether the current GAN model meets an optimization condition according to the detection result. If the optimization condition is not met, the discriminator of the current GAN model is determined as a target image detection model. The device further comprises an updating module, which, if the determination result of the determination module is that the optimization condition is met, updates the training set according to the detection result. The training module further performs the alternating training processing based on the updated training set.

[0006] One or more embodiments of the present specification provide an image detection device. The device comprises an acquisition module, which acquires a to-be-detected image. The device further comprises a detection module, which performs image detection processing on the to-be-detected image based on an image detection model, to obtain a detection result. The detection result represents the authenticity of the to-be-detected image. The image detection model is obtained by training a to-be-trained GAN model based on a training set. The training processing comprises updating the training set and performing training processing based on the updated training set when it is determined that an optimization condition is met.

[0007] One or more embodiments of the present specification provide a training device of an image detection model. The device comprises a processor. The device further comprises a memory arranged to store computer executable instructions. The computer executable instructions, when executed, cause the processor to perform alternating training processing on a generator and a discriminator of a to-be-trained GAN model based on a training set, to obtain a trained GAN model. The generator is configured to generate a false image containing a watermark. The discriminator is configured to detect the authenticity of an input image. If it is determined that a preset verification condition is met, a plurality of first false images generated by the generator of a current GAN model are sequentially input into the discriminator of the current GAN model for image detection processing, to obtain a detection result. It is determined whether the current GAN model meets an optimization condition according to the detection result. If the optimization condition is met, the training set is updated according to the detection result, and the alternating training processing is performed based on the updated training set. If the optimization condition is not met, the discriminator of the current GAN model is determined as a target image detection model.

[0008] One or more embodiments of the present specification provide an image detection device. The device includes a processor. The device also includes a memory arranged to store computer executable instructions. The computer executable instructions, when executed, cause the processor to acquire an image to be detected. An image detection processing is performed on the image to be detected based on an image detection model, to obtain a detection result. The detection result represents a degree of authenticity of the image to be detected. The image detection model is obtained by training a GAN model to be trained based on a training set. The training includes updating the training set and training based on the updated training set when it is determined that an optimization condition is met.

[0009] One or more embodiments of the present specification provide a storage medium. The storage medium is configured to store computer executable instructions. The computer executable instructions, when executed by a processor, perform alternating training on a generator and a discriminator of a GAN model to be trained based on a training set, to obtain a trained GAN model. The generator is configured to generate false images containing watermarks. The discriminator is configured to detect a degree of authenticity of an input image. If it is determined that a preset verification condition is met, a plurality of first false images generated by the generator of a current GAN model are sequentially input into the discriminator of the current GAN model for image detection processing, to obtain a detection result. Whether the current GAN model meets an optimization condition is determined according to the detection result. If the optimization condition is met, the training set is updated according to the detection result, and the alternating training is performed based on the updated training set. If the optimization condition is not met, the discriminator of the current GAN model is determined as a target image detection model.

[0010] One or more embodiments of the present specification provide a storage medium. The storage medium is configured to store computer executable instructions. The computer executable instructions, when executed by a processor, acquire an image to be detected. An image detection processing is performed on the image to be detected based on an image detection model, to obtain a detection result. The detection result represents a degree of authenticity of the image to be detected. The image detection model is obtained by training a GAN model to be trained based on a training set. The training includes updating the training set and training based on the updated training set when it is determined that an optimization condition is met. BRIEF DESCRIPTION OF DRAWINGS

[0011] In order to more clearly illustrate the technical solutions of one or more embodiments of the present specification or the prior art, the drawings needed in the embodiment or prior art description will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments described in the present specification, and those skilled in the art can also obtain other drawings according to these drawings without any creative labor.

[0012] Figure 1 A scene schematic diagram of a training method of an image detection model provided by an embodiment of the present specification;

[0013] Figure 2 A first flow schematic diagram of a training method of an image detection model provided by an embodiment of the present specification;

[0014] Figure 3 A second flow schematic diagram of a training method of an image detection model provided by an embodiment of the present specification;

[0015] Figure 4 A flow schematic diagram of an image detection method provided by an embodiment of the present specification;

[0016] Figure 5 A module composition schematic diagram of a training device of an image detection model provided by an embodiment of the present specification;

[0017] Figure 6 A module composition schematic diagram of an image detection device provided by an embodiment of the present specification;

[0018] Figure 7 A structure schematic diagram of a training equipment of an image detection model provided by an embodiment of the present specification;

[0019] Figure 8 A structure schematic diagram of an image detection equipment provided by an embodiment of the present specification. DETAILED DESCRIPTION

[0020] In order to make the person skilled in the art better understand the technical solutions in one or more embodiments of the present specification, the technical solutions in one or more embodiments of the present specification will be described clearly and completely in the following with reference to the drawings in one or more embodiments of the present specification. Obviously, the described embodiments are only a part of the embodiments of the present specification, not all the embodiments. Based on one or more embodiments of the present specification, all other embodiments obtained by the person skilled in the art without creative labor should belong to the protection scope of the present document.

[0021] Figure 1 An application scene schematic diagram of a training method of an image detection model provided by one or more embodiments of the present specification, as shown in the figure, Figure 1 The scene includes a training device of an image detection model (hereinafter referred to as a training device), which can be arranged in a terminal device (not shown in the figure), Figure 1 or arranged in a server (not shown in the figure), Figure 1The terminal device can be a mobile phone, a tablet computer, a desktop computer, a portable notebook computer, etc. The server can be a stand-alone server or a server cluster composed of multiple servers.

[0022] Specifically, the training device obtains training samples from the training set, and performs alternating training processing on the generator and the discriminator of the to-be-trained GAN model by using the training samples to obtain a trained GAN model. The generator is configured to generate a false image containing a watermark, and the discriminator is configured to detect the authenticity of an input image. If the training device determines that a preset verification condition is met, the training device inputs a plurality of first false images generated by the generator of the current GAN model into the discriminator of the current GAN model in sequence for image detection processing to obtain a detection result. The training device determines whether the current GAN model meets an optimization condition according to the detection result. If the optimization condition is met, the training device updates the training set according to the detection result, and performs the aforementioned alternating training processing based on the updated training set. If the optimization condition is not met, the training device determines the discriminator of the current GAN model as a target image detection model. In this way, in the training process of the image detection model, when it is determined that the verification condition is met, the plurality of first false images generated by the generator of the current GAN model are input into the discriminator of the current GAN model in sequence for image detection processing. When it is determined that the current GAN model meets the optimization condition according to the detection result, the training set is updated according to the detection result. This not only realizes dynamic updating of the training set, avoids problems such as insufficient samples in the training set and low coverage, but also enables the subsequent training based on the updated training set to strengthen the training of weak places of the GAN model, thereby improving the generalization ability and robustness of the GAN model, and further improving the accuracy of the detection result of the image detection model on the authenticity of an image.

[0023] Based on the above application scenario architecture, one or more embodiments of the present specification provide a training method of an image detection model. Figure 2 A flowchart of a training method of an image detection model provided by one or more embodiments of the present specification is shown in Figure 2 The method in Figure 1 The training device in Figure 2 As shown in

[0024] Step S102: performing alternating training processing on the generator and the discriminator of the to-be-trained GAN model based on the training set to obtain a trained GAN model. The generator is configured to generate a false image containing a watermark, and the discriminator is configured to detect the authenticity of an input image.

[0025] In actual applications, attackers often leave watermarks in images when performing attack operations. Therefore, detecting the authenticity of images based on watermarks is a solution to avoid attack behaviors. In order to improve the effectiveness of the image detection model and avoid the attack behaviors of attackers bypassing the image detection model, the GAN model is introduced in the specification. The generator of the GAN model generates false images containing watermarks, and the discriminator of the GAN model detects the authenticity of the false images generated by the generator. In this way, automatic attacks are formed, and convergence is achieved, thereby achieving robustness to the attack behaviors of attackers and improving the effectiveness of the model. That is, the generator and the discriminator of the GAN model to be trained are alternately trained in the specification, and the discriminator of the trained GAN model is determined as a target image detection model, so that the target image detection model can be used to perform image detection processing on the input image to be detected, and obtain a detection result representing the authenticity of the image to be processed.

[0026] In step S104, if it is determined that the preset verification condition is met, the plurality of first false images generated by the generator of the current GAN model are sequentially input into the discriminator of the current GAN model for image detection processing, and a detection result is obtained.

[0027] In the embodiments of the specification, one alternation training of the generator and the discriminator of the GAN model is referred to as one round of training. For example, the first iteration training of the generator is performed while keeping the discriminator unchanged, and after the first iteration training of the generator is completed, the first iteration training of the discriminator is performed while keeping the generator unchanged. When the first iteration training of the discriminator is completed, the first round of training is completed. Then, the second iteration training of the generator is performed while keeping the discriminator unchanged, and after the second iteration training of the generator is completed, the second iteration training of the discriminator is performed while keeping the generator unchanged. When the second iteration training of the discriminator is completed, the second round of training is completed. The same applies to the subsequent rounds of training.

[0028] In order to accurately determine whether the preset verification condition is met, in one or more embodiments of the specification, before step S104, the training rounds of the GAN model can also be recorded. Correspondingly, in step S104, determining that the preset verification condition is met can include: if it is determined that the training rounds of the GAN model reach the preset rounds, it is determined that the preset verification condition is met. In order to ensure the effectiveness of the GAN model, the preset rounds can include multiple rounds, for example, the preset rounds include 50, 100, 150, 200, etc.

[0029] In another or more embodiments of the present specification, determining that the preset verification condition is met in step S104 can include: if the loss value determined based on the first loss function for the trained GAN model does not exceed the first preset loss value, determining that the preset verification condition is met. The first loss function can be a loss function used in training of an existing GAN model, which is not specifically limited in the present specification.

[0030] Step S106, determining whether the current GAN model meets the optimization condition according to the detection results;

[0031] In one or more embodiments of the present specification, the detection result can include a first probability that the first fake image is detected as a fake image, and the greater the first probability, the higher the accuracy of the detection result of the discriminator; accordingly, step S106 can include: determining whether the minimum first probability in the first probability included in each detection result is greater than a preset probability threshold; if yes, determining that the current GAN model does not meet the optimization condition; if no, determining that the current GAN model meets the optimization condition. Specifically, the first probability is obtained from each detection result, and each obtained first probability is sorted to obtain the minimum first probability; the minimum first probability is compared with the preset probability threshold, if the minimum first probability is greater than the preset probability threshold, it is determined that the current GAN does not meet the optimization condition; if the minimum first probability is not greater than the preset probability threshold, it is determined that the current GAN meets the optimization condition.

[0032] In one or more embodiments of the present specification, the detection result can include a second probability that the first fake image is detected as a real image, and the smaller the second probability, the higher the accuracy of the detection result of the discriminator; accordingly, step S106 can include: determining whether the maximum probability in the second probability included in each detection result is less than a preset probability threshold; if yes, determining that the current GAN model does not meet the optimization condition; if no, determining that the current GAN model meets the optimization condition. Specifically, the second probability is obtained from each detection result, and each obtained second probability is sorted to obtain the maximum second probability; the maximum second probability is compared with the preset probability threshold, if the maximum second probability is less than the preset probability threshold, it is determined that the current GAN does not meet the optimization condition; if the maximum second probability is not less than the preset probability threshold, it is determined that the current GAN meets the optimization condition.

[0033] Step S108, if the optimization condition is met, updating the training set according to the detection result, and performing alternating training processing based on the updated training set; if the optimization condition is not met, determining the discriminator of the current GAN model as the target image detection model.

[0034] In one or more embodiments of the present specification, the generator and the discriminator of the GAN model to be trained are alternately trained based on the training set to obtain a trained GAN model; if it is determined that the preset verification condition is met, a plurality of first fake images generated by the generator of the current GAN model are sequentially input into the discriminator of the current GAN model for image detection processing to obtain a detection result; whether the current GAN model meets an optimization condition is determined according to the detection result; if the optimization condition is met, the training set is updated according to the detection result, and the alternately training processing is performed based on the updated training set; if the optimization condition is not met, the discriminator of the current GAN model is determined as a target image detection model. Thus, in the training process of the image detection model, when it is determined that the verification condition is met, a plurality of first fake images generated by the generator of the current GAN model are sequentially input into the discriminator of the current GAN model for image detection processing; and when it is determined that the current GAN model meets the optimization condition according to the detection result, the training set is updated according to the detection result, which not only realizes dynamic updating of the training set, avoids problems such as insufficient samples and low coverage range in the training set, but also enables the subsequent training based on the updated training set to strengthen the training of the current weak place of the GAN model, thereby improving the generalization ability and robustness of the GAN model, and further improving the accuracy of the detection result of the image detection model on the authenticity of the image.

[0035] It is considered that the current attacker may take measures such as changing the size of the watermark (i.e., changing the length and width of the watermark), changing the position of the watermark (i.e., changing the position of the watermark in the image), changing the color of the watermark (e.g., changing red to green, etc.), changing the font of the text in the watermark (e.g., changing KaiTi to SongTi, etc.), changing the type of text in the watermark (e.g., changing Chinese to English, etc.), etc. in order to bypass the image detection of the model. In order to improve the robustness of the image detection model to these means, thereby improving the accuracy of the detection result of the image detection model, in one or more embodiments of the present specification, a watermark style set is set in advance, and a first training set is constructed based on the watermark style set. Specifically, as shown in Figure 3 Before step S102, the following step S100 can also be included:

[0036] Step S100: constructing a first training set according to a preset watermark style set and a plurality of first real images without watermark;

[0037] The watermark pattern set includes multiple types of watermark patterns, and each type of watermark pattern includes multiple sub-patterns. In one or more embodiments of the present specification, the watermark pattern set can include any multiple types of watermark patterns in watermark size, watermark color, watermark position, watermark font, and text type in the watermark. The watermark size can include any multiple sub-patterns in No. 1, No. 2, No. 3, No. 4, small No. 4, No. 5, and small No. 5. Alternatively, the watermark size is represented by the proportion of the watermark area occupying the overall image area, and accordingly, the watermark size can include any multiple random numbers in 0 to 1, each random number being a sub-pattern. Alternatively, the watermark size is represented by the length-width ratio, and accordingly, the watermark size can include any multiple random numbers in 0.5 to 10, each random number being a sub-pattern. The watermark color can include any multiple sub-patterns in red, green, pink, white, black, purple, and gray. The watermark position can include any multiple sub-patterns in upper, middle, lower, left, right, upper left, lower left, upper right, and lower right. Alternatively, the watermark position can be represented by coordinates, and accordingly, the watermark position can include multiple coordinate combinations, each coordinate combination being a sub-pattern. The watermark font can include any multiple sub-patterns in Songti, Kaishu, Heiti, and Fongsong. The text type in the watermark can include any multiple sub-patterns in Chinese, English, Japanese, and various small languages such as Arabic.

[0038] Accordingly, step S100 can include: randomly selecting multiple first target watermark patterns from the preset watermark pattern set; wherein the first target watermark pattern includes a sub-pattern of each type of watermark pattern; combining each first target watermark pattern with at least one first real image to obtain at least one first training sample; and determining each obtained first training sample as a first training set.

[0039] As an example, N first target watermark patterns are randomly selected from the preset watermark pattern set, and M first real images without watermark are pre-acquired, where N and M are integers greater than 1. For ease of description, the N first target watermark patterns are sequentially denoted as first target watermark pattern 1, first target watermark pattern 2, …, and first target watermark pattern N, and the first real images are sequentially denoted as first real image 1, first real image 2, …, and first real image M. The first target watermark pattern 1 can be randomly combined with the first real image 1 to obtain a first training sample, the first target watermark pattern 1 can be combined with the first real image 3 to obtain a first training sample, the first target watermark pattern 1 can be combined with the first real image 5 to obtain a first training sample, the first target watermark pattern 2 can be combined with the first real image 1 to obtain a first training sample, the first target watermark pattern 2 can be combined with the first real image 10 to obtain a first training sample, …, and the first target watermark pattern N can be combined with the first real image 20 to obtain a first training sample, and so on. Each first training sample obtained is determined as a first training set.

[0040] Further, in order to enhance the robustness of the image detection model obtained by training, thereby improving the accuracy of the detection result, in one or more embodiments of the present specification, a sub-pattern is randomly selected from each type of watermark pattern, and is combined into a first target watermark pattern. Specifically, the above-mentioned random selection of a plurality of first target watermark patterns from the preset watermark pattern set can include: for each type of watermark pattern, randomly generating a onehot vector or a random number; according to the onehot vector or the random number, selecting a target sub-pattern from a plurality of sub-patterns included in the corresponding type of watermark pattern; and performing splicing processing on the target sub-patterns of each type of watermark pattern to obtain a first target watermark pattern.

[0041] The onehot vector is a one-dimensional row vector with only one element being 1 and other elements being 0.

[0042] To facilitate the random selection of the sub-patterns of each type of watermark pattern, in one or more embodiments of the present specification, each type of watermark pattern in the set of watermark patterns can correspond to a pattern table. When a 1*F onehot vector is randomly generated, F is an integer greater than 1, and the pattern table can be a 1*F row vector; in the pattern table, each of the F elements represents a sub-pattern. Correspondingly, according to the onehot vector, selecting the target sub-pattern from the multiple sub-patterns included in the corresponding type of watermark pattern can include: multiplying the onehot vector with the 1*F row vector, and determining the corresponding sub-pattern of the multiplication result as the target pattern. Taking color as an example for illustration, the pattern table of the watermark pattern "color" is a 1*12 row vector, where the first element represents red, the second element represents pink, the third element represents green, the tenth element represents white, the eleventh element represents black, and the twelfth element represents purple. When the randomly generated onehot vector is 001000000000, the obtained target sub-pattern is green, and when the randomly generated onehot vector is 000000000010, the obtained target sub-pattern is black.

[0043] Further, when a random number t is randomly generated, the pattern table can be represented as T rows and H columns, which is equivalent to a T*H matrix, and both T and H are integers greater than 1; in the pattern table, each row represents a sub-pattern, and each sub-pattern is represented by H elements. Correspondingly, the random number t is any integer from 1 to T. According to the random number, the target sub-pattern is selected from the multiple sub-patterns included in the corresponding type of watermark pattern, which can include: multiplying the random number t with the T*H matrix, and determining the corresponding sub-pattern of the multiplication result as the target sub-pattern. For example, the pattern table of the watermark pattern "color" is a 12*16 matrix, where the first row represents red, the second row represents pink, the third row represents green, the tenth row represents white, the eleventh row represents black, and the twelfth row represents purple; when the randomly generated random number is 2, the obtained target sub-pattern is pink, and when the randomly generated random number is 10, the obtained target sub-pattern is white.

[0044] Therefore, by randomly selecting multiple first target watermark patterns, and each first target watermark pattern including multiple types of watermark patterns, the first training set is constructed based on the multiple first target watermark patterns, which enriches the watermark patterns in the first training set, so that when subsequent training processing is performed based on the first training set, the model can learn rich watermark patterns, improve the robustness of the model, and make it difficult for attackers to bypass the image detection of the model by changing the watermark pattern.

[0045] Further, corresponding to the above step S100, as shown in Figure 3As shown, step S102 can include the following steps S102-2 to S102-6: before step S104, the following step S103 can also be included:

[0046] Step S102-2, based on the first training set, the generator of the GAN model to be trained is iteratively trained in the current training round, and a trained generator is obtained.

[0047] Specifically, the first training subset to be trained is obtained from the first training set in turn, and each first training sample in the first training subset is input into the generator of the GAN model to be trained for training processing. If it is determined that the first training end condition is met, the current generator is determined as the trained generator. The first training end condition can be that the number of training times of the generator reaches a first preset number, or that the second loss value determined based on the second loss function is less than a second preset loss value. The second loss function can use the loss function used in the training of the generator of the existing GAN model, which is not limited in the present specification.

[0048] Step S102-4, constructing a current second training set according to a plurality of second false images generated by the trained generator;

[0049] Specifically, a plurality of second real images are obtained from the specified image set; a plurality of second target watermark patterns corresponding to each second real image are randomly selected from the watermark pattern set; for each second real image, the second real image and each corresponding second target watermark pattern are combined to obtain a plurality of first to-be-generated samples; each first to-be-generated sample is input into the trained generator in turn for image generation processing to obtain a corresponding second false image; and each second false image obtained and each image in the specified image set are determined as the current second training set. For ease of distinction, each image in the second training set is referred to as a second training sample, and the label of each second training sample includes watermark information indicating whether it contains a watermark, and watermark position information when it contains a watermark.

[0050] The specified image set includes a plurality of second real images and can also include false images. The false images can include pre-collected images and / or images generated during the training of the generator. The plurality of second real images can be obtained from the specified image set, which can be all second real images in the specified image set, or a part of second real images randomly selected from the second real images included in the specified image set.

[0051] The process of randomly selecting a plurality of second target watermark patterns corresponding to each second real image from the watermark pattern set is the same as the process of randomly selecting a plurality of first target watermark patterns from the preset watermark pattern set as described above. For details, reference can be made to the foregoing description, and repeated descriptions are not repeated here. As an example, n second target watermark patterns corresponding to each second real image are randomly selected from the watermark pattern set, where n is an integer greater than 1; for the second real image 1, the corresponding n second target watermark patterns are sequentially recorded as the second target watermark pattern 1, the second target watermark pattern 2,..., and the second target watermark pattern n; the second real image 1 and the second target watermark pattern 1 are combined to obtain the first to-be-generated sample 1; the second real image 1 and the second target watermark pattern 2 are combined to obtain the first to-be-generated sample 2;..., and the second real image 1 and the second target watermark pattern n are combined to obtain the first to-be-generated sample n. Similarly, for each second real image, n first to-be-generated samples are obtained.

[0052] It can be understood that each first to-be-generated sample is input into the trained generator for image generation processing to obtain the corresponding second false image, that is, the process of attacking the second real image in the first to-be-generated sample by using the second target watermark pattern in the first to-be-generated sample. Thus, in the training process, the GAN model is continuously attacked and converged, greatly improving the accuracy of the GAN model, and thus ensuring the accuracy of the image detection model.

[0053] In step S102-6, the discriminator of the to-be-trained GAN model is iteratively trained based on the current second training set for the current training round to obtain a trained discriminator.

[0054] Specifically, each second training subset to be currently trained is sequentially obtained from the second training set, and each second training sample in the second training subset is input into the discriminator of the to-be-trained GAN model for training processing. If it is determined that a preset second training end condition is met, the current discriminator is determined as the trained discriminator. The second training end condition can be that the number of training times of the discriminator reaches a second preset number, or that a third loss value determined based on a third loss function does not exceed a third preset loss value. The third loss function can use the loss function used in the training of the discriminator of the existing GAN model, which is not limited in the present specification.

[0055] In step S103, it is determined whether a verification condition is met. If it is determined that the verification condition is not met, the next training round of the current training round is determined as the current training round, and the process returns to step S102-2.

[0056] For details of determining that the verification condition is met, reference can be made to the foregoing description, and repeated descriptions are not repeated here.

[0057] It can be seen that in the alternating training process of the generator and the discriminator of the GAN model to be trained, first, based on the preset watermark style set, a first training set is constructed and the generator is trained based on the first training set; then based on the trained generator and the preset watermark style set, a second training set is constructed and the discriminator is trained based on the second training set. On the one hand, since the training set is constructed based on the preset watermark style set, the model can learn multiple watermark styles in the training process, achieve robustness to multiple watermark styles, and thus make it difficult for attackers to bypass the image detection of the model by changing the watermark style. On the other hand, in the training process, the GAN model is constantly attacked and constantly converges, greatly improving the accuracy of the GAN model, and thus ensuring the accuracy of the image detection model.

[0058] Further, when it is determined that the verification condition is met, in order to realize effective verification of the model, in one or more embodiments of the present specification, after it is determined in step S104 that the preset verification condition is met, the method further includes the following steps A2 to A8:

[0059] Step A2, obtaining each trained real image from the training set;

[0060] Specifically, each real image that has participated in the training is obtained from the training set.

[0061] Step A4, randomly selecting a plurality of third target watermark styles corresponding to each trained real image from the preset watermark style set;

[0062] Wherein, the specific process of obtaining the third target watermark style is the same as the process of obtaining the first target watermark style, which can be referred to the related description of obtaining the first target watermark style in the foregoing, and the repeated parts will not be described here.

[0063] Step A6, combining each trained real image with each corresponding third target watermark style to obtain a plurality of second to-be-generated samples;

[0064] Wherein, the process of obtaining the second to-be-generated sample is the same as the process of obtaining the first to-be-generated sample, which can be referred to the related description of obtaining the first to-be-generated sample in the foregoing, and the repeated parts will not be described here.

[0065] Step A8, sequentially inputting each second to-be-generated sample into the generator of the current GAN model for image generation processing to obtain a corresponding first fake image.

[0066] Thus, when it is determined that the verification condition is met, the first fake image is generated based on the preset watermark pattern set and the current generator, so that the first fake image can be subjected to image detection processing based on the current discriminator to obtain a detection result; and whether the current GAN model meets the optimization condition is determined according to the detection result.

[0067] Further, when it is determined that the current GAN model meets the optimization condition, in order to strengthen the weak places of the current GAN model in the subsequent training process, in one or more embodiments of the present specification, the optimization information is determined according to the detection result, and the training set is updated according to the optimization information. That is, the updating of the training set according to the detection result in step S108 can include: determining the optimization information according to the detection result, and updating the training set according to the determined optimization information.

[0068] Specifically, the detection result is subjected to Bayesian optimization processing to obtain a fourth target watermark pattern to be learned by the generator of the current GAN model; the fourth target watermark pattern is determined as the optimization information; a target real sample is obtained from the training set, and the first training set is updated according to the fourth target watermark pattern and the target real sample.

[0069] The process of Bayesian optimization processing can refer to the prior art, and will not be described in detail in the present specification. The target real sample can be all real samples in the training set, or part of the real samples in the training set. Updating the first training set according to the fourth target watermark pattern and the target real sample can include: for each target real sample, combining the target real sample with each fourth target watermark pattern to obtain a new first training sample, adding the new first training sample to the first training set to obtain an updated first training set.

[0070] In one or more embodiments of the present specification, the generator and the discriminator of the GAN model to be trained are alternately trained based on the training set to obtain a trained GAN model; if it is determined that the preset verification condition is met, a plurality of first false images generated by the generator of the current GAN model are sequentially input into the discriminator of the current GAN model for image detection processing to obtain a detection result; whether the current GAN model meets an optimization condition is determined according to the detection result; if the optimization condition is met, the training set is updated according to the detection result, and the alternately training processing is performed based on the updated training set; if the optimization condition is not met, the discriminator of the current GAN model is determined as a target image detection model. Thus, in the training process of the image detection model, when it is determined that the verification condition is met, a plurality of first false images generated by the generator of the current GAN model are sequentially input into the discriminator of the current GAN model for image detection processing; and when it is determined that the current GAN model meets the optimization condition according to the detection result, the training set is updated according to the detection result, which not only realizes dynamic updating of the training set, avoids problems such as insufficient samples and low coverage range in the training set, but also enables the subsequent training based on the updated training set to strengthen the training of the current weak place of the GAN model, thereby improving the generalization ability and robustness of the GAN model, and further improving the accuracy of the detection result of the image detection model on the authenticity of the image.

[0071] Corresponding to the training method of the image detection model described above, based on the same technical concept, one or more embodiments of the present specification also provide an image detection method. Figure 4 A flowchart of an image detection method provided by one or more embodiments of the present specification is shown in Figure 4 The method in the above embodiment can be executed by an image detection device; the image detection device can be arranged in a terminal device or a server; the terminal device can be a mobile phone, a tablet computer, a desktop computer, a portable notebook computer, etc.; the server can be a stand-alone server or a server cluster composed of multiple servers. As shown in Figure 4 The method includes the following steps:

[0072] Step S202, obtaining an image to be detected;

[0073] Optionally, the image to be detected sent by an image acquisition device is received; or, the image to be detected sent by a request device is received, the request device can be a device providing a service based on the image to be detected, for example, a device providing an account opening service, a device providing a payment service, etc.; or, the image to be detected uploaded by a user is obtained, etc. The method for obtaining the image to be detected is not limited in the present specification, and can be set as needed in actual application.

[0074] In step S204, the image detection model is used to perform image detection processing on the to-be-detected image to obtain a detection result. The detection result represents the authenticity of the to-be-detected image. The image detection model is obtained by training a to-be-trained GAN model based on a training set. The training process includes updating the training set and training the to-be-trained GAN model based on the updated training set when it is determined that an optimization condition is met.

[0075] Specifically, the to-be-detected image is input into the image detection model, and the image detection model is used to perform target detection processing on the to-be-detected image to obtain an intermediate detection result. If the intermediate detection result indicates that the to-be-detected image does not contain a watermark, a detection result indicating that the to-be-detected image is a real image is generated. If the intermediate detection result indicates that the to-be-detected image contains a watermark, the image detection model is used to detect whether the watermark contained in the to-be-detected image is a real watermark. If the watermark contained in the to-be-detected image is a real watermark, a detection result indicating that the to-be-detected image is a real image is generated. If the watermark contained in the to-be-detected image is not a real watermark, a detection result indicating that the to-be-detected image is a fake image is generated.

[0076] In the embodiments of the present specification, the label of each training sample in the second training set used to train the image detection model (i.e., the discriminator of the GAN model) includes watermark information indicating whether a watermark is contained and watermark position information when a watermark is contained. That is, in the embodiments of the present specification, the existing label used only to indicate whether a watermark is contained is changed to a label containing watermark position information. Attack detection is ingeniously converted into target detection and authenticity detection, greatly improving the accuracy of watermark detection.

[0077] In one or more embodiments of the present specification, when the to-be-detected image is obtained, the image detection model is used to perform image detection processing on the to-be-detected image to obtain a detection result representing the authenticity of the to-be-detected image. Since the image detection model used in the image detection processing is obtained by training a to-be-trained GAN model based on a training set, and the training process includes updating the training set and training the to-be-trained GAN model based on the updated training set when it is determined that an optimization condition is met. Not only does it realize the dynamic updating of the training set, avoiding problems such as insufficient samples and low coverage in the training set, but also enables the subsequent training based on the updated training set to strengthen the training of the current weak areas of the GAN model, thereby improving the generalization ability and robustness of the GAN model, and further improving the accuracy of the detection result of the image detection model on the authenticity of the image. That is, the detection result obtained by using the image detection model to perform image detection processing on the to-be-detected image has high accuracy.

[0078] Corresponding to the training method of the image detection model described above, based on the same technical concept, one or more embodiments of the present specification also provide a training device of an image detection model.Figure 5 A schematic diagram of a module composition of a training device of an image detection model is provided for one or more embodiments of the present specification, as shown in Figure 5 The device comprises:

[0079] A training module 301 performs alternating training processing on a generator and a discriminator of a GAN model to be trained based on a training set, to obtain a trained GAN model; the generator is used to generate a false image containing a watermark, and the discriminator is used to detect the authenticity of an input image;

[0080] A detection module 302 inputs a plurality of first false images generated by the generator of the current GAN model into the discriminator of the current GAN model in sequence for image detection processing to obtain a detection result, if it is determined that a preset verification condition is met;

[0081] A determination module 303 determines whether the current GAN model meets an optimization condition according to the detection result; if the optimization condition is not met, the discriminator of the current GAN model is determined as a target image detection model;

[0082] An updating module 304 updates the training set according to the detection result if the determination result of the determination module is that the optimization condition is met.

[0083] The training module 301 also performs the alternating training processing based on the updated training set.

[0084] The training device of the image detection model provided by one or more embodiments of the present specification performs alternating training processing on the generator and the discriminator of the GAN model to be trained based on the training set, and obtains the trained GAN model; if it is determined that the preset verification condition is met, a plurality of first false images generated by the generator of the current GAN model are sequentially input into the discriminator of the current GAN model for image detection processing, and a detection result is obtained; whether the current GAN model meets the optimization condition is determined according to the detection result; if the optimization condition is met, the training set is updated according to the detection result, and the alternating training processing is performed based on the updated training set; if the optimization condition is not met, the discriminator of the current GAN model is determined as the target image detection model. Thus, in the training process of the image detection model, when it is determined that the verification condition is met, a plurality of first false images generated by the generator of the current GAN model are sequentially input into the discriminator of the current GAN model for image detection processing; and when it is determined that the current GAN model meets the optimization condition according to the detection result, the training set is updated according to the detection result, which not only realizes the dynamic update of the training set, avoids the problems of insufficient samples and low coverage range in the training set, but also enables the subsequent training based on the updated training set to strengthen the training of the current weak place of the GAN model, thereby improving the generalization ability and robustness of the GAN model, and further improving the accuracy of the detection result of the image detection model on the authenticity of the image.

[0085] It should be noted that the embodiments of the training device of the image detection model in the present specification are based on the same inventive concept as the embodiments of the training method of the image detection model in the present specification, and therefore the specific implementation of the embodiments can be referred to the foregoing implementation of the corresponding training method of the image detection model, and the repeated parts will not be described again.

[0086] Further, corresponding to the above-mentioned image detection method, based on the same technical concept, one or more embodiments of the present specification also provide an image detection device. Figure 6 A module composition diagram of an image detection device provided by one or more embodiments of the present specification is shown in Figure 6 As shown in the figure, the device comprises:

[0087] The acquisition module 401 acquires an image to be detected;

[0088] The detection module 402 performs image detection processing on the image to be detected based on the image detection model to obtain a detection result; the detection result represents the authenticity of the image to be detected;

[0089] The image detection model is obtained by training a GAN model based on a training set, and the training processing includes updating the training set and training based on the updated training set when it is determined that the optimization condition is met.

[0090] The image detection device provided by one or more embodiments of the present specification, when obtaining a to-be-detected image, performs image detection processing on the to-be-detected image based on an image detection model to obtain a detection result representing the authenticity of the to-be-detected image. Since the image detection model used in the image detection processing is obtained by training a to-be-trained GAN model based on a training set, and the training processing includes updating the training set and performing training processing based on the updated training set when it is determined that the optimization condition is met. It not only realizes the dynamic update of the training set, avoids the problems of insufficient samples and low coverage range in the training set, but also enables the training of the current weak place of the GAN model to be strengthened in the subsequent training based on the updated training set, thereby improving the generalization ability and robustness of the GAN model, and further improving the accuracy of the detection result of the image detection model on the authenticity of the image. That is, the detection result of the image detection processing based on the image detection model on the to-be-detected image has high accuracy.

[0091] It should be noted that the embodiments of the image detection device in the present specification are based on the same inventive concept as the embodiments of the image detection method in the present specification, and therefore the specific implementation of the embodiments can be referred to the foregoing implementation of the corresponding image detection method, and the repeated parts will not be described again.

[0092] Further, corresponding to the training method of the image detection model described above, based on the same technical concept, one or more embodiments of the present specification also provide a training device of an image detection model, which is used to execute the training method of the image detection model described above, Figure 7 A structural schematic diagram of a training device of an image detection model provided by one or more embodiments of the present specification.

[0093] As Figure 7 shown, the training device of the image detection model can have great differences due to different configurations or performances, and can include one or more processors 501 and memories 502, and one or more storage applications or data can be stored in the memories 502. Among them, the memory 502 can be temporary storage or persistent storage. The application stored in the memory 502 can include one or more modules (not shown in the figure), and each module can include a series of computer executable instructions in the training device of the image detection model. Further, the processor 501 can be configured to communicate with the memory 502, and execute a series of computer executable instructions in the memory 502 on the training device of the image detection model. The training device of the image detection model can also include one or more power supplies 503, one or more wired or wireless network interfaces 504, one or more input and output interfaces 505, one or more keyboards 506, etc.

[0094] In one specific embodiment, the training device of the image detection model comprises a memory and one or more programs, wherein one or more programs are stored in the memory, and one or more programs can include one or more modules, and each module can include a series of computer executable instructions for training the image detection model in the training device, and the one or more programs configured to be executed by one or more processors include computer executable instructions for:

[0095] Alternating training is performed on the generator and the discriminator of the to-be-trained GAN model based on the training set, to obtain a trained GAN model; the generator is used to generate false images containing watermarks, and the discriminator is used to detect the authenticity of input images;

[0096] If it is determined that the preset verification condition is met, a plurality of first false images generated by the generator of the current GAN model are sequentially input into the discriminator of the current GAN model for image detection processing, to obtain a detection result;

[0097] It is determined whether the current GAN model meets an optimization condition according to the detection result;

[0098] If the optimization condition is met, the training set is updated according to the detection result, and the alternating training is performed based on the updated training set; if the optimization condition is not met, the discriminator of the current GAN model is determined as a target image detection model.

[0099] The training device of the image detection model provided by one or more embodiments of the present specification performs alternating training processing on the generator and the discriminator of the to-be-trained GAN model based on the training set, to obtain the trained GAN model; if it is determined that the preset verification condition is met, a plurality of first fake images generated by the generator of the current GAN model are sequentially input into the discriminator of the current GAN model for image detection processing, to obtain a detection result; whether the current GAN model meets an optimization condition is determined according to the detection result; if the optimization condition is met, the training set is updated according to the detection result, and the alternating training processing is performed based on the updated training set; if the optimization condition is not met, the discriminator of the current GAN model is determined as the target image detection model. Thus, in the training process of the image detection model, when it is determined that the verification condition is met, a plurality of first fake images generated by the generator of the current GAN model are sequentially input into the discriminator of the current GAN model for image detection processing; and when it is determined that the current GAN model meets the optimization condition according to the detection result, the training set is updated according to the detection result, which not only realizes dynamic updating of the training set, avoids problems such as insufficient samples and low coverage range in the training set, but also enables the subsequent training based on the updated training set to strengthen the training of the current weak place of the GAN model, thereby improving the generalization ability and robustness of the GAN model, and further improving the accuracy of the detection result of the image detection model on the authenticity of the image.

[0100] Further, corresponding to the image detection method described above, based on the same technical concept, one or more embodiments of the present specification also provide an image detection device for executing the image detection method described above, Figure 8 FIG. 1 is a structural schematic diagram of an image detection device provided by one or more embodiments of the present specification.

[0101] As Figure 8 shown, the image detection device can have a large difference due to different configurations or performances, and can include one or more processors 601 and memories 602, and one or more storage applications or data can be stored in the memories 602. The memory 602 can be temporary storage or persistent storage. The application stored in the memory 602 can include one or more modules (not shown in the figure), and each module can include a series of computer executable instructions in the image detection device. Further, the processor 601 can be configured to communicate with the memory 602 and execute a series of computer executable instructions in the memory 602 on the image detection device. The image detection device can also include one or more power supplies 603, one or more wired or wireless network interfaces 604, one or more input and output interfaces 605, one or more keyboards 606, and the like.

[0102] In one specific embodiment, the image detection device comprises a memory and one or more programs, wherein one or more programs are stored in the memory, and the one or more programs can comprise one or more modules, and each module can comprise a series of computer-executable instructions in the image detection device, and the one or more programs configured to be executed by one or more processors include computer-executable instructions for performing the following:

[0103] obtaining an image to be detected;

[0104] performing image detection processing on the image to be detected based on an image detection model to obtain a detection result; the detection result represents the authenticity of the image to be detected;

[0105] The image detection model is obtained by training a GAN model to be trained based on a training set, and the training process includes updating the training set and training based on the updated training set when it is determined that the optimization condition is met.

[0106] The image detection device provided by one or more embodiments of the present specification, when obtaining an image to be detected, performs image detection processing on the image to be detected based on an image detection model to obtain a detection result representing the authenticity of the image to be detected. Since the image detection model used in the image detection processing is obtained by training a GAN model to be trained based on a training set, and the training process includes updating the training set and training based on the updated training set when it is determined that the optimization condition is met. Not only does it realize the dynamic update of the training set, avoiding the problems of insufficient samples and low coverage in the training set, but also enables the subsequent training based on the updated training set to strengthen the training of the current weak areas of the GAN model, thereby improving the generalization ability and robustness of the GAN model, and further improving the accuracy of the detection result of the image detection model on the authenticity of the image. That is, the detection result of the image detection processing on the image to be detected based on the image detection model has high accuracy.

[0107] It should be noted that the embodiments of the training device and the image detection device of the image detection model in the present specification are based on the same inventive concept as the embodiments of the training method and the image detection method of the image detection model in the present specification, and therefore the specific implementation of this embodiment can refer to the corresponding image detection model training method and image detection method implementation described above, and the repeated parts will not be repeated.

[0108] Further, based on the same technical concept, the training method of the image detection model and the image detection method described above, one or more embodiments of the present specification also provide a storage medium for storing computer executable instructions, in a specific embodiment, the storage medium can be a U disk, an optical disk, a hard disk, etc., and the computer executable instructions stored in the storage medium can implement the following process when executed by a processor:

[0109] Alternating training of the generator and the discriminator of the GAN model to be trained based on the training set is performed to obtain a trained GAN model; the generator is used to generate false images containing watermarks, and the discriminator is used to detect the authenticity of input images;

[0110] If it is determined that the preset verification condition is met, a plurality of first false images generated by the generator of the current GAN model are sequentially input into the discriminator of the current GAN model for image detection processing to obtain a detection result;

[0111] According to the detection result, it is determined whether the current GAN model meets an optimization condition;

[0112] If the optimization condition is met, the training set is updated according to the detection result, and the alternating training is performed based on the updated training set; if the optimization condition is not met, the discriminator of the current GAN model is determined as a target image detection model.

[0113] The storage medium provided by one or more embodiments of the present specification stores computer executable instructions which, when executed by a processor, perform the following processes: alternately training a generator and a discriminator of a GAN model to be trained based on a training set to obtain a trained GAN model; if it is determined that a preset verification condition is met, inputting a plurality of first fake images generated by the generator of the current GAN model into the discriminator of the current GAN model in sequence for image detection processing to obtain a detection result; determining whether the current GAN model meets an optimization condition according to the detection result; if the optimization condition is met, updating the training set according to the detection result and performing alternately training processing based on the updated training set; and if the optimization condition is not met, determining the discriminator of the current GAN model as a target image detection model. Thus, in the training process of the image detection model, when it is determined that the verification condition is met, a plurality of first fake images generated by the generator of the current GAN model are input into the discriminator of the current GAN model in sequence for image detection processing. When it is determined that the current GAN model meets the optimization condition according to the detection result, the training set is updated according to the detection result. Not only is the dynamic updating of the training set achieved, avoiding problems such as insufficient samples and low coverage range in the training set, but also the training of the current weak place of the GAN model is strengthened in the subsequent training based on the updated training set, thereby improving the generalization ability and robustness of the GAN model, and further improving the accuracy of the detection result of the image detection model on the authenticity of the image.

[0114] In another specific embodiment, the storage medium can be a U disk, an optical disk, a hard disk, etc. The computer executable instructions stored in the storage medium, when executed by a processor, can implement the following processes:

[0115] Obtaining an image to be detected;

[0116] Performing image detection processing on the image to be detected based on an image detection model to obtain a detection result; the detection result represents the authenticity of the image to be detected.

[0117] The image detection model is obtained by training a GAN model to be trained based on a training set. The training process includes updating the training set when it is determined that an optimization condition is met and training based on the updated training set.

[0118] The storage medium storing the computer executable instructions provided by one or more embodiments of the present specification, when executed by a processor, performs image detection processing on a to-be-detected image based on an image detection model when the to-be-detected image is acquired, to obtain a detection result representing the authenticity of the to-be-detected image. Since the image detection model used in the image detection processing is obtained by training a to-be-trained GAN model based on a training set, and the training processing includes updating the training set according to the detection result and performing training processing based on the updated training set when it is determined that the optimization condition is met. Not only does it realize the dynamic update of the training set, avoiding problems such as insufficient samples and low coverage in the training set, but also enables the training based on the updated training set to strengthen the training of the current weak place of the GAN model, thereby improving the generalization ability and robustness of the GAN model, and further improving the accuracy of the detection result of the image detection model on the authenticity of the image. That is, the detection result of the image detection processing on the to-be-detected image based on the image detection model has high accuracy.

[0119] It should be noted that the embodiments of the storage medium in the present specification and the embodiments of the training method of the image detection model and the image detection method in the present specification are based on the same inventive concept, so the specific implementation of this embodiment can refer to the foregoing implementation of the corresponding training method of the image detection model and the image detection method. The repeated parts will not be described again.

[0120] The above describes specific embodiments of the present specification. Other embodiments are within the scope of the appended claims. In some cases, the acts or steps recited in the claims can be performed in an order other than that in the embodiments and still achieve desirable results. In addition, the processes depicted in the figures do not necessarily require the particular order shown or sequential order to achieve the desired results. In certain implementations, multitasking and parallel processing can be utilized or can be advantageous.

[0121] In the 1990s, it was relatively easy to distinguish whether an improvement in a technology was a hardware improvement (e.g., an improvement in the circuit structure of a diode, transistor, switch, etc.) or a software improvement (an improvement in a method flow). However, as technology has evolved, many improvements in method flows today can be considered as direct improvements in hardware circuit structures. Designers almost always obtain the corresponding hardware circuit structures by programming the improved method flows into hardware circuits. Therefore, it cannot be said that an improvement in a method flow cannot be implemented using hardware entity modules. For example, a programmable logic device (PLD) (e.g., a field programmable gate array (FPGA)) is an integrated circuit whose logic function is determined by user programming of the device. A digital system is "integrated" on a PLD by the designer programming the PLD, rather than by ordering a chip manufacturer to design and fabricate a custom integrated circuit chip. Moreover, instead of manually fabricating integrated circuit chips, this programming is now mostly implemented using "logic compiler" software, which is similar to software compilers used in program development, and the original code to be compiled is written in a specific programming language, which is called a hardware description language (HDL), and there are many such languages, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc., and the most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should be aware that, as long as the method flow is logically programmed in the above-mentioned hardware description languages and programmed into an integrated circuit, a hardware circuit implementing the logical method flow can be easily obtained.

[0122] The controller can be implemented in any suitable way, for example, the controller can take the form of a microprocessor or processor and a computer readable medium storing computer readable program code, such as software or firmware, executable by the (micro)processor, logic gates, switches, an application specific integrated circuit (ASIC), a programmable logic controller and an embedded microcontroller, examples of which include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20 and Silicone Labs C8051F320, the memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also know that, in addition to implementing the controller purely in terms of computer readable program code, it is possible to implement the controller to perform the same functions using logic gates, switches, application specific integrated circuits, programmable logic controllers and embedded microcontrollers, by logically programming the method steps. The controller can therefore be considered a hardware component, and the means for performing the various functions comprised therein can be considered structures within the hardware component. Alternatively, or even additionally, the means for performing the various functions can be considered both software modules which implement the method and structures within the hardware component.

[0123] The systems, apparatuses, modules or units illustrated by the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer can be a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0124] For the sake of description, the above apparatuses are described in various units by functions respectively. Of course, the functions of each unit can be implemented in the same or multiple software and / or hardware in the implementation of the embodiments of the present specification.

[0125] Those skilled in the art will appreciate that one or more embodiments of the specification can be provided as a method, system or computer program product. Therefore, one or more embodiments of the specification can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the specification can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0126] The specification is presented with reference to flow diagrams and / or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the specification. It will be understood that each block of the flow diagrams and / or block diagrams, and combinations of blocks in the flow diagrams and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processing element or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flow diagrams and / or block diagrams block or blocks. Figure 1 The flow diagrams and / or block diagrams in the specification can present a method, apparatus or computer program product according to embodiments of the specification. Flow diagrams and / or block diagrams can also present a method, apparatus or computer program product to achieve functions specified in flow diagrams and / or block diagrams block or blocks. Figure 1 The flow diagrams and / or block diagrams in the specification can present a method, apparatus or computer program product according to embodiments of the specification. Flow diagrams and / or block diagrams can also present a method, apparatus or computer program product to achieve functions specified in flow diagrams and / or block diagrams block or blocks.

[0127] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the flow diagrams and / or block diagrams block or blocks. Figure 1 The flow diagrams and / or block diagrams in the specification can present a method, apparatus or computer program product according to embodiments of the specification. Flow diagrams and / or block diagrams can also present a method, apparatus or computer program product to achieve functions specified in flow diagrams and / or block diagrams block or blocks. Figure 1 The flow diagrams and / or block diagrams in the specification can present a method, apparatus or computer program product according to embodiments of the specification. Flow diagrams and / or block diagrams can also present a method, apparatus or computer program product to achieve functions specified in flow diagrams and / or block diagrams block or blocks.

[0128] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the flow diagrams and / or block diagrams block or blocks. Figure 1 The flow diagrams and / or block diagrams in the specification can present a method, apparatus or computer program product according to embodiments of the specification. Flow diagrams and / or block diagrams can also present a method, apparatus or computer program product to achieve functions specified in flow diagrams and / or block diagrams block or blocks. Figure 1 The flow diagrams and / or block diagrams in the specification can present a method, apparatus or computer program product according to embodiments of the specification. Flow diagrams and / or block diagrams can also present a method, apparatus or computer program product to achieve functions specified in flow diagrams and / or block diagrams block or blocks.

[0129] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.

[0130] The memory can include non-persistent memory and / or persistent memory, such as flash memory, read-only memory (ROM), and / or volatile / non-volatile random access memory (RAM), among others. The memory is an example of computer-readable media.

[0131] Computer-readable media includes permanent and non-permanent, movable and non-movable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette, magnetic tape disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible to a computing device. According to the definition herein, computer-readable media does not include transitory media such as modulated data signals and carriers.

[0132] It should also be noted that the terms "comprising", "containing", or any other variant thereof are intended to cover non-exclusive inclusion, such that processes, methods, articles or devices that include a series of elements not only include those elements, but also include other elements not explicitly listed or inherent to such processes, methods, articles or devices. Without more limitations, the element defined by the statement "comprising a" does not exclude the presence of additional identical elements in the process, method, article or device comprising the element.

[0133] One or more embodiments of the specification can be described in the general context of computer-executable instructions being executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. One or more embodiments of the specification can also be practiced in a distributed computing environment, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media, including storage devices.

[0134] Various embodiments in the specification are described in a progressive manner, and the same or similar parts between various embodiments can be referred to each other, and each embodiment focuses on the difference from other embodiments. In particular, for system embodiments, since they are basically similar to method embodiments, the description is relatively simple, and the relevant parts can be referred to the part of the method embodiment.

[0135] The above merely provides the example of the present document and is not intended to limit the present document. For those skilled in the art, the present document can have various modifications and changes. Any modification, equivalent replacement, improvement, etc. within the spirit and principle of the present document shall be included in the scope of claims of the present document.

Claims

1. A training method for an image detection model, comprising: A first training set is constructed based on a preset watermark style set and multiple first real images without watermarks. The watermark style set includes multiple types of watermark styles, and each type of watermark style includes multiple sub-styles. Based on the first training set, the generator and discriminator of the GAN model to be trained are trained alternately to obtain the trained GAN model; the generator is used to generate fake images with watermarks, and the discriminator is used to detect the authenticity of the input image. If the preset verification conditions are met, the multiple first fake images generated by the generator of the current GAN model are sequentially input into the discriminator of the current GAN model for image detection processing to obtain the detection result. Based on the detection results, determine whether the current GAN model meets the optimization conditions; If the optimization conditions are met, the first training set is updated according to the detection results, and the alternating training process is performed based on the updated first training set. If the optimization conditions are not met, the discriminator of the current GAN model will be determined as a target image detection model.

2. The method according to claim 1, wherein the alternating training process of the generator and discriminator of the GAN model to be trained based on the first training set includes: Based on the first training set, the generator of the GAN model to be trained is iteratively trained in the current training round to obtain the trained generator. The current second training set is constructed based on multiple second fake images generated by the trained generator. Based on the current second training set, the discriminator of the GAN model to be trained is subjected to iterative training in the current training round to obtain the trained discriminator; If it is determined that the verification conditions are not met, then the alternating training process is performed in the next training round.

3. The method according to claim 1, wherein constructing a first training set based on a preset watermark style set and multiple first real images without watermarks includes: Randomly select multiple first target watermark styles from a preset watermark style set, wherein each first target watermark style includes a sub-style of each type of watermark style; Each of the first target watermark styles is combined with at least one of the first real images to obtain at least one first training sample; Each of the first training samples obtained is determined as the first training set.

4. The method according to claim 3, wherein randomly selecting multiple first target watermark styles from a preset watermark style set includes: For each type of watermark style, randomly generate a one-hot vector or a random number; Based on the onehot vector or the random number, select the target sub-style from multiple sub-styles included in the corresponding type of watermark style; The target sub-styles of various watermark styles are spliced ​​together to obtain the first target watermark style.

5. The method according to claim 2, wherein constructing the current second training set based on the plurality of fake images generated by the trained generator comprises: Obtain multiple second real images from a specified image set; From the set of watermark styles, randomly select multiple second target watermark styles corresponding to each second real image; For each second real image, the second real image is combined with each corresponding second target watermark style to obtain multiple first samples to be generated; Each of the first samples to be generated is sequentially input into the trained generator for image generation processing to obtain the corresponding second fake image; The obtained second fake images and each image in the specified image set are determined as the current second training set.

6. The method according to claim 3, wherein after determining that the preset verification conditions are met, the method further includes: Obtain each real image that has been trained from the first training set; From the set of watermark styles, randomly select multiple third-target watermark styles corresponding to each trained real image; For each trained real image, the trained real image is combined with each corresponding third target watermark style to obtain multiple second samples to be generated; Each of the second samples to be generated is sequentially input into the generator of the current GAN model for image generation processing to obtain the corresponding first fake image.

7. The method according to claim 6, wherein updating the first training set based on the detection result comprises: Optimization information is determined based on the detection results; The first training set is updated based on the optimization information.

8. The method according to claim 7, wherein determining optimization information based on the detection result includes: The detection results are subjected to Bayesian optimization to obtain the fourth target watermark style to be learned by the generator of the current GAN model; The fourth target watermark style is determined as optimized information; Updating the first training set based on the optimization information includes: Obtain real target samples from the first training set; The first training set is updated based on the fourth target watermark style and the target real sample.

9. An image detection method, comprising: Acquire the image to be detected; The image to be detected is processed using an image detection model to obtain the detection result. The detection result characterizes the degree of authenticity of the image to be detected; The image detection model is obtained by alternating training of the GAN model to be trained based on a first training set. The alternating training process includes updating the first training set when the optimization conditions are met and performing the alternating training process based on the updated first training set. The first training set is constructed according to a preset watermark style set and multiple first real images without watermarks. The watermark style set includes multiple types of watermark styles, and each type of watermark style includes multiple sub-styles.

10. The method according to claim 9, wherein the image detection processing of the image to be detected based on the image detection model to obtain the detection result includes: The image to be detected is input into the image detection model, and the image detection model performs target detection processing on the image to be detected to obtain intermediate detection results; If the intermediate detection result does not contain a watermark, then a detection result is generated that indicates the image to be detected is a real image; If the intermediate detection result indicates that a watermark is present, then the image detection model is used to detect whether the watermark in the image to be detected is a real watermark. If the watermark contained in the image to be detected is a real watermark, then a detection result is generated that indicates that the image to be detected is a real image; If the watermark contained in the image to be detected is not a genuine watermark, a detection result is generated indicating that the image to be detected is a fake image.

11. A training device for an image detection model, comprising: The training module constructs a first training set based on a preset set of watermark styles and multiple real images without watermarks. The watermark style set includes multiple types of watermark styles, and each type of watermark style includes multiple sub-styles. Based on the first training set, the generator and discriminator of the GAN model to be trained are trained alternately to obtain the trained GAN model. The generator is used to generate fake images with watermarks, and the discriminator is used to detect the authenticity of the input image. If the detection module determines that the preset verification conditions are met, it sequentially inputs the multiple first fake images generated by the generator of the current GAN model into the discriminator of the current GAN model for image detection processing to obtain the detection result. The determination module determines whether the current GAN model meets the optimization conditions based on the detection results. If the optimization conditions are not met, the discriminator of the current GAN model will be determined as the target image detection model. The update module updates the first training set based on the detection result if the determination result of the determination module satisfies the optimization conditions. The training module also performs the alternating training process based on the updated first training set.

12. An image detection apparatus, comprising: The acquisition module acquires the image to be detected; The detection module performs image detection processing on the image to be detected based on an image detection model to obtain the detection result; The detection result characterizes the degree of authenticity of the image to be detected; The image detection model is obtained by alternating training of the GAN model to be trained based on a first training set. The alternating training process includes updating the first training set when the optimization conditions are met and performing the alternating training process based on the updated first training set. The first training set is constructed according to a preset watermark style set and multiple first real images without watermarks. The watermark style set includes multiple types of watermark styles, and each type of watermark style includes multiple sub-styles.

13. A training device for an image detection model, characterized in that, include: processor; as well as, A memory configured to store computer-executable instructions, which, when executed, cause the processor to: A first training set is constructed based on a preset watermark style set and multiple first real images without watermarks. The watermark style set includes multiple types of watermark styles, and each type of watermark style includes multiple sub-styles. Based on the first training set, the generator and discriminator of the GAN model to be trained are trained alternately to obtain the trained GAN model; the generator is used to generate fake images with watermarks, and the discriminator is used to detect the authenticity of the input image. If the preset verification conditions are met, the multiple first fake images generated by the generator of the current GAN model are sequentially input into the discriminator of the current GAN model for image detection processing to obtain the detection result. Based on the detection results, determine whether the current GAN model meets the optimization conditions; If the optimization conditions are met, the first training set is updated according to the detection results, and the alternating training process is performed based on the updated first training set. If the optimization conditions are not met, the discriminator of the current GAN model will be determined as a target image detection model.

14. An image detection device, characterized in that, include: processor; as well as, A memory configured to store computer-executable instructions, which, when executed, cause the processor to: Acquire the image to be detected; The image to be detected is processed using an image detection model to obtain a detection result; the detection result characterizes the realism of the image to be detected. The image detection model is obtained by alternating training of the GAN model to be trained based on a first training set. The alternating training process includes updating the first training set when the optimization conditions are met and performing the alternating training process based on the updated first training set. The first training set is constructed according to a preset watermark style set and multiple first real images without watermarks. The watermark style set includes multiple types of watermark styles, and each type of watermark style includes multiple sub-styles.

15. A computer-readable storage medium for storing computer-executable instructions, which, when executed by a processor, perform the following process: A first training set is constructed based on a preset watermark style set and multiple first real images without watermarks. The watermark style set includes multiple types of watermark styles, and each type of watermark style includes multiple sub-styles. Based on the first training set, the generator and discriminator of the GAN model to be trained are trained alternately to obtain the trained GAN model; the generator is used to generate fake images with watermarks, and the discriminator is used to detect the authenticity of the input image. If the preset verification conditions are met, the multiple first fake images generated by the generator of the current GAN model are sequentially input into the discriminator of the current GAN model for image detection processing to obtain the detection result. Based on the detection results, determine whether the current GAN model meets the optimization conditions; If the optimization conditions are met, the first training set is updated according to the detection results, and the alternating training process is performed based on the updated first training set. If the optimization conditions are not met, the discriminator of the current GAN model will be determined as a target image detection model.

16. A computer-readable storage medium for storing computer-executable instructions, which, when executed by a processor, perform the following process: Acquire the image to be detected; The image to be detected is processed using an image detection model to obtain a detection result; the detection result characterizes the realism of the image to be detected. in, The image detection model is obtained by alternating training of the GAN model to be trained based on the first training set. The alternating training process includes updating the first training set when the optimization conditions are met and performing the alternating training process based on the updated first training set. The first training set is constructed according to a preset watermark style set and multiple first real images without watermarks. The watermark style set includes multiple types of watermark styles, and each type of watermark style includes multiple sub-styles.

Citation Information

Patent Citations

  • Model training method and device

    CN110659657A