Image-based text recognition method, device, electronic device and medium

Through lightweight convolutional neural network and feature splitting technology, the problem of poor Chinese and English recognition results and insufficient offline computing power of the existing technology is solved, and the effect of rapid multi-language text recognition is achieved.

CN113869305BActive Publication Date: 2024-10-29BEIJING SOGOU TECHNOLOGY DEVELOPMENT CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202010621847.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-06-30
Publication Date
2024-10-29
Estimated Expiration
2040-06-30

AI Technical Summary

Technical Problem

Existing text recognition methods based on deep learning are not effective in English recognition, and it is difficult to achieve rapid multi-language recognition when the computing power of the offline chip is limited.

Method used

A lightweight convolutional neural network is used for image feature extraction. Through depth-separable convolution and Squeeze-and-Excitation modules, combined with the maximum pooling channel attention mechanism and a new activation function, feature splitting and feature extraction in the height direction are performed. Serialized feature extraction, and finally text recognition using singular value decomposition.

Benefits of technology

It improves the accuracy and speed of recognition while reducing the amount of calculation, and achieves rapid multi-language text recognition with low computing power and low memory usage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113869305B_ABST
    Figure CN113869305B_ABST
Patent Text Reader

Abstract

The embodiment of the present specification discloses an image-based text recognition method, which includes acquiring an image containing text data; performing feature extraction on the image using a lightweight convolutional neural network to obtain a feature map; acquiring serialized features based on a set of height sequence feature maps obtained by splitting the feature map in the height direction; performing text recognition on the serialized features to obtain a recognition result; since the lightweight CNN adopts a depth-separable convolution, the calculation speed can be increased and the memory usage can be reduced with a small amount of calculation; and the serialized features contain feature vectors in the height direction, while retaining the original feature vectors in the height direction, more original features are retained, and the more original features are retained, the higher the recognition accuracy will be; in this way, the recognition accuracy can be improved while reducing the amount of calculation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of this specification relate to the field of text recognition technology, and more particularly to an image-based text recognition method, device, electronic device, and medium. Background Art

[0002] With the continuous development of computer vision, scene text recognition is a branch of computer vision, which has also been rapidly developed and popularized, and has a wide range of application scenarios. For example, scene text recognition is widely used in various fields such as intelligent transportation, image and video retrieval, automatic entry of bills, security monitoring, etc., and in the development process of dictionary pens, scene text recognition technology is also needed.

[0003] At present, the text recognition methods based on deep learning are mainly divided into two categories: CTC loss-based and Attention-based. One is the CTC loss-based method, which has a higher recognition accuracy and a faster recognition speed for Chinese, but is not effective for English recognition. Attention can process non-horizontal texts and has better performance in English recognition, but at a slower speed.

[0004] With the increasing widespread application of dictionary pens in the prior art, there is an urgent need for optical character recognition (OCR) based on dictionary pens, and an offline OCR text recognition method is urgently needed, which can be applied when the computing power of offline chips is limited. Summary of the invention

[0005] The embodiments of this specification provide an image-based text recognition method, device, electronic device, and medium, which can be used to quickly perform multi-language recognition when the computing power of an offline chip is limited.

[0006] A first aspect of the embodiments of this specification provides an image-based text recognition method, comprising:

[0007] Get the image containing the text data;

[0008] Using a lightweight convolutional neural network to extract features from the image to obtain a feature map, wherein the lightweight convolutional neural network includes a depthwise separable convolution;

[0009] Obtain serialized features according to a height sequence feature atlas obtained by splitting the feature graph in the height direction, wherein the height sequence feature atlas includes feature graphs at at least 2 heights;

[0010] Perform text recognition on the serialized features to obtain a recognition result.

[0011] Optionally, acquiring the image containing text data includes:

[0012] The image sent by the scanning device is received, where the image is obtained by scanning the scanning device.

[0013] Optionally, in the process of extracting features from the image using a lightweight convolutional neural network to obtain a feature map, the method further includes:

[0014] If the lightweight convolutional neural network includes a Squeeze-and-Excitation module, the lightweight convolutional neural network adopts a maximum pooling channel attention mechanism when using the Squeeze-and-Excitation module.

[0015] Optionally, in the process of extracting features from the image using a lightweight convolutional neural network to obtain a feature map, the method further includes:

[0016] If the lightweight convolutional neural network adopts a new activation function, and when the value of the input variable of the new activation function is greater than a preset value, the corresponding output variable is determined to be the preset value, and the preset value is a value not less than 2; if the value of the input variable is within a set value range, the corresponding output variable is determined to be equal to the input variable, wherein the set value range is a range greater than 0 and not greater than the preset value; and when the value of the input variable is less than 0, the corresponding output variable is determined to be the product of the preset parameter and the input variable.

[0017] Optionally, performing text recognition on the serialized features to obtain a recognition result includes:

[0018] Singular value decomposition is used to perform text recognition on the serialized features to obtain a recognition result.

[0019] Optionally, the using singular value decomposition to perform text recognition on the serialized features to obtain a recognition result includes:

