Training method of text recognition system in natural scenes using self-supervised contrastive learning

Through the self-supervised comparative learning method, image and text positive and negative sample sets are used to train the text recognition system in natural scenes, which solves the problem of dependence on annotated data sets in the existing technology, improves the recognition accuracy and model robustness, and achieves Efficient detection and recognition of natural scene text.

CN114973226BActive Publication Date: 2024-09-24SHANGHAI UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210532609.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-13
Publication Date
2024-09-24
Estimated Expiration
2042-05-13

AI Technical Summary

Technical Problem

Existing natural scene text detection and recognition methods rely on a large number of annotated data sets, resulting in high costs and inability to effectively cover ever-changing actual scenes. There is currently no relevant research on text recognition tasks based on contrastive learning.

Method used

Self-supervised contrastive learning is used to train the text recognition system in natural scenes. Recognition training is performed simultaneously through image and text positive and negative sample sets to generate a recognition model with the ability to learn text contrast in natural scenes and reduce the dependence on labeled data sets. . Specific steps include image and text enhancement processing, encoder feature extraction, similarity measurement and loss function minimization, and weighted combination training using image-text and text-image loss functions.

Benefits of technology

It greatly reduces the dependence on annotated data sets, improves the accuracy of natural scene text detection and recognition, improves the robustness of the model and data utilization efficiency, and solves the problem of high dependence on annotated data sets in the existing technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114973226B
    Figure CN114973226B
Patent Text Reader

Abstract

The present invention relates to a method for training a text recognition system in a natural scene by self-supervised contrastive learning. The text labels in positive and negative samples of an image are used as positive and negative samples of a text label and sent to a text encoder for contrastive learning as an auxiliary training and learning of the image encoder. The image features extracted from the positive and negative samples of the image and the text features extracted from the positive and negative samples of the text label are used to form a feature pair. The image-text loss and the text-image loss are calculated respectively. The system is trained with the minimum weighted combination of the two losses of the positive sample image-text pair as the goal, and finally a parameterized image encoder function in the image encoder is obtained. The recognition training is performed simultaneously with the positive and negative sample sets of natural image text and text to obtain a recognition model with the ability to contrast and learn text in natural scenes. The trained model can detect and recognize text in natural scenes, greatly reducing the degree of dependence on labeled data sets.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a text detection and recognition technology, and in particular to a text recognition system training method in a natural scene using self-supervised contrast learning. Background Art

[0002] The success of deep learning often relies on the support of massive data. Supervised learning technology is mature, but it takes a lot of time and resources to label massive data, and the field of natural scene text detection and recognition is no exception. Unsupervised learning does not need to rely on data labels and can automatically discover potential structures in data, saving a lot of time and hardware resources. Therefore, academia and industry are investing more and more in and researching unsupervised learning algorithms.

[0003] As a type of unsupervised learning, contrastive learning focuses on learning the common features between similar instances and distinguishing the differences between non-similar instances. Compared with generative learning, contrastive learning does not need to pay attention to the tedious details of the instance, but only needs to learn to distinguish the data in the feature space at the abstract semantic level. Therefore, the model and its optimization become simpler and have stronger generalization ability. The goal of contrastive learning is to learn an encoder that encodes similar data in a similar way and makes the encoding results of different types of data as different as possible.

[0004] The text detection and recognition method based on self-supervised contrastive learning can be divided into the following five parts: (1) data enhancement process; (2) encoder; (3) representation extraction; (4) similarity measurement; (5) loss function. Assume that D = {x1, x2, ..., x N} is an unlabeled dataset of size N. The premise of contrastive learning is that all instances are classified into one category, that is, the dataset D has N category labels. In order to construct more similar data samples, it is necessary to generate two features (v α ,v + ), where v α Defined as the anchor feature, v + Defined as positive feature. Similarly, in order to construct different types of data samples, negative feature v is generated from different data samples x' - According to the actual situation of the task, the above three features can be vectors Or a multidimensional tensor The following is a description of the five parts:

[0005] Data enhancement process: In the natural scene text detection and recognition task, the purpose of the data enhancement process is to generate anchor, positive and negative features for contrastive learning, namely APN features. n is defined as a random natural scene text image enhancement process, such as random flipping and random channel discarding. Then, A=(α1,α2,...,α N ) is defined as a process of applying these enhancements in sequence. A can be applied to x to generate a new natural scene text image data sample x i , x i The essential characteristics of x are retained. This strategy provides a way to generate multiple samples of the same category defined by sample x. In other words, x can be used as a supervisory signal.

