A method for identifying location information in surveillance images based on DDT deep neural model structure
Through the Deep feature-Decoder Transformer model structure, combined with the multi-head attention mechanism and the prior probability cross-entropy function, the problem of unstable feature extraction and low accuracy in video image text recognition is solved, and efficient recognition of long characters is achieved.
Patent Information
- Application Number
- CN202111047096.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-07
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2041-09-07
AI Technical Summary
Existing video image text recognition methods based on deep learning are unstable in feature extraction when dealing with long characters and cannot effectively identify entire text lines. Moreover, the attention mechanism lacks richness, which reduces the accuracy of the recognition results.
The Deep feature-Decoder Transformer (DDT) model structure is used to extract features and reduce the dimensionality of the image through the Deep feature substructure, combine it with the multi-head attention mechanism for loop decoding, and use the cross-entropy function based on prior probability to optimize the recognition results.
It improves the accuracy of location information recognition in video images, reduces the need for character position encoding, can effectively identify long character information, and significantly improves the stability and accuracy of recognition results.
Smart Images

Figure CN113723337B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision, and in particular to a method for recognizing text with superimposed location information in video images based on deep learning. Background Art
[0002] The continuous construction of video surveillance infrastructure and public services in key industries such as safe cities, intelligent transportation, and smart cities has driven the rapid development of the security monitoring industry. According to the "GA / T 751-2008 Video Image Text Annotation Specification" issued by the Ministry of Public Security, the location information of the jurisdiction in the monitoring image must be manually and correctly annotated in accordance with the "Basic Information of Video Image Equipment" - referred to as "one machine, one file". This is not only the work content requirement for implementing the Ministry of Public Security's "Guiding Opinions on Strengthening the Intelligent Construction and Application of Public Security Big Data", but also the basic guarantee for the "National Public Security Video Image Data Governance Special" task.
[0003] The scale of video surveillance organized and built by the Ministry of Public Security across the country has reached 10 million. It is extremely inefficient and unsustainable to manually verify the labeled information in the surveillance images. Therefore, the automatic identification of location information in surveillance images through an AI algorithm has important practical significance for the current special task promotion work of the Ministry of Public Security.
[0004] Common deep learning-based text information recognition uses a recurrent neural network structure or a pure attention-based Transformer structure to recognize text data. Both structures have great drawbacks in recognizing location information. When the characters are too long, the model can only save part of the extracted features; the feature vector extracted from the image is not based on a single character; and finally, it cannot guarantee the stable recognition of the entire text line. The latter uses the attention mechanism to extract features from images, which lacks richness; it needs to add position encoding information, which will also reduce the accuracy of the recognition results to a certain extent. Summary of the invention
[0005] To solve the above problems, this paper proposes a method for location information recognition of surveillance images based on the DDT deep model structure.
[0006] The DDT deep model is a Deep Feature-Decoder Transformer deep neural model. The Deep feature substructure of the model extracts features from the input surveillance image and reduces the dimension of the extracted features to make them serialized. The feature sequence is then input into the Decoder substructure in parallel. In the Decoder substructure, a multi-head attention mechanism is used to cyclically decode the features, map the decoded results with the Chinese character library, and select characters of a specified length as the result of location recognition. The loss of the recognition result is calculated using a cross entropy function based on prior probability, and the loss is fed back to the network model to optimize the network parameters.
[0007] The method for identifying location information of surveillance images based on the DDT deep model structure proposed in the present invention comprises the following steps:
[0008] Step I: Preprocess the input surveillance image and adjust the image size to be equal to the input dimension of the deep neural network;
[0009] Step II: Send the preprocessed image into the Deep-Feature substructure to obtain the feature matrix of the monitoring image;
[0010] Step III: Randomly select values from the standard normal distribution N(0,1) to generate a position matrix of the same size as the feature matrix in step II. The position matrix represents the position information of the feature matrix.
[0011] Step IV: randomly select values from the standard normal distribution N(0,1) to generate a probability matrix consisting of membership vectors; using the same method of selecting values, generate a position matrix of the same size as the probability matrix, which represents the position information of the probability matrix;
[0012] Step V: Load the deep neural network model, use the feature matrix and its position matrix, the probability matrix and its position matrix as the input of the Decoder substructure, perform cyclic decoding on the feature matrix, and calculate the probability matrix of the recognition result;
[0013] Step VI: Use a linear mapping matrix to map the result of step V to t dimension, where t is equal to the character set S = {s1, s2, .......s t ,}, and get the probability of the model predicting each character in the character set. Output the index value with the highest probability value in each membership vector, and replace the index value with the character according to the mapping relationship between the index value and the character in the character set, and output it as the location information recognition result.
[0014] Preferably, step VII is further provided after step VI: using the prior probability cross entropy formula to calculate the loss between the recognition result and the location character, and feeding back the loss value to the network model to update its parameters and optimize the network model.
[0015] Preferably, the specific steps of step II are as follows:
[0016] Step II-1: Use the deep feature extraction network to extract image features from the preprocessed surveillance image, and obtain three deep feature maps C1, C2, and C3 from high to low;
[0017] Step II-2: Use convolution operation to unify the channel dimensions of feature maps C1, C2, and C3, and use the following formula to form fused features P1, P2, and P3;
[0018] P1=C1
[0019] P2=0.5C2+0.5Up ×2 (P1)
[0020] P3=0.5C3+0.5Up ×2 (P2)
[0021] Among them Up ×2 (P) represents the use of bilinear interpolation function to perform a 2x upsampling operation on the feature map P, and then the high-level and low-level features are fused by equal-weighted addition;
[0022] Step II-3: Use the following formula to transform the dimension of the fused feature P3 to obtain the feature matrix A of the monitoring image:
[0023] A c×hw =f(P c×h×w )
[0024] Function f(P c×h×w ) means that the tensor P of size c×h×w is transformed into a matrix A of size c×hw.
[0025] Preferably, the specific steps of step V are as follows:
[0026] Step V-1: Let the feature matrix be A and its position matrix be A loc , and matrix A and A loc Add the matrices to get the matrix A′, record the probability matrix as B, and its position matrix as B loc , B and B loc Perform matrix addition to obtain matrix B′;
[0027] Step V_2: Use the formula to calculate the positive and negative correlation covariance matrix of matrix B′ and matrix B′, add the positive and negative correlation covariance matrix to the initial B′, and normalize the result of the addition to obtain matrix B ln ;
[0028] Step V-3: Calculate the matrix A′ and matrix B using the formula ln The positive and negative correlation covariance matrix of ln Perform matrix addition;
[0029] Step V-4: multiply the result of step V-3 by the linear mapping matrix L1, and then normalize the multiplication result;
[0030] Step V-5: Upgrade the dimension of the membership vector, then use the activation function to activate the upgraded vector, and finally reduce the dimension to the initial dimension to obtain a new round of character membership vector matrix B1;
[0031] Step V-6: Replace A, A loc , B1, B loc As the input of a new round of Decoder substructure, repeat the above steps to cyclically decode the feature matrix A.
[0032] Preferably, the formula for calculating the positive and negative correlation covariance matrix P in steps V-2 and V-3 is as follows:
[0033] Q i , K i , V i =f splite (Q, K, V)
[0034]
[0035] P = f concat (f att (Q1, K1, V1), f att (Q2, K2, V3), ..., f att (Q n 'K n , V n ))
[0036] Where Q, K, V represent the linear mapping matrix of the input features;
[0037] f splite (Q, K, V) means that the linear mapping matrices Q, K, and V of size h×w are transformed into n matrices of size The sub-mapping matrix of
[0038] f att (Qi , K i , V i ) represents the calculation of Q i , K i , V i The positive and negative correlation covariance matrix of ;
[0039] f concat (f att (Q1, K1, V1), f att (Q2, K2, V3), ..., f att (Q n , K n , V n )) means to convert n dimensions into The dimension of the sub-positive and negative correlation covariance matrix is transformed to form a positive and negative correlation covariance matrix of size h×w.
[0040] Preferably, the specific calculation method of step VII is as follows:
[0041]
[0042] Among them, w i represents the weight of the model predicting the i-th character; t i Represents the index value corresponding to the i-th character label. The index value format is one-hot encoded; y i represents the probability of the model predicting the i-th character, and n represents the length of the location information string.
[0043] The beneficial effects of the present invention include:
[0044] (1) Compared with the attention mechanism, the Deep feature substructure of the DDT model uses a convolutional feature network for feature extraction. The use of convolution can better extract image features and reduce the need for character position encoding.
[0045] (2) In the Decoder substructure, the attention mechanism is used to decode image features. Compared with the use of recurrent neural networks for character recognition, the use of the attention mechanism solves the problem of dependence on the length of the feature vector, decodes the input global features, makes better use of image features, and recognizes location information of equal length to the original image, greatly improving recognition accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 It is a flowchart of the method for recognizing image location information based on the DDT deep neural model.
[0047] Figure 2 This is the structure diagram of the DDT deep neural model. Specific implementation methods
[0048] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0049] Combination Figure 1 , Figure 2 As shown, the method for identifying location information of surveillance images based on the DDT deep model structure includes the following steps:
[0050] Step I: Preprocess the input surveillance image and adjust the image size to be equal to the input size of the deep neural network.
[0051] In this embodiment, the monitoring image size input to the neural network is 96×32 pixels.
[0052] Step II: Send the preprocessed image into the Deep-Feature substructure to obtain the feature matrix of the monitoring image.
[0053] II-1. Use the deep feature extraction network to extract image features from the preprocessed surveillance image, and obtain three deep feature maps C1, C2, and C3 from high to low.
[0054] II-2. Use convolution operation to unify the channel dimensions of feature maps C1, C2, and C3, and use the following formula to form fused features P1, P2, and P3.
[0055] P1=C1
[0056] P2=0.5C2+0.5Up ×2 (P1)
[0057] P3=0.5C3+0.5Up ×2 (P2)
[0058] In this embodiment, the channels of feature maps C1, C2, and C3 are uniformly set to 768 dimensions.
[0059] Up ×2 (P) represents the use of a bilinear interpolation function to perform a 2x upsampling operation on the feature map P, followed by equal-weighted addition to fuse high-level and low-level features.
[0060] II-3. Use the following formula to transform the dimension of the fusion feature P3 to obtain the feature matrix A of the monitoring image:
[0061] A c×hw =f(P c×h×w )
[0062] Function f(P c×h×w ) means that the tensor P of size c×h×w is transformed into a matrix A of size c×hw.
[0063] In this embodiment, c=768, h=4, w=24 are set, and after dimensional transformation, a feature matrix consisting of 96 768-dimensional feature vectors is obtained, which is expressed as: A 96×768 ={a1, a2, ..., a 96} T .
[0064] Step III: Randomly select values from the standard normal distribution N(0, 1) to generate a position matrix of the same size as the feature matrix in step II. The position matrix represents the position information of the feature matrix.
[0065] Here the position matrix is denoted as A loc .
[0066] Step IV: Randomly select values from the standard normal distribution N(0, 1) to generate a probability matrix consisting of membership vectors. Using the same method of selecting values, generate a position matrix of the same size as the probability matrix, which represents the position information of the probability matrix.
[0067] Assuming that the maximum length of the character string of the location information to be identified in the surveillance image is n, a probability matrix consisting of n 768-dimensional membership vectors is generated.
[0068] In this embodiment, the maximum length of the character string is set to 10, and the probability matrix can be expressed as: 10×768 ={b1, b2, ..., b 10} T , and its corresponding position matrix is recorded as B loc
[0069] Step V: Load the deep neural network model, take the feature matrix and its position matrix, the probability matrix and its position matrix as the input of the Decoder substructure, perform cyclic decoding on the feature matrix, and calculate the probability matrix of the recognition result.
[0070] V-1, let the feature matrix be A, and its position matrix be A loc . Substitute the matrix A with A loc The matrix is added to get the matrix A′. The probability matrix is denoted as B, and its position matrix is denoted as B loc . loc Matrix addition is performed to obtain matrix B′.
[0071] The size of matrix A′ is 96×768, and the size of matrix B′ is 10×768.
[0072] V-2. Use the formula to calculate the positive and negative correlation covariance matrix of matrix B′ and matrix B′, add the positive and negative correlation covariance matrix to the initial B′, and normalize the result of the addition to obtain matrix B ln .
[0073] V-3. Use the formula to calculate the matrix A′ and the matrix B ln The positive and negative correlation covariance matrix of ln Perform matrix addition.
[0074] The formula for calculating the positive and negative correlation covariance matrix P is as follows:
[0075] Q i , K i , V i =f splite (Q, K, V)
[0076]
[0077] P = f concat (f att (Q1, K1, V1), f att (Q2, K2, V3), ..., f att (Q n 'K n , v n ))
[0078] Where Q, K, and V represent the linear mapping matrices of the input features.
[0079] f splite (Q, K, V) means that the linear mapping matrices Q, K, and V of size h×w are transformed into n matrices of size The sub-mapping matrix of .
[0080] f att (Q i , K i , V i ) represents the calculation of Q i , K i , V i The positive and negative correlation covariance matrix of .
[0081] f concat (f att (Q1, K1, V1), f att (Q2, K2, V3), ..., f att (Q n , K n , V n )) means to convert n dimensions into The dimension of the sub-positive and negative correlation covariance matrix is transformed to form a positive and negative correlation covariance matrix of size h×w.
[0082] where h and w are equal to the dimensions of the input matrix.
[0083] In this example, h=10, w=768, and n=12 are set.
[0084] V-4: Multiply the result of step V-3 by the linear mapping matrix L1, and then normalize the multiplication result.
[0085] In this example, the size of the linear mapping matrix L1 is 768×768.
[0086] V-5: The membership vector is upgraded, and then the upgraded vector is activated using an activation function, and finally the dimension is reduced to the initial dimension to obtain a new round of matrix B1 consisting of character membership vectors.
[0087] In this example, a matrix of size 768×2048 is multiplied by the result of step V-4 to increase the dimension of the membership vector to 2048, and the relu activation function is used to activate the increased-dimensional vector, and finally the dimension is reduced to 768 to obtain a new round of matrix B1 consisting of character membership vectors.
[0088] V-6: Put A, A loc , B1, B loc As the input of a new round of Decoder substructure, repeat the above steps to cyclically decode the feature matrix A.
[0089] Step VI: Use a linear mapping matrix to map the result of step V to t dimension, where t is equal to the character set S = {s1, s2, .......s t ,}, and get the probability of the model predicting each character in the character set. Output the index value with the highest probability value in each membership vector, and replace the index value with the character according to the mapping relationship between the index value and the character in the character set, and output it as the location information recognition result.
[0090] In this embodiment, the value of t (refer to the Chinese character secondary library) should be above 6000.
[0091] Preferably, step VII: use the following prior probability cross entropy formula to calculate the loss between the recognition result and the location character, and feed the loss value back to the network model to update its parameters and optimize the network model.
[0092]
[0093] Among them, w i represents the weight of the model predicting the i-th character; t iRepresents the index value corresponding to the i-th character label. The index value format is one-hot encoded; y i represents the probability of the model predicting the i-th character, and n represents the length of the location information string.
[0094] In this embodiment, similar to step IV, n=10 is set.
[0095] The present invention, under 4000 samples, i.e., 4000 lines of location information strings (excluding English, numbers, Roman characters, and punctuation marks) are randomly selected from the surveillance images, has the following recognition accuracy indicators:
[0096] The full match rate is 91.8% and the average edit distance percentage is 2.81%.
[0097] Finally, it should be noted that the above is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for identifying location information of surveillance images based on a DDT deep model structure, wherein DDT is the abbreviation of DeepFeature-Decoder Transformer, and is characterized in that: The steps include: Step I: Preprocess the input surveillance image and adjust the image size to be equal to the input dimension of the deep neural network; Step II: Send the preprocessed image into the Deep-Feature substructure of the DDT deep model structure to obtain the feature matrix of the monitoring image; Step III: Randomly select values from the standard normal distribution N(0,1) to generate a position matrix of the same size as the feature matrix in step II. The position matrix represents the position information of the feature matrix. Step IV: Randomly select values from the standard normal distribution N(0,1) to generate a probability matrix consisting of membership vectors; using the same method of selecting values, generate a position matrix of the same size as the probability matrix, which represents the position information of the probability matrix; Step V: Load the deep neural network model, use the feature matrix and its position matrix, the probability matrix and its position matrix as the input of the Decoder substructure, perform cyclic decoding on the feature matrix, and calculate the probability matrix of the recognition result; Step VI: Use a linear mapping matrix to map the result of step V to t dimension, where t is equal to the character set S = {s1, s2, .......s t ,}, and obtain the probability of the model predicting each character in the character set; output the index value with the highest probability value in each membership vector, and replace the index value with the character according to the mapping relationship between the index value and the character in the character set, and output it as the location information recognition result.
2. The method for identifying location information of surveillance images based on the DDT deep model structure according to claim 1 is characterized in that: After step VI, there is also Step VII: Use the prior probability cross entropy formula to calculate the loss between the recognition result and the location character, and feed the loss value back to the network model to update its parameters and optimize the network model.
3. The method for identifying location information of surveillance images based on the DDT deep model structure according to claim 1, characterized in that: The specific steps of step II are as follows: Step II-1: Use the deep feature extraction network to extract image features from the preprocessed surveillance image, and obtain three deep feature maps C1, C2, and C3 from high to low; Step II-2: Use convolution operation to unify the channel dimensions of feature maps C1, C2, and C3, and use the following formula to form fused features P1, P2, and P3; P1=C1 P2=0.5C2+0.5Up ×2 (P1) <h2 style=";text-align:left;direction:ltr">P3 = 0.5C3 + 0.5Up<h2 style=";text-align:left;direction:ltr"> ×2 <h2 style=";text-align:left;direction:ltr"> (P2) Among them Up ×2 (P) represents the use of a bilinear interpolation function to perform a 2x upsampling operation on the feature map P, followed by equal-weighted addition to fuse high-level and low-level features; Step II-3: Use the following formula to transform the dimension of the fused feature P3 to obtain the feature matrix A of the monitoring image: A c×hw =f(P c×h×w ) Function f(P c×h×w ) means that the tensor P of size c×h×w is transformed into a matrix A of size c×hw.
4. The method for identifying location information of surveillance images based on the DDT deep model structure according to claim 1, characterized in that: The specific steps of step V are as follows: Step V-1: Let the feature matrix be A and its position matrix be A loc , and the matrix A and A loc Add the matrices to get the matrix A′, record the probability matrix as B, and its position matrix as B loc , B and B loc Perform matrix addition to obtain matrix B′; Step V-2: Use the formula to calculate the matrix B′ and the matrix B′ and the position matrix B loc The positive and negative correlation covariance matrix is added to the initial B′ matrix, and the result of the addition is normalized to obtain the matrix B ln ; Step V-3: Use the formula to calculate the matrix A′ and matrix B ln And the position matrix is denoted by A loc The positive and negative correlation covariance matrix of ln Perform matrix addition; Step V-4: multiply the result of step V-3 by the linear mapping matrix L1, and then normalize the multiplication result; Step V-5: Upgrade the dimension of the membership vector, then use the activation function to activate the upgraded vector, and finally reduce the dimension to the initial dimension to obtain a new round of character membership vector matrix B1; Step V-6: Place A, A loc , B1, B loc As the input of a new round of Decoder substructure, repeat the above steps to cyclically decode the feature matrix A. The formula for calculating the positive and negative correlation covariance matrix P in steps V-2 and V-3 is as follows: Q i ,K i ,V i =f splite (Q,K,V) P=f concat (f att (Q1,K1,V1),f att (Q2,K2,V3),...,f att (Q n ,K n ,V n )) Where Q, K, V represent the linear mapping matrix of the input features; f splite (Q, K, V) means that the linear mapping matrices Q, K, and V of size h×w are transformed into n matrices of size The sub-mapping matrix of f att (Q i ,K i ,V i ) represents the calculation of Q i ,K i ,V i The positive and negative correlation covariance matrix of ; f concat (f att (Q1,K1,V1),f att (Q2,K2,V3),...,f att (Q n ,K n ,V n )) means to convert n dimensions into The dimension of the sub-positive and negative correlation covariance matrix is transformed to form a positive and negative correlation covariance matrix of size h×w.
5. The method for identifying location information of surveillance images based on the DDT deep model structure according to claim 2, characterized in that: The specific calculation method of step VII is as follows: Among them, w i represents the weight of the model predicting the i-th character; t i Represents the index value corresponding to the i-th character label. The index value format is one-hot encoded; y i represents the probability of the model predicting the i-th character, and n represents the length of the location information string.