[0020] Mapping the serialized features into a matrix of classification probabilities and splitting the matrix to obtain M matrices, where M is an integer not less than 2;

[0021] The text recognition is performed according to the M matrices and the serialized features to obtain the recognition result. The second aspect of the embodiment of this specification provides an image-based text recognition device, comprising:

[0022] An image acquisition module, which acquires images containing text data;

[0023] A feature map acquisition module, used to extract features from the image using a lightweight convolutional neural network to obtain a feature map, wherein the lightweight convolutional neural network includes a depth-separable convolution;

[0024] A serialization feature acquisition module, used for acquiring serialization features according to a height sequence feature atlas obtained by splitting the feature graph in the height direction, wherein the height sequence feature atlas includes feature graphs at at least 2 heights;

[0025] The recognition module is used to perform text recognition on the serialized features to obtain a recognition result.

[0026] Optionally, the image acquisition module is used to receive the image sent by a scanning device, and the image is scanned by the scanning device.

[0027] Optionally, the feature map acquisition module further includes:

[0028] Pooling unit, if the lightweight convolutional neural network includes a Squeeze-and-Excitation module, is used for the lightweight convolutional neural network to use a maximum pooling channel attention mechanism when using the Squeeze-and-Excitation module.

[0029] Optionally, the feature map acquisition module further includes:

[0030] An activation unit, if the lightweight convolutional neural network adopts a new activation function, and the new activation function is used to determine that the corresponding output variable is the preset value when the value of the input variable is greater than the preset value, and the preset value is a value not less than 2; if the value of the input variable is within a set value range, the corresponding output variable is determined to be equal to the input variable, wherein the set value range is a range greater than 0 and not greater than the preset value; and when the value of the input variable is less than 0, the corresponding output variable is determined to be the product of the preset parameter and the input variable.

[0031] Optionally, the recognition module is used to perform text recognition on the serialized features using singular value decomposition to obtain a recognition result.

[0032] Optionally, the identification module further includes:

[0033] A matrix splitting unit, used for splitting the matrix of the classification probability mapped to the serialized feature to obtain M matrices, where M is an integer not less than 2;

[0034] A recognition unit is used to perform text recognition according to the M matrices and the serialization features to obtain the recognition result.

[0035] A third aspect of the embodiments of the present specification provides a device for data processing, characterized in that it includes a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors. The one or more programs include steps for the image-based text recognition method as described above.

[0036] A fourth aspect of the embodiments of this specification provides a machine-readable medium having instructions stored thereon, which, when executed by one or more processors, enables the device to perform the above-mentioned image-based text recognition method.

[0037] The beneficial effects of the embodiments of this specification are as follows:

[0038] Based on the above technical solution, after obtaining an image containing text data, a lightweight CNN is used to process the image to obtain a feature map; the feature map is then split in the height direction to obtain a height sequence feature atlas, and serialized features are obtained based on the height feature sequence atlas; finally, the serialized features are used for recognition to obtain a recognition result; since the lightweight CNN adopts a depth-separable convolution, the calculation speed can be improved and the memory usage can be reduced with a small amount of calculation; and the serialized features contain feature vectors in the height direction, while retaining the original feature vectors in the height direction, more original features are retained, and the more original features are retained, the higher the recognition accuracy will be; in this way, the recognition accuracy can be improved while reducing the amount of calculation, so that the text recognition method of the present invention can be applied to quickly perform multi-language text recognition under low computing power and low memory usage. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 This is a flow chart of the channel attention mechanism using maximum pooling when the SE module is used in the embodiments of this specification;

[0040] Figure 2 This is a first flow chart of the image-based text recognition method in the embodiments of this specification;

[0041] Figure 3 is a second flow chart of the image-based text recognition method in the embodiments of this specification;

[0042] Figure 4 is an overall flow chart of the image-based text recognition method in the embodiments of this specification;

[0043] Figure 5 Schematic diagram of the structure of the image-based text recognition device in the embodiments of this specification;

[0044] Figure 6It is a structural block diagram of the apparatus for image-based text recognition used as a device in the embodiments of this specification;

[0045] Figure 7 This is a structural block diagram of the server in some embodiments of the present specification. DETAILED DESCRIPTION

[0046] In order to better understand the above technical scheme, the technical scheme of the embodiments of this specification is described in detail below through the accompanying drawings and specific embodiments. It should be understood that the embodiments of this specification and the specific features in the embodiments are detailed descriptions of the technical scheme of the embodiments of this specification, rather than limitations on the technical scheme of this specification. In the absence of conflict, the embodiments of this specification and the technical features in the embodiments can be combined with each other.

[0047] In response to the technical problem of image-based text recognition methods under the condition of limited offline chip computing power, an embodiment of the present invention provides an image-based text recognition solution, which is used to perform text recognition on an acquired image in real time, and specifically may include: acquiring an image containing text data; using a lightweight convolutional neural network to perform feature extraction on the image to obtain a feature map, wherein the lightweight convolutional neural network includes a depth-separable convolution; obtaining serialized features based on a height sequence feature atlas obtained by splitting the feature map in the height direction, wherein the height sequence feature atlas includes feature maps at at least 2 heights; performing text recognition on the serialized features to obtain a recognition result.