[0006] There are numerous methods to choose from for generating anchor features and positive features of natural scene text images. One of them is to generate v α and v + The method is to sample two subsets from the same feature vector. α 、v + ∈v x (v x is the complete set of features of sample x). The second method is to take the same input and pass it through A twice. At this time, v α ~A(x), due to the randomness of A, this method will generate two different feature sets. Similarly, the negative feature v - ~A(x') is obtained through the same processing method, but the difference is that it is based on the sample x'.

[0007] Encoder: Set f θ Defined as an encoder parameterized by θ, the natural scene text image encoder can be an approximation of any function, such as a fully connected or convolutional neural network. The encoder maps the input v to a set of vectors r, which can be called the representation of x. When x is an image, the input channel is s, the width is w, and the height is h, the encoder f θ The following mapping is performed: In other words, the natural scene text image encoder returns k c-dimensional feature vectors as representations of the input. When the encoder is a convolutional neural network, r is a vector set of feature maps m, where

[0008] Representation extraction: In order to conduct contrastive learning of natural scene text images, it is necessary to extract representations that can be compared with each other. Let r α =f θ (v α ) is the anchor representation, r + =f θ (v +) is a positive example representation, r - =f θ (v - ) is the negative example representation. The representation is applied to v · There are many ways to perform representation extraction, one of which is to extract any representation Generate a single d-dimensional vector as the final output of the encoder. Another approach is to represent each Output a matrix and r α A subset of r - , thereby generating multiple negative example scores.

[0009] Similarity measure: Let φ(r a , r b ) measure two representations of natural scene text images r a and r b The function outputs a scalar score S, which is used to measure r a and r b The similarity between . Examples of similarity measures are dot product, cosine similarity, or bilinear transformation, such as In this case, φ has its own independent parameter W.

[0010] Loss function: S + =φ(r α , r + ) as the positive example score of natural scene text images, S - =φ(r α , r - ) as the negative score. The loss function is defined as a combination of positive and negative scores that reflects the learning progress. Minimizing this loss function corresponds to maximizing the positive score and minimizing the negative score. Currently, the widely used loss functions are: Negative Contrast Estimation Loss, Triplet Loss, and InfoNCE.

[0011] At present, most text detection and recognition methods are based on supervised learning. Such methods rely heavily on massive amounts of natural scene text data, and these data sets cannot cover the ever-changing actual scenes, resulting in the inability to achieve ideal accuracy in actual applications. Although some scholars have proposed text recognition methods based on weakly supervised learning, they can only be used in the training of virtual data sets and cannot be applied to real scene text data sets. In addition, no relevant scholars have yet conducted relevant research on text recognition tasks based on contrastive learning.

[0012] Contrastive learning is an important research method in self-supervised learning methods. Recently, there have been many successful research works in the field of computer vision. In contrastive learning tasks, the goal is to generate representations of instances so that similar instances are close to each other and far away from dissimilar instances. In supervised learning, the similarity between instances is determined by labels. However, without labels, we must seek a new way to exploit the similarity implicit in the instances. Contrastive learning came into being, which represents the similarity between samples by generating anchors, positive samples, and negative samples from unlabeled datasets.

[0013] Currently, natural scene text detection and recognition requires a lot of manual annotation, which makes the cost very high, and how to do it remains an open problem to be solved. Summary of the invention

[0014] To address the problem that natural scene text detection and recognition algorithms rely on a large number of labeled datasets, a self-supervised contrastive learning method for training text recognition systems in natural scenes was proposed. Natural image text and positive and negative sample sets of text were used for simultaneous recognition training to obtain a recognition model with the ability to contrast and learn text in natural scenes. After training, the model can detect and recognize text in natural scenes, greatly reducing the dependence on labeled datasets.

[0015] The technical solution of the present invention is: a method for training a text recognition system in a natural scene by self-supervised contrastive learning, which specifically comprises the following steps:

[0016] 1) Image positive and negative samples: Using a public image dataset, a natural scene text image is selected and processed by image enhancement to obtain multiple samples of the same type as image positive samples. Other natural scene text images are processed by image enhancement to expand the samples and serve as image negative samples;

