WO2020215573A1 - 验证码的识别方法、装置、计算机设备和存储介质 - Google Patents
验证码的识别方法、装置、计算机设备和存储介质 Download PDFInfo
- Publication number
- WO2020215573A1 WO2020215573A1 PCT/CN2019/103538 CN2019103538W WO2020215573A1 WO 2020215573 A1 WO2020215573 A1 WO 2020215573A1 CN 2019103538 W CN2019103538 W CN 2019103538W WO 2020215573 A1 WO2020215573 A1 WO 2020215573A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- verification code
- target
- result
- picture
- calculation
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/044—Recurrent networks, e.g. Hopfield networks
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/045—Combinations of networks
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/20—Image preprocessing
- G06V10/30—Noise filtering
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/40—Extraction of image or video features
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V30/00—Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
- G06V30/10—Character recognition
- G06V30/14—Image acquisition
- G06V30/148—Segmentation of character regions
- G06V30/153—Segmentation of character regions using recognition of characters or words
Definitions
- This application relates to the technical field of data analysis, and particularly relates to a verification code identification method, device, computer equipment and storage medium.
- CAPTCHA is a Turing test that distinguishes between humans and computers. It is usually carried out in a way that can be easily recognized by humans but difficult to recognize by computer programs by displaying simple characters, object images, and questions, and is used to prevent password cracking Malicious behaviors, such as swiping tickets, and forum irrigation. Among them, character verification codes are particularly widely used. Character verification codes are generally randomly generated and deformed Chinese, English, and digital characters, supplemented by random lines and noise background interference. Before the code is put into use, it needs to be tested to verify its safety, so the verification code needs to be identified and tested.
- the existing industry when recognizing the verification code image, it is generally necessary to preprocess the verification code image and then recognize it. For example, first perform a binarization process to remove background noise, etc., and then segment the remaining characters to separate a single character After they are separated, the characters are recognized by convolutional neural networks or other machine learning algorithms. The process is complicated and troublesome. Moreover, in the prior art, the existing recognition models generally only use CNN convolutional neural network training alone, and the recognition rate of overlapping characters is low. high.
- the main purpose of this application is to provide a verification code identification method, device, computer equipment, and storage medium, aiming to solve the technical problem that the verification code needs to be preprocessed in the prior art.
- this application proposes a verification code identification method, including:
- the verification code recognition model includes a CNN module and an LSTM module, wherein, in the verification code recognition model, The CNN module extracts target features from the target verification code picture, and inputs the extracted target features into the LSTM module for sequence prediction to obtain a prediction result, and then calculates the prediction result through a preset function.
- This application also provides a verification code identification device, including:
- the obtaining picture unit is used to obtain the target verification code picture
- the recognition picture unit is used to input the target verification code image into a verification code recognition model based on a convolutional neural network to obtain a calculation result.
- the verification code recognition model includes a CNN module and an LSTM module.
- the CNN module is used to extract the target features of the target verification code picture, and the extracted target features are input to the LSTM module for sequence prediction to obtain the prediction result, and then the prediction result is passed through the prediction
- the calculated function is calculated to obtain the calculation result;
- the obtaining result unit is configured to obtain the calculation result output by the verification code recognition model, where the calculation result is a verification code character corresponding to the target verification code picture.
- the present application also provides a computer device, including a memory and a processor, the memory stores computer-readable instructions, and the processor implements the steps of the foregoing method when the computer-readable instructions are executed.
- the present application also provides a computer non-volatile readable storage medium, on which computer readable instructions are stored, and when the computer readable instructions are executed by a processor, the steps of the foregoing method are implemented.
- the beneficial effects of this application are: end-to-end recognition is completed without preprocessing the verification code image, and the corresponding characters can be obtained by inputting the verification code image into the verification code recognition model.
- the model uses the CNN module to verify the verification code. Image feature extraction, and input the extracted features into the LSTM module for sequence prediction. The character overlap and noise interference in the captcha image are more adaptable and the recognition accuracy is higher.
- FIG. 1 is a schematic diagram of steps of a verification code identification method in an embodiment of this application
- FIG. 2 is a schematic block diagram of the structure of a verification code identification device in an embodiment of this application.
- FIG. 3 is a schematic block diagram of the structure of a computer device according to an embodiment of the application.
- the verification code identification method in this embodiment includes:
- Step S1 Obtain a picture of the target verification code
- Step S2 Input the target verification code image into a verification code recognition model based on convolutional neural network to obtain a calculation result.
- the verification code recognition model includes a CNN module and an LSTM module, wherein the verification code recognition model , Using the CNN module to extract the target features of the target verification code picture, and input the extracted target features to the LSTM module for sequence prediction to obtain the prediction result, and then pass the prediction result through a preset function Calculate the calculation result;
- Step S3 Obtain the calculation result output by the verification code recognition model, where the calculation result is a verification code character corresponding to the target verification code picture.
- the system directly obtains the target verification code image to be identified from the website.
- a browser is simulated through software to obtain the link of the verification code image and download the image.
- the calculation result is the verification code character corresponding to the above-mentioned target verification code picture.
- the verification code character is generally It is composed of Chinese and English numbers. Among them, the verification code recognition model is based on the preset convolutional recurrent neural network training.
- the model is specifically divided into CNN (Convolutional Neural Network, convolutional neural network) and LSTM (long-short term memory, long-short-term memory network).
- CNN Convolutional Neural Network, convolutional neural network
- LSTM long-short term memory, long-short-term memory network
- step S2 first use the CNN module to extract the features of the target verification code image to obtain the target feature, then input the target feature into the LSTM module for sequence prediction to obtain the prediction result, and calculate the prediction result through the preset function
- the verification code characters corresponding to the above-mentioned target verification code image are obtained, and the above-mentioned preset function may be a set speed search function (beam_search_decoder function).
- the above-mentioned CNN module includes multiple network layers, and each layer includes a convolutional layer and a pooling layer.
- the above-mentioned step S2 includes:
- Step S21 calculating the target verification picture through the convolutional layer of the first network layer to obtain a first calculation value
- Step S22 Input the first calculation value into the pooling layer of the first layer network layer to calculate a second calculation value
- Step S23 Input the second calculated value to the convolutional layer of the next layer of the network layer for calculation to obtain a third calculated value
- Step S24 By analogy, the target feature is obtained through iterative calculation of multiple layers of the network.
- the multi-layer network layer of the CNN module in the above-mentioned verification code recognition model each network layer includes a convolutional layer and a pooling layer, and the target verification code is calculated through the operation of each convolutional layer and the pooling layer.
- Image feature extraction Specifically, starting from the first layer, first input the target verification code image into the convolutional layer of the first network layer for calculation to obtain the first calculation value, and then input the first calculation value into the pooling layer for calculation Obtain the second calculation value.
- the calculation of the first layer is completed, and then the second calculation value is input to the convolution layer of the next layer to start calculation, that is, input to the convolution layer of the second layer for calculation, and the third calculation value is obtained , And then input to the pooling layer of this layer for calculation.
- the target feature of the target verification code image is obtained.
- the convolutional layer of each layer can be calculated by the following formula:
- Netc conv2d(x,filter,strides,name), where Netc is the result of the convolution of the layer, conv2d is the convolution function, x is the input, filter is the convolution kernel, strides is the movement step length of the convolution kernel, and name is The name of the network layer.
- the pooling layer of each layer can be calculated using the following formula:
- Netp max_pooling(x,pool,strides), where Netp is the pooling result of this layer, max_pooling is the pooling function, x is the input, pool is the pooling size, and strides is the moving step length of the convolution kernel.
- the functions of the convolution layer and the pooling layer of the first layer can be obtained from the above.
- the depth of the model here can be used to measure the number of layers, and the width is used to measure how many convolution kernels are set for each layer, so in order to reduce the amount of calculation .
- the LSTM module contains multiple LSTMs with a bidirectional structure, and each LSTM with a bidirectional structure includes an LSTM that performs forward sequence prediction on the target feature and the target feature.
- the two LSTMs are respectively denoted as the first LSTM and the second LSTM.
- Step S25 Input a plurality of the target features into the first LSTM of each of the two-way structure LSTMs for forward sequence prediction to obtain the first result, and input into the second LSTM for reverse sequence prediction to obtain the second result;
- Step S26 concatenate the first result and the second result to obtain the prediction result, where the prediction result is the probability value of each character corresponding to the target feature.
- each target feature is transmitted to a first LSTM and a second LSTM at the same time, that is, the positive and negative sequence prediction of the target feature is performed at the same time, and the corresponding first result and second result are obtained respectively, and then this
- each target feature is input into a two-way structure LSTM for prediction to obtain a corresponding prediction result, thereby obtaining the probability value of multiple characters of each character image in the verification code image.
- the target verification code picture includes a plurality of character pictures
- the prediction result includes the probability value of a plurality of characters corresponding to each character picture
- the prediction result is passed through a preset function
- the step of calculating the calculation result includes:
- Step S27 Calculate the probability value of each character in each character picture through the set speed search function to obtain the character with the highest probability value corresponding to each character picture, and record it as the first character;
- Step S28 Sort each of the first characters according to the order of the corresponding character picture in the target verification picture to obtain the verification code character.
- the prediction result is obtained after sequence prediction by the LSTM module, and the prediction result is the probability value of multiple characters corresponding to each character picture. At this time, it can be obtained through the calculation of the beam_search_decoder function (set speed search function) mentioned above. Correspond to the character with the highest probability value of each character picture, and then sort these characters in the order of the corresponding character picture to obtain the above verification code characters. If the verification code character corresponding to the target verification code picture is " ⁇ H6T", the predicted result is The first character is the probability value of me, you, him, etc. in Chinese, the second character is the probability value of letters such as H, S, Y, and the third character is the probability value of a series of numbers such as 6, 2, 7, etc.
- the fourth character is the probability value of letters such as T, A, O, etc., and then through the operation of the set speed search function, the entire verification code character when the character at each position in the sequence is the maximum probability value in the sequence is obtained.
- the above-mentioned "I”, “H”, “6” and “T” are the characters with the highest probability value in the corresponding sequence positions respectively, so the final result is the verification code character " ⁇ H6T".
- the above beam_search_decoder function is an existing algorithm, and the specific calculation process is not repeated here.
- the above-mentioned verification code recognition model needs to be obtained, so training needs to be performed first. Specifically, before the above step S1, it includes:
- the convolutional neural network includes multiple convolutional layers with unresolved parameters, a pooling layer, and multiple unresolved bidirectional Structured LSTM, and a preset loss function, wherein the function of the convolution layer is defined by a convolution function, a batch normalization algorithm, and an activation function;
- the result training model is recorded as the verification code recognition model based on the convolutional neural network.
- convolution function conv
- batch normalization BN
- activation function Rectified linear unit, ReLU
- the CNN part uses the multi-layer convolution function Conv (vector convolution operation) for feature extraction, and in order to reduce the artificial selection of parameters and alleviate overfitting, each layer uses the BN algorithm (Batch Normalization) and ReLU activation function, for example, first combine conv, BN and Relu to get a custom function as follows: def conv2d_layer(x,filter,strides,is_training,scope), and then name the function,
- LSTM part when building, first define two identical LSTM modules, initialize them, and then define the two LSTM modules as positive and negative directions, and combine them to obtain the above-mentioned bidirectional structure LSTM module.
- the output of the LSTM module is For the prediction results of the combination of positive and negative sequences, in order to make the results more accurate and obtain the desired results, the model of this scheme also uses a loss function for training, because the input is the probability of each character in the sequence, the combined probability That is, multiple multiplications, and the result of multiple multiplications tends to 0, which may cause information loss. Therefore, the likelihood function is used to take the natural logarithm of the result.
- the formula is as follows:
- L(S) is the loss under the data set S
- x) is the probability of a given input x and an output sequence z.
- the loss function of the model built above is minimized by using the gradient descent method to optimize the loss function.
- the verification code recognition model based on the convolutional neural network only after the training is completed, can it be used to calculate the verification code characters corresponding to the verification code picture.
- the sample data includes the verification code picture and the verification code picture.
- this embodiment provides a verification code identification device corresponding to the above verification code identification method, the device includes:
- the image obtaining unit 100 is used to obtain a target verification code image
- the recognition picture unit 200 is configured to input the target verification code picture into a verification code recognition model based on a convolutional neural network for calculation to obtain a calculation result.
- the verification code recognition model includes a CNN module and an LSTM module.
- the CNN module is used to extract the target features of the target verification code picture, and the extracted target features are input to the LSTM module for sequence prediction to obtain the prediction result, and then the prediction result is passed A preset function calculation to obtain the calculation result;
- the obtaining result unit 300 is configured to obtain the calculation result output by the verification code recognition model, where the calculation result is a verification code character corresponding to the target verification code picture.
- the aforementioned CNN module includes multiple network layers, and each layer includes a convolutional layer and a pooling layer.
- the aforementioned image recognition unit 200 includes:
- the first calculation unit is configured to calculate the target verification picture through the convolution layer of the first network layer to obtain the first calculation value
- a second calculation unit configured to input the first calculation value into the pooling layer of the first layer network layer to calculate a second calculation value
- An iterative calculation unit configured to input the second calculated value into the convolutional layer of the next network layer to calculate the third calculated value, and so on, to obtain the target through iterative calculation of multiple layers of the network layer feature.
- the convolutional layer of each layer can be calculated by the following formula:
- Netc conv2d(x,filter,strides,name), where Netc is the result of the convolution of the layer, conv2d is the convolution function, x is the input, filter is the convolution kernel, strides is the movement step length of the convolution kernel, and name is The name of the network layer.
- the pooling layer of each layer can be calculated using the following formula:
- Netp max_pooling(x,pool,strides), where Netp is the pooling result of this layer, max_pooling is the pooling function, x is the input, pool is the pooling size, and strides is the moving step length of the convolution kernel.
- the LSTM module contains multiple LSTMs with a bidirectional structure, and each LSTM with a bidirectional structure includes an LSTM that performs forward sequence prediction on the target feature and the target feature.
- the two LSTMs are respectively denoted as the first LSTM and the second LSTM, and the aforementioned identifying picture unit 200 includes:
- a bidirectional prediction unit configured to input a plurality of the target features into the first LSTM of each LSTM of the bidirectional structure for forward sequence prediction to obtain the first result, and input into the second LSTM for reverse sequence prediction Get the second result;
- the splicing result unit is used to splice the first result and the second result to obtain the prediction result, and the prediction result is the probability value of each character corresponding to the target feature.
- the target verification code picture includes multiple character pictures
- the prediction result includes the probability values of multiple characters corresponding to each character picture
- the recognizing picture unit 200 further includes:
- the character calculation unit is used to calculate the probability value of each character in each character picture through the set speed search function to obtain the character with the highest probability value corresponding to each character picture, and record it as the first character;
- the character sorting unit is used to sort each of the first characters according to the order of the corresponding character picture in the target verification picture to obtain the verification code character.
- the verification code recognition model before using the verification code recognition model based on the convolutional neural network, the verification code recognition model needs to be obtained, so training is required first.
- the steps of training the verification code recognition model include:
- the training model unit is used to input the sample data into the preset convolutional neural network for training, and obtain the result training model.
- the convolutional neural network includes multiple convolutional layers without parameters, pooling layers, and multiple An LSTM with a bidirectional structure without parameters and a preset loss function, wherein the function of the convolution layer is defined by a convolution function, a batch normalization algorithm, and an activation function;
- the result training model is recorded as the verification code recognition model based on the convolutional neural network.
- the model of this application also uses a loss function for training, because the input is the probability of each character in the sequence.
- the combined probability is multiple multiplications. After multiple multiplications, the result tends to 0, which may cause information loss. Therefore, the likelihood function is used, and the natural logarithm of the result is taken.
- the formula is as follows:
- L(S) is the loss under the data set S
- x) is the probability of a given input x and an output sequence z.
- an embodiment of the present application also provides a computer device.
- the computer device may be a server, and its internal structure may be as shown in FIG. 3.
- the computer equipment includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the computer designed processor is used to provide calculation and control capabilities.
- the memory of the computer device includes a non-volatile storage medium and an internal memory.
- the non-volatile storage medium stores an operating system, computer readable instructions, and a database.
- the memory provides an environment for the operation of the operating system and computer readable instructions in the non-volatile storage medium.
- the database of the computer equipment is used to store the identification verification code picture and all the data required for training the verification code identification model.
- the network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer readable instruction is executed by the processor, any one of the verification code identification methods described above is realized.
- the processor executes the steps of the verification code identification method: obtaining a target verification code picture; inputting the target verification code picture into a verification code recognition model based on a convolutional neural network for calculation to obtain a calculation result, the verification code recognition model It includes a CNN module and an LSTM module.
- the CNN module is used to extract the target features of the target verification code image, and the extracted target features are input to the LSTM module for sequence
- the prediction result is obtained by prediction, and then the prediction result is calculated by a preset function to obtain the calculation result; the calculation result output by the verification code recognition model is obtained, and the calculation result is the corresponding image of the target verification code Verification code character.
- the CNN module includes multiple network layers, and each network layer includes a convolutional layer and a pooling layer.
- the step of using the CNN module to extract the target feature of the target verification code image includes : Calculate the target verification picture through the convolutional layer of the first network layer to obtain the first calculated value; input the first calculated value into the pooling layer of the first network layer to calculate the second Calculated value; input the second calculated value to the convolutional layer of the next layer of the network layer for calculation to obtain the third calculated value; and so on, obtain the target feature through iterative calculation of multiple layers of the network layer.
- the LSTM module contains multiple LSTMs with a bidirectional structure, each of which includes a first LSTM that performs forward sequence prediction on the target feature and a
- the target feature is used as the second LSTM for reverse sequence prediction
- the step of inputting the extracted target feature to the LSTM module for sequence prediction to obtain a prediction result includes: inputting a plurality of the target features into each of the bidirectional In the first LSTM of the structured LSTM, the first result is obtained by forward sequence prediction, and the second result is obtained by inputting to the second LSTM for reverse sequence prediction; splicing the first result and the second result to obtain
- the prediction result, the prediction result is the probability value of each character corresponding to the target feature.
- the above-mentioned preset function is a set-speed search function
- the target verification code picture includes a plurality of character pictures
- the prediction result includes the probability values of a plurality of characters corresponding to each of the character pictures
- the step of calculating the prediction result through a preset function to obtain the verification code character includes: calculating the probability value of each character in each character picture through the set speed search function to obtain the corresponding one
- the character with the highest probability value of the character picture is recorded as the first character; each of the first characters is sorted according to the order of the corresponding character picture in the target verification picture to obtain the verification code character.
- the step before the step of obtaining the target verification code image, includes: inputting sample data into a preset convolutional neural network for training, and obtaining a result training model, the convolutional neural network including multiple layers Parameter convolutional layer and pooling layer, multiple LSTMs with two-way structure without parameters, and preset loss function, wherein the function of the convolutional layer is composed of convolution function, batch normalization algorithm and activation Function definition; use test samples to verify the result training model; if the verification passes, record the result training model as the verification code recognition model based on the convolutional neural network.
- FIG. 3 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied.
- An embodiment of the present application also provides a computer non-volatile readable storage medium on which computer readable instructions are stored.
- the computer readable instructions are executed by a processor, any of the foregoing verification code identification methods is implemented.
- Non-volatile memory may include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
- Volatile memory may include random access memory (RAM) or external cache memory.
- RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual-rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous Link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- General Physics & Mathematics (AREA)
- General Health & Medical Sciences (AREA)
- General Engineering & Computer Science (AREA)
- Biophysics (AREA)
- Computational Linguistics (AREA)
- Data Mining & Analysis (AREA)
- Evolutionary Computation (AREA)
- Artificial Intelligence (AREA)
- Molecular Biology (AREA)
- Computing Systems (AREA)
- Biomedical Technology (AREA)
- Life Sciences & Earth Sciences (AREA)
- Mathematical Physics (AREA)
- Software Systems (AREA)
- Health & Medical Sciences (AREA)
- Multimedia (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Image Analysis (AREA)
- Character Discrimination (AREA)
Abstract
基于数据分析验证码的识别方法、装置、计算机设备和存储介质,包括:获取目标验证码图片(S1);将所述目标验证码图片输入基于卷积神经网络的验证码识别模型中进行计算得到计算结果,所述验证码识别模型包括CNN模块以及LSTM模块,其中,在所述验证码识别模型中,利用所述CNN模块对所述目标验证码图片进行目标特征提取,并将提取到的目标特征输入到所述LSTM模块进行序列预测得到预测结果,然后将所述预测结果通过预设的函数计算得到所述计算结果(S2);获取所述验证码识别模型输出的所述计算结果,所述计算结果为对应所述目标验证码图片的验证码字符(S3),这样直接端到端完成识别,模型的计算量更小,识别的准确率更高。
Description
本申请要求于2019年4月22日提交中国专利局、申请号为201910325511.3,发明名称为“验证码的识别方法、装置、计算机设备和存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本申请涉及到数据分析的技术领域,特别是涉及到一种验证码的识别方法、装置、计算机设备和存储介质。
验证码(CAPTCHA)是一种区分人类和计算机的图灵测试,通常通过显示简单的字符、物体图像及问题等可以让人类非常容易识别但计算机程序却难以识别的方式进行,用于防止破解密码、刷票、论坛灌水等恶意行为,其中,字符型验证码应用得尤为广泛,字符型验证码一般为随机生成变形的中文、英文及数字字符,再辅以随机线和噪声背景干扰,而在验证码在投入使用之前,需要对其进行测试,验证其安全性,故而需要对验证码进行识别测试。
现有的业内在对验证码图片进行识别时,一般需要对验证码图片做预处理再进行识别,如先做二值化处理来去除背景噪音等,再对剩余的字符做分割,将单个字符分离出来,之后利用卷积神经网络或其他机器学习算法识别出字符,过程复杂麻烦,而且现有技术中,现有识别模型中一般只是单独采用CNN卷积神经网络训练,对重叠字符识别率不高。
发明内容
本申请的主要目的为提供一种验证码的识别方法、装置、计算机设备和存储介质,旨在解决现有技术中识别验证码需要进行预处理的技术问题。
基于上述发明目的,本申请提出一种验证码的识别方法,包括:
获取目标验证码图片;
将所述目标验证码图片输入基于卷积神经网络的验证码识别模型中进行计算得到计算结果,所述验证码识别模型包括CNN模块以及LSTM模块,其中,在所述验证码识别模型中,利用所述CNN模块对所述目标验证码图片进 行目标特征提取,并将提取到的目标特征输入到所述LSTM模块进行序列预测得到预测结果,然后将所述预测结果通过预设的函数计算得到所述计算结果;
获取所述验证码识别模型输出的所述计算结果,所述计算结果为对应所述目标验证码图片的验证码字符。
本申请还提供一种验证码的识别装置,包括:
获取图片单元,用于获取目标验证码图片;
识别图片单元,用于将所述目标验证码图片输入基于卷积神经网络的验证码识别模型中进行计算得到计算结果,所述验证码识别模型包括CNN模块以及LSTM模块,其中,在所述验证码识别模型中,利用所述CNN模块对所述目标验证码图片进行目标特征提取,并将提取到的目标特征输入到所述LSTM模块进行序列预测得到预测结果,然后将所述预测结果通过预设的函数计算得到所述计算结果;
获取结果单元,用于获取所述验证码识别模型输出的所述计算结果,所述计算结果为对应所述目标验证码图片的验证码字符。
本申请还提供一种计算机设备,包括存储器和处理器,所述存储器存储有计算机可读指令,所述处理器执行所述计算机可读指令时实现上述方法的步骤。
本申请还提供了一种计算机非易失性可读存储介质,其上存储有计算机可读指令,所述计算机可读指令被处理器执行时实现上述方法的步骤。
本申请的有益效果为:直接端到端完成识别,不需要对验证码图片预处理,只需将验证码图片输入到上述验证码识别模型即可得到对应字符,该模型利用CNN模块对验证码图片进行特征提取,并将提取到的特征输入到LSTM模块进行序列预测,验证码图片中的字符重叠和噪音干扰的适应性更好,识别的准确率更高。
图1为本申请一实施例中验证码的识别方法的步骤示意图;
图2为本申请一实施例中验证码的识别装置的结构示意框图;
图3为本申请一实施例的计算机设备的结构示意框图。
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。
应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。
参照图1,本实施例中的验证码的识别方法,包括:
步骤S1:获取目标验证码图片;
步骤S2:将所述目标验证码图片输入基于卷积神经网络的验证码识别模型中进行计算得到计算结果,所述验证码识别模型包括CNN模块以及LSTM模块,其中,在所述验证码识别模型中,利用所述CNN模块对所述目标验证码图片进行目标特征提取,并将提取到的目标特征输入到所述LSTM模块进行序列预测得到预测结果,然后将所述预测结果通过预设的函数计算得到所述计算结果;
步骤S3:获取所述验证码识别模型输出的所述计算结果,所述计算结果为对应所述目标验证码图片的验证码字符。
本实施例中,在网站验证码自动化测试过程中,系统直接从网站上获取待识别的目标验证码图片,例如自动化测试过程中,通过软件模拟浏览器,获得验证码图片的链接并下载图片。然后将上述目标验证码图片输入上述验证码识别模型中进行计算,从而获得该验证码识别模型输出的计算结果,该计算结果即为对应上述目标验证码图片的验证码字符,该验证码字符一般由中文英文数字等组合而成。其中上述验证码识别模型基于预设的卷积循环神经网络训练而成,该模型具体分成CNN(Convolutional Neural Network,卷积神经网络)以及LSTM(long-short term memory,长短期记忆网络)两个模块,CNN卷积神经网络特点是局部感知,并将权值共享,对比全连接的神经网络,可以减少计算量。
如上述步骤S2所述,首先利用CNN模块对目标验证码图片进行特征提取,得到目标特征,然后将该目标特征输入到LSTM模块进行序列预测得到预测结果,将预测结果通过预设函数计算得到计算结果,即得到对应上述目标验证码图片的验证码字符,上述预设的函数可为集速搜索函数(beam_search_decoder函数)。
在一实施例中,上述CNN模块包括多层网络层,且每一层均包括有卷积层和池化层,上述步骤S2,包括:
步骤S21:通过第一层网络层的卷积层对所述目标验证图片进行计算得到 第一计算值;
步骤S22:将所述第一计算值输入到所述第一层网络层的池化层中计算得到第二计算值;
步骤S23:将所述第二计算值输入到下一层网络层的卷积层进行计算得到第三计算值;
步骤S24:以此类推,经过多层所述网络层的迭代计算得到所述目标特征。
本实施例中,上述验证码的识别模型中的CNN模块多层网络层,每层网络层均包含卷积层以及池化层,通过每层卷积层以及池化层的运算对目标验证码图片进行特征提取。具体而言,从第一层开始,先将目标验证码图片输入到第一层网络层的卷积层进行计算,得到第一计算值,然后将第一计算值输入到池化层中进行计算得到第二计算值,此时第一层计算完毕,然后将第二计算值输入到下一层的卷积层开始计算,即输入到第二层的卷积层进行计算,得到第三计算值,然后再输入到该层的池化层进行计算,这样通过多层堆叠,迭代计算从而得到目标验证码图片的目标特征。
其中,每层的卷积层均可采用以下公式进行计算:
Netc=conv2d(x,filter,strides,name),其中Netc是该层卷积的结果,conv2d是卷积函数,x是输入,filter是卷积核,strides是卷积核移动步长,name是该网络层的名字。
每层的池化层均可采用以下公式进行计算:
Netp=max_pooling(x,pool,strides),其中Netp为该层池化结果,max_pooling是池化函数,x为输入,pool为池化尺寸,strides是卷积核移动步长。
举例地,当网络层为2层时,即移动步长为2时,卷积核为3x3时,由上可得第一层的卷积层以及池化层的函数,
分别为:x=conv2d_layer(input_x,filter=[3,3],strides=2,is_training=True,scope=’conv_1’)以及x=max_pooling(x,pool_size=[2,2],strides=2)。
另外,通过对比模型宽度和深度对准确率的影响,得到结果是深度更加有效,此处的模型深度可用于衡量层数,宽度用于衡量每层设置卷积核的多少,所以为了减少计算量,提高准确率,预设的卷积循环神经网络设置为深层,如三百多层。在采用深层的同时,采用小体积卷积核进行计算,例如,两个3x3的卷积相当于一个5x5的卷积,但是在模型参数上来看,两个3x3卷积核参数 为2x3x3=18,一个5x5卷积核参数为1x5x5=25,对比而言,两个3x3参数更少,相对比更大的卷积核,这样计算量更小。
在一实施例中,上述目标特征有多个,LSTM模块中包含有多个双向结构的LSTM,且每一个双向结构的LSTM均包含有对目标特征做正向序列预测的LSTM以及对目标特征所反向序列预测的LSTM,本实施例中,分别将这两个LSTM记为第一LSTM以及第二LSTM,则上述将提取到的目标特征输入到LSTM模块进行序列预测得到预测结果的步骤,包括:
步骤S25:将多个所述目标特征分别输入各个所述双向结构的LSTM的第一LSTM中做正向序列预测得到第一结果,以及输入到所述第二LSTM做反向序列预测得到第二结果;
步骤S26:将所述第一结果和所述第二结果拼接得到所述预测结果,所述预测结果为对应该目标特征的各个字符的概率值。
本实施例中,当通过上述CNN提取特征之后,得到多个对应上述目标验证码图片的目标特征,将这些目标特征输入LSTM模块得到预测结果,预测结果为各字符的概率值。具体而言即将每个目标特征均同时传输到一个第一LSTM以及一个第二LSTM,即同时对该目标特征做正反序列预测,并分别得到对应的第一结果以及第二结果,然后将这两个结果拼接(concat),即将正向LSTM以及反向LSTM的输出拼接得到对应该目标特征的的预测结果,例如将0.3与0.4拼接,即0.3concat 0.4=[0.3,0.4]。该结果同时反映了正反双向的预测,综合考虑了正反双向的可能性,对字符重叠和噪音干扰的适应性更好,也提高了识别准确率。如此将每个目标特征均输入到一个双向结构的LSTM中进行预测得到对应的预测结果,从而得到验证码图片中每个字符图片的多个字符的概率值。
在一个实施例中,已知的是,目标验证码图片包括多个字符图片,上述预测结果包括每个字符图片对应的多个字符的概率值,则上述将所述预测结果通过预设的函数计算得到所述计算结果的步骤,包括:
步骤S27:将每个所述字符图片中各字符的概率值通过所述集速搜索函数计算,得到对应每个所述字符图片概率值最大的字符,并记作第一字符;
步骤S28:将各所述第一字符按对应的所述字符图片在所述目标验证图片中的顺序进行排序,得到所述验证码字符。
本实施例中,在通过LSTM模块序列预测之后得到预测结果,该预测结 果为每个字符图片对应的多个字符的概率值,这时可通过上述beam_search_decoder函数(集速搜索函数)的计算,得到对应每个字符图片概率值最大的字符,然后将这些字符按对应的字符图片顺序排序得到上述验证码字符,如对应目标验证码图片的验证码字符为“我H6T”,则得的预测结果有第一个字符分别是我、你、他等等中文的概率值,第二字符为H、S、Y等字母的概率值,第三个字符为6、2、7等一系列数字的概率值,第四个字符为T、A、O等字母的概率值,然后通过集速搜索函数的运算,得到按照顺序,序列中每个位置的字符都为最大概率值的时候的整个验证码字符,如上述“我”、“H”、“6”、“T”分别在对应的序列位置中都是概率值最大的字符,故而最后得到的为验证码字符“我H6T”。上述beam_search_decoder函数是现有算法,具体运算过程这里不再赘述。
在一个实施例中,在使用上述基于卷积神经网络的验证码识别模型的之前,需要获得上述验证码识别模型,故而需要先进行训练,具体的说在上述步骤S1之前,包括:
将样本数据输入到预设的卷积神经网络中进行训练,得到结果训练模型,所述卷积神经网络包括多层未求参数的卷积层以及池化层、多个未求得参数的双向结构的LSTM,以及预设的损失函数,其中,所述卷积层的函数由卷积函数、批量归一化算法以及激活函数定义;
利用测试样本验证所述结果训练模型;
如果验证通过,则将所述结果训练模型记为所述基于卷积神经网络的验证码识别模型。
在训练之前,首先搭建上述模型框架,对于CNN提取特征部分,采用卷积函数(conv),批量归一化算法(Batch Normalization,BN)和激活函数(Rectified linear unit,ReLU)。由于在神经网络中,每一层的输入在经过层内操作之后必然会导致与原来对应的输入信号分布不同,并且前层神经网络的增加会被后面的神经网络不断累积放大,而BN算法则可以用来规范化某些层或者所有层的输入,从而固定每层输入信号的均值与方差,与使用dropout和L2正则项参数相比,不需要使用局部响应归一化,减少了对学习率的要求。具体而言,在训练过程中,CNN部分采用多层卷积函数Conv(向量卷积运算)进行特征提取,且为了减少参数的人为选择,缓解过拟合,每一层都使用BN算法(Batch Normalization)以及ReLU激活函数,例如先将conv,BN和Relu 组合打包得到自定义函数如下:def conv2d_layer(x,filter,strides,is_training,scope),然后给该函数命名,
如:with tf.name_scope(scope),其中上述三个函数的表达式分别为x=conv2d(x,filter,strides,name=scope+'_conv1')、x=Batch_Normalization(x,training=is_training,scope=scope+'_batch1')以及x=Relu(x),当计算完之后返回x。对于LSTM部分,搭建时首先定义两个一样的LSTM模块,对其进行初始化,然后将两个LSTM模块分别定义成正反两向,并组合得到上述双向结构的LSTM模块,该LSTM模块输出的即为正反两向序列合并的预测结果,为了使结果更准确,得到期望的结果,本方案的模型还采用了损失函数进行训练,因为输入的是序列中每个字符的概率,合起来的概率即是多个相乘,多个连乘后结果趋于0,可能造成信息丢失,所以采用似然函数,对结果取自然对数,公式如下:
L(s)=-ln∏
(x,z)∈Sln p(z|x)=-Σ
(x,z)∈Sln p(z|x)
其中,L(S)为数据集S下的损失,P(z|x)为给定输入x,输出序列z的概率。
在训练时,通过采用梯度下降法通过损失函数优化使上述搭建的模型函数损失最小。
对于基于卷积神经网络的的验证码识别模型,只有在训练完成之后,才能用于计算出对应验证码图片的验证码字符。而在对基于卷积神经网络的验证码识别模型进行训练时,需要获取大量的样本数据,并将上述样本数据分成训练集和测试集,其中上述样本数据包括验证码图片,以及与所述验证码图片对应的验证码字符。将上述训练集的样本数据输入到上述搭建完成的模型函数(即预设的基于卷积神经网络)中进行训练,得到用于进行识别验证码的结果训练模型,再采用已知的测试集的样本数据去验证,如输入到该模型,并将得到的结果与经验总结出的结果进行对比,若两者一致,则说明验证通过,这时可将结果训练模型记为上述基于卷积神经网络的验证码识别模型。
参照图2,本实施例提供一种与上述验证码的识别方法对应的验证码的识别装置,该装置包括:
获取图片单元100,用于获取目标验证码图片;
识别图片单元200,用于将所述目标验证码图片输入基于卷积神经网络的验证码识别模型中进行计算得到计算结果,所述验证码识别模型包括CNN模块以及LSTM模块,其中,在所述验证码识别模型中,利用所述CNN模块对 所述目标验证码图片进行目标特征提取,并将提取到的目标特征输入到所述LSTM模块进行序列预测得到预测结果,然后将所述预测结果通过预设的函数计算得到所述计算结果;
获取结果单元300,用于获取所述验证码识别模型输出的所述计算结果,所述计算结果为对应所述目标验证码图片的验证码字符。
在一实施例中,上述CNN模块包括多层网络层,且每一层均包括有卷积层和池化层,上述识别图片单元200,包括:
第一计算单元,用于通过第一层网络层的卷积层对所述目标验证图片进行计算得到第一计算值;
第二计算单元,用于将所述第一计算值输入到所述第一层网络层的池化层中计算得到第二计算值;
迭代计算单元,用于将所述第二计算值输入到下一层网络层的卷积层进行计算得到第三计算值,以此类推,经过多层所述网络层的迭代计算得到所述目标特征。
其中,每层的卷积层均可采用以下公式进行计算:
Netc=conv2d(x,filter,strides,name),其中Netc是该层卷积的结果,conv2d是卷积函数,x是输入,filter是卷积核,strides是卷积核移动步长,name是该网络层的名字。
每层的池化层均可采用以下公式进行计算:
Netp=max_pooling(x,pool,strides),其中Netp为该层池化结果,max_pooling是池化函数,x为输入,pool为池化尺寸,strides是卷积核移动步长。
在一实施例中,上述目标特征有多个,LSTM模块中包含有多个双向结构的LSTM,且每一个双向结构的LSTM均包含有对目标特征做正向序列预测的LSTM以及对目标特征所反向序列预测的LSTM,本实施例中,分别将这两个LSTM记为第一LSTM以及第二LSTM,则上述识别图片单元200,包括:
双向预测单元,用于将多个所述目标特征分别输入各个所述双向结构的LSTM的第一LSTM中做正向序列预测得到第一结果,以及输入到所述第二LSTM做反向序列预测得到第二结果;
拼接结果单元,用于将所述第一结果和所述第二结果拼接得到所述预测结果,所述预测结果为对应该目标特征的各个字符的概率值。
在一个实施例中,已知的是,目标验证码图片包括多个字符图片,上述预测结果包括每个字符图片对应的多个字符的概率值,则上述识别图片单元200,还包括:
计算字符单元,用于将每个所述字符图片中各字符的概率值通过所述集速搜索函数计算,得到对应每个所述字符图片概率值最大的字符,并记作第一字符;
字符排序单元,用于将各所述第一字符按对应的所述字符图片在所述目标验证图片中的顺序进行排序,得到所述验证码字符。
在一个实施例中,在使用上述基于卷积神经网络的验证码识别模型的之前,需要获得上述验证码识别模型,故而需要先进行训练,具体的说训练上述验证码识别模型的步骤包括:
训练模型单元,用于将样本数据输入到预设的卷积神经网络中进行训练,得到结果训练模型,所述卷积神经网络包括多层未求参数的卷积层以及池化层、多个未求得参数的双向结构的LSTM,以及预设的损失函数,其中,所述卷积层的函数由卷积函数、批量归一化算法以及激活函数定义;
利用测试样本验证所述结果训练模型;
如果验证通过,则将所述结果训练模型记为所述基于卷积神经网络的验证码识别模型。
本申请的模型还采用了损失函数进行训练,因为输入的是序列中每个字符的概率,合起来的概率即是多个相乘,多个连乘后结果趋于0,可能造成信息丢失,所以采用似然函数,对结果取自然对数,公式如下:
L(s)=-ln∏
(x,z)∈Sln p(z|x)=-Σ
(x,z)∈Sln p(z|x)
其中,L(S)为数据集S下的损失,P(z|x)为给定输入x,输出序列z的概率。在训练时,通过采用梯度下降法通过损失函数优化使上述搭建的模型函数损失最小。
参照图3,本申请实施例中还提供一种计算机设备,该计算机设备可以是服务器,其内部结构可以如图3所示。该计算机设备包括通过系统总线连接的处理器、存储器、网络接口和数据库。其中,该计算机设计的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统、计算机可读指令和数据库。该内存器为非易失性存储介质中的操作系统和计算机可读指令的运行提供环境。该计算机 设备的数据库用于存储识别验证码图片以及训练上述验证码识别模型所需的所有数据。该计算机设备的网络接口用于与外部的终端通过网络连接通信。该计算机可读指令被处理器执行时以实现上述任一种验证码的识别方法。
上述处理器执行上述验证码的识别方法的步骤:获取目标验证码图片;将所述目标验证码图片输入基于卷积神经网络的验证码识别模型中进行计算得到计算结果,所述验证码识别模型包括CNN模块以及LSTM模块,其中,在所述验证码识别模型中,利用所述CNN模块对所述目标验证码图片进行目标特征提取,并将提取到的目标特征输入到所述LSTM模块进行序列预测得到预测结果,然后将所述预测结果通过预设的函数计算得到所述计算结果;获取所述验证码识别模型输出的所述计算结果,所述计算结果为对应所述目标验证码图片的验证码字符。
上述计算机设备,上述CNN模块包括多层网络层,每一层网络层均包括卷积层以及池化层,所述利用所述CNN模块对所述目标验证码图片进行目标特征提取的步骤,包括:通过第一层网络层的卷积层对所述目标验证图片进行计算得到第一计算值;将所述第一计算值输入到所述第一层网络层的池化层中计算得到第二计算值;将所述第二计算值输入到下一层网络层的卷积层进行计算得到第三计算值;以此类推,经过多层所述网络层的迭代计算得到所述目标特征。
在一个实施例中,上述通过第一层网络层的卷积层对所述目标验证码图片进行计算得到第一计算值的步骤,包括:利用以下公式进行计算得到所述第一计算值:Net=conv2d(x,filter,strides,name),其中,Net为所述第一计算值,conv2d为卷积函数,x为输入参数,filter为卷积核,strides是卷积核的移动步长,name为所述网络层的名字。
在一个实施例中,上述目标特征具有多个,所述LSTM模块中包含有多个双向结构的LSTM,每一个均包含有对所述目标特征做正向序列预测的第一LSTM以及对所述目标特征做反向序列预测的第二LSTM,所述将提取到的目标特征输入到所述LSTM模块进行序列预测得到预测结果的步骤,包括:将多个所述目标特征分别输入各个所述双向结构的LSTM的第一LSTM中做正向序列预测得到第一结果,以及输入到所述第二LSTM做反向序列预测得到第二结果;将所述第一结果和所述第二结果拼接得到所述预测结果,所述预测结果为对应该目标特征的各个字符的概率值。
在一个实施例中,上述预设的函数为集速搜索函数,所述目标验证码图片包括多个字符图片,所述预测结果包括每个所述字符图片对应的多个字符的概率值,所述将所述预测结果通过预设的函数计算得到所述验证码字符的步骤,包括:将每个所述字符图片中各字符的概率值通过所述集速搜索函数计算,得到对应每个所述字符图片概率值最大的字符,并记作第一字符;将各所述第一字符按对应的所述字符图片在所述目标验证图片中的顺序进行排序,得到所述验证码字符。
在一个实施例中,上述获取目标验证码图片的步骤之前,包括:将样本数据输入到预设的卷积神经网络中进行训练,得到结果训练模型,所述卷积神经网络包括多层未求参数的卷积层以及池化层、多个未求得参数的双向结构的LSTM,以及预设的损失函数,其中,所述卷积层的函数由卷积函数、批量归一化算法以及激活函数定义;利用测试样本验证所述结果训练模型;如果验证通过,则将所述结果训练模型记为所述基于卷积神经网络的验证码识别模型。
在一个实施例中,上述预设的损失函数公式如下:L(s)=-Σ
(x,z)∈Sln p(z|x),其中,L(S)为数据集S下的损失,P(z|x)为给定输入x,输出序列z的概率。
本领域技术人员可以理解,图3中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定。
本申请一实施例还提供一种计算机非易失性可读存储介质,其上存储有计算机可读指令,计算机可读指令被处理器执行时实现上述任一种验证码的识别方法。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机可读指令来指令相关的硬件来完成,所述的计算机可读指令可存储与一非易失性计算机可读取存储介质中,该计算机可读指令在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的和实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可以包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM一多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双速据率SDRAM(SSRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、 存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、装置、物品或者方法不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、装置、物品或者方法所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、装置、物品或者方法中还存在另外的相同要素。
以上所述仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。
Claims (20)
- 一种验证码的识别方法,其特征在于,包括:获取目标验证码图片;将所述目标验证码图片输入基于卷积神经网络的验证码识别模型中进行计算得到计算结果,所述验证码识别模型包括CNN模块以及LSTM模块,其中,在所述验证码识别模型中,利用所述CNN模块对所述目标验证码图片进行目标特征提取,并将提取到的目标特征输入到所述LSTM模块进行序列预测得到预测结果,然后将所述预测结果通过预设的函数计算得到所述计算结果;获取所述验证码识别模型输出的所述计算结果,所述计算结果为对应所述目标验证码图片的验证码字符。
- 根据权利要求1所述的验证码的识别方法,其特征在于,所述CNN模块包括多层网络层,每一层网络层均包括卷积层以及池化层,所述利用所述CNN模块对所述目标验证码图片进行目标特征提取的步骤,包括:通过第一层网络层的卷积层对所述目标验证图片进行计算得到第一计算值;将所述第一计算值输入到所述第一层网络层的池化层中计算得到第二计算值;将所述第二计算值输入到下一层网络层的卷积层进行计算得到第三计算值;以此类推,经过多层所述网络层的迭代计算得到所述目标特征。
- 根据权利要求2所述的验证码的识别方法,其特征在于,所述通过第一层网络层的卷积层对所述目标验证码图片进行计算得到第一计算值的步骤,包括:利用以下公式进行计算得到所述第一计算值:Net=conv2d(x,filter,strides,name)其中,Net为所述第一计算值,conv2d为卷积函数,x为输入参数,filter为卷积核,strides是卷积核的移动步长,name为所述网络层的名字。
- 根据权利要求1所述的验证码的识别方法,其特征在于,所述目标特征具有多个,所述LSTM模块中包含有多个双向结构的LSTM,每一个均包含有对所述目标特征做正向序列预测的第一LSTM以及对所述目标特征做反向序列预测的第二LSTM,所述将提取到的目标特征输入到所述LSTM模块进行序列预测得到预测结果的步骤,包括:将多个所述目标特征分别输入各个所述双向结构的LSTM的第一LSTM中做正向序列预测得到第一结果,以及输入到所述第二LSTM做反向序列预测得到第二结果;将所述第一结果和所述第二结果拼接得到所述预测结果,所述预测结果为对应该目标特征的各个字符的概率值。
- 根据权利要求1所述的验证码的识别方法,其特征在于,所述预设的函数为集速搜索函数,所述目标验证码图片包括多个字符图片,所述预测结果包括每个所述字符图片对应的多个字符的概率值,所述将所述预测结果通过预设的函数计算得到所述验证码字符的步骤,包括:将每个所述字符图片中各字符的概率值通过所述集速搜索函数计算,得到对应每个所述字符图片概率值最大的字符,并记作第一字符;将各所述第一字符按对应的所述字符图片在所述目标验证图片中的顺序进行排序,得到所述验证码字符。
- 根据权利要求1所述的验证码的识别方法,其特征在于,所述获取目标验证码图片的步骤之前,包括:将样本数据输入到预设的卷积神经网络中进行训练,得到结果训练模型,所述卷积神经网络包括多层未求参数的卷积层以及池化层、多个未求得参数的双向结构的LSTM,以及预设的损失函数,其中,所述卷积层的函数由卷积函数、批量归一化算法以及激活函数定义;利用测试样本验证所述结果训练模型;如果验证通过,则将所述结果训练模型记为所述基于卷积神经网络的验证码识别模型。
- 根据权利要求6所述的验证码的识别方法,其特征在于,所述预设的 损失函数公式如下:L(s)=-∑ (x,z)∈Sln p(z|x)其中,L(S)为数据集S下的损失,P(z|x)为给定输入x,输出序列z的概率。
- 一种验证码的识别装置,其特征在于,包括:获取图片单元,用于获取目标验证码图片;识别图片单元,用于将所述目标验证码图片输入基于卷积神经网络的验证码识别模型中进行计算得到计算结果,所述验证码识别模型包括CNN模块以及LSTM模块,其中,在所述验证码识别模型中,利用所述CNN模块对所述目标验证码图片进行目标特征提取,并将提取到的目标特征输入到所述LSTM模块进行序列预测得到预测结果,然后将所述预测结果通过预设的函数计算得到所述计算结果;获取结果单元,用于获取所述验证码识别模型输出的所述计算结果,所述计算结果为对应所述目标验证码图片的验证码字符。
- 根据权利要求8所述的验证码的识别装置,其特征在于,所述CNN模块包括多层网络层,每一层网络层均包括卷积层以及池化层,所述识别图片单元,包括:第一计算单元,用于通过第一层网络层的卷积层对所述目标验证图片进行计算得到第一计算值;第二计算单元,用于将所述第一计算值输入到所述第一层网络层的池化层中计算得到第二计算值;迭代计算单元,用于将所述第二计算值输入到下一层网络层的卷积层进行计算得到第三计算值,以此类推,经过多层所述网络层的迭代计算得到所述目标特征。
- 根据权利要求9所述的验证码的识别装置,其特征在于,所述第一计算单元,包括:利用以下公式进行计算得到所述第一计算值:Net=conv2d(x,filter,strides,name)其中,Net为所述第一计算值,conv2d为卷积函数,x为输入参数,filter 为卷积核,strides是卷积核的移动步长,name为所述网络层的名字。
- 根据权利要求8所述的验证码的识别装置,其特征在于,所述目标特征具有多个,所述LSTM模块中包含有多个双向结构的LSTM,每一个均包含有对所述目标特征做正向序列预测的第一LSTM以及对所述目标特征做反向序列预测的第二LSTM,所述识别图片单元,包括:双向预测单元,用于将多个所述目标特征分别输入各个所述双向结构的LSTM的第一LSTM中做正向序列预测得到第一结果,以及输入到所述第二LSTM做反向序列预测得到第二结果;拼接结果单元,用于将所述第一结果和所述第二结果拼接得到所述预测结果,所述预测结果为对应该目标特征的各个字符的概率值。
- 根据权利要求8所述的验证码的识别装置,其特征在于,所述预设的函数为集速搜索函数,所述目标验证码图片包括多个字符图片,所述预测结果包括每个所述字符图片对应的多个字符的概率值,所述识别图片单元,包括:计算字符单元,用于将每个所述字符图片中各字符的概率值通过所述集速搜索函数计算,得到对应每个所述字符图片概率值最大的字符,并记作第一字符;字符排序单元,用于将各所述第一字符按对应的所述字符图片在所述目标验证图片中的顺序进行排序,得到所述验证码字符。
- 一种计算机设备,包括存储器和处理器,所述存储器存储有计算机可读指令,其特征在于,所述处理器执行所述计算机可读指令时实现一种验证码的识别方法的步骤:获取目标验证码图片;将所述目标验证码图片输入基于卷积神经网络的验证码识别模型中进行计算得到计算结果,所述验证码识别模型包括CNN模块以及LSTM模块,其中,在所述验证码识别模型中,利用所述CNN模块对所述目标验证码图片进行目标特征提取,并将提取到的目标特征输入到所述LSTM模块进行序列预测得到预测结果,然后将所述预测结果通过预设的函数计算得到所述计算结果;获取所述验证码识别模型输出的所述计算结果,所述计算结果为对应所述 目标验证码图片的验证码字符。
- 根据权利要求13所述的计算机设备,其特征在于,所述CNN模块包括多层网络层,每一层网络层均包括卷积层以及池化层,所述处理器利用所述CNN模块对所述目标验证码图片进行目标特征提取的步骤,包括:通过第一层网络层的卷积层对所述目标验证图片进行计算得到第一计算值;将所述第一计算值输入到所述第一层网络层的池化层中计算得到第二计算值;将所述第二计算值输入到下一层网络层的卷积层进行计算得到第三计算值;以此类推,经过多层所述网络层的迭代计算得到所述目标特征。
- 根据权利要求14所述的计算机设备,其特征在于,所述处理器通过第一层网络层的卷积层对所述目标验证码图片进行计算得到第一计算值的步骤,包括:利用以下公式进行计算得到所述第一计算值:Net=conv2d(x,filter,strides,name)其中,Net为所述第一计算值,conv2d为卷积函数,x为输入参数,filter为卷积核,strides是卷积核的移动步长,name为所述网络层的名字。
- 根据权利要求13所述的计算机设备,其特征在于,所述目标特征具有多个,所述LSTM模块中包含有多个双向结构的LSTM,每一个均包含有对所述目标特征做正向序列预测的第一LSTM以及对所述目标特征做反向序列预测的第二LSTM,所述处理器将提取到的目标特征输入到所述LSTM模块进行序列预测得到预测结果的步骤,包括:将多个所述目标特征分别输入各个所述双向结构的LSTM的第一LSTM中做正向序列预测得到第一结果,以及输入到所述第二LSTM做反向序列预测得到第二结果;将所述第一结果和所述第二结果拼接得到所述预测结果,所述预测结果为对应该目标特征的各个字符的概率值。
- 一种计算机非易失性可读存储介质,其上存储有计算机可读指令,其特征在于,所述计算机可读指令被处理器执行时实现一种验证码的识别方法的步骤:获取目标验证码图片;将所述目标验证码图片输入基于卷积神经网络的验证码识别模型中进行计算得到计算结果,所述验证码识别模型包括CNN模块以及LSTM模块,其中,在所述验证码识别模型中,利用所述CNN模块对所述目标验证码图片进行目标特征提取,并将提取到的目标特征输入到所述LSTM模块进行序列预测得到预测结果,然后将所述预测结果通过预设的函数计算得到所述计算结果;获取所述验证码识别模型输出的所述计算结果,所述计算结果为对应所述目标验证码图片的验证码字符。
- 根据权利要求17所述的计算机非易失性可读存储介质,其特征在于,所述CNN模块包括多层网络层,每一层网络层均包括卷积层以及池化层,所述处理器利用所述CNN模块对所述目标验证码图片进行目标特征提取的步骤,包括:通过第一层网络层的卷积层对所述目标验证图片进行计算得到第一计算值;将所述第一计算值输入到所述第一层网络层的池化层中计算得到第二计算值;将所述第二计算值输入到下一层网络层的卷积层进行计算得到第三计算值;以此类推,经过多层所述网络层的迭代计算得到所述目标特征。
- 根据权利要求18所述的计算机非易失性可读存储介质,其特征在于,所述处理器通过第一层网络层的卷积层对所述目标验证码图片进行计算得到第一计算值的步骤,包括:利用以下公式进行计算得到所述第一计算值:Net=conv2d(x,filter,strides,name)其中,Net为所述第一计算值,conv2d为卷积函数,x为输入参数,filter为卷积核,strides是卷积核的移动步长,name为所述网络层的名字。
- 根据权利要求17所述的计算机非易失性可读存储介质,其特征在于,所述目标特征具有多个,所述LSTM模块中包含有多个双向结构的LSTM,每一个均包含有对所述目标特征做正向序列预测的第一LSTM以及对所述目标特征做反向序列预测的第二LSTM,所述处理器将提取到的目标特征输入到所述LSTM模块进行序列预测得到预测结果的步骤,包括:将多个所述目标特征分别输入各个所述双向结构的LSTM的第一LSTM中做正向序列预测得到第一结果,以及输入到所述第二LSTM做反向序列预测得到第二结果;将所述第一结果和所述第二结果拼接得到所述预测结果,所述预测结果为对应该目标特征的各个字符的概率值。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201910325511.3 | 2019-04-22 | ||
| CN201910325511.3A CN110188761A (zh) | 2019-04-22 | 2019-04-22 | 验证码的识别方法、装置、计算机设备和存储介质 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2020215573A1 true WO2020215573A1 (zh) | 2020-10-29 |
Family
ID=67714914
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2019/103538 Ceased WO2020215573A1 (zh) | 2019-04-22 | 2019-08-30 | 验证码的识别方法、装置、计算机设备和存储介质 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN110188761A (zh) |
| WO (1) | WO2020215573A1 (zh) |
Cited By (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112270325A (zh) * | 2020-11-09 | 2021-01-26 | 携程旅游网络技术(上海)有限公司 | 字符验证码识别模型训练方法、识别方法、系统、设备及介质 |
| CN112419413A (zh) * | 2020-12-07 | 2021-02-26 | 萱闱(北京)生物科技有限公司 | 终端设备的运动方向监测方法、介质、装置和计算设备 |
| CN112927173A (zh) * | 2021-04-12 | 2021-06-08 | 平安科技(深圳)有限公司 | 模型压缩方法、装置、计算设备及存储介质 |
| CN113473026A (zh) * | 2021-07-08 | 2021-10-01 | 厦门四信通信科技有限公司 | 一种摄像头的日夜切换方法、装置、设备和存储介质 |
| CN114329414A (zh) * | 2021-12-27 | 2022-04-12 | 杭州卓健信息科技股份有限公司 | 一种不定长通用数字字母验证码识别系统及方法 |
| CN115063803A (zh) * | 2022-05-31 | 2022-09-16 | 北京开拓鸿业高科技有限公司 | 图像处理方法、装置、存储介质及电子设备 |
| CN117132989A (zh) * | 2023-10-23 | 2023-11-28 | 山东大学 | 基于卷积神经网络的字符验证码识别方法、系统及设备 |
Families Citing this family (11)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110674488B (zh) * | 2019-09-06 | 2024-04-26 | 深圳壹账通智能科技有限公司 | 基于神经网络的验证码识别方法、系统及计算机设备 |
| CN110765442A (zh) * | 2019-09-30 | 2020-02-07 | 奇安信科技集团股份有限公司 | 一种识别验证图片中验证码的方法、装置及电子设备 |
| CN111310156B (zh) * | 2019-11-28 | 2022-08-19 | 苏宁金融科技(南京)有限公司 | 一种滑块验证码的自动识别方法及系统 |
| CN111259366B (zh) * | 2020-01-22 | 2021-06-18 | 支付宝(杭州)信息技术有限公司 | 一种基于自监督学习的验证码识别器的训练方法和装置 |
| CN111401354B (zh) * | 2020-03-24 | 2023-07-11 | 南京红松信息技术有限公司 | 一种基于端到端自适应的垂直粘连字符的识别方法 |
| CN113591887A (zh) * | 2020-04-30 | 2021-11-02 | 中国移动通信集团广东有限公司 | 验证码识别模型训练方法、验证码自动识别方法及服务器 |
| CN111783062B (zh) * | 2020-05-28 | 2023-05-02 | 苏宁金融科技(南京)有限公司 | 验证码识别方法、装置、计算机设备和存储介质 |
| CN112101346A (zh) * | 2020-08-27 | 2020-12-18 | 南方医科大学南方医院 | 一种基于目标检测的验证码识别方法及装置 |
| CN112214750B (zh) * | 2020-10-16 | 2023-04-25 | 上海携旅信息技术有限公司 | 字符验证码的识别方法、系统、电子设备和存储介质 |
| CN113359101B (zh) * | 2021-08-10 | 2021-11-05 | 中南大学 | 一种地下目标探测方法、系统及计算机存储介质 |
| CN116416486A (zh) * | 2022-01-04 | 2023-07-11 | 中移动信息技术有限公司 | 图像识别方法及系统 |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107085730A (zh) * | 2017-03-24 | 2017-08-22 | 深圳爱拼信息科技有限公司 | 一种字符验证码识别的深度学习方法及装置 |
| CN107239733A (zh) * | 2017-04-19 | 2017-10-10 | 上海嵩恒网络科技有限公司 | 连续手写字识别方法及系统 |
| CN107360137A (zh) * | 2017-06-15 | 2017-11-17 | 深圳市牛鼎丰科技有限公司 | 用于验证码识别的神经网络模型的构建方法和装置 |
| WO2018090011A1 (en) * | 2016-11-14 | 2018-05-17 | Kodak Alaris Inc. | System and method of character recognition using fully convolutional neural networks |
| CN108154148A (zh) * | 2018-01-22 | 2018-06-12 | 厦门美亚商鼎信息科技有限公司 | 训练样本的人工合成方法及基于该样本的验证码识别方法 |
| CN109389059A (zh) * | 2018-09-26 | 2019-02-26 | 华南理工大学 | 一种基于cnn-lstm网络的p300检测方法 |
Family Cites Families (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2016197381A1 (en) * | 2015-06-12 | 2016-12-15 | Sensetime Group Limited | Methods and apparatus for recognizing text in an image |
| CN107644014A (zh) * | 2017-09-25 | 2018-01-30 | 南京安链数据科技有限公司 | 一种基于双向lstm和crf的命名实体识别方法 |
| CN109409195A (zh) * | 2018-08-30 | 2019-03-01 | 华侨大学 | 一种基于神经网络的唇语识别方法及系统 |
| CN109086594A (zh) * | 2018-09-21 | 2018-12-25 | 郑州云海信息技术有限公司 | 一种实现滑动型验证码验证的方法、装置及系统 |
-
2019
- 2019-04-22 CN CN201910325511.3A patent/CN110188761A/zh active Pending
- 2019-08-30 WO PCT/CN2019/103538 patent/WO2020215573A1/zh not_active Ceased
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2018090011A1 (en) * | 2016-11-14 | 2018-05-17 | Kodak Alaris Inc. | System and method of character recognition using fully convolutional neural networks |
| CN107085730A (zh) * | 2017-03-24 | 2017-08-22 | 深圳爱拼信息科技有限公司 | 一种字符验证码识别的深度学习方法及装置 |
| CN107239733A (zh) * | 2017-04-19 | 2017-10-10 | 上海嵩恒网络科技有限公司 | 连续手写字识别方法及系统 |
| CN107360137A (zh) * | 2017-06-15 | 2017-11-17 | 深圳市牛鼎丰科技有限公司 | 用于验证码识别的神经网络模型的构建方法和装置 |
| CN108154148A (zh) * | 2018-01-22 | 2018-06-12 | 厦门美亚商鼎信息科技有限公司 | 训练样本的人工合成方法及基于该样本的验证码识别方法 |
| CN109389059A (zh) * | 2018-09-26 | 2019-02-26 | 华南理工大学 | 一种基于cnn-lstm网络的p300检测方法 |
Cited By (14)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112270325A (zh) * | 2020-11-09 | 2021-01-26 | 携程旅游网络技术(上海)有限公司 | 字符验证码识别模型训练方法、识别方法、系统、设备及介质 |
| CN112270325B (zh) * | 2020-11-09 | 2024-05-24 | 携程旅游网络技术(上海)有限公司 | 字符验证码识别模型训练方法、识别方法、系统、设备及介质 |
| CN112419413A (zh) * | 2020-12-07 | 2021-02-26 | 萱闱(北京)生物科技有限公司 | 终端设备的运动方向监测方法、介质、装置和计算设备 |
| CN112419413B (zh) * | 2020-12-07 | 2024-01-05 | 萱闱(北京)生物科技有限公司 | 终端设备的运动方向监测方法、介质、装置和计算设备 |
| CN112927173B (zh) * | 2021-04-12 | 2023-04-18 | 平安科技(深圳)有限公司 | 模型压缩方法、装置、计算设备及存储介质 |
| CN112927173A (zh) * | 2021-04-12 | 2021-06-08 | 平安科技(深圳)有限公司 | 模型压缩方法、装置、计算设备及存储介质 |
| CN113473026A (zh) * | 2021-07-08 | 2021-10-01 | 厦门四信通信科技有限公司 | 一种摄像头的日夜切换方法、装置、设备和存储介质 |
| CN113473026B (zh) * | 2021-07-08 | 2023-04-07 | 厦门四信通信科技有限公司 | 一种摄像头的日夜切换方法、装置、设备和存储介质 |
| CN114329414A (zh) * | 2021-12-27 | 2022-04-12 | 杭州卓健信息科技股份有限公司 | 一种不定长通用数字字母验证码识别系统及方法 |
| CN114329414B (zh) * | 2021-12-27 | 2025-06-13 | 杭州卓健信息科技股份有限公司 | 一种不定长通用数字字母验证码识别系统及方法 |
| CN115063803A (zh) * | 2022-05-31 | 2022-09-16 | 北京开拓鸿业高科技有限公司 | 图像处理方法、装置、存储介质及电子设备 |
| CN115063803B (zh) * | 2022-05-31 | 2024-07-09 | 北京开拓鸿业高科技有限公司 | 图像处理方法、装置、存储介质及电子设备 |
| CN117132989A (zh) * | 2023-10-23 | 2023-11-28 | 山东大学 | 基于卷积神经网络的字符验证码识别方法、系统及设备 |
| CN117132989B (zh) * | 2023-10-23 | 2024-01-26 | 山东大学 | 基于卷积神经网络的字符验证码识别方法、系统及设备 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN110188761A (zh) | 2019-08-30 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2020215573A1 (zh) | 验证码的识别方法、装置、计算机设备和存储介质 | |
| CN112613515B (zh) | 语义分割方法、装置、计算机设备和存储介质 | |
| CN110532884B (zh) | 行人重识别方法、装置及计算机可读存储介质 | |
| CN108846355B (zh) | 图像处理方法、人脸识别方法、装置和计算机设备 | |
| CN111832581B (zh) | 肺部特征识别方法、装置、计算机设备及存储介质 | |
| CN111191539B (zh) | 证件真伪验证方法、装置、计算机设备和存储介质 | |
| CN110021439A (zh) | 基于机器学习的医疗数据分类方法、装置和计算机设备 | |
| CN109472213B (zh) | 掌纹识别方法、装置、计算机设备和存储介质 | |
| KR20190085098A (ko) | 키워드 추출 방법, 컴퓨터 장치, 및 저장 매체 | |
| CN110033018B (zh) | 图形相似度判断方法、装置及计算机可读存储介质 | |
| CN110598206A (zh) | 文本语义识别方法、装置、计算机设备和存储介质 | |
| CN112163110B (zh) | 图像分类方法、装置、电子设备和计算机可读存储介质 | |
| EP2806374A1 (en) | Method and system for automatic selection of one or more image processing algorithm | |
| CN113342927B (zh) | 敏感词识别方法、装置、设备及存储介质 | |
| CN110717407A (zh) | 基于唇语密码的人脸识别方法、装置及存储介质 | |
| CN115565146B (zh) | 基于自编码器获取鸟瞰图特征的感知模型训练方法及系统 | |
| CN110781677B (zh) | 药品信息匹配处理方法、装置、计算机设备和存储介质 | |
| CN108021806A (zh) | 一种恶意安装包的识别方法和装置 | |
| CN111401473A (zh) | 基于注意力机制卷积神经网络的红外目标分类方法 | |
| US20240290065A1 (en) | Method for multimodal embedding and system therefor | |
| CN118368136B (zh) | Dga域名检测方法及装置 | |
| CN112231556B (zh) | 基于对话场景的用户画像方法、装置、设备及介质 | |
| CN115455225B (zh) | 一种图文语义对齐模型的构建方法及装置 | |
| CN116091596A (zh) | 一种自下而上的多人2d人体姿态估计方法及装置 | |
| CN111027400A (zh) | 一种活体检测方法及装置 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 19926064 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 19926064 Country of ref document: EP Kind code of ref document: A1 |