[0048] In an embodiment of the present invention, after an image is obtained by scanning an electronic book or a paper book through a scanning device, the image is transmitted to a server so that the server obtains the image. In this way, the obtained image can contain text data, wherein the text data can be any text data in English, Japanese, Chinese, French, German, etc.

[0049] In the embodiment of the present invention, a lightweight neural network model (Convolutional Neural Networks, CNN for short) may be, for example, SqueezeNet, MobileNet, ShuffleNet, and Xception.

[0050] Specifically, lightweight CNN uses depthwise separable convolution, which is composed of channel-by-channel convolution and point-by-point convolution. A convolution kernel of channel-by-channel convolution is only responsible for one channel, and a channel is convolved by only one convolution kernel. For example, if lightweight CNN has three channels, convolution is performed on the three channels separately, and the attributes of the three channels are output: the convolution kernel 1x1x3 is used to perform convolution again on the attributes of the output three channels, and the output data is the same as the traditional convolution output data.

[0051] At this time, since the lightweight CNN uses depthwise separable convolution, which is equivalent to traditional convolution, it splits the calculation data, which can greatly reduce the amount of calculation, thereby reducing the number of operations, improving network speed, and reducing memory usage.

[0052] Before training the lightweight CNN, the image needs to be preprocessed. Specifically, the image can be grayed, enhanced, height-fixed, and resized normalized. In this way, when the preprocessed image is used for feature extraction, the extracted feature map is more accurate.

[0053] When training the lightweight CNN, its training samples may be pictures containing text data, and the text data may be in English, Chinese characters, Japanese, French, etc., and this specification does not impose any specific restrictions.

[0054] Specifically, when performing model training, a large number of pictures containing text data can be obtained as training sample sets. For the training samples in the training sample set, the training steps include: step A1, preprocessing the training samples; step A2, inputting the preprocessed training samples into the lightweight CNN to obtain feature maps; step A3, splitting the feature maps in the height direction to obtain a height sequence feature map set, the height sequence feature map set contains feature maps at least at 2 heights; and obtaining serialized features based on the height sequence feature map set; step A4, inputting the serialized features into the classifier for classification and recognition; step A5, adjusting the lightweight CNN according to the classification and recognition results until the classification and recognition results meet the constraints, and taking the model corresponding to the constraints as the final lightweight CNN.

[0055] Also, during the model training process, Focal CTC Loss can be used as the loss function, and during recognition, decoding can be performed based on the classification probability to obtain the recognition result. Furthermore, the trained lightweight CNN can be verified using the test set, and after the verification meets the verification requirements, the lightweight CNN is obtained; if the model verification does not meet the verification requirements, the model is trained again using the training samples until the trained model meets the verification requirements, and the trained model is used as the final model, which is the lightweight CNN.

[0056] Specifically, in the process of creating lightweight CNN, a new activation function is also designed for lightweight CNN. On the one hand, the new activation function can prevent the gradient from becoming 0 when the input is negative, and on the other hand, it can limit the maximum output value to 6, so that the lightweight CNN can better maintain accuracy after quantization (FP16, int8). If the activation range is not restricted and the output range is positive infinity, the low-precision FP16 or int8 cannot accurately describe such a large range of values, which will result in loss of accuracy. The new activation function is much less computationally expensive than hard swish and can achieve an approximate effect. Therefore, compared with hard swish, the new activation function has an approximate accuracy but a faster calculation speed, which can improve the computational efficiency while ensuring the computational accuracy of lightweight CNN.

[0057] Specifically, if the lightweight convolutional neural network adopts a new activation function, and the new activation function is greater than the preset value when the value of the input variable is greater than the preset value, then the corresponding output variable is determined to be the preset value, and the preset value is a value not less than 2; if the value of the input variable is within the set value range, the corresponding output variable is determined to be equal to the input variable, where the set value range is a range greater than 0 and not greater than the preset value; and when the value of the input variable is less than 0, the corresponding output variable is determined to be the product of the preset parameter and the input variable.

[0058] In the embodiments of this specification, the preset value may be, for example, 3, 4, 5, and 6, and preferably, the preset value is 6. The preset value of 6 is specifically taken as an example below.

[0059] If the value of the input variable of the new activation function is greater than 6, the corresponding output variable is determined to be 6; if the value of the input variable is within the set value range, the corresponding output variable is determined to be equal to the input variable, where the set value range is greater than 0 and not greater than 6; and when the value of the input variable is less than 0, the corresponding output variable is determined to be the product of the preset parameter and the input variable. Specifically, the formula of the new activation function is as follows:

[0060]

[0061] In formula 1, x i represents the input variable, f(x i ) represents the output variable, a i are the preset parameters that need to be learned.

[0062] Specifically, if a i =1 / 2, the output vector of a convolutional layer is According to formula 1, the input vector of the next convolutional layer is determined as

[0063] Specifically, when the lightweight CNN uses the Squeeze-and-Excitation (SE) module, it adopts the maximum pooling channel attention mechanism.