[0017] 2) Text label positive and negative samples: After the text labels corresponding to the positive samples of the image in step 1) are subjected to text enhancement processing, multiple samples of the same type are obtained as text label positive samples. After the text labels corresponding to the negative samples of the image in step 1) are subjected to text enhancement processing and expanded samples are used as text negative samples;

[0018] 3) The positive and negative samples of the image obtained in step 1) are sent to the image encoder for feature vector extraction, and the positive and negative samples of the text label obtained in step 2) are sent to the text encoder for feature vector extraction;

[0019] 4) In step 3), the feature vector output by the image encoder and the feature vector output by the text encoder are used as a vector pair for similarity calculation to obtain image-text loss and text-image loss respectively. The system is trained with the goal of minimizing the weighted combination of the two losses of the positive sample image-text pair, and finally a parameterized image encoder function in the image encoder is obtained, which is used to extract text features in natural scene text images.

[0020] Furthermore, the image enhancement process in step 1) is as follows: for a natural scene text image, the image is subjected to the image enhancement function t v ,t v is a random transformation function. After the natural scene text image is enhanced, m enhanced natural scene text images are obtained. The processed images retain the essential features of the original images.

[0021] Further, the specific implementation method of step 3) is: the enhanced positive and negative samples of the image After the image encoder function f v Then we get the d-dimensional feature vector h v As the final output of the image encoder, similarly, the enhanced text label positive and negative samples After the text encoder function f u Then we get the d-dimensional feature vector h u As the final output of the text encoder;

[0022] Get h v and h u Afterwards, in order to avoid overfitting of the model during training, h v and h u All adopt nonlinear transformation, and h v Input nonlinear projection function g v , thus obtaining the eigenvector v as g v The output:

[0023]

[0024] h u Input nonlinear projection function g u , so that the eigenvector u is obtained as g u The output:

[0025]

[0026] g v and g u The projection functions belonging to two different modalities are projected from their encoder spaces to the same d-dimensional space for contrastive learning.

[0027] Furthermore, the loss calculation method in step 4) is as follows: during training, a small batch of N image-text input pairs (x v ,x u ), and calculate their eigenvector pairs (v,u), using (v i ,u i ) represents the i-th pair of feature vectors. The training objective includes two loss function calculations. The first loss function is the i-th image-text contrast loss:

[0028]

[0029] in, <v i ,u i > represents cosine similarity, that is, <v i ,u i >=v T u / ||v||||u||, used to measure v i and u i The similarity between the two, Represents the temperature coefficient, which is a hyperparameter for adjusting the cosine similarity weight. The second loss function is the i-th text-image contrast loss:

[0030]

[0031] The final training loss is defined as a weighted combination of the two losses for all positive image-text pairs in each mini-batch, and the average of all mini-batch loss functions is selected as the final training loss:

[0032]

[0033] where λ∈[0,1] is a scalar weight.

[0034] Furthermore, the text encoder function f u Participate in the comparative learning of positive and negative samples of text labels, and assist in training the image encoder function through weighted calculation of two loss functions to improve text recognition accuracy.

[0035] A method for training an image encoder in a self-supervised contrastive learning text recognition system in a natural scene, wherein text labels in positive and negative image samples are used as positive and negative text label samples and sent to a text encoder for contrastive learning as auxiliary training learning of the image encoder, and then image features extracted from positive and negative image samples and text features extracted from positive and negative text label samples are used to form feature pairs, and image-text loss and text-image loss are calculated respectively. The system is trained with the goal of minimizing the weighted combination of the two losses of the positive sample image-text pair, and finally a parameterized image encoder function in the image encoder is obtained.

[0036] The beneficial effect of the present invention is that the method for training a text recognition system in a natural scene using self-supervised comparative learning solves the problem that the text recognition model in existing image data is highly dependent on annotated data sets. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 It is a schematic diagram of the application of the natural scene text detection and recognition system based on self-supervised contrastive learning of the present invention;

[0038] Figure 2 This is a specific implementation diagram of natural scene text detection and recognition training based on self-supervised contrastive learning of the present invention;

[0039] Figure 3 Schematic diagram of positive and negative samples in the present invention. DETAILED DESCRIPTION

[0040] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. This embodiment is implemented based on the technical solution of the present invention, and provides a detailed implementation method and specific operation process, but the protection scope of the present invention is not limited to the following embodiments.

[0041] Figure 1 Schematic diagram of the application of the natural scene text detection and recognition system based on self-supervised contrastive learning. The camera captures the natural scene text image, which is sent to the trained natural scene text detection and recognition model, and the input natural scene text image is inferred and predicted to recognize the text in the natural scene text image.

