Scene text recognition method for guiding attention generation based on cross-domain supervision signal
The attention generation method guided by cross-domain supervision signals solves the problem of attention drift in attention-based scene text recognition, achieves more accurate text feature encoding and more efficient decoding, and improves the text recognition effect.
Patent Information
- Application Number
- CN202410700418.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-31
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2044-05-31
AI Technical Summary
Attention-based scene text recognition methods are easily affected by attention drift, leading to text recognition errors. Existing technologies fail to effectively solve the problem of attention drift during the encoding process.
The cross-domain supervision signal is used to guide the attention generation method, by extracting the core area of the text as the supervision signal, using the supervision signal of the CNN domain to recursively guide the attention learning of the Transformer domain, and integrating it with the original encoding information through the gating mechanism, combined with non-attention Force-adaptive decoder avoids attentional shifts in the decoding stage.
It effectively alleviates the attention drift during the encoding process, improves the accuracy of text feature encoding and decoding speed, improves the model's learning ability of the core area of text, and significantly improves the text recognition effect.
Smart Images

Figure CN118675162A
Abstract
Description
Technical Field
[0001] The present invention relates to a scene text recognition method based on cross-domain supervisory signal-guided attention generation, and belongs to the field of scene text recognition. Background Art
[0002] Scene text recognition is an important topic in the field of computer vision and is the basis for many downstream visual tasks such as scene understanding, autonomous driving, visual question answering, key information extraction, etc. In recent years, scene text recognition methods have made significant progress. Although the methods based on temporal connection sequence (CTC) and the methods based on segmentation have their own advantages, the attention-based text recognition method has shown obvious vocabulary learning and observation capabilities and has become the mainstream in the field of text recognition.
[0003] With the emergence of Visual Transformer (ViT), attention-based methods have better recognition capabilities for both regular and irregular text than previous methods. Some researchers use a combination of ViT and ResNet to extract rich text information, and then use the attention mechanism to decode the feature encoding sequence. In addition, in order to make full use of the rich information of ViT feature encoding sequences for text sequence prediction, some researchers proposed a customized adaptive addressing and aggregation module to select meaningful token combinations and integrate them into a token corresponding to a specific character. Nevertheless, attention-based methods, whether 1D or 2D, are susceptible to attention drift, which ultimately leads to text recognition errors.
[0004] The problem of attention drift during decoding has recently attracted widespread attention in the academic community. On the one hand, researchers have tried to eliminate the problem of attention misalignment caused by decoding errors by separating the alignment operation from the decoding process and avoiding the use of historical decoding information. On the other hand, researchers have redefined the text recognition task as a character-level segmentation task, by segmenting the text area in the image and translating the segmentation results to obtain the final character sequence.
[0005] Although researchers have taken some approaches to alleviate the attention drift problem and have made significant progress, they have ignored the attention drift problem in the encoding process. However, in major visual tasks, the role of encoders is becoming more and more important and is regarded as the foundation of various business vision models and general vision models. The field of scene text recognition is no exception. As problems accumulate in the encoding process, it may directly lead to attention drift in the decoding process and further cause text recognition errors. Summary of the invention
[0006] In order to solve the shortcomings of the prior art, the present invention proposes a scene text recognition method based on cross-domain supervisory signal-guided attention generation. The method extracts the core area of the text as a supervisory signal, recursively uses the supervisory signal extracted from the CNN domain in a cross-domain manner to guide the attention of the Transformer domain to accurately learn in the feature encoding process, and uses the guided attention to correct the encoding information, and then uses the gating mechanism to adaptively fuse with the original attention-based encoding information to obtain accurate text feature encoding. For the above-mentioned acquired text feature encoding information, the present invention uses a non-attention adaptive decoder to decode the text feature encoding. This design avoids the attention drift problem caused by the use of erroneous historical decoding information, while improving the decoding speed. In addition, the generation of the core area of the text combines the training strategies of artificial guidance and adaptive learning, so that the model can independently learn and understand the core area of the text that is beneficial to text recognition from its own perspective, improve the model's learning ability for the core area of the text, and further promote the text recognition effect.
[0007] To achieve the above object, the present invention adopts the following technical solutions:
[0008] A scene text recognition method based on cross-domain supervisory signal guided attention generation is characterized in that: in the encoding stage, by extracting the core area of the text as a supervisory signal, recursively using the supervisory signal extracted from the CNN domain in a cross-domain manner to guide the attention of the Transformer domain to learn in the feature encoding process, alleviate the attention drift in the encoding process, and use the guided attention to correct the encoded information, and then use the gating mechanism to adaptively fuse with the original attention-based encoded information to obtain the final text feature encoding. In the decoding stage, the above-obtained encoding result is decoded using a non-attention adaptive conversion decoder to alleviate the attention drift in the decoding stage. The method comprises the following steps:
[0009] S1. Construct the true value label for manually guiding the generation of the core area of the text, which is the smallest rectangular box (x min ,y min ,x max ,y max ) is scaled γ times toward the center;
[0010] S2. Construct a feature extractor, which is used for text feature extraction and text core region generation, wherein the text core region is generated by the constructed feature pyramid network structure;
[0011] S3. In the encoding stage, firstly, multiple basic ViT blocks are used for feature encoding, and the encoded information is input into the attention guidance module. Then, the core area of the text obtained in step S2 is used as a supervisory signal to guide the attention generation in the Transformer. The guidance process uses a cross-domain method to recursively guide the attention generation in the Transformer domain using the supervisory signal obtained in the CNN domain, and uses the guided attention to correct the encoded information output in the ViT block. Finally, the encoded information generated by the guided attention and the encoded information generated by the unguided attention are input into the feature fusion module, which uses a gating mechanism to fuse the two encoded information to obtain the final encoded information.
[0012] S4. In the decoding stage, a non-attention adaptive decoder is constructed using a series of 1×1 convolution blocks and conventional matrix operations such as compression and transformation. The decoder accepts the output of the encoding stage as input and outputs the decoding result to obtain a character sequence;
[0013] S5. In the training phase, a fusion training strategy learning method of manual guidance and model adaptive learning is adopted, wherein the manual guidance method is to use the text core area constructed in S1 as the supervision information to supervise the learning of the text core area in the feature extractor, so that the model can have the ability to extract the text core area. The model adaptive learning uses the model obtained by the above manual guidance method as the basis. In the absence of text core area as supervision, but only text recognition results as supervision, the model adaptively learns the text core area that the model understands itself and is effective in text recognition.
[0014] Furthermore, step S1 specifically includes:
[0015] The construction is used to manually guide the true value label generated by the core area of the text, which is obtained by the minimum rectangular box (x min ,y min ,x max y max ) is scaled γ times toward the center, and the specific formula is as follows:
[0016] w=x max -x min
[0017] h=y max -y min
[0018]
[0019] Among them, (x min ,y min ,x max ,y max) are the coordinates of the original character box, γ is the scaling ratio, The four variables in are the upper left point horizontal coordinate, upper left point vertical coordinate, lower right point horizontal coordinate, and lower right point vertical coordinate of the core area of the text used for manual guidance.
[0020] Furthermore, step S2 specifically includes:
[0021] The feature extractor is constructed, which is composed of a convolutional network, uses a bottom-up link to extract text features, and uses a top-down feature pyramid structure to generate a text core area; the text feature extraction can be expressed as follows:
[0022]
[0023] Among them, x f represents the text feature map, represents a bottom-up text feature extractor, X represents a text image, H represents the height of the text image, W represents the width of the text image, and C represents the number of channels of the text feature map.
[0024] Furthermore, step S3 specifically includes:
[0025] In the encoding stage, first, M basic ViT blocks are used for feature encoding. Specifically, the feature map x in step S2 is f Perform convolution and matrix transformation operations to form the input Z0 of the ViT block, and pass through M ViT blocks for feature encoding;
[0026] Secondly, we construct an attention guidance module and use the obtained text core area to generate a text guidance vector v m , and combined with the category vector v c Generate the final attention guidance vector v a , the formula is as follows:
[0027]
[0028] Then the attention to ViT t a Guide and use the guided attention to correct the encoding result of ViT. The formula is as follows:
[0029]
[0030] Among them, t a' is the attention matrix of each head in ViT, t a is the mean of the attention matrices of all attention heads, h is the number of attention heads in ViT, N is the number of patches, and tga is the attention guided by the attention guidance vector, v ts' is the encoded information corrected using guided attention, v ts is the ViT block encoding result, D is the embedding dimension, sigmoid is the activation function, and norm represents layer normalization;
[0031] Finally, a feature fusion module is constructed, the original ViT encoding branch is maintained, and the encoding information generated without guided attention is output. Then, the guided attention obtained in S3 is used to correct this encoding information and perform a preliminary fusion with it to obtain the initially fused encoding information v f Finally, the gating mechanism is used to adaptively fuse the initially fused coding information with the coding information generated by unguided attention to obtain the final fused coding information F. The specific method is as follows:
[0032]
[0033] F=G⊙v ts +(1-G)⊙v f
[0034] Among them, W gated is the learnable weight, G is the gated weight, t ga is the attention guided by the attention guidance vector, v ts' is the encoded information corrected using guided attention, v ts is the visual ViT block encoding result, N is the number of patches, D is the embedding dimension, sigmoid is the activation function, and norm represents layer normalization.
[0035] Further, step S4 is specifically as follows:
[0036] Construct a non-attention-based adaptive transformation decoder, expressed as follows:
[0037]
[0038] Among them, Y is the decoded character information matrix, and the corresponding character sequence can be obtained through post-processing. ψ is an adaptive transformation function composed of a series of 1×1 convolution blocks and conventional matrix operations such as compression and transformation. T is the maximum character sequence length output by the decoder, and K is the number of character categories.
[0039] Furthermore, step S5 is specifically as follows:
[0040] Depending on whether the text core area described in S1 is used to supervise the generation of the text core area in the feature extractor, the training process is divided into two stages, namely the manual guidance stage and the adaptive learning stage. In the manual guidance stage, the character sequence and the artificially set text core area are used to supervise the model, and in the adaptive learning stage, only the character sequence is used to supervise the model.
[0041] Compared with the prior art, the present invention has the following advantages:
[0042] 1. Compared with the prior art, the present invention uses the core area of the text in a cross-domain manner to guide the attention learning in the encoding process during the encoding stage, and uses a feature encoding fusion module to fuse the encoding information generated by guiding attention with the encoding generated without guided attention, so as to obtain correct encoding information, prevent feature encoding errors caused by attention drift in the encoding process, improve the quality of text feature encoding, and provide a strong guarantee for obtaining the correct text sequence later.
[0043] 2. Compared with the prior art, the present invention adopts an efficient, parallel and non-attention adaptive decoder to decode text feature encoding. This design avoids the attention drift problem caused by the use of erroneous historical decoding information and improves the decoding speed. In addition, the generation of the core area of the text integrates the training strategies of manual guidance and adaptive learning, so that the model can independently learn and understand the core area of the text that is beneficial to text recognition from its own perspective, which improves the model's learning ability of the core area of the text and further promotes the text recognition effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 It is a network structure diagram of the scene text recognition method based on cross-domain supervisory signal guided attention generation of the present invention. DETAILED DESCRIPTION
[0045] The scene text recognition method based on cross-domain supervision signal guided attention generation disclosed in the present invention comprises the following steps:
[0046] Step S1 specifically includes:
[0047] Using the synthetic scene text dataset ST as the base dataset, we construct the real value label for manually guided text core region generation, which is represented by the minimum rectangular box (x min ,y min ,x max y max ) is scaled γ times toward the center, and the specific formula is as follows:
[0048] w=x max -x min
[0049] h=y max -y min
[0050]
[0051] Among them, (x min ,y min ,x max y max ) are the horizontal coordinates of the upper left point, the upper left point, the lower right point, and the lower right point, respectively, which are the coordinates of the original character box. γ is the scaling ratio, which is set to 0.5. It is the core area of the text for manual guidance. So far, the ST dataset can be used to supervise the training of text recognition methods and the process of generating the core area of the text;
[0052] Step S2 specifically includes:
[0053] Construct a feature extractor such as Figure 1 As shown in the dotted box of the feature extractor, the feature extractor consists of a convolutional network, uses a bottom-up link to extract text features, and uses a top-down feature pyramid structure to generate the text core area; text feature extraction can be expressed as follows:
[0054]
[0055] Among them, x f represents the text feature map, represents a bottom-up text feature extractor, X represents the text image, H represents the height of the text image, which is set to 32, W represents the width of the text image, which is set to 128, and C represents the number of channels of the text feature map.
[0056] Step S3 specifically includes:
[0057] In the encoding stage, first, the feature map output in S2 The input Z0 of the ViT block is converted through operations such as convolution and matrix transformation, and Z0 is initially encoded using L-2 ViT blocks. The specific implementation method is as follows:
[0058]
[0059] z l '=MSA(LN(z l-1 ))+z l-1
[0060] Z l =MLP(LN(z l '))+z l '
[0061] Among them, x class is the category embedding, E pos is the position embedding, r(·) represents the reshape operation, f(·) represents the flatten operation, α(·) represents the 1×1 convolutional block, l=1...L, L is the number of ViT blocks, which are set to 10 and 6 respectively in our implementation, and z l represents the encoding result, MSA represents the multi-head self-attention matrix, MLP represents the multi-layer perceptron, LN represents the layer normalization, N is the number of patches, set to 256, N is the number of patches, set to 256;
[0062] Secondly, an attention guidance module is constructed. In the last two ViT blocks, the text core area output in S2 is used as a supervision signal to guide the learning of attention in the ViT block, and the guided attention is used to correct the encoding result of ViT, as shown in Figure 1 As shown in the attention guidance module, the obtained text core area is used to generate the text guidance vector v m , and combined with the category vector v c Generate the final attention guidance vector v a , the formula is as follows:
[0063]
[0064] v m = r(f(x m ))
[0065] Among them, x m is the text core area diagram, r represents the reshape operation, f represents the flatten operation; then the attention t to the ViT block a Guide and use the guided attention to correct the encoding result of the ViT block. The formula is as follows:
[0066]
[0067] Among them, t a' is the attention matrix of each head in ViT, t a is the mean of the attention matrices of all attention heads, h is the number of attention heads in ViT, set to 12, N is the number of patches, set to 256, and t ga is the attention guided by the attention guidance vector, v ts' is the encoded information corrected using guided attention, v ts is the result of visual ViT block encoding, D is the embedding dimension, set to 768, sigmoid is the activation function, and norm represents layer normalization;
[0068] Again, construct a feature fusion module, such as Figure 1 As shown in the feature fusion module, the original ViT encoding branch is kept, the encoding information generated without guided attention is output, and then the obtained guided attention is used to correct this encoding information and perform a preliminary fusion with it to obtain the preliminary fused encoding information v f Finally, the gating mechanism is used to adaptively fuse the initially fused coding information with the coding information generated by unguided attention to obtain the final fused coding information F. The specific method is as follows:
[0069]
[0070] F=G⊙v ts +(1-G)⊙v f
[0071] Among them, W gated is the learnable weight, G is the gated weight, t ga is the attention guided by the attention guidance vector, v ts' is the encoded information corrected using guided attention, v ts is the visual ViT block encoding result, N is the number of patches, set to 256, D is the embedding dimension, set to 768, sigmoid is the activation function, and norm represents layer normalization.
[0072] Step S4 specifically includes:
[0073] In the decoding stage, an efficient parallel and non-attention-based adaptive transformation decoder is constructed, such as Figure 1 As shown in the rightmost adaptive conversion decoder module, it is expressed as follows:
[0074]
[0075] Among them, Y is the decoded character information matrix, and the corresponding character sequence can be obtained through post-processing. ψ is an adaptive transformation function composed of a series of 1×1 convolution operations and normalization operations. T is the maximum character sequence length output by the decoder, which is set to 27. K is the number of character categories, which is set to 38.
[0076] By removing the attention calculation process during decoding, the decoding speed can be increased by at least 30% compared to the current advanced attention-based decoder.
[0077] Step S5 specifically includes:
[0078] For the training process, we use the Adadelta optimizer, the Cosine Annealing LR learning rate decay strategy, the RandAugment data augmentation method, the ST and MJ scene text synthesis data, and the training strategy of manual guidance and model adaptive learning; the training process is divided into two stages. The first stage is the manual guidance learning stage, using the ST dataset with artificially set text core areas generated in S1 to supervise the text core area generation and text recognition sequence generation in the model. The second stage is the model adaptive learning stage, only using the character sequences in the ST and MJ datasets to supervise the text recognition sequence generation in the model, where the loss function of the character sequence uses the cross entropy loss L ce , the loss function of the core area of the text uses the binary cross entropy loss function L bce , therefore, the loss function of the first stage is:
[0079] L=λ1L ce +λ2L bce
[0080] Among them, λ1 and λ2 are balance coefficients, which are set to 1 and 0.5 respectively. The loss function of the second stage is:
[0081] L=L ce
[0082] At this stage, only the generation of character sequences requires supervision.
[0083] The experimental results are shown in Table 1. The present invention achieves superior performance than other methods on both regular text and irregular text datasets, where the bold numbers represent the highest recognition accuracy on the dataset.
[0084] Table 1 Comparison of recognition accuracy of the present invention and other methods on the public test set
[0085]
Claims
1. A scene text recognition method based on cross-domain supervision signal guided attention generation, characterized by: In the encoding stage, by extracting the core area of the text as a supervisory signal, the supervisory signal extracted from the CNN domain is recursively used in a cross-domain manner to guide the attention of the Transformer domain to learn in the feature encoding process, thereby alleviating the attention drift in the encoding process, and using the guided attention to correct the encoded information, and then using the gating mechanism to adaptively fuse with the original attention-based encoded information to obtain the final text feature encoding. In the decoding stage, the above-obtained encoding result is decoded using a non-attention adaptive transformation decoder to alleviate the attention drift in the decoding stage. The method includes the following steps: S1. Construct the true value label for manually guiding the generation of the core area of the text, which is the smallest rectangular box (x min ,y min ,x max ,y max ) is scaled γ times toward the center; S2. Construct a feature extractor, which is used for text feature extraction and text core region generation, wherein the text core region is generated by the constructed feature pyramid network structure; S3. In the encoding stage, firstly, multiple basic ViT blocks are used for feature encoding, and the encoded information is input into the attention guidance module. Then, the core area of the text obtained in step S2 is used as a supervisory signal to guide the attention generation in the Transformer. The guidance process uses a cross-domain method to recursively guide the attention generation in the Transformer domain using the supervisory signal obtained in the CNN domain, and uses the guided attention to correct the encoded information output in the ViT block. Finally, the encoded information generated by the guided attention and the encoded information generated by the unguided attention are input into the feature fusion module, which uses a gating mechanism to fuse the two encoded information to obtain the final encoded information. S4. In the decoding stage, a non-attention adaptive decoder is constructed using a series of 1×1 convolution blocks and conventional matrix operations such as compression and transformation. The decoder accepts the output of the encoding stage as input and outputs the decoding result to obtain a character sequence; S5. In the training phase, a fusion training strategy learning method of manual guidance and model adaptive learning is adopted, wherein the manual guidance method is to use the text core area constructed in S1 as the supervision information to supervise the learning of the text core area in the feature extractor, so that the model can have the ability to extract the text core area. The model adaptive learning uses the model obtained by the above manual guidance method as the basis. In the absence of text core area as supervision, but only text recognition results as supervision, the model adaptively learns the text core area that the model understands itself and is effective in text recognition.
2. The scene text recognition method based on cross-domain supervision signal guided attention generation according to claim 1 is characterized in that: Step S1 specifically includes: The construction is used to manually guide the true value label generated by the core area of the text, which is obtained by the minimum rectangular box (x min ,y min ,x max y max ) is scaled γ times toward the center, and the specific formula is as follows: w=x max -x min h=y max -y min Among them, (x min ,y min ,x max ,y max ) are the coordinates of the original character box, γ is the scaling ratio, The four variables in are the upper left point horizontal coordinate, upper left point vertical coordinate, lower right point horizontal coordinate, and lower right point vertical coordinate of the core area of the text used for manual guidance.
3. The scene text recognition method based on cross-domain supervisory signal-guided attention generation according to claim 1, characterized in that: Step S2 specifically includes: The feature extractor is constructed, which is composed of a convolutional network, uses a bottom-up link to extract text features, and uses a top-down feature pyramid structure to generate a text core area; the text feature extraction can be expressed as follows: Among them, x f represents the text feature map, represents a bottom-up text feature extractor, X represents a text image, H represents the height of the text image, W represents the width of the text image, and C represents the number of channels of the text feature map.
4. The scene text recognition method based on cross-domain supervision signal guided attention generation according to claim 1, characterized in that: Step S3 specifically includes: In the encoding stage, first, M basic ViT blocks are used for feature encoding. Specifically, the feature map x in step S2 is f Perform convolution and matrix transformation operations to form the input Z0 of the ViT block, and pass through M ViT blocks for feature encoding; Secondly, we construct an attention guidance module and use the obtained text core area to generate a text guidance vector v m , and combined with the category vector v c Generate the final attention guidance vector v a , the formula is as follows: Then the attention to ViT t a Guide and use the guided attention to correct the encoding result of ViT. The formula is as follows: Among them, t a' is the attention matrix of each head in ViT, t a is the mean of the attention matrices of all attention heads, h is the number of attention heads in ViT, N is the number of patches, and t ga is the attention guided by the attention guidance vector, v ts' is the encoded information corrected using guided attention, v ts is the ViT block encoding result, D is the embedding dimension, sigmoid is the activation function, and norm represents layer normalization; Finally, a feature fusion module is constructed, the original ViT encoding branch is maintained, and the encoding information generated without guided attention is output. Then, the guided attention obtained in S3 is used to correct this encoding information and perform a preliminary fusion with it to obtain the initially fused encoding information v f Finally, the gating mechanism is used to adaptively fuse the initially fused coding information with the coding information generated by unguided attention to obtain the final fused coding information F. The specific method is as follows: F=G⊙v ts +(1-G)⊙v f Among them, W gated is the learnable weight, G is the gated weight, t ga is the attention guided by the attention guidance vector, v ts' is the encoded information corrected using guided attention, v ts is the visual ViT block encoding result, N is the number of patches, D is the embedding dimension, sigmoid is the activation function, and norm represents layer normalization.
5. The scene text recognition method based on cross-domain supervision signal guided attention generation according to claim 1, characterized in that: Step S4 is specifically as follows: Construct a non-attention-based adaptive transformation decoder, expressed as follows: Among them, Y is the decoded character information matrix, and the corresponding character sequence can be obtained through post-processing. ψ is an adaptive transformation function composed of a series of 1×1 convolution blocks and conventional matrix operations such as compression and transformation. T is the maximum character sequence length output by the decoder, and K is the number of character categories.
6. The scene text recognition method based on cross-domain supervisory signal-guided attention generation according to claim 1, characterized in that: Step S5 is specifically as follows: Depending on whether the text core area described in S1 is used to supervise the generation of the text core area in the feature extractor, the training process is divided into two stages, namely the manual guidance stage and the adaptive learning stage. In the manual guidance stage, the character sequence and the artificially set text core area are used to supervise the model, and in the adaptive learning stage, only the character sequence is used to supervise the model.
Citation Information
Patent Citations
A character recognition method based on a gating cascade attention mechanism
CN109919174A
End-to-end text recognition method based on sequence attention supervision
CN117710991A
Multi-directional scene text recognition method and system based on multi-element attention mechanism
US20220121871A1
Speech synthesis method and apparatus, and readable storage medium
US20230075891A1
Speech recognition method and apparatus based on self-attention mechanism and memory network
WO2022121150A1
Cited By
Text recognition method and device for large language model and electronic equipment
CN119830900A