[0064] Since the embodiment of the present invention is used for text recognition, the image needs to be scaled according to the aspect ratio, the height is fixed, and the image with insufficient width is padded with 0; however, when using lightweight CNN for recognition, the image is not padded with 0, and the average pooling used by the SE module will cause the weight of the SE module to be inconsistent with the weight during training during recognition, so that the accuracy of the recognition result of the lightweight CNN is low during recognition. Thus, in order to solve the above problem, the embodiment of the present invention adopts the channel attention mechanism of maximum pooling when using the SE module.

[0065] Specifically, when using the SE module, the channel attention mechanism of maximum pooling is used in the specific implementation process. Before the SE module is input, the part of the feature corresponding to the 0-padded part is set to 0 to prevent the 0-padded part from not being 0 after passing through CNN to ensure the calculation accuracy. When calculating attention, since the image feature part usually contains a part greater than 0, the use of maximum pooling can ensure that the weights of the SE module are consistent during training and recognition. Through the above-mentioned attention mechanism, the interdependence between feature channels can be explicitly modeled, useful features can be enhanced and some invalid features can be suppressed, and the probability of attention changes caused by image padding operations can be reduced.

[0066] like Figure 1 As shown in FIG. 1 , it is a flow chart of the channel attention mechanism using the maximum pooling when using the SE module. The input10 layer inputs the image containing the text data cry; however, after the image is scaled according to the aspect ratio and the height is fixed, the width of the image is not enough, so the image needs to be padded with 0, and the padded 0 part is 101; then the padded 0 image is subjected to the block11 layer, i.e., convolution, to obtain the feature map; since the features corresponding to the padded 0 part in the feature map may not be 0, it is necessary to multiply the feature map with the mask matrix 20, where mask20 is a matrix, the features corresponding to the image in the mask20 matrix are 1, and the features corresponding to the padded 0 part are 0, so that the feature map is multiplied with mask20 through the mul12 layer, and then the features corresponding to the padded 0 part in the feature map are changed to 0 through the Mul12 layer, and the features corresponding to the image remain unchanged; then the feature map processed by the mul12 layer is processed using the global max pooling 13, where the global max pooling 13 is used as a Squeeze operation. Then two fully connected (FC) layers form a Bottleneck structure to model the correlation between channels and output the same number of weights as the input features.

[0067] In the global maximum pooling 13, each W×H×C feature map input will be converted into a 1×1×C output. Therefore, it is actually equivalent to the FC layer operation where the weight of each position is 1 / (W×H).

[0068] After the feature map passes through the global maximum pooling 13, it first enters the FC layer 14 to reduce the feature dimension of the feature map to 1 / 16 of the input, and then passes through the ReLu layer 15 to activate and then pass through the FC layer 16 to return to the original dimension; the advantages of doing this over directly using an FC layer are: 1) it has more nonlinearity and can better fit the complex correlation between channels; 2) it greatly reduces the number of parameters and the amount of calculation. Then a Sigmoid 17 layer is used to obtain a normalized weight between 0 and 1, and finally a Scale 18 layer is used to weight the normalized weight to the features of each channel.

[0069] In this way, before the feature is input into the SE module, the part of the feature corresponding to the 0-padded part is set to 0 to prevent the 0-padded part from being non-0 after passing through CNN. When calculating attention, since the image feature part usually contains a part greater than 0, the maximum pooling process is used to ensure that the SE weights are consistent during training and prediction. Through this attention mechanism, the interdependence between feature channels can be explicitly determined, useful features can be promoted, and some invalid features can be suppressed, so that the feature map obtained by the SE module is more accurate.

[0070] After training a lightweight CNN, the lightweight CNN is used to extract features from the image to obtain a feature map; and after obtaining the feature map, the feature map is split in the height direction to obtain a height sequence feature atlas set, which includes feature maps at at least 2 heights; and then serialized features are obtained based on the height feature sequence atlas set.

[0071] Specifically, if the feature map is represented by F, then F is decomposed into a sequence F1, F2, and so on to F n The characteristic graph of F1, F2 to F n The feature graph of is used as a height sequence feature atlas; and the serialized features are obtained according to the height sequence feature atlas. Of course, n can also be an integer equal to 2, and the present invention does not make any specific limitation.

[0072] Specifically, the formula for serialization features is as follows:

[0073]

[0074] In formula 2, W i To learn the parameters of the model, F i Represents the feature map in the height direction.

[0075] According to Formula 2, the serialized features include feature vectors in the height direction. While retaining the original feature vectors in the height direction, more original features are retained. The more original features are retained, the higher the recognition accuracy will be.

[0076] After obtaining the serialized features, the classifier is used to identify the serialized features to obtain the recognition result. Specifically, since the classifier is used to classify the serialized features, the serialized features are obtained as the classification probability of each word in the dictionary. At this time, in order to make the obtained recognition result more accurate, the classification probability of the serialized feature mapping can be decoded by beam search and greedy search, and the decoding result is the recognition result.

