Image text recognition method and device based on CTC

By combining the CTC text recognition model and the semantic correction model in image text recognition, the problem of low image text recognition accuracy in natural scenes is solved, efficient recognition and error correction of image text is achieved, and the recognition accuracy and user experience are improved. .

CN112766052BActive Publication Date: 2024-10-15GUANGZHOU YOUMI INFORMATION TECH
View PDF 11 Cites 0 Cited by

Patent Information

Application Number
CN202011600857.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-29
Publication Date
2024-10-15
Estimated Expiration
2040-12-29

AI Technical Summary

Technical Problem

Image text recognition in natural scenes has low recognition accuracy due to noise interference, and it is difficult to effectively deal with noise issues such as lighting changes, shooting angle changes, and different font sizes.

Method used

Using the CTC-based image text recognition method, the text in the target image is recognized through the trained text recognition model, and the recognized original text is converted into a vector and input into the pre-trained semantic correction model to perform semantic correction and finally determine the image quality. Text recognition results.

Benefits of technology

The recognition accuracy of image text is improved, and the error correction of the recognized image text is realized through the combination of semantic correction models, which improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112766052B_ABST
    Figure CN112766052B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for image text recognition based on CTC, including: recognizing text in a target image based on a trained text recognition model, obtaining a set of original text corresponding to the target image, the set of original text including at least one original text recognized from the target image; converting each original text into a corresponding vector, and inputting the vectors corresponding to all original texts into a pre-trained semantic correction model to obtain a predicted text corresponding to each original text; determining the predicted text corresponding to all original texts as the text recognition result of the target image; wherein the text recognition model is a text recognition model based on connected temporal classification CTC. It can be seen that the present invention can realize the recognition of image text based on the combination of a text recognition model and a semantic correction model, and realizes semantic error correction of the recognized image text while recognizing the image text, which is conducive to improving the recognition accuracy of image text.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image and text recognition, and in particular to a CTC-based image and text recognition method and device. Background Art

[0002] At present, people need to process a large amount of text in their daily life and work. In order to save people's time in processing text and improve processing efficiency, more and more application scenarios have adopted text recognition technology. As text recognition technology becomes more and more mature, it has a higher recognition accuracy rate for document text.

[0003] In practical applications, in addition to processing document text, a large amount of image text needs to be processed. However, practice has found that different types of noise often appear in images in natural scenes, such as noise caused by changes in lighting, shooting angles, and font sizes. When recognizing text in such images, the text may be misrecognized, which will lead to low accuracy in image text recognition. It can be seen that how to improve the recognition accuracy of image text is particularly important. Summary of the invention

[0004] The present invention provides a method and device for image character recognition based on CTC, which can improve the recognition accuracy of image characters.

[0005] The first aspect of the present invention discloses a method for image text recognition based on CTC, the method comprising:

[0006] Recognize characters in a target image based on a trained character recognition model, and obtain an original character set corresponding to the target image, wherein the original character set includes at least one original character recognized from the target image;

[0007] Convert each of the original characters into a corresponding vector, and input the vectors corresponding to all the original characters into a pre-trained semantic correction model to obtain a predicted character corresponding to each of the original characters;

[0008] Determine the predicted characters corresponding to all the original characters as the character recognition result of the target image;

[0009] The text recognition model is a text recognition model based on connection temporal classification (CTC).

[0010] As an optional implementation, in the first aspect of the present invention, the step of inputting the vectors corresponding to all the original characters into a pre-trained semantic correction model to obtain the predicted characters corresponding to each of the original characters comprises:

[0011] For each of the original characters, the vector corresponding to the original character is multiplied by the predetermined matrix W. Q , matrix W K And the matrix W V , obtain the query vector corresponding to the original text, the key vector corresponding to the original text and the value vector corresponding to the original text, and perform encoding and decoding operations on the query vector, key vector and value vector corresponding to the original text to obtain the predicted text corresponding to the original text.

[0012] As an optional implementation, in the first aspect of the present invention, before recognizing the text in the target image based on the trained text recognition model to obtain the original text set corresponding to the target image, the method further includes:

[0013] The text recognition model and the semantic correction model are jointly trained based on the predetermined training image samples.

[0014] As an optional implementation, in the first aspect of the present invention, the joint training of the text recognition model and the semantic correction model based on the predetermined training image samples includes:

[0015] Inputting a predetermined training image sample into a text recognition model to obtain an initial text recognition result and a CTC loss function corresponding to the training image sample; and inputting the initial text recognition result corresponding to the training image sample into a semantic correction model to obtain a target text recognition result and a cross entropy loss function corresponding to the training image sample;

[0016] The training parameters corresponding to the text recognition model and the training parameters corresponding to the semantic correction model are adjusted according to the CTC loss function and the cross-entropy loss function, and the operation of inputting the predetermined training image sample into the text recognition model to obtain the initial text recognition result corresponding to the training image sample and the CTC loss function is triggered, and the operation of inputting the initial text recognition result corresponding to the training image sample into the semantic correction model to obtain the target text recognition result corresponding to the training image sample and the cross-entropy loss function is triggered.

[0017] As an optional implementation, in the first aspect of the present invention, before adjusting the training parameters corresponding to the text recognition model and the training parameters corresponding to the semantic correction model according to the CTC loss function and the cross entropy loss function, the method further includes:

[0018] Determining whether the target text recognition result corresponding to the training image sample matches the original text corresponding to the training image sample;

[0019] When it is determined that the target text recognition result corresponding to the training image sample does not match the original text corresponding to the training image sample, the operation of adjusting the training parameters corresponding to the text recognition model and the training parameters corresponding to the semantic correction model according to the CTC loss function and the cross entropy loss function is triggered.

[0020] As an optional implementation, in the first aspect of the present invention, before jointly training the text recognition model and the semantic correction model based on the predetermined training image samples, the method further includes:

[0021] Get a training sample set;

[0022] A pre-training operation is performed on the semantic correction model according to the training sample set.

[0023] As an optional implementation, in the first aspect of the present invention, obtaining a training sample set includes:

[0024] Collect training semantic data;

[0025] Performing an adjustment operation on part of the semantic data in the training semantic data to obtain an error sample set;

[0026] Determining the remaining semantic data in the training semantic data except the partial semantic data as a correct sample set;

[0027] The error sample set and the correct sample set are determined as training sample sets required for a pre-trained semantic correction model.

[0028] The second aspect of the present invention discloses a CTC-based image character recognition device, the device comprising:

[0029] A recognition module, used for recognizing characters in a target image based on a trained character recognition model, and obtaining an original character set corresponding to the target image, wherein the original character set includes at least one original character recognized from the target image;

[0030] A conversion module, used for converting each of the original words into a corresponding vector;

[0031] A correction module, used for inputting the vectors corresponding to all the original characters into a pre-trained semantic correction model to obtain a predicted character corresponding to each original character;

[0032] A determination module, used to determine the predicted text corresponding to all the original texts as the text recognition result of the target image;

[0033] The text recognition model is a text recognition model based on connection temporal classification (CTC).

[0034] As an optional implementation, in the second aspect of the present invention, the correction module includes:

[0035] The vector generation submodule is used to multiply the vector corresponding to each original word by a predetermined matrix W. Q , matrix W K And the matrix W V , obtain the query vector corresponding to the original text, the key vector corresponding to the original text, and the value vector corresponding to the original text;

[0036] The encoding and decoding submodule is used to perform encoding and decoding operations on the query vector, key vector and value vector corresponding to each original character to obtain the predicted character corresponding to the original character.

[0037] As an optional implementation, in the second aspect of the present invention, the device further includes:

[0038] The joint training module is used to jointly train the text recognition model and the semantic correction model based on predetermined training image samples before the recognition module recognizes the text in the target image based on the trained text recognition model to obtain the original text set corresponding to the target image.

[0039] As an optional implementation, in the second aspect of the present invention, the joint training module includes:

[0040] The first training submodule is used to input a predetermined training image sample into a text recognition model to obtain an initial text recognition result and a CTC loss function corresponding to the training image sample;

[0041] The second training submodule is used to input the initial text recognition result corresponding to the training image sample into the semantic correction model to obtain the target text recognition result corresponding to the training image sample and the cross entropy loss function;

[0042] The training adjustment submodule is used to adjust the training parameters corresponding to the text recognition model and the training parameters corresponding to the semantic correction model according to the CTC loss function and the cross entropy loss function, and trigger the first training submodule to execute the operation of inputting the predetermined training image sample into the text recognition model to obtain the initial text recognition result corresponding to the training image sample and the CTC loss function, and trigger the second training submodule to execute the operation of inputting the initial text recognition result corresponding to the training image sample into the semantic correction model to obtain the target text recognition result corresponding to the training image sample and the cross entropy loss function.

[0043] As an optional implementation, in the second aspect of the present invention, the joint training module further includes:

[0044] A judgment submodule is used to judge whether the target text recognition result corresponding to the training image sample matches the original text corresponding to the training image sample; when it is judged that the target text recognition result corresponding to the training image sample does not match the original text corresponding to the training image sample, the training adjustment submodule is triggered to perform the operation of adjusting the training parameters corresponding to the text recognition model and the training parameters corresponding to the semantic correction model according to the CTC loss function and the cross entropy loss function.

[0045] As an optional implementation, in the second aspect of the present invention, the device further includes:

[0046] An acquisition module, used for acquiring a training sample set before the joint training module jointly trains a text recognition model and a semantic correction model based on predetermined training image samples;

[0047] The pre-training module is used to perform a pre-training operation on the semantic correction model according to the training sample set before the joint training module jointly trains the text recognition model and the semantic correction model based on the predetermined training image samples.

[0048] As an optional implementation, in the second aspect of the present invention, the specific manner in which the acquisition module acquires the training sample set is:

[0049] Collect training semantic data;

[0050] Performing an adjustment operation on part of the semantic data in the training semantic data to obtain an error sample set;

[0051] Determining the remaining semantic data in the training semantic data except the partial semantic data as a correct sample set;

[0052] The error sample set and the correct sample set are determined as training sample sets required for a pre-trained semantic correction model.

[0053] The third aspect of the present invention discloses another image character recognition device based on CTC, the device comprising:

[0054] A memory storing executable program code;

[0055] a processor coupled to the memory;

[0056] The processor calls the executable program code stored in the memory to execute part or all of the steps in the CTC-based image text recognition method disclosed in the first aspect of the present invention.

[0057] The fourth aspect of the present invention discloses a computer storage medium, which stores computer instructions. When the computer instructions are called, they are used for some or all steps of the CTC-based image text recognition method disclosed in the first aspect of the present invention.