[0042] like Figure 2 The specific implementation diagram of natural scene text detection and recognition training based on self-supervised contrastive learning is shown in the figure. The input is a public dataset, which is divided into two parts: n natural scene text image samples x v and the n text label samples x in the corresponding image u For each natural scene text image, it will go through the image enhancement function t v ,t v For a random natural scene text image enhancement process, such as random flipping and random channel dropout, the natural scene text image sample x v After enhancement processing, we get n×m natural scene text image samples Keep x v This strategy provides a method for generating multiple samples of the same category from an image sample, which are called positive image samples. At the same time, all other expanded text image samples are used as negative samples of the image, such as Figure 3 Schematic diagram of positive and negative samples. Similarly, for each text label, it will go through the text enhancement function tu ,t u is a random text enhancement process, so the text label sample set x u After enhancement processing, we get n×m text labels Keep x u The strategy provides a method for generating multiple samples of the same category expanded from the text labels corresponding to the positive samples of the image, which are called positive label samples. At the same time, the text label samples after the expansion of all other text labels are used as negative samples of the label. Normally, it is only necessary to enhance the image to obtain the positive and negative samples required for contrastive learning. In the present invention, the text labels are also enhanced to obtain positive and negative samples of the text labels, so that a more robust model is obtained in the final training. At the same time, the label information in the public data set is fully utilized to improve the efficiency of data utilization.

[0043] Then, the enhanced image samples Input image encoder function f v , the enhanced text label Input text encoder function f u . Image encoder function f v and the text encoder function f u Both are parameterized encoders that can be approximations of any function, such as fully connected or convolutional neural networks. The goal of model training is to learn a parameterized image encoder function f v , the text encoder function f u It will also be learned during the training process, but the text encoder function f is not needed in the inference process after training. u , in other words, the text encoder function f u It is to assist in training a more robust image encoder function f v . Enhanced image sample After the image encoder function f v Then we get the d-dimensional feature vector h v As the final output of the image encoder, similarly, the enhanced text label After the text encoder function f u Then we get the d-dimensional feature vector h u As the final output of the text encoder.

[0044] Get h v and h u Afterwards, in order to avoid overfitting of the model during training, h v and h u All of them adopt nonlinear transformation. Specifically, h v Input nonlinear projection function gv , thus obtaining the eigenvector v as g v The output:

[0045]

[0046] Similarly, h u Input nonlinear projection function g u , so that the eigenvector u is obtained as g u The output:

[0047]

[0048] g v and g u The projection functions belonging to two different modalities are projected from their encoder spaces to the same d-dimensional space for contrastive learning.

[0049] During training, a small batch of N image-text input pairs (x v ,x u ), and calculate their eigenvector pairs (v,u). i ,u i ) represents the i-th pair of feature vectors. The training objective includes two loss function calculations. The first loss function is the i-th image-text contrast loss:

[0050]

[0051] in, <v i ,u i 〉 represents the cosine similarity, that is, <v i ,u i 〉=v T u / ||v||||u||, used to measure v i and u i The similarities between the two. In addition, represents the temperature coefficient, which serves as a hyperparameter to adjust the weight of the cosine similarity. This loss function has the same form as the InfoNCE loss, and minimizing this loss will result in an encoder that maximizes the mutual information between positive pairs under the representation function. Intuitively, this is the log loss of an N-way classifier, which attempts to predict (v i ,u i ) is a positive example pair. It is worth noting that unlike previous work that uses contrastive loss between inputs of the same modality, the image-text contrastive loss is asymmetric for each input pair. Therefore, a similar second loss function is the i-th text-image contrastive loss defined as:

[0052]

[0053] Then, the final training loss is defined as a weighted combination of the two losses for all positive image-text pairs in each mini-batch, and the average of all mini-batch loss functions is chosen as the final training loss:

[0054]

[0055] Here, λ∈[0,1] is a scalar weight. It is worth noting that by constructing a weighted combination of the two losses, the loss of the positive pairs is explicitly calculated, and the model implicitly learns to distinguish between negative samples. Minimizing this loss function corresponds to maximizing the positive score and minimizing the negative score, thereby greatly improving the model's ability to distinguish between positive and negative samples, and ultimately improving the recognition accuracy of text in natural scene text images during the reasoning process.