[0077] For example, if the dictionary is a, b and c, when generating the first word, select the word with the highest probability. If the current words with the highest probability are a and b respectively, then the current sequence is a; when generating the second word, combine the current sequence a or b with all the words in the dictionary respectively to obtain 6 new sequences aa ab ac ba bb bc, and then select the one with the highest probability as the current sequence, for example, ab, and repeat this process until the end symbol is encountered; finally, output the sequence with the highest probability as the recognition result.

[0078] After acquiring an image containing text data, the embodiment of the present invention uses a lightweight CNN to process the image to obtain a feature map; then splits the feature map in the height direction to obtain a height sequence feature atlas, and obtains serialized features based on the height feature sequence atlas; finally, uses the serialized features for recognition to obtain a recognition result; because the lightweight CNN adopts a depth-separable convolution, it can improve the calculation speed and reduce the memory usage with a small amount of calculation; and the serialized features include feature vectors in the height direction, while retaining the original feature vectors in the height direction, more original features are retained, and the more original features are retained, the higher the recognition accuracy; in this way, the recognition accuracy can be improved while reducing the amount of calculation, so that the text recognition method of the present invention can be applied to quickly perform multi-language text recognition under low computing power and low memory occupancy.

[0079] Method Example 1

[0080] Reference Figure 2 , shows a flowchart of a first embodiment of an image-based text recognition method of the present invention, which may specifically include the following steps:

[0081] S201, acquiring an image containing text data;

[0082] S202, using a lightweight convolutional neural network to extract features from the image to obtain a feature map, wherein the lightweight convolutional neural network includes a depthwise separable convolution;

[0083] S203, obtaining serialized features according to a height sequence feature atlas obtained by splitting the feature graph in the height direction, wherein the height sequence feature atlas includes feature graphs at at least two heights;

[0084] S204: Perform text recognition on the serialized features to obtain recognition results.

[0085] The text recognition method in the embodiment of the present invention can also be applied in the client and the server, wherein the client can be a scanning device such as a dictionary pen, a scanning pen and a camera device; the server can be an electronic device such as a desktop computer, a laptop computer, a tablet computer, an all-in-one machine, a smart phone and a smart watch.

[0086] In step S201, when the text recognition method in the embodiment of the present invention is applied to a server, an image sent by a scanning device can be received, and the image is scanned by the scanning device. When the text recognition method in the embodiment of the present invention is applied to a client, the client is directly used to scan and obtain the image.

[0087] Specifically, the scanning device can be a dictionary pen, a scanning pen, a camera device, etc. In this way, after scanning an electronic book or a paper book and obtaining an image through the scanning device, the image can be transmitted to a server so that the server obtains the image. In this way, the obtained image can contain text data.

[0088] After the image is acquired in step S201, step S202 is executed.

[0089] In executing step S202, the image may be preprocessed first, and then step S202 may be executed on the preprocessed image; or the image may be directly used to execute step S202, which is not specifically limited in this specification.

[0090] When preprocessing an image, the image may be subjected to at least one of grayscale processing, image enhancement processing, image height fixing processing, and image size normalization processing, so that when feature extraction is performed on the preprocessed image, the extracted feature map is more accurate.

[0091] Specifically, in order to ensure that the feature map extracted by the lightweight CNN is more accurate during the feature extraction process, the image preprocessing may include at least three steps: grayscale processing of the image, image height fixing processing, and image size normalization processing.

[0092] In the embodiments of this specification, a lightweight neural network model (Convolutional Neural Networks, referred to as CNN) is used. For example, a lightweight CNN may be SqueezeNet, MobileNet, ShuffleNet, and Xception.

[0093] Specifically, lightweight CNN uses depthwise separable convolution, which is composed of channel-by-channel convolution and point-by-point convolution. A convolution kernel of channel-by-channel convolution is only responsible for one channel, and a channel is convolved by only one convolution kernel. For example, if lightweight CNN has three channels, convolution is performed on the three channels separately, and the attributes of the three channels are output: the convolution kernel 1x1x3 is used to perform convolution again on the attributes of the output three channels, and the output data is the same as the traditional convolution output data.

[0094] At this time, since the lightweight CNN uses depthwise separable convolution, which is equivalent to traditional convolution, it splits the calculation data, which can greatly reduce the amount of calculation, thereby reducing the number of operations, improving network speed, and reducing memory usage.

[0095] Before executing step S202, model training is required to obtain a lightweight CNN. The training process of the lightweight CNN is specifically referred to the training process of the above steps A1-A5. For the sake of brevity of the specification, it will not be repeated here.

[0096] Specifically, a lightweight CNN is used to extract features from the preprocessed image. Since a new activation function is used in the feature extraction process of the lightweight CNN, the new activation function can prevent the gradient from becoming 0 when the input is negative, and can limit the maximum output value to 6, so that the lightweight CNN can better maintain accuracy after quantization (FP16, int8). If the activation range is not restricted and the output range is positive infinity, the low-precision FP16 or int8 cannot accurately describe such a large range of values, resulting in a loss of accuracy. The new activation function is much less computationally expensive than hard swish and can achieve an approximate effect. Therefore, compared with hard swish, the new activation function has an approximate accuracy but a faster calculation speed, which can improve the calculation efficiency while ensuring the calculation accuracy of the lightweight CNN.