[0058] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:

[0059] In an embodiment of the present invention, the text in the target image is recognized based on a trained text recognition model to obtain a set of original texts corresponding to the target image, the set of original texts including at least one original text recognized from the target image; each original text is converted into a corresponding vector, and the vectors corresponding to all the original texts are input into a pre-trained semantic correction model to obtain a predicted text corresponding to each original text; the predicted text corresponding to all the original texts is determined as the text recognition result of the target image; wherein the text recognition model is a text recognition model based on connected temporal classification CTC. It can be seen that the present invention can realize the recognition of image text based on the combination of the text recognition model and the semantic correction model, and realizes semantic error correction of the recognized image text while recognizing the image text, which is conducive to improving the recognition accuracy of image text, and further conducive to improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0061] Figure 1 It is a flowchart of a CTC-based image text recognition method disclosed in an embodiment of the present invention.

[0062] Figure 2 It is a flowchart of another CTC-based image text recognition method disclosed in an embodiment of the present invention;

[0063] Figure 3 It is a structural schematic diagram of a CTC-based image character recognition device disclosed in an embodiment of the present invention;

[0064] Figure 4 It is a structural schematic diagram of another CTC-based image character recognition device disclosed in an embodiment of the present invention;

[0065] Figure 5 It is a structural schematic diagram of another CTC-based image and text recognition device disclosed in an embodiment of the present invention. DETAILED DESCRIPTION

[0066] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0067] The terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, device, product or equipment that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units that are inherent to these processes, methods, products or equipment.

[0068] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0069] The present invention discloses a method and device for image text recognition based on CTC, which can realize image text recognition based on the combination of a text recognition model and a semantic correction model, realize semantic error correction of the recognized image text while recognizing the image text, which is beneficial to improve the recognition accuracy of the image text, and further improve the user experience. The following are detailed descriptions.

[0070] Embodiment 1

