A method, apparatus, and device for verifying image generation
By acquiring the prediction labels and sample image labels of the sample image, and combining the image generation algorithm to generate candidate verification images, the problem of low initial sample number leads to low efficiency in the generation of verification code images is solved, and the effect of quickly and efficiently generating a large number of verification code images is achieved.
Patent Information
- Application Number
- CN202110123699.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-29
- Publication Date
- 2025-06-13
- Estimated Expiration
- 2041-01-29
AI Technical Summary
In the prior art, when generating verification code images, if the number of initial sample images is small, it is difficult to quickly and effectively generate a large number of verification code images. In order to avoid duplication, large distortions of the image are required, resulting in low generation efficiency.
By acquiring the prediction label and sample image label of the sample image, a prior loss is determined; a candidate verification image is generated using the second sample image based on the image generation algorithm, and the posterior loss is calculated; when the prior loss and posterior loss meet the conditions, the candidate verification image is determined as a verification image.
There is no need to manually label all sample images one by one, to avoid excessive differences between the generated images and the previous images, and to improve the generation efficiency and effective utilization of verification code images.
Smart Images

Figure CN112801186B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of this specification relate to the field of artificial intelligence technology, and particularly to a method, device, and equipment for verifying image generation. Background Art
[0002] In order to ensure the information security of users and verify the true identities of users, when users perform account logins, financial transactions, and other network services, it is generally necessary to display corresponding verification code images to users, and the users input the characters recognized from the verification code images, so as to authenticate the user identities and achieve effects such as human-machine recognition.
[0003] Currently, with the popularization of the Internet and the needs of various network affairs, the demand for the number of verification code images is gradually increasing. In order to meet the demand for the number of verification code images, when generating verification code images currently, it often relies on a certain number of sample verification images and generates verification code images through corresponding algorithms. However, when generating verification code images currently, if the number of sample verification images provided in the initial state is small, the corresponding number of verification code images that can be obtained will also be small. If the number of generated verification code images is increased on this basis, in order to avoid a high degree of repetition between verification code images, it is generally necessary to greatly distort or modify the images, and thus the obtained verification code images often need to be manually verified and secondarily annotated, which greatly reduces the generation efficiency of verification code images. Therefore, there is an urgent need for a method that can quickly and effectively generate a large number of verification code images. Summary of the Invention
[0004] The purpose of the embodiments of this specification is to provide a method, device, and equipment for verifying image generation to solve the technical problem of how to effectively generate a large number of available verification images.
[0005] To solve the above technical problems, an embodiment of this specification proposes a method for generating verification images, including: obtaining a first predicted label of a first sample image; the first sample image corresponds to a sample image label; the sample image label is used to describe the characters presented in the first sample image; the first predicted label represents the classification category obtained after classifying and recognizing the first sample image; determining a prior loss according to the first predicted label and the sample image label; the prior loss is used to represent the ratio of the first predicted label to the first sample image; generating a candidate verification image based on an image generation algorithm using a second sample image; the image generation algorithm is used to construct the difference between the candidate verification image and the second sample image; calculating a posterior loss using the second sample image and the candidate verification image; the posterior loss is used to represent the degree of difference between the second sample image and the candidate verification image; when the prior loss and the posterior loss meet the picture application conditions, determining the candidate verification image as the verification image; the verification image is used to verify the user identity.
[0006] An embodiment of this specification also proposes a verification image generation device, including: a first predicted label determination module, configured to obtain a first predicted label of a first sample image; the first sample image corresponds to a sample image label; the sample image label is used to describe the characters presented in the first sample image; the first predicted label represents the classification category obtained after classifying and recognizing the first sample image; a prior loss determination module, configured to determine a prior loss according to the first predicted label and the sample image label; the prior loss is used to represent the ratio of the first predicted label to the first sample image; a candidate verification image generation module, configured to generate a candidate verification image based on an image generation algorithm using a second sample image; the image generation algorithm is used to construct the difference between the candidate verification image and the second sample image; a posterior loss calculation module, configured to calculate a posterior loss using the second sample image and the candidate verification image; the posterior loss is used to represent the degree of difference between the second sample image and the candidate verification image; a verification image determination module, configured to determine the candidate verification image as the verification image when the prior loss and the posterior loss meet the picture application conditions; the verification image is used to verify the user identity.
[0007] A verification image generation device includes a memory and a processor; the memory is used to store computer program instructions; the processor is used to execute the computer program instructions to implement the following steps: obtaining a first predicted label of a first sample image; the first sample image corresponds to a sample image label; the sample image label is used to describe the character presented by the first sample image; the first predicted label represents the classification category obtained after classifying and recognizing the first sample image; determining a prior loss according to the first predicted label and the sample image label; the prior loss is used to represent the ratio of the first predicted label to the first sample image; generating a candidate verification image based on an image generation algorithm using a second sample image; the image generation algorithm is used to construct the difference between the candidate verification image and the second sample image; calculating a posterior loss using the second sample image and the candidate verification image; the posterior loss is used to represent the degree of difference between the second sample image and the candidate verification image; when the prior loss and the posterior loss meet the picture application conditions, determining the candidate verification image as a verification image; the verification image is used to verify the user identity.
[0008] As can be seen from the technical solutions provided in the embodiments of this specification above, after obtaining the first sample image with the sample image label, the embodiments of this specification determine the first predicted label representing the category of the first sample image and determine the prior loss. Then, a candidate verification image is generated using the second sample image, and the posterior loss is calculated using the second sample image and the candidate verification image, so that after comprehensively considering the prior loss and the posterior loss, a verification image can be selected from the candidate verification images to verify the user identity. The above method does not require manual annotation of all sample images one by one, and after generating the images, it can also avoid the generated images being too different from the previous images, thereby ensuring the effective utilization of the generated verification images and reducing the time and resources consumed by manual annotation. Description of the Drawings
[0009] In order to more clearly illustrate the technical solutions in the embodiments of this specification or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments recorded in this specification. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0010] Figure 1 It is a flowchart of a verification image generation method according to an embodiment of this specification;
[0011] Figure 2 It is a schematic diagram of a process for calculating the prior loss according to an embodiment of this specification;
[0012] Figure 3Schematic diagram of a process for obtaining candidate verification images in an embodiment of this specification;
[0013] Figure 4 Schematic diagram of a process for calculating posterior loss in an embodiment of this specification;
[0014] Figure 5 Schematic diagram of a process for calculating final loss and applying verification images in an embodiment of this specification;
[0015] Figure 6 Schematic diagram of the whole process of a verification image generation method in an embodiment of this specification;
[0016] Figure 7 Module diagram of a verification image generation device in an embodiment of this specification;
[0017] Figure 8 Structural diagram of a verification image generation device in an embodiment of this specification. Detailed implementation manners
[0018] Next, the technical solutions in the embodiments of this specification will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of this specification. Obviously, the described embodiments are only a part of the embodiments of this specification, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in this specification without creative efforts shall fall within the protection scope of this specification.
[0019] To solve the above technical problems, an embodiment of this specification first proposes a verification image generation method. The execution subject of the verification image generation method is a verification image generation device, and the verification image generation device includes but is not limited to a server, an industrial control computer, a PC, etc. As Figure 1 shown, the verification image generation method may specifically include the following steps.
[0020] S110: Obtain a first prediction label of a first sample image; the first sample image corresponds to a sample image label; the sample image label is used to describe the characters presented by the first sample image; the first prediction label represents the classification category obtained after classifying and identifying the first sample image.
[0021] The first sample image and the second sample image may belong to the original sample image. The original sample image may be an image acquired before the verification image generation method is executed. The original sample image may be used to verify the user's identity. For example, the original sample image contains distorted, colored, or rotated characters. When ensuring that the characters in the verification image have a certain degree of distortion, the computer may not be able to directly recognize the characters in the image. However, people can often identify the characters in the image, thus realizing human-machine recognition through the original sample image, verifying the user's identity, and reducing the probability of illegal acts such as account scanning and database dragging through computer programs.
[0022] When using the verification image to verify the user's identity, the server performing the verification operation needs to store the actual labels corresponding to each verification image. The actual label is used to represent the actual content of the verification image. After receiving the input content fed back by the client, the server compares the input content with the actual label to determine whether the input content corresponds to the characters in the verification image, thus completing the identity verification process. Therefore, before applying the verification image, it is necessary to determine the actual label corresponding to the verification image.
[0023] The original sample image may not have corresponding label content at the initial stage. Therefore, it is necessary to determine the label corresponding to the original sample image to better apply the image. However, in the case of a large number of original sample images, manually labeling each original sample image will consume a large amount of manpower and time, which obviously does not conform to the actual application scenario.
[0024] Therefore, in the above embodiment, the original sample image can be divided into a first sample image and a second sample image. The quantity ratio of the first sample image and the second sample image can be set according to the actual application requirements. For example, it can be allocated according to a ratio of one to one, or according to a ratio of one to five. There is no limit to the specific allocation ratio, and it can be flexibly adjusted according to the actual application situation.
[0025] After determining the first sample image, the first sample image can be labeled. Labeling means sequentially determining the sample image labels of each first sample image. The sample image label is used to describe the characters presented in the first sample image. For example, when the image presented in a certain first sample image is the distorted "8ER0", the corresponding sample image label should be "8ER0". The sample image labels include but are not limited to Arabic numerals, capital English letters, lowercase English letters, simplified Chinese characters, traditional Chinese characters, etc. By expanding the styles of the sample image labels, the difficulty of machine recognition of the verification image can be increased, effectively ensuring the effect of human-machine recognition.
[0026] The specific labeling process may be to push the first sample image to the client. After the operator identifies the characters in the first sample image and inputs the corresponding label, after the client feeds back the label, the label is stored as the sample image label corresponding to the first sample image. The specific labeling process can be set according to the requirements of actual applications and is not limited to the above example, so it will not be elaborated here.
[0027] After obtaining the first sample image corresponding to the sample image label, the first prediction label corresponding to the first sample image can also be determined. The first prediction label may be the label obtained by classifying and identifying the first sample image. Specifically, it may be the character represented in the first sample image determined by means of image recognition, or it may just be to divide the image into the corresponding categories set in advance. There may be a certain error in the first prediction label, that is, there is a possibility that the first prediction label does not correspond to the actual sample image label.
[0028] In some embodiments, the classification model can be trained to obtain the first prediction label by using the classification model. In this embodiment, the classification model can be a mathematical model for determining the category to which the character corresponding to the picture belongs. The classification model can be a Bayesian classification model, a support vector machine classification model (Support Vector Machine, SVM), or a convolutional neural network classification model (Convolutional Neural Networks, CNN), etc. The classification model can be a risk classification model, an emotion classification model, or a topic classification model, etc. Of course, the classification model can not only be used to identify the first prediction label, but also be used to identify the labels corresponding to other images.
[0029] Specifically, the first sample image and the sample image label can be used as training samples to train the classification model. Since the number of first sample images is small in the initial state, a neural network model with a shallow layer and few rounds can be used to construct the classification model. Since the training data has corresponding labels, the classification model can be trained by means of supervised learning. The specific training process can be set according to the model settings and the actual operation process, so it will not be elaborated here.
[0030] After obtaining the classification model, the classification model can be used to identify the first prediction label. For example, the first sample image can be directly input into the classification model to obtain the corresponding first prediction label.
[0031] Through the above steps, the training of the model is directly realized by using the original sample data without the need to obtain other sample data additionally, which simplifies the process of step execution, and the first predicted label obtained by recognition can also be used for the calculation in subsequent steps.
[0032] S120: Determine the prior loss according to the first predicted label and the sample image label; the prior loss is used to represent the ratio corresponding to the first predicted label and the first sample image.
[0033] After obtaining the predicted label, the prior loss can be determined by comparing the predicted label and the sample image label. The prior loss can be used to describe the ratio corresponding to the predicted label and the first sample image. Correspondingly, in the case of using the classification model to determine the first predicted label, the prior loss can also be used to describe the accuracy rate of the label recognized by the classification model, so as to comprehensively evaluate whether the generated image meets the standard of the verification image in subsequent steps.
[0034] Specifically, the conditional probability P θ (y|x) corresponding to the sample and the label can be determined according to the sample image label and the predicted label, and then the prior loss L trior is calculated by using the conditional probability. For example, the conditional probability can be directly used as the prior loss.
[0035] The following combines the attached Figure 2 , and introduces a scenario example of obtaining the prior loss. As Figure 2 shown, after obtaining the first sample image 21, the sample image label 22 of the first sample image 21 is also obtained. Then the first sample image 21 is used to train the classification model 23, and the classification model 23 is used to determine the first predicted label 24 corresponding to the first sample image 21. The prior loss 25 can be obtained by comprehensively considering the correspondence between the first predicted label 24 and the sample image label 22.
[0036] S130: Use the second sample image to generate a candidate verification image based on the image generation algorithm; the image generation algorithm is used to construct the difference between the candidate verification image and the second sample image.
[0037] The candidate verification image can be generated according to the second sample image. In order to increase the number of verification images, on the basis of the original sample image, the sample image needs to be modified to a certain extent so that there is a certain difference between the candidate verification image and the second sample image. Since the second sample image has no label, the corresponding generated candidate verification image also has no label.
[0038] When generating a candidate verification image, an image generation algorithm can be used to modify the second sample image. The image generation algorithm is used to construct the difference between the candidate verification image and the second sample image. Specifically, the process of generating a candidate verification image can be regarded as a propagation of the second sample image, and information loss occurs during the propagation, which can also be regarded as a conditional probability. Assume the second sample image is X, and the generated candidate verification image is Then the process of image generation is The image generation algorithm is used to determine of the algorithm.
[0039] In some embodiments, the image generation algorithm can be the GAN (Generative Adversarial Networks) algorithm. The GAN algorithm is a deep learning algorithm based on unsupervised learning, and one of its important uses is to generate images. For example, a new image can be generated by receiving certain noise data and then the image can be discriminated. The specific way to use GAN to generate candidate verification images can be set according to the actual application requirements and will not be elaborated here. The degree of difference between the second sample image and the candidate verification image can be reflected in the GAN algorithm itself, so the degree of modification to the second sample image can also be changed by adjusting the GAN algorithm itself. The GAN algorithm can generate candidate verification images conveniently and quickly, accelerating the progress of the process execution.
[0040] The following combines the attached Figure 3 to illustrate a specific scenario example of this step. As Figure 3 shown, after obtaining the second sample image 31, the second sample image 31 can be directly input into the GAN network 32 to obtain the candidate verification image 33.
[0041] By generating candidate verification images in the above manner, the number of sample images is expanded. After subsequent screening, the number of applicable verification images can be increased, thus meeting the requirements for verification images.
[0042] S140: Calculate the posterior loss using the second sample image and the candidate verification image; the posterior loss is used to represent the degree of difference between the second sample image and the candidate verification image.
[0043] After obtaining the candidate verification image, the second prediction label corresponding to the second sample image and the third prediction label corresponding to the candidate verification image can be obtained respectively. The second prediction label can be the label obtained after classifying and recognizing the second sample image, and the third prediction label can be the label obtained after classifying and recognizing the candidate verification image, that is, the second prediction label and the third prediction label can respectively represent the results obtained after recognizing the characters in the corresponding images.
[0044] In some embodiments, the classification model trained in step S110 can be used to determine the second prediction label corresponding to the second sample image and the third prediction label corresponding to the candidate verification image respectively. The specific classification and recognition process can refer to the introduction in step S110 and will not be elaborated here.
[0045] After obtaining the second prediction label and the third prediction label, the posterior loss can be calculated according to the second prediction label and the third prediction label. The posterior loss can be used to represent the degree of difference between the candidate verification image and the second sample image. In subsequent steps, by comprehensively considering the prior loss and the posterior loss, it can be determined whether the generated candidate verification image has too large a deviation, so as to judge whether the candidate verification image can be actually applied.
[0046] In some embodiments, to calculate the posterior loss, the first conditional probability can be calculated first according to the second prediction label and the second sample image, and the first conditional probability is used to represent the proportion corresponding to the second prediction label and the second sample image. Then, the second conditional probability is calculated according to the third prediction label and the candidate verification image, and the second conditional probability represents the proportion corresponding to the third prediction label and the candidate verification image. The calculation of the posterior probability is completed by combining the first conditional probability and the second conditional probability.
[0047] Specifically, the first conditional probability can be calculated by softmax(l(x) / τ), and the conditional probability corresponding to the second prediction label and the second sample image is obtained as where l(x) is the logical distribution probability of the prediction result, τ is an adjustment factor, and the larger τ is, the more dispersed the distribution is. Softmax is an important function in machine learning, especially widely used in multi-classification scenarios. It maps some inputs to real numbers between 0 and 1 and normalizes to ensure that the sum is 1, so the sum of the probabilities of multi-classification is also exactly 1. In the process of classifying and recognizing the second sample image, the accuracy of the classification and recognition result is guaranteed.
[0048] Correspondingly, the second conditional probability can also be obtained in the same way. Assume that the second sample image is X and the generated candidate verification image is Combined with the obtained third prediction label, the conditional probability that the third prediction label corresponds to the candidate verification image is
[0049] After calculating the first conditional probability and the second conditional probability, the posterior loss can be calculated according to the first conditional probability and the second conditional probability. Specifically, the formula can be used to calculate the posterior loss, where is the posterior loss, D KL is the divergence, is the first conditional probability, is the second conditional probability. The above formula determines the posterior loss by determining the divergence between the first conditional probability and the second conditional probability, so as to determine the deviation of the candidate verification image from the second sample image according to the correlation degree between the first conditional probability and the second conditional probability, and then accurate calculations can be carried out in the subsequent process.
[0050] A specific scenario example is used for illustration. As Figure 4 shown, after obtaining the second sample image 41, the second sample image 41 can be input into the GAN network 43 to obtain the candidate verification image 44, and then the first conditional probability 42 and the second conditional probability 45 of the second sample image 41 and the candidate verification image 44 are obtained respectively. Finally, the posterior loss 46 is obtained by combining the first conditional probability 42 and the second conditional probability 45.
[0051] S150: When the prior loss and the posterior loss meet the picture application conditions, determine the candidate verification image as the verification image; the verification image is used to verify the user identity.
[0052] After obtaining the prior loss and the posterior loss, the prior loss and the posterior loss can be combined to determine whether the generated candidate verification image meets the requirements of actual applications. Since the prior loss represents the accuracy of the classification model, and the posterior loss represents the degree of difference between the second sample image and the candidate verification image determined based on the classification model, the prior loss and the posterior loss can be combined to determine whether the difference between the candidate verification image and the second sample image is too large.
[0053] In some embodiments, when determining whether the prior loss and the posterior loss meet the picture application conditions, the final loss can be obtained by combining the prior loss and the posterior loss, and then determined based on the final loss.
[0054] In practical applications, for a certain second sample image, multiple candidate verification images can be generated using an image generation algorithm. To ensure the usability of the finally obtained image, the minimum posterior loss can be selected from these candidate verification images as the target posterior loss. Correspondingly, there is a minimum degree of difference between the target posterior loss and the corresponding second sample image. Subsequently, the final loss can be obtained by integrating the prior loss and the target posterior loss. By comparing the final loss with a determination threshold, when the final loss is not greater than the determination threshold, the candidate verification image corresponding to the target posterior loss can be determined as the verification image.
[0055] The determination threshold can be a pre-set determination criterion for calibrating the maximum difference between the candidate verification image and the sample image. The determination threshold can be directly set by an operator based on work experience, or can be data obtained through deep learning model training, and there is no limitation on this.
[0056] In some specific examples, the formula is used to calculate the final loss, where is the final loss, L trior is the prior loss, λ is an adjustment coefficient, and L posterior is the target posterior loss. The adjustment coefficient can be adjusted according to application requirements. Generally, the adjustment coefficient can be set to 1.
[0057] In practical applications, the prior loss and the posterior loss can also be integrated in other ways, and corresponding picture application conditions can be set to determine the verification image, which is not limited to the above examples and will not be elaborated here.
[0058] After obtaining the verification image, the verification image can be used to verify the user. In some embodiments, after obtaining the verification image, the verification image can be labeled to enable the verification image to have the function of verification. Since the verification image can have the same label as the corresponding second sample image, the time consumed for labeling is reduced.
[0059] In some embodiments, after determining the verification image, since the verification image corresponds to a corresponding label, the verification image can be used as the first sample image to iteratively train the classification model. Since the number of first sample images used to train the classification model is small initially, the trained classification model may lack a certain degree of accuracy. Therefore, the newly generated verification image can be used as training data to retrain the classification model, thereby improving the classification and recognition accuracy of the classification model and enabling the verification image to be obtained faster and better in subsequent steps. The specific training process can be set according to the actual application situation and will not be elaborated here.
[0060] In some embodiments, after determining the verification images, certain verification images can also be screened from the verification images to optimize the image generation algorithm. Since the differential adjustment of the candidate verification images is determined by the image generation algorithm, when the adjustment degree of the image generation algorithm for the second sample image is too high or too low, it will affect the effect of the generated candidate verification images, and the verification images are the images determined by screening that can be used to verify the user identity. Therefore, the image generation algorithm can be optimized in combination with the criteria of the verification images, so as to improve the quality of the generated candidate verification images and be able to obtain verification images faster and better in subsequent steps. The specific process of optimizing the image verification algorithm using the verification images can be set according to the requirements of actual applications and will not be elaborated here.
[0061] A specific scenario example is used to illustrate the above steps, as Figure 5 shown, after obtaining the prior loss 51 and the posterior loss 52, the final loss 53 is obtained by integrating the prior loss 51 and the posterior loss 52, and then step 54 is executed to obtain some images with small final loss for label transfer and use them for the training of the classification model. Another part of the unlabeled verification images is taken and put into the GAN for training.
[0062] Based on the above verification image generation method, a specific scenario example is used to illustrate the above process. As Figure 6 shown, first, after obtaining the original sample image 610, the original sample image 610 is split into a first sample image 620 and a second sample image 660. Then, step 630 is executed to perform image annotation on the first sample image. Step 640 is executed to train the classification model using the annotated first sample image, and step 650 is executed to calculate the prior loss according to the classification result of the classification model and the annotation result of the image. For the second sample image 660, first, step 670 is executed to input the second sample image into the GAN network to obtain candidate verification images. Step 680 is executed to perform a consistency determination on the second sample image and the candidate verification images, and according to the determination result, step 690 is executed to calculate the posterior loss. Then, step 6100 can be executed to calculate the final loss by integrating the prior loss and the posterior loss, and the verification images are obtained by judging the final loss. For the verification images, a part of the verification images can be taken to execute step 6110 to add labels to these verification images, and step 6120 is executed to add these labeled images to the first sample image, so as to perform iterative training on the classification model. For another part of the verification images, step 6130 can be executed to use some of the verification images to train the GAN network.
[0063] After obtaining the first sample image with the sample image label through the above verification image generation method, determine the first prediction label representing the category of the first sample image, and determine the prior loss. Then, generate candidate verification images using the second sample image, and after determining the corresponding second prediction label and third prediction label, calculate the posterior loss using the second prediction label and the third prediction label, so that after comprehensively considering the prior loss and the posterior loss, verification images can be selected from the candidate verification images to verify the user's identity. The above method does not require manual annotation of all sample images one by one, and after generating the images, it can also avoid the generated images being too different from the previous images, thus ensuring the effective utilization of the generated verification images and reducing the time and resources consumed by manual annotation.
[0064] Based on the above verification image generation method, an embodiment of this specification further provides a verification image generation device, which can be integrated into a verification image generation device. As Figure 7 shown, the device may include the following specific modules.
[0065] The first prediction label determination module 710 is configured to obtain the first prediction label of the first sample image; the first sample image corresponds to a sample image label; the sample image label is used to describe the characters presented by the first sample image; the first prediction label represents the classification category obtained after classifying and identifying the first sample image;
[0066] The prior loss determination module 720 is configured to determine the prior loss according to the first prediction label and the sample image label; the prior loss is used to represent the ratio of the first prediction label to the first sample image;
[0067] The candidate verification image generation module 730 is configured to generate candidate verification images using the second sample image based on an image generation algorithm; the image generation algorithm is used to construct the difference between the candidate verification image and the second sample image;
[0068] The posterior loss calculation module 740 is configured to calculate the posterior loss using the second sample image and the candidate verification image; the posterior loss is used to represent the degree of difference between the second sample image and the candidate verification image;
[0069] The verification image determination module 750 is configured to determine the candidate verification image as a verification image when the prior loss and the posterior loss meet the picture application conditions; the verification image is used to verify the user's identity.
[0070] Based on the above verification image generation method, an embodiment of this specification further provides a verification image generation device. As Figure 8 shown, the verification image generation device may include a memory and a processor.
[0071] In this embodiment, the memory can be implemented in any suitable manner. For example, the memory can be a read-only memory, a mechanical hard disk, a solid-state drive, or a USB flash drive, etc. The memory can be used to store computer program instructions.
[0072] In this embodiment, the processor can be implemented in any suitable manner. For example, the processor can take the form of, for example, a microprocessor or a 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, and so on.
[0073] The processor can execute the computer program instructions to implement the following steps: obtaining a first predicted label of a first sample image; the first sample image corresponding to a sample image label; the sample image label being used to describe the character presented by the first sample image; the first predicted label indicating the classification category obtained after classifying and recognizing the first sample image; determining a prior loss according to the first predicted label and the sample image label; the prior loss being used to represent the ratio of the first predicted label to the first sample image; generating a candidate verification image using a second sample image based on an image generation algorithm; the image generation algorithm being used to construct the difference between the candidate verification image and the second sample image; calculating a posterior loss using the second sample image and the candidate verification image; the posterior loss being used to represent the degree of difference between the second sample image and the candidate verification image; determining the candidate verification image as a verification image when the prior loss and the posterior loss meet the picture application conditions; the verification image being used to verify the user identity.
[0074] In the 1990s, improvements to a technology could be clearly distinguished as either hardware improvements (e.g., improvements to circuit structures such as diodes, transistors, switches, etc.) or software improvements (improvements to method flows). However, with the development of technology, many method flow improvements today can be regarded as direct improvements to hardware circuit structures. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement to a method flow cannot be implemented using a hardware entity module. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is an integrated circuit whose logical function is determined by the user programming the device. Designers can program themselves to "integrate" a digital system onto a single PLD, without having to ask a chip manufacturer to design and fabricate a dedicated integrated circuit chip. Moreover, nowadays, instead of manually fabricating integrated circuit chips, this programming is mostly implemented using "logic compiler" software, which is similar to the software compiler used in program development and writing. The original code before compilation also has to be written in a specific programming language, which is called a Hardware Description Language (HDL), and there is not just one type of HDL, but many, 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. Currently, the most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also be aware that by simply performing a little logical programming on the method flow using the above-mentioned several hardware description languages and programming it into an integrated circuit, it is easy to obtain the hardware circuit that implements the logical method flow.
[0075] The systems, apparatuses, modules or units illustrated in the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer can be, for example, 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 any combination of these devices.
[0076] From the description of the above embodiments, those skilled in the art can clearly understand that this specification can be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of this specification, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments of this specification.
[0077] Each embodiment in this specification is described in a progressive manner. For the same or similar parts among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiment.
[0078] This specification can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet-type devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, and so on.
[0079] This specification can be described in the general context of computer-executable instructions 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. This specification can also be practiced in a distributed computing environment, where 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.
[0080] Although this specification is described by way of examples, those of ordinary skill in the art will recognize that this specification has many modifications and variations without departing from the spirit of this specification. It is intended that the appended claims cover these modifications and variations without departing from the spirit of this specification.
Claims
1. A method for verifying image generation, characterized in that, it includes: Obtain the first prediction label of the first sample image; The first sample image corresponds to a sample image label; The sample image label is used to describe the characters presented by the first sample image; the first prediction label represents the classification category obtained after classifying and identifying the first sample image; Determine the prior loss according to the first prediction label and the sample image label; the prior loss is used to represent the ratio of the first prediction label to the first sample image; Generate a candidate verification image based on the second sample image using an image generation algorithm; the image generation algorithm is used to construct the difference between the candidate verification image and the second sample image; Calculate the posterior loss using the second sample image and the candidate verification image; the posterior loss is used to represent the degree of difference between the second sample image and the candidate verification image; When the prior loss and the posterior loss meet the picture application conditions, determine the candidate verification image as the verification image; The verification image is used to verify the user identity; Wherein, the calculating the posterior loss using the second sample image and the candidate verification image includes: Obtain the second prediction label corresponding to the second sample image and the third prediction label corresponding to the candidate verification image respectively; the second prediction label and the third prediction label respectively represent the classification categories obtained after classifying and identifying the second sample image and the candidate verification image; Calculate the posterior loss using the second prediction label and the third prediction label; Wherein, the calculating the posterior loss using the second prediction label and the third prediction label includes: Calculate the first conditional probability according to the second prediction label and the second sample image; the first conditional probability represents the ratio of the second prediction label to the second sample image; Calculate the second conditional probability according to the third prediction label and the candidate verification image; the second conditional probability represents the ratio of the third prediction label to the candidate verification image; Calculate the posterior loss according to the first conditional probability and the second conditional probability; Wherein, the calculating the posterior loss according to the first conditional probability and the second conditional probability includes: Use the formula to calculate the posterior loss, where is the posterior loss, D KL is the divergence between the first conditional probability and the second conditional probability, is the first conditional probability, is the second conditional probability.
2. The method according to claim 1, characterized in that, The sample image label includes at least one of Arabic numerals, capital English letters, lowercase English letters, simplified Chinese, and traditional Chinese.
3. The method according to claim 1, characterized in that, The image generation algorithm includes the GAN algorithm.
4. The method according to claim 1, characterized in that, The obtaining the first prediction label of the first sample image includes: Train a classification model using the first sample image and the sample image label; the classification model is used to identify the label corresponding to the image; Use the classification model to determine the first prediction label of the first sample image.
5. The method according to claim 4, characterized in that, The obtaining the second prediction label corresponding to the second sample image and the third prediction label corresponding to the candidate verification image respectively includes: Use the classification model to respectively determine a second predicted label corresponding to the second sample image and a third predicted label corresponding to the candidate verification image.
6. The method according to claim 4, wherein, after determining the candidate verification image as a verification image, further includes: Use the verification image to iteratively train the classification model.
7. The method according to claim 1, wherein, the determining the candidate verification image as a verification image when the prior loss and the posterior loss meet the picture application conditions includes: Select the smallest posterior loss as the target posterior loss; Combine the prior loss and the target posterior loss to obtain a final loss; When the final loss is not greater than the determination threshold, determine the candidate verification image corresponding to the target posterior loss as a verification image.
8. The method according to claim 7, wherein, the combining the prior loss and the target posterior loss to obtain a final loss includes: Use the formula to calculate the final loss, where is the final loss, L trior is the prior loss, λ is the adjustment coefficient, and L posterior is the target posterior loss.
9. The method according to claim 1, wherein, after determining the candidate verification image as a verification image, further includes: Use the verification image to optimize the image generation algorithm.
10. A verification image generation device, wherein, includes: A first predicted label determination module, configured to obtain a first predicted label of a first sample image; The first sample image corresponds to a sample image label; The sample image label is used to describe the characters presented by the first sample image; the first predicted label represents the classification category obtained after classifying and recognizing the first sample image; A prior loss determination module, configured to determine a prior loss according to the first predicted label and the sample image label; the prior loss is used to represent the ratio of the first predicted label to the first sample image; A candidate verification image generation module, configured to generate a candidate verification image based on an image generation algorithm using a second sample image; the image generation algorithm is used to construct the difference between the candidate verification image and the second sample image; A posterior loss calculation module, configured to calculate a posterior loss using the second sample image and the candidate verification image; the posterior loss is used to represent the degree of difference between the second sample image and the candidate verification image; A verification image determination module, configured to determine the candidate verification image as a verification image when the prior loss and the posterior loss meet the picture application conditions; The verification image is used to verify the user identity; wherein, the calculating the posterior loss using the second sample image and the candidate verification image includes: Respectively obtain a second predicted label corresponding to the second sample image and a third predicted label corresponding to the candidate verification image; the second predicted label and the third predicted label respectively represent the classification categories obtained after classifying and recognizing the second sample image and the candidate verification image; Calculate the posterior loss using the second predicted label and the third predicted label; wherein, the calculating the posterior loss using the second predicted label and the third predicted label includes: Calculate a first conditional probability based on the second predicted label and the second sample image; the first conditional probability represents the ratio corresponding to the second predicted label and the second sample image; Calculate a second conditional probability based on the third predicted label and the candidate verification image; the second conditional probability represents the ratio corresponding to the third predicted label and the candidate verification image; Calculate a posterior loss based on the first conditional probability and the second conditional probability; Wherein, calculating the posterior loss based on the first conditional probability and the second conditional probability includes: Calculate the posterior loss using the formula wherein is the posterior loss, D KL is the divergence between the first conditional probability and the second conditional probability, is the first conditional probability, is the second conditional probability.
11. A verification image generation device, comprising a memory and a processor; The memory is used to store computer program instructions; The processor is configured to execute the computer program instructions to implement the following steps: obtain a first predicted label of a first sample image; the first sample image corresponds to a sample image label; the sample image label is used to describe the characters presented by the first sample image; the first predicted label represents the classification category obtained after classifying and recognizing the first sample image; determine a prior loss according to the first predicted label and the sample image label; the prior loss is used to represent the ratio corresponding to the first predicted label and the first sample image ; Generate a candidate verification image based on the second sample image using an image generation algorithm; the image generation algorithm is used to construct the difference between the candidate verification image and the second sample image; Calculate a posterior loss using the second sample image and the candidate verification image; the posterior loss is used to represent the degree of difference between the second sample image and the candidate verification image; when the prior loss and the posterior loss meet the picture application conditions, determine the candidate verification image as the verification image; The verification image is used to verify the user identity; Wherein, calculating the posterior loss using the second sample image and the candidate verification image includes: Obtain a second predicted label corresponding to the second sample image and a third predicted label corresponding to the candidate verification image respectively; the second predicted label and the third predicted label respectively represent the classification categories obtained after classifying and recognizing the second sample image and the candidate verification image; Calculate the posterior loss using the second predicted label and the third predicted label; Wherein, calculating the posterior loss using the second predicted label and the third predicted label includes: Calculate a first conditional probability based on the second predicted label and the second sample image; the first conditional probability represents the ratio corresponding to the second predicted label and the second sample image; Calculate a second conditional probability based on the third predicted label and the candidate verification image; the second conditional probability represents the ratio corresponding to the third predicted label and the candidate verification image; Calculate the posterior loss based on the first conditional probability and the second conditional probability; Wherein, calculating the posterior loss based on the first conditional probability and the second conditional probability includes: Using the formula calculate the posterior loss, where is the posterior loss, D KL is the divergence between the first conditional probability and the second conditional probability, is the first conditional probability, is the second conditional probability.
Citation Information
Patent Citations
Verification code image generation method and device and electronic equipment
CN109902475A
Graph verification code identification method based on deep learning
CN110009057A