[0097] Specifically, when the lightweight CNN uses the SE module, the maximum pooling channel attention mechanism is adopted. In this way, the maximum pooling processing is used when using the SE module, which can ensure the consistency of SE weights during training and prediction, and can explicitly determine the interdependence between feature channels, enhance useful features and suppress some invalid features, so that the feature map obtained by the SE module is more accurate.

[0098] After the feature map is obtained, step S203 is executed. In this step, the feature map is first split in the height direction to obtain a height sequence feature map set, which includes feature maps at least at two heights; and then the serialized features are obtained according to the height feature sequence map set.

[0099] Specifically, if the feature map is represented by F, then F is decomposed into a sequence F1, F2, and so on to F n The characteristic graph of F1, F2 to F n The feature graph of is used as a height sequence feature atlas; and the serialized features are obtained according to the height sequence feature atlas. Of course, n can also be an integer equal to 2, and the present invention does not make any specific limitation.

[0100] Specifically, the serialized features can be obtained through the above formula 2. Since the serialized features include the feature vectors in the height direction, more original features are retained while retaining the original feature vectors in the height direction. The more original features are retained, the higher the recognition accuracy will be.

[0101] Next, step S204 is executed to perform text recognition on the serialized features to obtain a recognition result.

[0102] Specifically, a classifier can be used to identify the serialized features to obtain a recognition result. Specifically, since a classifier is used to classify the serialized features, a series of probabilities are obtained. At this time, in order to make the obtained recognition result more accurate, beam search and greedy search can be used for decoding, and the decoding result is the recognition result.

[0103] After acquiring an image containing text data, the embodiment of the present invention uses a lightweight CNN to process the image to obtain a feature map; then splits the feature map in the height direction to obtain a height sequence feature atlas, and obtains serialized features based on the height feature sequence atlas; finally, uses the serialized features for recognition to obtain a recognition result; because the lightweight CNN adopts a depth-separable convolution, it can improve the calculation speed and reduce the memory usage with a small amount of calculation; and the serialized features include feature vectors in the height direction, while retaining the original feature vectors in the height direction, more original features are retained, and the more original features are retained, the higher the recognition accuracy; in this way, the recognition accuracy can be improved while reducing the amount of calculation, so that the text recognition method of the present invention can be applied to quickly perform multi-language text recognition under low computing power and low memory occupancy.

[0104] Method Example 2

[0105] Reference Figure 3, shows a flowchart of a first embodiment of an image-based text recognition method of the present invention, which may specifically include the following steps:

[0106] S301, acquiring an image containing text data;

[0107] S302, using a lightweight convolutional neural network to extract features from the image to obtain a feature map, wherein the lightweight convolutional neural network includes a depthwise separable convolution;

[0108] S303, obtaining serialized features according to a height sequence feature atlas obtained by splitting the feature graph in the height direction, wherein the height sequence feature atlas includes feature graphs at at least two heights;

[0109] S304: Use singular value decomposition to perform text recognition on the serialized features to obtain a recognition result.

[0110] Among them, steps S301-S303 can refer to the description of steps S201-S203 in the above method embodiment 1, and for the sake of brevity of the description, they will not be repeated here.

[0111] After the serialization features are obtained in step S303, step S304 is executed.

[0112] In step S304, when performing text recognition on serialized features, the serialized features are mapped to classification probabilities; since the matrix of serialized features mapped to classification probabilities is too large, the matrix of serialized features mapped to classification probabilities can be split to obtain M matrices, where M is an integer not less than 2; text recognition is performed based on the M matrices and serialized features to obtain recognition results.

[0113] Specifically, since the embodiment of the present invention is applied to the text recognition method, when performing text recognition on the serialized features, the serialized features are mapped to the classification probability of each word in the dictionary. Also, in the process of performing text recognition based on M matrices and serialized features, since the calculated result is the classification probability of each word in the dictionary for the serialized features, in order to make the recognition result more accurate, the classification probability mapped by the serialized features can be decoded by using beam search and greedy search, and the decoding result is the recognition result.

[0114] For example, the serialized features are 512-dimensional, and the mapping to the dictionary is divided into 8143 categories, one category corresponds to one word, and the full connection between the serialized features and the dictionary requires 512×8143, but the computational complexity of the 512×8143 matrix is ​​too large. Therefore, it is necessary to decompose the 512×8143 matrix to remove redundant information. For example, decompose the 512×8143 matrix into two matrices, 512×128 and 128×8143. The computational complexity of the two small matrices is much smaller than that of the large matrix 512×8143, which can effectively improve the recognition efficiency.

[0115] In this way, by performing text recognition on serialized features through singular value decomposition, it is possible to reduce the amount of calculation and thus improve recognition efficiency while ensuring the accuracy of recognition.