[0071] See also Figure 1 , Figure 1 : is a flow chart of a CTC-based image text recognition method disclosed in an embodiment of the present invention. Figure 1 The described method can be applied to a text recognition device, which can be further applied to a text recognition device, which can be any one of a smart phone (Android phone, iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (Mobile Internet Devices, MID) and a cloud server, etc., and the embodiments of the present invention are not limited thereto. Figure 1As shown, the CTC-based image text recognition method may include the following operations:

[0072] 101. A text recognition device recognizes text in a target image based on a trained text recognition model to obtain an original text set corresponding to the target image.

[0073] In the embodiment of the present invention, the target image is any image that needs to be recognized by text, and the obtained original text set can be empty or include at least one original text recognized from the target image, wherein when the original text set includes at least one original text recognized from the target image, step 102 is triggered. The text recognition model described in the embodiment of the present invention is a text recognition model based on connectionist temporal classification CTC (Connectionist Temporal Classification), and the text recognition model based on connectionist temporal classification CTC mainly consists of two parts: an image feature extraction network (such as CNN, VGG, ResNet, etc.) and a text classification network (such as RNN, LSTM, etc.). The text recognition device recognizes the text in the target image based on the trained text recognition model, and obtains the original text set corresponding to the target image, which may include:

[0074] The text recognition device extracts an image feature vector in the target image according to the determined image feature extraction network, wherein, taking the image feature extraction network CNN as an example, CNN can maximize the use of local features of the target image and splice all the extracted local features to obtain image features of the entire image, thereby obtaining an image feature vector of the entire image;

[0075] The text recognition device inputs the extracted image feature vector into the determined text classification network to obtain the recognition result of the text classification network;

[0076] The text recognition device inputs the recognition result of the text classification network into the determined Softmax classification function to obtain the original text set corresponding to the target image.

[0077] 102. The character recognition device converts each original character into a corresponding vector.

[0078] In the embodiment of the present invention, after recognizing the original text in the target image, the text recognition device can convert each original text recognized into a corresponding vector through word-embedding technology, and each original text corresponds to a vector. For example, when the recognized original text set is "Youmi Technology", the text recognition device can convert "Youmi Technology" into a 4*512 matrix, that is, each original text is replaced by a 512-dimensional vector.

[0079] 103. The text recognition device inputs the vectors corresponding to all the original characters into a pre-trained semantic correction model to obtain the predicted characters corresponding to each original character.

[0080] In the embodiment of the present invention, the pre-trained semantic correction model can be a Transformer model. The text recognition device can input the vectors corresponding to each original character into the trained Transformer model for semantic correction to obtain the predicted characters (i.e., "corrected characters") corresponding to each original character.

[0081] 104. The text recognition device determines the predicted characters corresponding to all the original characters as the text recognition result of the target image.

[0082] For example, when the set of original characters recognized by the pre-trained text recognition model is "岌岌可危 (jījī kě wēi)", the text recognition device inputs the vectors corresponding to "岌岌可危 (jījī kě wēi)" into the trained Transformer model for semantic correction, and obtains the corrected text "岌岌可危 (jíjí kě wēi)" for "岌岌可危 (jījī kě wēi)", and then uses "岌岌可危 (jíjí kě wēi)" as the final text recognition result of the image.

[0083] It can be seen that the method described in the embodiment of the present invention can effectively embed the corresponding semantic correction module (which can also be called a semantic enhancement module) into the current OCR system, that is, it can realize the recognition of image text based on the combination of the text recognition model and the semantic correction model, and at the same time realize the semantic error correction of the recognized image text, which is beneficial to improving the recognition accuracy of image text, and thus beneficial to improving the user experience.

[0084] In an optional embodiment, when the text recognition device inputs the vectors corresponding to all the original characters into a pre-trained semantic correction model to obtain the predicted characters corresponding to each original character, it may include:

[0085] For each original character, the text recognition device multiplies the vector corresponding to the original character by the pre-determined matrices W Q , matrix W K and matrix W V respectively to obtain the query vector, key vector, and value vector corresponding to the original character, and perform encoding and decoding operations on the query vector, key vector, and value vector corresponding to the original character to obtain the predicted character corresponding to the original character.

[0086] It can be seen that this optional embodiment can realize the semantic correction of image text based on the Transformer model, which is beneficial to improving the recognition accuracy of image text.

[0087] In another optional embodiment, before executing step 101, the method may further include the following operations:

[0088] After determining the target image that needs to be recognized, the text recognition device performs enhancement processing on the target image, which is beneficial to improving the visual effect of the image, and further beneficial to improving the efficiency and accuracy of the text recognition model in recognizing the text in the target image.

[0089] In yet another optional embodiment, after executing step 101 and before executing step 102, the method may further include the following operations:

[0090] After obtaining the original character set, the character recognition device predicts the character entity type corresponding to the original character set according to all the characters in the original character set and counts the number of characters of all the original characters included in the original character set;

[0091] The character recognition device determines whether the character entity type matches the character quantity based on the pre-acquired character database;

[0092] When it is determined that the text entity type does not match the number of characters, the text recognition device re-executes the above-mentioned operation of enhancing the target image, or the text recognition device re-executes the above-mentioned operation of recognizing the characters in the target image based on the trained text recognition model to obtain the original text set corresponding to the target image;

[0093] When it is determined that the character entity type matches the character quantity, the character recognition device performs the above-mentioned operation of converting each original character into a corresponding vector.

[0094] Optionally, the text entity type may be one of an idiom type, a company name type, a person name type, a brand logo type, etc. For example, when the predicted text entity type is an idiom type, if the counted number of characters is greater than or equal to 4, the text recognition device determines that the text entity type matches the number of characters; if the counted number of characters is less than 4, the text recognition device determines that the text entity type does not match the number of characters.

[0095] It can be seen that this optional embodiment can, after preliminarily identifying the original text set, determine whether to fully recognize the text in the target image based on the text entity type and the number of characters. If so, perform a subsequent semantic correction process; if not, re-recognize the text on the image. This can reduce the occurrence of incorrect semantic correction due to incomplete recognition of the text in the image, and is conducive to improving the accuracy and reliability of semantic correction of the original text set.

[0096] In this optional embodiment, further optionally, after obtaining the original text set, the method may further include the following operations:

[0097] The text recognition device determines whether the obtained original text set is empty. If so, the text recognition device re-executes the above-mentioned operation of enhancing the target image, or the text recognition device re-executes the above-mentioned operation of recognizing the text in the target image based on the trained text recognition model to obtain the original text set corresponding to the target image.

[0098] Further optionally, if it is determined that the obtained original character set is not empty, the character recognition device performs the above-mentioned operation of predicting the character entity type corresponding to the original character set based on all the characters in the original character set and counting the number of all the original characters included in the original character set.

[0099] It can be seen that this optional embodiment can also determine whether the original text set is empty before determining whether to fully recognize the text in the target image. If it is not empty, determine whether to fully recognize the text in the target image based on the text entity type and the number of characters. If it is empty, re-recognize the text on the image. This can reduce unnecessary operations of the text recognition device when the recognized text is empty, thereby improving the reliability and effectiveness of the text recognition device in performing related operations.

[0100] Further optionally, when it is determined that the obtained original text set is empty, the text recognition device may further perform the following operations:

[0101] The text recognition device determines whether the original text set is obtained by the text recognition model recognizing the target image for the first time. When it is determined that the original text set is obtained by the text recognition model recognizing the target image for the first time, the above-mentioned operation of enhancing the target image is re-executed, or the above-mentioned operation of recognizing the text in the target image based on the trained text recognition model is re-executed to obtain the original text set corresponding to the target image.

[0102] When it is determined that the original character set is not obtained by the character recognition model when recognizing the target image for the first time, the character recognition device determines whether the original character set obtained by the character recognition model when recognizing the target image historically is empty and whether the number of times the original character set obtained by the character recognition model when recognizing the target image cumulatively reaches a determined number threshold. When the judgment result is yes, a prompt message is output, which is used to prompt that there is no character to be recognized in the target image or to prompt to re-enter a target image that meets the requirements; when it is determined that the original character set obtained by the character recognition model when recognizing the target image historically is not empty or it is determined that the original character set obtained by the character recognition model when recognizing the target image historically is empty and the number of times the original character set obtained by the character recognition model when recognizing the target image cumulatively does not reach a determined number threshold, the above-mentioned operation of enhancing the target image is re-executed, or the above-mentioned operation of recognizing the characters in the target image based on the trained character recognition model to obtain the original character set corresponding to the target image is re-executed.

[0103] It can be seen that this optional embodiment can also perform matching operations on the cumulative recognition times and cumulative recognition results of the target image in combination with the text recognition model. It can not only recognize the image multiple times through the text recognition model to improve the recognition accuracy and comprehensiveness of the image, but also effectively control the number of image recognition times, which is conducive to improving the flexibility of the text recognition device in recognizing image text.

[0104] In yet another optional embodiment, after executing step 101 and before executing step 102, the method may further include the following operations:

[0105] The character recognition device determines whether there is at least one original character with similar shape in the original character set according to the predetermined similar character database;

[0106] When it is determined that there is at least one original character with a similar shape in the original character set, step 102 is triggered.

[0107] Optionally, the method may further include the following operations:

[0108] When it is determined that there are no original characters with similar shapes in the original character set, the character recognition device determines all the original characters included in the original character set as the character recognition results of the target image.

[0109] It can be seen that this optional embodiment can also perform operations matching the judgment result by judging whether there are original characters with similar shapes in the original character set, and can reduce unnecessary semantic correction operations when there are no original characters with similar shapes in the original character set, thereby improving the accuracy of the text recognition results for the image and the efficiency of text recognition for the image.

[0110] Embodiment 2

[0111] See also Figure 2 , Figure 2 is a flow chart of another CTC-based image text recognition method disclosed in an embodiment of the present invention. Figure 2 The described method can be applied to a text recognition device, which can be further applied to a text recognition device, which can be any one of a smart phone (Android phone, iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (Mobile Internet Devices, MID) and a cloud server, etc., and the embodiments of the present invention are not limited thereto. Figure 2 As shown, the CTC-based image text recognition method may include the following operations:

[0112] 201. The text recognition device inputs a predetermined training image sample into a text recognition model to obtain an initial text recognition result and a CTC loss function corresponding to the training image sample.

[0113] In the embodiment of the present invention, the text recognition device inputs the predetermined training image sample into the text recognition model to obtain the initial text recognition result and CTC loss function corresponding to the training image sample, which may include:

[0114] The text recognition device inputs the predetermined training image sample into the determined convolutional neural network (CNN) to obtain the output result of the convolutional neural network;

[0115] The character recognition device inputs the output result of the convolutional neural network into the determined recurrent neural network (RNN) to obtain the output result of the recurrent neural network;

[0116] The text recognition device inputs the output result of the recurrent neural network into a predetermined Softmax classification function to obtain the initial text recognition result and CTC loss function (CTC_Loss) corresponding to the training image sample.

[0117] 202. The text recognition device inputs the initial text recognition result corresponding to the training image sample into the semantic correction model to obtain the target text recognition result and the cross entropy loss function corresponding to the training image sample.

[0118] Among them, the semantic correction model is a Transformer model, and the cross entropy loss function obtained by inputting the initial text recognition result corresponding to the training image sample into the semantic correction model is Cross_Entropy_Loss.

[0119] It should be noted that the text recognition device inputs the initial text recognition result corresponding to the training image sample into the semantic correction model to obtain the target text recognition result corresponding to the training image sample and the cross entropy loss function can be specifically:

[0120] The character recognition device multiplies the vector corresponding to each original character recognized from the training image sample by a predetermined matrix W. Q , matrix W K And the matrix W V , obtain the query vector corresponding to the original text, the key vector corresponding to the original text, and the value vector corresponding to the original text;

[0121] The text recognition device performs encoding and decoding operations on the query vectors, key vectors and value vectors corresponding to all original texts to obtain the target text recognition results and cross entropy loss functions corresponding to the training image samples.

[0122] 203. The text recognition device determines whether the target text recognition result corresponding to the training image sample matches the original text corresponding to the training image sample. When the judgment result of step 203 is yes, step 205 is triggered; when the judgment result of step 203 is no, step 204 is triggered.

[0123] The original text corresponding to the training image sample is also the correct text corresponding to the training image sample.

[0124] 204. The text recognition device adjusts the training parameters corresponding to the text recognition model and the training parameters corresponding to the semantic correction model according to the CTC loss function and the cross entropy loss function.

[0125] In the embodiment of the present invention, after executing step 204, step 201 and step 202 may be continuously triggered, and when step 201 is re-triggered, the training parameters used are the training parameters corresponding to the adjusted text recognition model in step 204, and when step 202 is re-triggered, the training parameters used are the training parameters corresponding to the adjusted semantic correction model in step 204. Specifically, assuming that the label of the target image predicted by RNN is y_pred_crnn, and the label after semantic correction by the Transformer model is y_pred_transformer, then CTC_Loss = ctc (y_pred_crnn, label), and Cross_Entropy_Loss = - label * log (y_pred_transformer), the final loss function is Loss = CTC_Loss + Cross_Entropy_Loss.

[0126] 205. The text recognition device recognizes the text in the target image based on the trained text recognition model to obtain an original text set corresponding to the target image.

[0127] In the embodiment of the present invention, the target image is any image that needs to be recognized, and the obtained original text set may include at least one original text recognized from the target image. And the text recognition model described in the embodiment of the present invention is a text recognition model based on connectionist temporal classification CTC (Connectionist Temporal Classification).

[0128] 206. The text recognition device converts each original text into a corresponding vector.

[0129] 207. The text recognition device inputs the vectors corresponding to all the original texts into a pre-trained semantic correction model to obtain the predicted text corresponding to each original text.

[0130] 208. The text recognition device determines the predicted text corresponding to all the original text as the text recognition result of the target image.

[0131] In the embodiment of the present invention, for other descriptions of step 205 to step 208, please refer to the detailed description of step 101 to step 104 in the first embodiment, and the embodiment of the present invention will not be repeated.

[0132] It can be seen that the method described in the embodiment of the present invention can realize the recognition of image text based on the combination of the text recognition model and the semantic correction model, and realizes the semantic correction of the recognized image text while recognizing the image text, which is beneficial to improve the recognition accuracy of image text. In addition, the text recognition model and the semantic correction model can be jointly trained based on the training image samples, and the training parameters of the text recognition model and the semantic correction model can be adaptively adjusted based on the loss function corresponding to the text recognition model and the loss function corresponding to the semantic correction model during the joint training process, so as to improve the accuracy of the text recognition model in extracting image text and the accuracy of the semantic correction model in semantic correction of image text.

[0133] In an optional embodiment, before executing step 201, the method may further include:

[0134] The text recognition device obtains a training sample set;

[0135] The text recognition device performs a pre-training operation on the semantic correction model according to the acquired training sample set.

[0136] It should be noted that, in this optional embodiment, after the pre-training operation is performed on the semantic correction model, when the text recognition model and the semantic correction model are subsequently jointly trained, the semantic correction model involved is the pre-trained semantic correction model.

[0137] In this optional embodiment, further optionally, the character recognition device obtains a training sample set, which may include:

[0138] The text recognition device collects training semantic data;

[0139] The text recognition device performs an adjustment operation on part of the semantic data in the training semantic data to obtain an error sample set;

[0140] The text recognition device determines the remaining semantic data except for some semantic data in the training semantic data as a correct sample set;

[0141] The text recognition device determines the error sample set and the correct sample set as the training sample set required for the pre-training semantic correction model.

[0142] Optionally, the adjustment operation may include one or more combinations of an operation of replacing similar characters according to the acquired set of similar characters, an operation of deleting some characters, and an operation of adding similar characters.

[0143] It should be noted that when training the semantic correction model, whether it is jointly trained with the text recognition model or pre-trained, the semantic correction model does not need to shield other text behind a certain text when predicting the text. This allows the semantic correction model to learn two-way attention and perform semantic inference and correction based on the context.

[0144] It can be seen that this optional embodiment can also pre-train the semantic correction model through the corresponding training sample set before jointly training the text recognition model and the semantic correction model, which is conducive to accelerating the convergence speed of the semantic correction model. In addition, it is also possible to directly generate the corresponding correct sample set and the error sample set by performing corresponding adjustment operations on the acquired training semantic data, without having to obtain the error sample set separately, which is conducive to simplifying the process of obtaining the training sample set required for the semantic correction model, improving the efficiency of obtaining the training sample set required for the semantic correction model, and thus helping to improve the efficiency of pre-training the semantic correction model.

[0145] Embodiment 3

[0146] See also Figure 3 , Figure 3 : is a schematic diagram of the structure of a CTC-based image character recognition device disclosed in an embodiment of the present invention. Figure 3 The described text recognition device can be applied to a text recognition device, which can be any one of a smart phone (Android phone, iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (Mobile Internet Devices, MID) and a cloud server, etc., and the embodiments of the present invention are not limited thereto. Figure 3 As shown, the CTC-based image text recognition device may include:

[0147] The recognition module 301 is used to recognize the characters in the target image based on the trained character recognition model, and obtain an original character set corresponding to the target image, where the original character set includes at least one original character recognized from the target image.

[0148] The conversion module 302 is used to convert each original word into a corresponding vector.

[0149] The correction module 303 is used to input the vectors corresponding to all the original characters into a pre-trained semantic correction model to obtain the predicted characters corresponding to each original character.

[0150] The determination module 304 is used to determine the predicted text corresponding to all the original texts as the text recognition result of the target image.

[0151] Among them, the text recognition model is a text recognition model based on connection temporal classification CTC.

[0152] It can be seen that implementation Figure 3 The described device can realize the recognition of image text based on the combination of the text recognition model and the semantic correction model, and realizes the semantic error correction of the recognized image text while recognizing the image text, which is beneficial to improving the recognition accuracy of image text.

[0153] In an optional embodiment, if Figure 4 As shown, the correction module 303 may include:

[0154] The vector generation submodule 3031 is used to multiply the vector corresponding to each original word by a predetermined matrix W. Q , matrix W K And the matrix W V , obtain the query vector corresponding to the original text, the key vector corresponding to the original text, and the value vector corresponding to the original text;

[0155] The encoding and decoding submodule 3032 is used to perform encoding and decoding operations on the query vector, key vector and value vector corresponding to each original character to obtain the predicted character corresponding to the original character.

[0156] It can be seen that implementation Figure 4The described device can also realize semantic correction of image text based on the Transformer model, which is helpful to improve the accuracy of image text recognition.

[0157] In another optional embodiment, Figure 4 As shown, the device may also include:

[0158] The joint training module 305 is used to jointly train the text recognition model and the semantic correction model based on predetermined training image samples before the recognition module 301 recognizes the text in the target image based on the trained text recognition model to obtain the original text set corresponding to the target image.

[0159] In this optional embodiment, further optional, such as Figure 4 As shown, the joint training module 305 may include:

[0160] The first training submodule 3051 is used to input the predetermined training image sample into the text recognition model to obtain the initial text recognition result and CTC loss function corresponding to the training image sample;

[0161] The second training submodule 3052 is used to input the initial text recognition result corresponding to the training image sample into the semantic correction model to obtain the target text recognition result corresponding to the training image sample and the cross entropy loss function;

[0162] The training adjustment submodule 3053 is used to adjust the training parameters corresponding to the text recognition model and the training parameters corresponding to the semantic correction model according to the CTC loss function and the cross-entropy loss function, and trigger the first training submodule 3051 to execute the above-mentioned operation of inputting the predetermined training image samples into the text recognition model to obtain the initial text recognition results corresponding to the training image samples and the CTC loss function, and trigger the second training submodule 3052 to execute the above-mentioned operation of inputting the initial text recognition results corresponding to the training image samples into the semantic correction model to obtain the target text recognition results corresponding to the training image samples and the cross-entropy loss function.

[0163] Further optional, such as Figure 4 As shown, the joint training module 305 also includes:

[0164] The judgment submodule 3054 is used to judge whether the target text recognition result corresponding to the training image sample matches the original text corresponding to the training image sample; when it is judged that the target text recognition result corresponding to the training image sample does not match the original text corresponding to the training image sample, the training adjustment submodule 3053 is triggered to perform the above-mentioned operation of adjusting the training parameters corresponding to the text recognition model and the training parameters corresponding to the semantic correction model according to the CTC loss function and the cross entropy loss function.

[0165] It can be seen that implementation Figure 4 The described device can also jointly train the text recognition model and the semantic correction model based on training image samples, and can also adaptively adjust the training parameters of the text recognition model and the semantic correction model based on the loss function corresponding to the text recognition model and the loss function corresponding to the semantic correction model during the joint training process, so as to improve the accuracy of image text extraction by the text recognition model and the accuracy of semantic correction of image text by the semantic correction model.

[0166] In yet another optional embodiment, Figure 4 As shown, the device may also include:

[0167] The acquisition module 306 is used to acquire a training sample set before the joint training module 305 jointly trains the text recognition model and the semantic correction model based on the predetermined training image samples.

[0168] The pre-training module 307 is used to perform a pre-training operation on the semantic correction model according to the training sample set before the joint training module 305 jointly trains the text recognition model and the semantic correction model based on the predetermined training image samples.

[0169] In this optional embodiment, further optionally, the specific manner in which the acquisition module 306 acquires the training sample set may be:

[0170] Collect training semantic data;

[0171] Performing an adjustment operation on part of the semantic data in the training semantic data to obtain an error sample set;

[0172] Determine the remaining semantic data except some semantic data in the training semantic data as the correct sample set;

[0173] The error sample set and the correct sample set are determined as the training sample set required for the pre-training semantic correction model.

[0174] It can be seen that implementation Figure 4 The described device can also pre-train the semantic correction model through the corresponding training sample set before jointly training the text recognition model and the semantic correction model, which is conducive to accelerating the convergence speed of the semantic correction model. In addition, it is also possible to directly generate the corresponding correct sample set and the error sample set by performing corresponding adjustment operations on the acquired training semantic data, without the need to obtain the error sample set separately, which is conducive to simplifying the process of obtaining the training sample set required for the semantic correction model, improving the efficiency of obtaining the training sample set required for the semantic correction model, and thus helping to improve the efficiency of pre-training the semantic correction model.

[0175] Embodiment 4

[0176] See also Figure 5 , Figure 5 is a schematic diagram of the structure of another CTC-based image character recognition device disclosed in an embodiment of the present invention. Figure 5 The described device can be applied to any text recognition device such as a smart phone (Android phone, iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (Mobile Internet Devices, MID) and a cloud server, etc., and the embodiments of the present invention are not limited thereto. Figure 5 As shown, the device may include:

[0177] A memory 401 storing executable program codes;

[0178] a processor 402 coupled to the memory 401;

[0179] The processor 402 calls the executable program code stored in the memory 401 to execute part or all of the steps in the CTC-based image text recognition method described in the first or second embodiment.

[0180] Embodiment 5

[0181] An embodiment of the present invention discloses a computer storage medium storing a computer program for electronic data exchange, wherein the computer program enables a computer to execute part or all of the steps in the CTC-based image text recognition method described in Embodiment 1 or Embodiment 2.

[0182] Embodiment 6

[0183] An embodiment of the present invention discloses a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to enable a computer to execute some or all of the steps in the CTC-based image text recognition method described in Example 1 or Example 2.

[0184] The device embodiments described above are only illustrative, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, i.e., they may be located in one place, or they may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Those of ordinary skill in the art may understand and implement it without creative work.

[0185] Through the specific description of the above embodiments, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on such an understanding, the above technical solution can be essentially or partly contributed to the prior art in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, and the storage medium includes a read-only memory (ROM), a random access memory (RAM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electronically erasable rewritable read-only memory (EEPROM), a compact disc (CD-ROM) or other optical disc storage, magnetic disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.

[0186] Finally, it should be noted that the CTC-based image text recognition method and device disclosed in the embodiment of the present invention discloses only the preferred embodiments of the present invention, which are only used to illustrate the technical solution of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments can still be modified, or some of the technical features therein can be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A CTC-based image text recognition method, characterized in that: The method comprises: Based on the predetermined training image samples, a text recognition model and a semantic correction model are jointly trained, and the text in the target image is recognized based on the trained text recognition model to obtain an original text set corresponding to the target image, wherein the original text set includes at least one original text recognized from the target image; Convert each of the original characters into a corresponding vector, and input the vectors corresponding to all the original characters into a pre-trained semantic correction model to obtain a predicted character corresponding to each of the original characters; Determine the predicted characters corresponding to all the original characters as the character recognition result of the target image; Wherein, the text recognition model is a text recognition model based on connection temporal classification CTC; Furthermore, the joint training of the text recognition model and the semantic correction model based on the predetermined training image samples includes: Inputting a predetermined training image sample into a text recognition model to obtain an initial text recognition result and a CTC loss function corresponding to the training image sample; and inputting the initial text recognition result corresponding to the training image sample into a semantic correction model to obtain a target text recognition result and a cross entropy loss function corresponding to the training image sample; The training parameters corresponding to the text recognition model and the training parameters corresponding to the semantic correction model are adjusted according to the CTC loss function and the cross-entropy loss function, and the operation of inputting the predetermined training image sample into the text recognition model to obtain the initial text recognition result corresponding to the training image sample and the CTC loss function is triggered, and the operation of inputting the initial text recognition result corresponding to the training image sample into the semantic correction model to obtain the target text recognition result corresponding to the training image sample and the cross-entropy loss function is triggered.

2. The CTC-based image text recognition method according to claim 1, characterized in that: The step of inputting the vectors corresponding to all the original characters into a pre-trained semantic correction model to obtain the predicted characters corresponding to each original character comprises: For each of the original characters, the vector corresponding to the original character is multiplied by the predetermined matrix W. Q , matrix W K And the matrix W V , obtain the query vector corresponding to the original text, the key vector corresponding to the original text and the value vector corresponding to the original text, and perform encoding and decoding operations on the query vector, key vector and value vector corresponding to the original text to obtain the predicted text corresponding to the original text.

3. The CTC-based image text recognition method according to claim 1, characterized in that: Before adjusting the training parameters corresponding to the text recognition model and the training parameters corresponding to the semantic correction model according to the CTC loss function and the cross entropy loss function, the method further includes: Determining whether the target text recognition result corresponding to the training image sample matches the original text corresponding to the training image sample; When it is determined that the target text recognition result corresponding to the training image sample does not match the original text corresponding to the training image sample, the operation of adjusting the training parameters corresponding to the text recognition model and the training parameters corresponding to the semantic correction model according to the CTC loss function and the cross entropy loss function is triggered.

4. The CTC-based image text recognition method according to claim 3, characterized in that: Before jointly training the text recognition model and the semantic correction model based on the predetermined training image samples, the method further includes: Get a training sample set; A pre-training operation is performed on the semantic correction model according to the training sample set.

5. The CTC-based image text recognition method according to claim 4, characterized in that: The step of obtaining a training sample set includes: Collect training semantic data; Performing an adjustment operation on part of the semantic data in the training semantic data to obtain an error sample set; Determining the remaining semantic data in the training semantic data except the partial semantic data as a correct sample set; The error sample set and the correct sample set are determined as training sample sets required for a pre-trained semantic correction model.

6. A CTC-based image character recognition device, characterized in that: The device comprises: A joint training module, used for jointly training a text recognition model and a semantic correction model based on predetermined training image samples; A recognition module, configured to recognize characters in a target image based on a trained character recognition model, and obtain an original character set corresponding to the target image, wherein the original character set includes at least one original character recognized from the target image; A conversion module, used for converting each of the original characters into a corresponding vector; A correction module, used for inputting the vectors corresponding to all the original characters into a pre-trained semantic correction model to obtain a predicted character corresponding to each original character; A determination module, used for determining the predicted text corresponding to all the original texts as the text recognition result of the target image; Wherein, the text recognition model is a text recognition model based on connection temporal classification CTC; And, the joint training module includes: The first training submodule is used to input a predetermined training image sample into a text recognition model to obtain an initial text recognition result and a CTC loss function corresponding to the training image sample; The second training submodule is used to input the initial text recognition result corresponding to the training image sample into the semantic correction model to obtain the target text recognition result corresponding to the training image sample and the cross entropy loss function; The training adjustment submodule is used to adjust the training parameters corresponding to the text recognition model and the training parameters corresponding to the semantic correction model according to the CTC loss function and the cross entropy loss function, and trigger the first training submodule to execute the operation of inputting the predetermined training image sample into the text recognition model to obtain the initial text recognition result corresponding to the training image sample and the CTC loss function, and trigger the second training submodule to execute the operation of inputting the initial text recognition result corresponding to the training image sample into the semantic correction model to obtain the target text recognition result corresponding to the training image sample and the cross entropy loss function.

7. A CTC-based image character recognition device, characterized in that: The device comprises: A memory storing executable program code; a processor coupled to the memory; The processor calls the executable program code stored in the memory to execute the CTC-based image text recognition method according to any one of claims 1 to 5.

8. A computer storage medium, characterized in that The computer storage medium stores computer instructions, and when the computer instructions are called, they are used to execute the CTC-based image text recognition method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Image identification method and device

    CN106446782A

  • Character recognition method and device, electronic equipment and storage medium

    CN109615006A

  • Character recognition method, device and equipment and storage medium

    CN109685050A

  • Image recognition method and device

    CN109766872A

  • Image recognition, training and searching method, device and equipment and medium

    CN109961068A