[0056] In the embodiments of the present invention, when the precision and accuracy of the evaluation results are examined, the mean square error method in mathematical statistics is usually used, but the practicality of the results is poor. The present invention proposes a new result examination method, which can implement pixel-level evaluation indicators to evaluate the output results, thereby greatly solving the evaluation unreliability and accuracy in practical problems, and verifying the practical applicability of the system.

[0057] The above-mentioned embodiments only express several implementation methods of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.

Claims

1. A method for training a text recognition system in a natural scene using self-supervised contrastive learning, characterized in that: The specific steps include: 1) Image positive and negative samples: Using a public image dataset, a natural scene text image is selected and processed by image enhancement to obtain multiple samples of the same type as image positive samples. Other natural scene text images are processed by image enhancement to expand the samples and serve as image negative samples; 2) Text label positive and negative samples: After the text labels corresponding to the positive samples of the image in step 1) are subjected to text enhancement processing, multiple samples of the same type are obtained as text label positive samples. After the text labels corresponding to the negative samples of the image in step 1) are subjected to text enhancement processing and expanded samples are used as text negative samples; 3) The positive and negative samples of the image obtained in step 1) are sent to the image encoder for feature vector extraction, and the positive and negative samples of the text label obtained in step 2) are sent to the text encoder for feature vector extraction; Specific implementation method: Enhanced image positive and negative samples After the image encoder function f v Then we get the d-dimensional feature vector h v As the final output of the image encoder, similarly, the enhanced text label positive and negative samples After the text encoder function f u Then we get the d-dimensional feature vector h u As the final output of the text encoder; Get h v and h u Afterwards, in order to avoid overfitting of the model during training, h v and h u All adopt nonlinear transformation, and h v Input nonlinear projection function g v , thus obtaining the eigenvector v as g v The output: h u Input nonlinear projection function g u , so that the eigenvector u is obtained as g u The output: g v and g u The projection functions belonging to two different modalities are projected from their encoder spaces to the same d-dimensional space for contrastive learning; 4) In step 3), the feature vector output by the image encoder and the feature vector output by the text encoder are used as vector pairs for similarity calculation, and image-text loss and text-image loss are obtained respectively. The weighted combination of the two losses of the positive sample image-text pair is minimized as the target to train the system, and finally a parameterized image encoder function in the image encoder is obtained, which is used to extract text features in natural scene text images; Loss calculation method: During training, a small batch of N image-text input pairs (x v ,x u ), and calculate their eigenvector pairs (v,u), using (v i ,u i ) represents the i-th pair of feature vectors. The training objective includes two loss function calculations. The first loss function is the i-th image-text contrast loss: in, <v i ,u i > represents cosine similarity, that is, <v i ,u i >=v T u / ||v||||u||, used to measure v i and u i The similarity between the two, Represents the temperature coefficient, which is a hyperparameter for adjusting the cosine similarity weight. The second loss function is the i-th text-image contrast loss: The final training loss is defined as a weighted combination of the two losses for all positive image-text pairs in each mini-batch, and the average of all mini-batch loss functions is selected as the final training loss: where λ∈[0,1] is a scalar weight.

2. The method for training a text recognition system in a natural scene using self-supervised contrastive learning according to claim 1, characterized in that: The image enhancement process in step 1) is as follows: for a natural scene text image, the image is subjected to an image enhancement function t v ,t v is a random transformation function. After the natural scene text image is enhanced, m enhanced natural scene text images are obtained. The processed images retain the essential features of the original images.

3. The method for training a text recognition system in a natural scene using self-supervised contrastive learning according to claim 1, characterized in that: The text encoder function f in the text encoder u Participate in the comparative learning of positive and negative samples of text labels, and assist in training the image encoder function through weighted calculation of two loss functions to improve text recognition accuracy.

4. A method for training an image encoder, characterized in that: In the self-supervised contrastive learning method for training a text recognition system in a natural scene as described in any one of claims 1 to 3, the text labels in the positive and negative samples of the image are used as positive and negative samples of the text labels and sent to the text encoder for contrastive learning as auxiliary training learning of the image encoder, and then the image features extracted from the positive and negative samples of the image and the text features extracted from the positive and negative samples of the text labels are used to form feature pairs, and the image-text loss and the text-image loss are calculated respectively. The system is trained with the goal of minimizing the weighted combination of the two losses of the positive sample image-text pair, and finally a parameterized image encoder function in the image encoder is obtained.