[0116] See also Figure 4 , which is the overall flow chart of the image-based text recognition method of the embodiment of the present invention. First, execute step 41 to obtain an image containing text data; then execute step 42 to perform preprocessing, which includes at least one of the processing steps of graying the image, image enhancement, image height fixing, and image size normalization; then execute step 43 to use lightweight CNN to extract features, that is, input the preprocessed image into the lightweight CNN to obtain a feature map, and its specific implementation process refers to the discussion of step S202; then execute step 44 to perform feature serialization, and the specific implementation process refers to the discussion of step S203; then execute step 45 to calculate the classification probability, and the specific implementation process refers to the discussion of step S304; then execute step 46 to decode, and specifically, the classification probability can be decoded using beam search and greedy search to obtain the recognition result.

[0117] Device Embodiment

[0118] Reference Figure 5 , shows a structural block diagram of an embodiment of an image-based text recognition device of the present invention, which may specifically include:

[0119] An image acquisition module 501 acquires an image containing text data;

[0120] A feature map acquisition module 502, configured to extract features from the image using a lightweight convolutional neural network to obtain a feature map, wherein the lightweight convolutional neural network includes a depthwise separable convolution;

[0121] A serialization feature acquisition module 503 is used to acquire serialization features according to a height sequence feature atlas obtained by splitting the feature graph in the height direction, wherein the height sequence feature atlas includes feature graphs at at least two heights;

[0122] The recognition module 504 is used to perform text recognition on the serialization features to obtain a recognition result.

[0123] In an optional implementation, the image acquisition module 501 is used to receive the image sent by a scanning device, where the image is scanned by the scanning device.

[0124] In an optional implementation, the feature map acquisition module 502 further includes:

[0125] Pooling unit, if the lightweight convolutional neural network includes a Squeeze-and-Excitation module, is used for the lightweight convolutional neural network to use a maximum pooling channel attention mechanism when using the Squeeze-and-Excitation module.

[0126] In an optional implementation, the feature map acquisition module 502 further includes:

[0127] An activation unit, if the lightweight convolutional neural network adopts a new activation function, and the new activation function is used to determine that the corresponding output variable is the preset value when the value of the input variable is greater than the preset value, and the preset value is a value not less than 2; if the value of the input variable is within a set value range, the corresponding output variable is determined to be equal to the input variable, wherein the set value range is a range greater than 0 and not greater than the preset value; and when the value of the input variable is less than 0, the corresponding output variable is determined to be the product of the preset parameter and the input variable.

[0128] In an optional implementation, the recognition module 504 is used to perform text recognition on the serialization features using singular value decomposition to obtain a recognition result.

[0129] In an optional implementation, the identification module 504 further includes:

[0130] A matrix splitting unit, used for splitting the matrix of the classification probability mapped to the serialized feature to obtain M matrices, where M is an integer not less than 2;

[0131] A recognition unit is used to perform text recognition according to the M matrices and the serialization features to obtain the recognition result.

[0132] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0133] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0134] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0135] Figure 6 1 is a block diagram of a device for image-based text recognition according to an exemplary embodiment. For example, the device 900 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0136] Reference Figure 6 , the device 900 may include one or more of the following components: a processing component 902 , a memory 904 , a power component 906 , a multimedia component 908 , an audio component 910 , an input / output (I / O) interface 912 , a sensor component 914 , and a communication component 916 .

[0137] The processing component 902 generally controls the overall operation of the device 900, such as operations associated with display, incoming calls, data communications, camera operations, and recording operations. The processing component 902 may include one or more processors 920 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 902 may include one or more modules to facilitate the interaction between the processing component 902 and other components. For example, the processing component 902 may include a multimedia module to facilitate the interaction between the multimedia component 908 and the processing component 902.

[0138] The memory 904 is configured to store various types of data to support operations on the device 900. Examples of such data include instructions for any application or method operating on the device 900, contact data, caller book data, messages, pictures, videos, etc. The memory 904 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0139] The power supply component 906 provides power to the various components of the device 900. The power supply component 906 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 900.

[0140] The multimedia component 908 includes a screen that provides an output interface between the device 900 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide motion action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 908 includes a front camera and / or a rear camera. When the device 900 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0141] The audio component 910 is configured to output and / or input audio signals. For example, the audio component 910 includes a microphone (MIC), and when the device 900 is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 904 or sent via the communication component 916. In some embodiments, the audio component 910 also includes a speaker for outputting audio signals.

[0142] I / O interface 912 provides an interface between processing component 902 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.

[0143] The sensor assembly 914 includes one or more sensors for providing various aspects of status assessment for the device 900. For example, the sensor assembly 914 can detect the open / closed state of the device 900, the relative positioning of components, such as the display and keypad of the device 900, and the sensor assembly 914 can also detect the position change of the device 900 or a component of the device 900, the presence or absence of user contact with the device 900, the orientation or acceleration / deceleration of the device 900, and the temperature change of the device 900. The sensor assembly 914 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 914 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 914 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0144] The communication component 916 is configured to facilitate wired or wireless communication between the device 900 and other devices. The device 900 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 916 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 916 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0145] In an exemplary embodiment, the apparatus 900 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above method.

[0146] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 904 including instructions, and the instructions can be executed by the processor 920 of the device 900 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0147] Figure 7 1 is a block diagram of the structure of the server in some embodiments of the present invention. The server 1900 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 1922 (for example, one or more processors) and memory 1932, and one or more storage media 1930 (for example, one or more mass storage devices) storing application programs 1942 or data 1944. Among them, the memory 1932 and the storage medium 1930 can be short-term storage or permanent storage. The program stored in the storage medium 1930 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the server. Furthermore, the central processing unit 1922 can be configured to communicate with the storage medium 1930 and execute a series of instruction operations in the storage medium 1930 on the server 1900.

[0148] The server 1900 may also include one or more power supplies 1926, one or more wired or wireless network interfaces 1950, one or more input and output interfaces 1958, one or more keyboards 1956, and / or, one or more operating systems 1941, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.

[0149] A non-temporary computer-readable storage medium, when the instructions in the storage medium are executed by a processor of an apparatus (device or server), enables the apparatus to execute an image-based text recognition method, the method comprising: determining a duration feature corresponding to a text to be processed; the text to be processed involves at least two languages; determining a target speech sequence corresponding to the text to be processed based on the duration feature; determining a target image sequence corresponding to the text to be processed based on the duration feature; the target image sequence is obtained based on a text sample and its corresponding image sample; the language corresponding to the text sample includes: all languages ​​involved in the text to be processed; the target speech sequence and the target image sequence are fused to obtain a corresponding target video.

[0150] This specification is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of this specification. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that has the functions specified in one or more boxes.

[0151] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0152] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0153] Although the preferred embodiments of this specification have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of this specification.

[0154] Obviously, those skilled in the art can make various changes and modifications to this specification without departing from the spirit and scope of this specification. Thus, if these modifications and variations of this specification fall within the scope of the claims of this specification and their equivalents, this specification is also intended to include these modifications and variations.

Claims

1. A text recognition method based on an image, characterized in that: include: Get the image containing the text data; Using a lightweight convolutional neural network to extract features from the image to obtain a feature map, wherein the lightweight convolutional neural network includes a depthwise separable convolution; Obtain serialized features according to a height sequence feature atlas obtained by splitting the feature graph in the height direction, wherein the height sequence feature atlas includes feature graphs at at least 2 heights; Performing text recognition on the serialized features to obtain a recognition result; The performing text recognition on the serialized features to obtain a recognition result includes: Mapping the serialized features into a matrix of classification probabilities and splitting the matrix to obtain M matrices, where M is an integer not less than 2; Text recognition is performed according to the M matrices and the serialized features to obtain the recognition result.

2. The method according to claim 1, characterized in that The step of acquiring an image containing text data comprises: The image sent by the scanning device is received, where the image is obtained by scanning the scanning device.

3. The method according to claim 2, characterized in that In the process of extracting features from the image using a lightweight convolutional neural network to obtain a feature map, the method further includes: If the lightweight convolutional neural network includes a Squeeze-and-Excitation module, the lightweight convolutional neural network adopts a maximum pooling channel attention mechanism when using the Squeeze-and-Excitation module.

4. The method according to claim 3, characterized in that In the process of extracting features from the image using a lightweight convolutional neural network to obtain a feature map, the method further includes: If the lightweight convolutional neural network adopts a new activation function, and when the value of the input variable of the new activation function is greater than a preset value, the corresponding output variable is determined to be the preset value, and the preset value is a value not less than 2; if the value of the input variable is within a set value range, the corresponding output variable is determined to be equal to the input variable, wherein the set value range is a range greater than 0 and not greater than the preset value; and when the value of the input variable is less than 0, the corresponding output variable is determined to be the product of the preset parameter and the input variable.

5. An image-based text recognition device, characterized in that: include: An image acquisition module, which acquires images containing text data; A feature map acquisition module, used to extract features from the image using a lightweight convolutional neural network to obtain a feature map, wherein the lightweight convolutional neural network includes a depth-separable convolution; A serialization feature acquisition module, used for acquiring serialization features according to a height sequence feature atlas obtained by splitting the feature graph in the height direction, wherein the height sequence feature atlas includes feature graphs at at least 2 heights; A recognition module, used to perform text recognition on the serialized features to obtain a recognition result; The identification module further includes: A matrix splitting unit, used for splitting the matrix of the classification probability mapped to the serialized feature to obtain M matrices, where M is an integer not less than 2; A recognition unit is used to perform text recognition according to the M matrices and the serialization features to obtain the recognition result.

6. The device according to claim 5, characterized in that The image acquisition module is used to receive the image sent by the scanning device, and the image is scanned by the scanning device.

7. A device for data processing, characterized in that: The device comprises a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors, and the one or more programs include the method steps according to any one of claims 1 to 4.

8. A machine-readable medium having instructions stored thereon, which, when executed by one or more processors, causes a device to perform the image-based text recognition method as claimed in any one of claims 1 to 4.

Citation Information

Patent Citations

  • End-to-end lightweight license plate recognition method and device

    CN107704857A

  • Image processing method and device, electronic equipment and storage medium

    CN110348537A

  • SSD target detection method based on SE module and computer storage medium

    CN110543879A

  • Image target detection method and system based on convolutional neural network, and readable storage medium

    CN113052006A

  • Text recognition method and device, model training method and device and electronic equipment

    CN114693904A