A text recognition network, a neural network training method and related equipment
By combining image features and semantic features of predicted characters, a text recognition network using self-attention encoding and decoding operations solves the problem of recognition errors caused by low-quality images and occluded characters, and improves recognition accuracy and robustness.
Patent Information
- Application Number
- CN202010723541.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-24
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2040-07-24
AI Technical Summary
Existing neural networks are prone to output erroneous results when recognizing low-quality images or occluded characters, resulting in reduced text recognition accuracy.
Design a text recognition network that combines image features and semantic features of predicted characters, uses convolutional neural networks, oriented gradient histograms, or local binary patterns for feature extraction, and uses self-attention encoding and decoding operations to generate recognition results. Ensure the accuracy of recognition results.
It improves the accuracy of text recognition results, especially when the image is blurred or some characters are blocked, ensuring that the accuracy of predicted characters is not affected, and enhancing the robustness of the recognition network.
Smart Images

Figure CN112016543B
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence, and in particular to a text recognition network, a neural network training method, and related equipment. Background Art
[0002] Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a branch of computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making. At present, recognizing characters in images based on deep learning neural networks is a common application of artificial intelligence.
[0003] However, in actual situations, when the quality of the image to be recognized is low, for example, the image to be recognized is blurred or some characters in the image to be recognized are blocked, the neural network may output an incorrect recognition result, thereby reducing the accuracy of the text recognition result. Therefore, a solution to improve the accuracy of text recognition results is urgently needed. Summary of the invention
[0004] The embodiments of the present application provide a text recognition network, a neural network training method and related equipment, which generate recognition results based on the semantic features of the predicted characters and the image features of the image to be recognized, and perform recognition operations based on features of more dimensions; and image problems such as image blur or partial occlusion of characters in the image to be recognized will not affect the accuracy of the predicted characters, which is beneficial to improving the accuracy of the text recognition results.
[0005] To solve the above technical problems, the present application provides the following technical solutions:
[0006] In a first aspect, an embodiment of the present application provides a text recognition network that can be used in the field of text recognition in the field of artificial intelligence. The text recognition network is a neural network for recognizing characters in an image, and the text recognition network includes an image feature extraction module, a text feature acquisition module, and a recognition module. The image feature extraction module is used to obtain an image to be recognized, and to perform feature extraction on the image to be recognized, so as to generate a first feature corresponding to a first character in the image to be recognized. Among them, the first character is a character that needs to be recognized in the image to be recognized, and the image feature extraction module in the text recognition network can be specifically expressed as a convolutional neural network, a histogram of oriented gradients, or a local binary pattern. The image to be recognized can be an entire image, or it can be a segmented image that includes a row of characters or a column of characters after performing an image segmentation operation. The text feature acquisition module is used to obtain a preset character corresponding to the first character in the image to be recognized, and to perform text prediction based on the preset character to generate a semantic feature of the first predicted character. The preset character can be a starting mark character, which can be expressed in a computer program as <bos>The character is used to instruct the text feature acquisition module to start text prediction. The recognition module is used to combine the first feature and the semantic feature of the first predicted character, and perform a recognition operation according to the combined feature to generate a recognition result corresponding to the first character in the image to be recognized. The recognition module can be specifically a classification network, and the classification network can be specifically expressed as a classifier. The classifier can be a multi-layer perceptron, or composed of a linear transformation matrix and a classification function.
[0007] In the present implementation, not only the image features of the image to be recognized are obtained, but also the semantic features of the predicted characters are generated according to the second character corresponding to the recognized characters in the first character. The recognition operation is performed according to features of more dimensions, which is beneficial to improving the accuracy of the text recognition results. Moreover, due to factors such as blurry image to be recognized or partial obstruction of characters in the image to be recognized, the accuracy of the features of the blurred characters or obscured characters included in the first feature will be greatly reduced. Based on the semantic information of the recognized characters, the semantic features of the predicted characters are generated. Problems with the image such as blurry image or partial obstruction of characters in the image to be recognized will not affect the accuracy of the predicted characters. The recognition results are generated according to the semantic features of the predicted characters together with the image features, which is beneficial to improving the accuracy of the text recognition results.
[0008] In a possible implementation of the first aspect, the text feature acquisition module is specifically used to obtain a preset character corresponding to the first character in the image to be recognized when the recognition operation is performed on the image to be recognized for the first time, and perform text prediction based on the preset character to generate a semantic feature of the first predicted character. Wherein, if the execution device has performed image segmentation on the entire image to be recognized, the first recognition operation on the first character in the image to be recognized refers to the first time the recognition operation is performed on the segmented image to be recognized (that is, a text area of the image to be recognized). If the execution device has not performed image segmentation on the entire image to be recognized, the first recognition operation on the first character in the image to be recognized refers to the first time the recognition operation is performed on the entire image to be recognized. The text feature acquisition module is specifically used to determine at least one recognition result corresponding to at least one recognized character in the first character and the preset character as the second character when the recognition operation has been performed on at least one character in the first character, and perform text prediction based on the second character to generate a semantic feature of a second predicted character corresponding to the second character.
[0009] In this implementation, when the recognition operation is performed on the first character in the image to be recognized for the first time, the execution device generates a semantic feature of the first predicted character based on the preset character. When the recognition operation has been performed on at least one of the first characters, the execution device determines at least one recognition result corresponding to the recognized character in the first character and the preset character as at least one second character corresponding to the recognized character in the first character, thereby ensuring the integrity of the present solution, and the entire recognition process no longer requires manual intervention, thereby improving the user stickiness of the present solution.
[0010] In a possible implementation manner of the first aspect, the recognition module is further used to perform a recognition operation according to the first feature and the semantic feature of the second predicted character to generate a recognition result corresponding to the first character in the image to be recognized.
[0011] In this implementation, since the text recognition network in this scheme may only be able to obtain recognition results for some of the first characters each time it performs a recognition operation, when the recognition operation has been performed on at least one of the first characters, the execution device performs text prediction based on at least one recognition result corresponding to at least one recognized character to generate a semantic feature of a second predicted character, and then performs a recognition operation based on the first feature and the semantic feature of the second predicted character, thereby further improving the integrity of this scheme.
[0012] In a possible implementation of the first aspect, the text feature acquisition module includes: a first generation submodule, which is used to perform vectorization processing on each preset character in at least one preset character to generate a character code of each preset character, and generate a position code of each preset character according to the position of each preset character in the first character in the image to be recognized. A combination submodule, which is used to combine the character code of the preset character and the position code of the preset character to obtain the initial feature of the preset character, and perform a self-attention encoding operation and a self-attention decoding operation according to the initial feature of the preset character to generate a semantic feature of the first predicted character. The combination method between the character code of the preset character and the position code of the preset character is any one of the following: splicing, addition, fusion and multiplication.
[0013] In this implementation, text prediction is performed by performing self-attention encoding operations and self-attention decoding operations on initial features of preset characters to generate semantic features of the first predicted character, with fast calculation speed and low complexity.
[0014] In a possible implementation of the first aspect, the recognition module includes: a calculation submodule, which is used to calculate the similarity between the first feature and the semantic feature of the first predicted character. The similarity can be obtained by calculating the cosine similarity, Euclidean distance, Mahalanobis distance, etc. between the first feature and the semantic feature of the first predicted character, or the similarity can be obtained by performing a dot product operation on the first feature and the semantic feature of the first predicted character. The similarity can include a similarity value or two transposed similarity values. A second generation submodule is used to generate a second feature and a third feature based on the first feature, the semantic feature of the first predicted character and the similarity, wherein the second feature is the semantic feature of the first predicted character combined with the first feature, and the third feature is the semantic feature of the first predicted character combined with the first feature. The second generation submodule is also used to combine the second feature and the third feature, and perform a recognition operation based on the combined features to generate a recognition result.
[0015] In this implementation, the similarity between the first feature and the semantic feature of the first predicted character is calculated, and then the second feature and the third feature are generated according to the similarity between the first feature and the semantic feature of the first predicted character. The second feature is the first feature combined with the semantic feature of the first predicted character, and the third feature is the first feature combined with the semantic feature of the first predicted character. That is, not only the image features of the character to be recognized are enhanced according to the semantic features of the predicted character, but also the image features of the character to be recognized are integrated into the semantic features of the predicted character, which is conducive to the full integration of image features and predicted character features, and is conducive to improving the accuracy of text recognition results.
[0016] In a possible implementation of the first aspect, the text recognition network also includes a feature update module, the feature update module is used to: combine the feature of the preset character with the first feature to generate an updated first feature; wherein the feature of the preset character can be the initial feature of the preset character or the updated feature of the preset character. The first feature includes image features of multiple first characters, at least one of the multiple first characters is a character that has been subjected to a recognition operation, and in the case where the preset character includes recognition results corresponding to multiple recognized characters, the feature of the preset character includes features of the recognition results corresponding to the recognized characters. Then, the updated first feature will enhance the features of the recognized characters relative to the first feature. The recognition module is specifically used to perform a recognition operation based on the updated first feature and the semantic features of the first predicted character to generate a recognition result corresponding to the first character in the image to be recognized.
[0017] In this implementation, the semantic features of the recognized characters are integrated into the image features, making the features of the recognized characters in the image features more obvious, so that the recognition module can focus more on recognizing the characters that have not yet been recognized, thereby reducing the difficulty of the recognition module's single recognition process, which is conducive to improving the accuracy of text recognition.
[0018] In a possible implementation of the first aspect, the feature updating module is specifically used to: perform a self-attention encoding operation according to an initial feature of a preset character to obtain an updated feature of the preset character, and perform a self-attention encoding operation according to the first feature and the updated feature of the preset character to generate an updated first feature. In this implementation, the feature of the preset character is combined with the first feature by using a self-attention encoding method, which is conducive to achieving a full combination of the preset character feature and the first feature, and has low complexity and is easy to implement.
[0019] In a possible implementation of the first aspect, when the granularity of the text recognition network for performing the recognition operation is character, a first character includes at least one character, and a recognition result output by the text recognition network for performing a recognition operation includes a character. When the granularity of the text recognition network for performing the recognition operation is word, a first character includes at least one word, and a recognition result output by the text recognition network for performing a recognition operation is a word including one or more characters.
[0020] In this implementation, the granularity of the recognition operation performed by the text recognition network can be characters or words, which expands the application scenarios of this solution and improves the implementation flexibility of this solution.
[0021] In the second aspect, the embodiment of the present application provides a training method for a text recognition network, which can be used in the field of text recognition in the field of artificial intelligence. The text recognition network is a neural network for recognizing characters in an image, and the text recognition network includes an image feature extraction module, a text feature acquisition module, and a recognition module. The method includes: the training device inputs the image to be recognized into the image feature extraction module, performs feature extraction on the image to be recognized, so as to generate a first feature corresponding to the first character in the image to be recognized, wherein the first character is the character to be recognized in the image to be recognized; and inputs a preset character corresponding to the first character in the image to be recognized into the text feature acquisition module, and performs text prediction based on the preset character to generate a semantic feature of the first predicted character. The training device performs a recognition operation through the recognition module based on the first feature and the semantic feature of the first predicted character to generate a recognition result corresponding to the first character in the image to be recognized. The training device trains the text recognition network according to the correct result corresponding to the first character in the image to be recognized, the recognition result and the loss function. The loss function indicates the similarity between the correct result corresponding to the first character in the image to be recognized and the recognition result corresponding to the first character in the image to be recognized. The training goal of the loss function is to narrow the similarity between the correct result corresponding to the first character in the image to be recognized and the recognition result corresponding to the first character in the image to be recognized. The loss function can specifically be a cross entropy loss function, a focal loss function or a center loss function.
[0022] The second aspect of the embodiment of the present application can also execute the steps in each possible implementation method of the first aspect. For the specific implementation steps of the second aspect of the embodiment of the present application and the various possible implementation methods of the second aspect, as well as the beneficial effects brought about by each possible implementation method, you can refer to the description of the various possible implementation methods in the first aspect, and will not be repeated here one by one.
[0023] In a third aspect, an embodiment of the present application provides a text recognition method that can be used in the field of text recognition in the field of artificial intelligence. The method includes: the execution device inputs the image to be recognized into the image feature extraction module, performs feature extraction on the image to be recognized, so as to generate a first feature corresponding to the first character in the image to be recognized, wherein the first character is the character that needs to be recognized in the image to be recognized; and inputs the preset character corresponding to the first character in the image to be recognized into the text feature acquisition module, and performs text prediction based on the second character to generate the semantic feature of the first predicted character. The execution device performs a recognition operation through the recognition module according to the first feature and the semantic feature of the first predicted character to generate a recognition result corresponding to the first character in the image to be recognized. Among them, the image feature extraction module, the text feature acquisition module and the recognition module belong to the same text recognition network.
[0024] The third aspect of the embodiment of the present application can also execute the steps in each possible implementation method of the first aspect. For the specific implementation steps of the third aspect of the embodiment of the present application and the various possible implementation methods of the third aspect, as well as the beneficial effects brought about by each possible implementation method, you can refer to the description of the various possible implementation methods in the first aspect, and will not be repeated here one by one.
[0025] In a fourth aspect, an embodiment of the present application provides a training device for a text recognition network, wherein the text recognition network is a neural network for recognizing characters in an image, and the text recognition network includes an image feature extraction module, a text feature acquisition module, and a recognition module. The training device for the text recognition network includes: an input unit, which is used to input the image to be recognized into the image feature extraction module, perform feature extraction on the image to be recognized, so as to generate a first feature corresponding to a first character in the image to be recognized, wherein the first character is a character to be recognized in the image to be recognized; the input unit is also used to input a preset character corresponding to the first character in the image to be recognized into the text feature acquisition module, and perform text prediction based on the preset character to generate a semantic feature of the first predicted character; a recognition unit, which is used to perform a recognition operation through the recognition module based on the first feature and the semantic feature of the first predicted character to generate a recognition result corresponding to the first character in the image to be recognized; a training unit, which is used to train the text recognition network based on the correct result corresponding to the first character in the image to be recognized, the recognition result, and the loss function, wherein the loss function indicates the similarity between the correct result corresponding to the first character in the image to be recognized and the recognition result corresponding to the first character in the image to be recognized.
[0026] The fourth aspect of the embodiment of the present application can also execute the steps in each possible implementation method of the second aspect. For the specific implementation steps of the fourth aspect of the embodiment of the present application and the various possible implementation methods of the fourth aspect, as well as the beneficial effects brought about by each possible implementation method, you can refer to the description of the various possible implementation methods in the second aspect, and will not be repeated here one by one.
[0027] In a fifth aspect, an embodiment of the present application provides an execution device, which may include a processor, the processor and a memory are coupled, the memory stores program instructions, and when the program instructions stored in the memory are executed by the processor, the steps of the text recognition network execution described in the first aspect above are implemented.
[0028] In a sixth aspect, an embodiment of the present application provides a training device, which may include a processor, the processor and a memory are coupled, the memory stores program instructions, and when the program instructions stored in the memory are executed by the processor, the training method of the text recognition network described in the second aspect above is implemented.
[0029] In the seventh aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer-readable storage medium is run on a computer, it enables the computer to execute the steps performed by the text recognition network described in the first aspect above, or enables the computer to execute the training method of the text recognition network described in the second aspect above.
[0030] In an eighth aspect, an embodiment of the present application provides a circuit system, which includes a processing circuit, and the processing circuit is configured to execute the steps performed by the text recognition network described in the first aspect above, or to execute the training method of the text recognition network described in the second aspect above.
[0031] In a ninth aspect, an embodiment of the present application provides a computer program which, when executed on a computer, enables the computer to execute the steps performed by the text recognition network described in the first aspect above, or to execute the training method of the text recognition network described in the second aspect above.
[0032] In a tenth aspect, an embodiment of the present application provides a chip system, which includes a processor for implementing the functions involved in the above-mentioned various aspects, for example, sending or processing the data and / or information involved in the above-mentioned method. In one possible design, the chip system also includes a memory, which is used to store program instructions and data necessary for a server or communication device. The chip system can be composed of a chip, or it can include a chip and other discrete devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 A schematic diagram of the structure of the artificial intelligence main framework provided in the embodiment of the present application;
[0034] Figure 2 A system architecture diagram of a text recognition system provided in an embodiment of the present application;
[0035] Figure 3 A flowchart of the workflow of the text recognition network provided in the embodiment of the present application;
[0036] Figure 4 A schematic diagram of a process for generating a fourth feature in the workflow of a text recognition network provided in an embodiment of the present application;
[0037] Figure 5 A schematic diagram of a process for generating the fifth feature and the sixth feature in the workflow of the text recognition network provided in an embodiment of the present application;
[0038] Figure 6 A schematic diagram of a network architecture of a text recognition network provided in an embodiment of the present application;
[0039] Figure 7 A flowchart of a text recognition network training method provided in an embodiment of the present application;
[0040] Figure 8 A schematic diagram of a beneficial effect of a text recognition network provided in an embodiment of the present application;
[0041] Fig. 9 A schematic diagram of a structure of a text recognition network provided in an embodiment of the present application;
[0042] Fig.10 Another structural diagram of a text recognition network provided in an embodiment of the present application;
[0043] Fig.11 A schematic diagram of a structure of a training device for a text recognition network provided in an embodiment of the present application;
[0044] Fig.12 Another structural schematic diagram of a text recognition network training device provided in an embodiment of the present application;
[0045] Fig.13 A schematic diagram of the structure of an execution device provided in an embodiment of the present application;
[0046] Fig.14 A schematic diagram of the structure of a training device provided in an embodiment of the present application;
[0047] Fig.15 A schematic diagram of the structure of a chip provided in an embodiment of the present application. DETAILED DESCRIPTION
[0048] The embodiments of the present application provide a text recognition network, a neural network training method and related equipment, which generate recognition results based on the semantic features of the predicted characters and the image features of the image to be recognized, and perform recognition operations based on features of more dimensions; and image problems such as image blur or partial occlusion of characters in the image to be recognized will not affect the accuracy of the predicted characters, which is beneficial to improving the accuracy of the text recognition results.
[0049] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0050] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchanged under appropriate circumstances. This is merely a way of distinguishing objects with the same properties when describing the embodiments of the present application. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, so that a process, method, system, product, or device that includes a series of units is not necessarily limited to those units, but may include other units that are not explicitly listed or inherent to these processes, methods, products, or devices.
[0051] First, the overall workflow of the artificial intelligence system is described. Figure 1 , Figure 1 The following is a structural diagram of the main framework of artificial intelligence. The following is an explanation of the above artificial intelligence theme framework from two dimensions: "intelligent information chain" (horizontal axis) and "IT value chain" (vertical axis). Among them, the "intelligent information chain" reflects a series of processes from data acquisition to processing. For example, it can be a general process of intelligent information perception, intelligent information representation and formation, intelligent reasoning, intelligent decision-making, intelligent execution and output. In this process, the data has undergone a condensed process of "data-information-knowledge-wisdom". The "IT value chain" reflects the value that artificial intelligence brings to the information technology industry from the underlying infrastructure of human intelligence, information (providing and processing technology implementation) to the industrial ecological process of the system.
[0052] (1) Infrastructure
[0053] The infrastructure provides computing power support for the artificial intelligence system, enables communication with the outside world, and is supported by the basic platform. It communicates with the outside world through sensors; computing power is provided by smart chips, including but not limited to central processing units (CPU), embedded neural network processing units (NPU), graphics processing units (GPU), application specific integrated circuits (ASIC) and field programmable gate arrays (FPGA) and other hardware acceleration chips; the basic platform includes distributed computing frameworks and networks and other related platform guarantees and support, which may include cloud storage and computing, interconnected networks, etc. For example, sensors communicate with the outside world to obtain data, and these data are provided to the smart chips in the distributed computing system provided by the basic platform for calculation.
[0054] (2) Data
[0055] The data on the upper layer of the infrastructure is used to represent the data sources in the field of artificial intelligence. The data involves graphics, images, voice, text, and IoT data of traditional devices, including business data of existing systems and perception data such as force, displacement, liquid level, temperature, and humidity.
[0056] (3) Data processing
[0057] Data processing usually includes data training, machine learning, deep learning, search, reasoning, decision-making and other methods.
[0058] Among them, machine learning and deep learning can symbolize and formalize data for intelligent information modeling, extraction, preprocessing, and training.
[0059] Reasoning refers to the process of simulating human intelligent reasoning in computers or intelligent systems, using formalized information to perform machine thinking and solve problems based on reasoning control strategies. Typical functions are search and matching.
[0060] Decision-making refers to the process of making decisions after intelligent information is reasoned, usually providing functions such as classification, sorting, and prediction.
[0061] (4) General ability
[0062] After the data has undergone the data processing mentioned above, some general capabilities can be further formed based on the results of the data processing, such as an algorithm or a general system, for example, translation, text analysis, computer vision processing, speech recognition, etc.
[0063] (5) Smart products and industry applications
[0064] Smart products and industry applications refer to the products and applications of artificial intelligence systems in various fields. They are the encapsulation of the overall artificial intelligence solution, which productizes intelligent information decision-making and realizes practical application. Its application areas mainly include: smart terminals, smart manufacturing, smart transportation, smart homes, smart medical care, smart security, autonomous driving, safe cities, etc.
[0065] The embodiments of the present application can be applied to various fields of artificial intelligence, and can be specifically applied to various scenarios where characters in images need to be recognized, and the aforementioned images are images collected by devices such as cameras, printers, and scanners. As an example, in one application scenario, in the fields of finance, accounting, and taxation, enterprises need to scan documents such as receipts or invoices to obtain image files, and recognize the characters in the image files to extract text information, thereby realizing functions such as digital file archiving, fast file indexing, or file analysis. In another application scenario, the user needs to enter information on documents such as identity cards, driver's licenses, vehicle licenses, or passports, then the user can use the camera to collect images of the aforementioned documents, and recognize the characters in the images to extract key information, etc. It should be understood that the examples here are only for the convenience of understanding the application scenarios of the embodiments of the present application, and the application scenarios of the embodiments of the present application are not exhaustive. In the aforementioned various scenarios, there may be the possibility of low image quality, so it is necessary to recognize the image through the text recognition network provided by the embodiments of the present application to improve the accuracy of the recognition results.
[0066] In order to facilitate understanding of this solution, the present application embodiment first combines Figure 2 For an introduction to the text recognition system provided in the embodiments of the present application, please refer to Figure 2 , Figure 2 A system architecture diagram of a text recognition system provided in an embodiment of the present application. Figure 2 In the embodiment, the text recognition system 200 includes an execution device 210 , a training device 220 , a database 230 and a data storage system 240 , and the execution device 210 includes a computing module 211 .
[0067] In the training phase, a training data set is stored in the database 230, and the training data set may include multiple images to be recognized and the correct result corresponding to the first character in each image to be recognized. The training device 220 generates a target model / rule 201 for processing sequence data, and iteratively trains the target model / rule 201 using the training data set in the database to obtain a mature target model / rule 201.
[0068] In the inference stage, the execution device 210 can call the data, code, etc. in the data storage system 240, or store the data, instructions, etc. in the data storage system 240. The data storage system 240 can be configured in the execution device 210, or the data storage system 240 can be an external memory relative to the execution device 210. The calculation module 211 can perform a recognition operation on the image to be recognized input by the execution device 210 through the mature target model / rule 201 to obtain the recognition result of the first character in the image to be recognized.
[0069] In some embodiments of the present application, for example Figure 2 In the embodiment, the "user" can directly interact with the execution device 210, that is, the execution device 210 and the client device are integrated into the same device. Figure 2 It is only a schematic diagram of the architecture of two image processing systems provided by the embodiments of the present invention, and the positional relationship between the devices, components, modules, etc. shown in the figure does not constitute any limitation. In other embodiments of the present application, the execution device 210 and the client device can be independent devices, and the execution device 210 is configured with an input / output interface to interact with the client device. The "user" can input the collected image to the input / output interface through the client device, and the execution device 210 returns the processing result to the client device through the input / output interface.
[0070] Based on the above description, an embodiment of the present application provides a text recognition network, which includes an image feature extraction module, a text feature acquisition module and a recognition module. The image feature extraction module is used to extract the image features of the first character in the image to be recognized, and the text feature acquisition module is used to predict text based on the semantic information of the preset character corresponding to the first character in the image to be recognized, and obtain the semantic features of the predicted character. Then, the recognition module performs recognition operations based on the image features of the first character in the image to be recognized and the semantic features of the predicted character to generate a recognition result. Image problems such as image blur or partial occlusion of characters in the image to be recognized do not affect the accuracy of the predicted character. Generating recognition results based on the semantic features and image features of the predicted character is beneficial to improving the accuracy of the text recognition results. Figure 2 As can be seen from the description in, the embodiment of the present application includes a reasoning stage and a training stage, and the processes of the reasoning stage and the training stage are different. The reasoning stage and the training stage are described below respectively.
[0071] 1. Reasoning Stage
[0072] In the embodiment of the present application, the inference stage describes the process of how the execution device 210 uses a mature text recognition network to perform character recognition on the image to be recognized. Figure 3 , Figure 3 A flowchart of the workflow of the text recognition network provided in the embodiment of the present application, the method may include:
[0073] 301. The execution device inputs the image to be recognized into the image feature extraction module, and performs feature extraction on the image to be recognized to generate a first feature corresponding to a first character in the image to be recognized.
[0074] In an embodiment of the present application, after acquiring the image to be recognized, the execution device will input the image to be recognized into the image feature extraction module of the text recognition network, so as to perform feature extraction on the image to be recognized through the image feature extraction module to generate a first feature corresponding to the first character in the image to be recognized, and the first character is the character that needs to be recognized in the image to be recognized.
[0075] Among them, the image feature extraction module in the text recognition network can be specifically expressed as a convolutional neural network, a histogram of oriented gradient (HOG), a local binary pattern (LBP) or other neural networks for extracting features from images.
[0076] An image to be recognized may include one or more rows of first characters, or an image to be recognized may include one or more columns of first characters. If the granularity of the recognition operation performed by the text recognition network is characters, that is, the execution device can obtain a recognition result for a character in the image to be recognized each time it performs a recognition operation through the text recognition network, then a first character includes one or more characters. As an example, for example, a first character included in the image to be recognized is "cat", and the text recognition network performs a recognition operation once to obtain a recognition result of a character "c". As another example, for example, a first character included in the image to be recognized is "The weather is great today", and the text recognition network performs a recognition operation once to generate a feature of a character "today", and the output is a recognition result corresponding to the character "today".
[0077] If the granularity of the recognition operation performed by the text recognition network is words, that is, each time the execution device performs a recognition operation through the text recognition network, it can obtain a recognition result of a word in the image to be recognized, then a first character includes one or more words. As an example, for example, a first character included in the image to be recognized is "how are you", and the text recognition network performs a recognition operation once to obtain a recognition result of the word "how". As another example, for example, a first character included in the image to be recognized is "Today's weather is great", and the text recognition network performs a recognition operation once to obtain a recognition result of the word "today", etc. It should be understood that the above examples are only for the convenience of understanding this solution and do not limit this solution.
[0078] Specifically, in one implementation, after acquiring the image to be recognized, the execution device will perform image segmentation on the image to be recognized to generate at least one segmented image to be recognized (that is, segment the image to be recognized into at least one text area). If an image to be recognized includes one or more rows of first characters, each segmented image to be recognized (that is, each text area) includes a row of first characters; if an image to be recognized includes one or more columns of first characters, each segmented image to be recognized includes a column of first characters.
[0079] More specifically, in one case, the text recognition network is also configured with an image segmentation module, and the execution device performs image segmentation on the image to be recognized through the image segmentation module of the text recognition network to obtain at least one segmented image to be recognized. In another case, in addition to the text recognition network, the execution device may also be configured with a first neural network for image segmentation, and the execution device performs image segmentation on the image to be recognized through the first neural network to obtain at least one segmented image to be recognized. Furthermore, the image segmentation module in the text recognition network or the first neural network for image segmentation can be specifically expressed as a shape robust text detection network based on a progressive scale expansion network (shape Robust Text Detection with Progressive Scale Expansion Network, PSENet), rCTPN, ASTER or other neural networks for image segmentation, etc., which are not limited here.
[0080] Correspondingly, step 301 may include: the execution device inputs the segmented image to be recognized into the image feature extraction module, performs feature extraction on the segmented image to be recognized, so as to generate a first feature corresponding to the first character in the segmented image to be recognized, and the segmented image is a text area in the image to be recognized. A first feature refers to a feature of a segmented image to be recognized, including image features of a row of first characters (i.e., a text area in the image to be recognized), or, including image features of a column of first characters.
[0081] In another implementation, when an image to be recognized includes multiple rows of first characters or multiple columns of first characters, after acquiring the image to be recognized, the execution device inputs the entire image to be recognized into the image feature extraction module of the text recognition network, and performs feature extraction on the entire image to be recognized to generate a first feature corresponding to the first character in the image to be recognized. Among them, a first feature refers to the feature of the entire image to be recognized. If an image to be recognized includes a row of first characters or a column of first characters, a first feature is an image feature of a row or a column of first characters in the image to be recognized; if an image to be recognized includes multiple rows or columns of first characters, a first feature is an image feature of multiple rows or columns of first characters in the image to be recognized.
[0082] 302. The execution device inputs a preset character corresponding to a first character in the image to be recognized into a text feature acquisition module, and performs text prediction according to the preset character to generate a semantic feature of the first predicted character.
[0083] In an embodiment of the present application, when the execution device performs a recognition operation on the first character in the image to be recognized for the first time, it will obtain a preset character corresponding to the first character in the image to be recognized, and input the preset character corresponding to the first character in the image to be recognized into a text feature acquisition module of the text recognition network, so as to perform text prediction through the text feature acquisition module based on the preset character to generate a semantic feature of the first predicted character.
[0084] Wherein, if the execution device has performed image segmentation on the entire image to be recognized, the first recognition operation on the first character in the image to be recognized refers to the first time the recognition operation is performed on the segmented image to be recognized (that is, a text area of the image to be recognized). If the execution device has not performed image segmentation on the entire image to be recognized, the first recognition operation on the first character in the image to be recognized refers to the first time the recognition operation is performed on the entire image to be recognized.
[0085] The preset character can be a start mark character, which can be represented in a computer program as <bos>Character, used to instruct the text feature acquisition module to start text prediction. The representation form of the preset character is predefined, and can be specifically represented as a vector including N elements, each of the N elements is a certain value. Further, N is an integer greater than or equal to 1. As an example, for example, the preset character can be specifically a vector including 32 1s, or the preset character can be specifically a vector including 64 2s, etc., which are not exhaustive here.
[0086] The text feature acquisition module of the text recognition network may include an encoding module and a decoding module, wherein the encoding module is used to extract the text features of the input characters, and the decoding module is used to generate the text features of the predicted characters according to the text features of the input characters. Further, the encoding module may be an encoder in a recurrent neural network (RNNs), and the decoding module may be a decoder in a recurrent neural network; as an example, the encoding module and the decoding module may be an encoding module and a decoding module in a long short term memory network (LSTM). The encoding module may also be a self-attention encoding module, and the decoding module may be a self-attention decoding module; as an example, the encoding module and the decoding module may be a self-attention encoding module and a self-attention decoding module of a neural network based on bidirectional encoder representations from transformers (BERT), etc. The encoding module and the decoding module may also be an encoding module and a decoding module in other neural networks for text prediction, etc., which are not exhaustive here.
[0087] Specifically, in one implementation, the encoding module and the decoding module in the text feature acquisition module are a self-attention encoding module and a self-attention decoding module, respectively. Step 302 may include: the execution device converts the preset character from a character form to a tensor form through the text feature acquisition module to generate a character encoding of the preset character, and generates a position encoding of the preset character according to the position of the preset character in the first character of the image to be recognized; the character encoding of the preset character and the position encoding of the preset character are combined to obtain the initial feature of the preset character. Then, the execution device performs a self-attention encoding operation and a self-attention decoding operation according to the initial feature of the preset character through the text feature acquisition module to generate a semantic feature of the first predicted character.
[0088] In an embodiment of the present application, text prediction is performed by performing self-attention encoding operations and self-attention decoding operations on initial features of preset characters to generate semantic features of the first predicted character, with fast calculation speed and low complexity.
[0089] More specifically, for the character encoding generation process. The execution device can perform vectorization (embedding) processing on the preset characters through the text feature acquisition module to generate the character encoding of the preset characters. The training device can also obtain the one-hot encoding of the preset characters, and determine the one-hot encoding of the preset characters as the character encoding of the preset characters, etc. The process of generating the character encoding of the preset characters is not limited here. Among them, the character encoding of the preset characters can be a vector including M elements, and the value of M is related to what kind of neural network is adopted by the text feature acquisition module of the text recognition network, which is not limited here.
[0090] Generation process of position coding. The position of the preset character in the image to be recognized is the first position, and the position coding of the preset character indicates that the position of the preset character is the first position. Optionally, the position coding of the preset character can also be a vector including M elements. As an example, for example, if the value of M is 512, the position coding of the preset character can be a vector including 1 1 and 511 0s, and the 1 in the position coding of the preset character is located in the first position, indicating that the position of the preset character in the image to be recognized is the first position. Optionally, the execution device can also perform a secondary conversion on the aforementioned 512 elements through a cosine function, etc. It should be understood that the examples of the value of M and the expression form of the position coding here are only for the convenience of understanding this scheme, and are not used to limit this scheme. The way of combining character coding and position coding includes but is not limited to concatenation, addition, fusion and multiplication.
[0091] The process of generating the semantic features of the first predicted character. After obtaining the initial features of the preset character, the execution device needs to perform text prediction through the text feature acquisition module of the text recognition network, that is, perform a self-attention encoding operation on the initial features of the preset character to generate an updated feature of the preset character, and perform a self-attention decoding operation on the updated feature of the preset character to generate the semantic features of the first predicted character.
[0092] In another implementation, the encoding module and the decoding module in the text feature acquisition module are selected from a recurrent neural network. Step 302 may include: the execution device converts the preset character from a character form to a tensor form through the text feature acquisition module to generate a character encoding of the preset character, and determines the character encoding of the preset character as the initial feature of the preset character. Then, the execution device performs an encoding operation and a decoding operation according to the initial feature of the preset character through the text feature acquisition module to generate a semantic feature of the first predicted character.
[0093] It should be noted that when the encoding module and the decoding module in the text feature acquisition module are selected from other types of neural networks for text prediction, step 302 can be modified accordingly, which is not exhaustive here.
[0094] In addition, the embodiment of the present application does not limit the execution order of step 301 and step 302. Step 301 may be executed first, and then step 302, or step 302 may be executed first, and then step 301, or step 301 and step 302 may be executed simultaneously.
[0095] 303. The execution device combines the feature of the preset character with the first feature through a feature updating module to generate a fourth feature.
[0096] In some embodiments of the present application, after the execution device generates a first feature corresponding to the first character in the image to be recognized through the image feature extraction module of the text recognition network, it can also combine the feature of the preset character with the first feature to generate a fourth feature, and the fourth feature is the updated first feature. The feature of the preset character can be the updated feature of the preset character or the initial feature of the preset character.
[0097] Specifically, in one implementation, the execution device performs a self-attention encoding operation according to the initial feature of the preset character through the feature update module of the text recognition network to obtain the updated feature of the preset character, and performs a self-attention encoding operation according to the first feature and the updated feature of the preset character to generate a fourth feature.
[0098] For the generation process of the updated features of the preset characters, in order to more intuitively understand the process of self-attention encoding, the formula for performing self-attention encoding operation on the preset characters is disclosed as follows:
[0099] Q′ char =Norm(softmax(Q char K char )V char +Q char ); (1)
[0100] Among them, Q char K is obtained by multiplying the initial features of the preset character by the first transformation matrix. char Q is obtained by multiplying the initial features of the preset character by the second transformation matrix. char K char Representative Q char With K char Point product, softmax(Q char K char )V char represents softmax(Q char K char ) and V char Dot product, V char Q′ is obtained by multiplying the initial features of the preset character with the third transformation matrix. char Representing the updated features of the preset characters, the first conversion matrix, the second conversion matrix and the third conversion matrix may be the same or different. It should be understood that the example in formula (1) is only for easier understanding of the present solution and is not used to limit the present solution.
[0101] Regarding the process of generating the fourth feature, in order to more intuitively understand the process of performing self-attention encoding according to the first feature and the updated feature of the preset character, the formula for performing the self-attention encoding operation on the preset character is disclosed as follows:
[0102] Q′ img =Norm(softmax(Q′ char K img )V img +Q′ char ); (2)
[0103] Among them, Q′ img Represents the fourth characteristic, Q′ char represents the updated features of the preset characters, K img To obtain V by multiplying the first feature with the fourth transformation matrix, img To obtain the first characteristic by multiplying the fifth conversion matrix, the fourth conversion matrix and the fifth conversion matrix may be the same or different. It should be understood that the example in formula (2) is only for easier understanding of the present solution and is not used to limit the present solution.
[0104] For a more intuitive understanding of this solution, please refer to Figure 4 , Figure 4 A schematic diagram of a process for generating a fourth feature in the workflow of a text recognition network provided in an embodiment of the present application, Figure 4 In the example, a text recognition network performs a recognition operation to obtain a recognition result of a character, that is, a second character includes a character. Figure 4 As shown, the execution device inputs the image to be recognized into the image feature extraction module of the text recognition network to obtain the image feature of the first character in the image to be recognized (that is, the first feature of the first character in the image to be recognized). Figure 4 In the example, the image feature extraction module includes multiple convolutional layers and multiple pooling layers, and max poll refers to the maximum pooling. Figure 4 As shown, the execution device generates a character code and a position code of the preset character to obtain an initial feature of the preset character, and generates an updated feature Q′ of the preset character through the above formula (1): char After obtaining the image feature of the first character in the image to be recognized (that is, the first feature of the first character in the image to be recognized) and the updated feature of the preset character, the execution device performs a self-attention encoding operation through the above formula (2) to generate a fourth feature. It should be noted that, in actual situations, in addition to performing the self-attention encoding operation according to the first feature and the updated feature of the preset character, the feature update module in the text recognition network can also be provided with more neural networks, for example, the feature update module in the text recognition network can also be provided with a feedforward neural network, a regularization module, etc. Figure 4 This is only an example to facilitate understanding of the present invention and is not intended to limit the present invention.
[0105] In another implementation, the execution device performs a self-attention encoding operation based on the first feature and the initial feature of the preset character through a feature update module of the text recognition network to generate a fourth feature.
[0106] In another implementation, the execution device performs an encoding operation according to the initial feature of the preset character through the feature update module of the text recognition network to obtain the updated feature of the preset character, and performs an encoding operation according to the first feature and the updated feature of the preset character to generate a fourth feature. Further, the feature update module of the text recognition network performs the encoding operation through an encoder, which is an encoder in a recurrent neural network.
[0107] In another implementation, the execution device performs an encoding operation according to the first feature and the initial feature of the preset character through a feature updating module of the text recognition network to generate a fourth feature.
[0108] 304. The execution device performs a recognition operation through a recognition module according to the first feature and the semantic feature of the first predicted character to generate a first recognition result.
[0109] In an embodiment of the present application, the execution device combines the first feature and the semantic feature of the first predicted character through the recognition module, and performs a recognition operation based on the combined feature to generate a first recognition result. If the granularity at which the text recognition network performs the recognition operation is character, then a first recognition result is a character recognized by the text recognition network. If the granularity at which the text recognition network performs the recognition operation is word, then a first recognition result is a word recognized by the text recognition network.
[0110] Specifically, step 303 is an optional step. If step 303 is executed, step 304 includes: the execution device combines the fourth feature (that is, the updated first feature) and the fifth feature through the recognition module, and performs a recognition operation based on the combined features to generate a first recognition result.
[0111] The process of combining the fourth feature with the semantic feature of the first predicted character. In one implementation, the execution device directly combines the fourth feature (that is, the updated first feature) and the fifth feature by concatenation, matrix multiplication, combination, etc. through the recognition module.
[0112] In another implementation, the execution device performs a combination operation of the fourth feature and the semantic feature of the first predicted character according to the similarity between the fourth feature and the semantic feature of the first predicted character through the recognition module. The execution device calculates the first similarity between the fourth feature and the semantic feature of the first predicted character through the recognition module; generates a fifth feature according to the fourth feature, the semantic feature of the first predicted character, and the first similarity; and generates a sixth feature according to the fourth feature, the semantic feature of the first predicted character, and the similarity. Then, the fifth feature and the sixth feature are combined through the recognition module.
[0113] Among them, the first similarity can be obtained by calculating the cosine similarity, Euclidean distance, Mahalanobis distance, etc. between the fourth feature and the semantic feature of the first predicted character, or the first similarity can be obtained by performing a dot product operation on the fourth feature and the semantic feature of the first predicted character. Furthermore, the first similarity can include one similarity value, or two transposed similarity values. The fifth feature is a combination of the semantic feature of the first predicted character on the basis of the fourth feature, and the sixth feature is a combination of the fourth feature on the basis of the semantic feature of the first predicted character. The way of combining the fifth feature and the sixth feature includes but is not limited to splicing, addition, multiplication or other combinations, etc., which are not exhaustive here.
[0114] More specifically, to more intuitively understand the process of generating the fifth and sixth features, please refer to Figure 5 , Figure 5 A schematic diagram of a process for generating the fifth feature and the sixth feature in the workflow of the text recognition network provided in an embodiment of the present application, Figure 5 In the example, the first similarity is generated by point multiplication. vis represents the fourth feature (that is, the updated first feature), Q lin represents the semantic features of the first predicted character, and are the first weight and the second weight respectively, P lin By Q lin Multiply it by the first weight to get P vis By K vis The first weight and the second weight are determined during the text recognition network training phase. vis represents the similarity between the fourth feature and the first predicted character, S vis By formula Calculated, S lin represents the similarity between the first predicted character and the fourth feature, S lin By formula Calculated, d represents the number of dimensions of the feature, that is, d represents the number of elements included in the fourth feature or the fifth feature. The fifth feature is a combination of the semantic features of the first predicted character on the basis of the fourth feature. Figure 5 In the above example, the fifth feature is expressed as Splicing get, By formula S lin , K lin and The sixth feature is obtained by combining the fourth feature based on the semantic feature of the first predicted character. Figure 5 In the example, the sixth feature is expressed as Splicing get, By formula S vis , K vis and It should be understood that Figure 5 This is only an example to facilitate understanding of the present invention and is not intended to limit the present invention.
[0115] The process of performing a recognition operation according to the combined features. After the execution device combines the fifth feature and the sixth feature through the recognition module, the combined feature is input into the classification network in the recognition module to perform the recognition operation through the classification network in the recognition module, and obtain a first recognition result output by the entire recognition module.
[0116] The classification network can be specifically expressed as a classifier. The classifier can be a multi-layer perceptron (MLP). The classifier can also be composed of a linear transformation matrix and a softmax classification function, etc. The specific form of the classification network is not limited here.
[0117] If step 303 is not performed, step 304 includes: the execution device combines the first feature obtained in step 301 with the semantic feature of the first predicted character through the recognition module, and performs a recognition operation according to the combined feature to generate a first recognition result. The specific implementation process can be referred to the description of the case of executing step 303, which will not be repeated here.
[0118] 305. The execution device inputs a second character corresponding to the recognized character in the first character into a text feature acquisition module, and performs text prediction according to the second character to generate a semantic feature of the first predicted character.
[0119] In the embodiment of the present application, the specific implementation method of step 305 is similar to the specific implementation method of step 302. When the execution device has performed a recognition operation on at least one character in the first character, it will obtain at least one second character corresponding to all the recognized characters in the first character. Specifically, the execution device determines at least one recognition result corresponding to all the recognized characters in the first character as at least one second character corresponding to the recognized characters in the first character. In the embodiment of the present application, when the recognition operation has been performed on at least one character in the first character, the execution device determines at least one recognition result corresponding to the recognized characters in the first character and a preset character as at least one second character corresponding to the recognized characters in the first character. When the recognition operation is performed on the first character in the image to be recognized for the first time, the execution device generates the semantic features of the first predicted character according to the preset character, thereby ensuring the integrity of the present solution. The entire recognition process no longer requires manual intervention, thereby improving the user stickiness of the present solution.
[0120] More specifically, if the execution device enters step 305 through step 304, step 305 includes: the execution device determines the first recognition result and the preset character as a second character corresponding to the recognized character in the first character. If the execution device enters step 305 through step 307, step 305 includes: the execution device determines the preset character, the first recognition result, and at least one second recognition result as a plurality of second characters corresponding to the recognized character in the first character.
[0121] Among them, when the granularity of the text recognition network performing the recognition operation is characters, the first character is a word including at least one character, one recognition result includes one character, and each second character includes one character. When the granularity of the text recognition network performing the recognition operation is words, the first character includes at least one word, one recognition result is a word including one or more characters, and each second character is a word including one or more characters. In an embodiment of the present application, the granularity of the text recognition network performing the recognition operation can be characters or words, which expands the application scenarios of the present solution and improves the implementation flexibility of the present solution.
[0122] The execution device inputs all second characters corresponding to all recognized characters in the first character into the text feature acquisition module of the text recognition network, so as to perform text prediction based on all the second characters through the encoding module and the decoding module in the text feature acquisition module to generate the semantic features of the first predicted character.
[0123] Specifically, in one implementation, the encoding module and the decoding module in the text feature acquisition module are a self-attention encoding module and a self-attention decoding module, respectively. Step 302 may include: the execution device converts any second character of at least one second character from a character form to a tensor form through the text feature acquisition module to generate a character encoding of the second character, and generates a position encoding of the second character according to the position of any second character of at least one second character in the first character in the image to be recognized. The execution device combines the character encoding and the position encoding of any second character of at least one second character through the text feature acquisition module of the text recognition network to obtain an initial feature of the second character. The execution device performs the above operation on each second character of at least one second character through the text feature acquisition module of the text recognition network, thereby generating an initial feature of each second character of at least one second character. Then, the execution device performs a self-attention encoding operation and a self-attention decoding operation according to the initial feature of the second character through the text feature acquisition module to generate a semantic feature of the first predicted character.
[0124] In another implementation, the encoding module and the decoding module in the text feature acquisition module are selected from a recurrent neural network. Step 302 may include: the execution device converts each second character in the at least one second character from a character form to a tensor form through the text feature acquisition module to generate a character encoding of each second character, and determines the character encoding of each second character as an initial feature of each second character. Then, the execution device performs encoding and decoding operations according to the initial features of all second characters in the at least one second character through the text feature acquisition module to generate a semantic feature of the first predicted character.
[0125] The specific implementation methods of the above two implementation methods can refer to the description in the above step 302, which will not be repeated here.
[0126] 306. The execution device combines the feature of the second character with the first feature through a feature updating module to generate a seventh feature.
[0127] In the embodiment of the present application, the specific implementation method of step 306 is similar to the specific implementation method of step 303. After the execution device generates the first feature corresponding to the first character in the image to be recognized through the image feature extraction module of the text recognition network, it can also combine the feature of the second character with the first feature to generate a seventh feature, and the seventh feature is the updated first feature. Among them, the feature of the second character can be an updated feature of the preset character, or it can be an initial feature of the preset character. The first feature includes image features of multiple first characters, and at least one of the multiple first characters is a character that has been recognized. In the case where the second character includes recognition results corresponding to multiple recognized characters, the feature of the second character includes the features of the recognition results corresponding to the recognized characters. Then, relative to the first feature, the feature of the recognized character will be enhanced in the seventh feature.
[0128] In an embodiment of the present application, the semantic features of the recognized characters are integrated into the image features, making the features of the recognized characters in the image features more obvious, so that the recognition module can focus more on recognizing the characters that have not yet been recognized, thereby reducing the difficulty of a single recognition process of the recognition module, which is beneficial to improving the accuracy of text recognition.
[0129] Specifically, in one implementation, the execution device performs a self-attention encoding operation according to the initial feature of the second character through the feature update module of the text recognition network to obtain the updated feature of the second character, and performs a self-attention encoding operation according to the first feature and the updated feature of the second character to generate the seventh feature (that is, the updated first feature). In the embodiment of the present application, the feature of the second character is combined with the first feature by using the self-attention encoding method, which is conducive to achieving a full combination of the second character feature and the first feature, and has low complexity and is easy to implement.
[0130] In another implementation, the execution device performs a self-attention encoding operation based on the first feature and the initial feature of the second character through a feature update module of the text recognition network to generate a seventh feature.
[0131] In another implementation, the execution device performs an encoding operation according to the initial feature of the second character through the feature update module of the text recognition network to obtain an updated feature of the second character, and performs an encoding operation according to the first feature and the updated feature of the second character to generate a seventh feature. Further, the feature update module of the text recognition network performs the encoding operation through an encoder, which is an encoder in a recurrent neural network.
[0132] In another implementation, the execution device performs an encoding operation based on the first feature and the initial feature of the second character through a feature updating module of the text recognition network to generate a seventh feature.
[0133] The specific implementation methods of various forms in step 306 can refer to the description in the above step 303, which will not be repeated here.
[0134] 307. The execution device performs a recognition operation through a recognition module according to the first feature and the semantic feature of the first predicted character to generate a second recognition result.
[0135] In an embodiment of the present application, the specific implementation method of step 307 is similar to the specific implementation method of step 304. The execution device combines the first feature and the semantic feature of the first predicted character through the recognition module, and performs a recognition operation based on the combined feature to generate a second recognition result.
[0136] Specifically, step 306 is an optional step. If step 306 is executed, step 307 includes: the execution device combines the seventh feature (that is, the first feature after update) and the semantic feature of the first predicted character through the recognition module, and performs a recognition operation based on the combined feature to generate a second recognition result.
[0137] The process of combining the seventh feature with the semantic feature of the first predicted character. In one implementation, the execution device directly combines the seventh feature (that is, the updated first feature) and the first feature by concatenation, matrix multiplication, combination, etc. through the recognition module.
[0138] In another implementation, the execution device performs a combination operation of the seventh feature and the semantic feature of the first predicted character according to the similarity between the seventh feature and the semantic feature of the first predicted character through the recognition module. The execution device calculates the similarity between the seventh feature (that is, the updated first feature) and the semantic feature of the first predicted character through the recognition module; generates the second feature and the third feature according to the seventh feature, the semantic feature of the first predicted character and the similarity. Among them, the second feature is the semantic feature of the first predicted character combined with the seventh feature, and the third feature is the semantic feature of the first predicted character combined with the seventh feature; the recognition operation is performed according to the second feature and the third feature to generate a second recognition result.
[0139] In an embodiment of the present application, the similarity between the first feature and the semantic feature of the first predicted character is calculated, and then the second feature and the third feature are generated based on the similarity between the first feature and the semantic feature of the first predicted character. The second feature is a combination of the semantic feature of the first predicted character on the basis of the first feature, and the third feature is a combination of the first feature on the basis of the semantic feature of the first predicted character. That is, not only the image features of the character to be recognized are enhanced based on the semantic features of the predicted character, but also the image features of the character to be recognized are integrated into the semantic features of the predicted character, which is conducive to the full integration of the image features and the predicted character features, and is conducive to improving the accuracy of the text recognition results.
[0140] The process of performing a recognition operation based on the combined features. After the execution device combines the second feature and the third feature through the recognition module, the combined feature is input into the classification network in the recognition module to perform the recognition operation through the classification network in the recognition module, and obtain a first recognition result output by the entire recognition module.
[0141] If step 306 is not performed, step 307 includes: the execution device combines the first feature obtained in step 301 with the semantic feature of the first predicted character through the recognition module, and performs a recognition operation according to the combined feature to generate a second recognition result. The specific implementation of step 307 can refer to the description in the above step 304, which will not be repeated here.
[0142] It should be noted that the embodiment of the present application does not limit the number of times steps 301 to 304 and steps 305 to 307 are executed. After executing steps 301 to 304 once, steps 305 to 307 may be repeatedly executed to obtain multiple second recognition results.
[0143] Specifically, if the granularity of the text recognition network performing a recognition operation is a character, the execution device can obtain the recognition result of one character in the first character each time it executes steps 305 to 307, and the execution device repeatedly executes steps 305 to 307 multiple times to obtain the recognition results of all characters in the first character. If the granularity of the text recognition network performing a recognition operation is a word, the execution device can obtain the recognition result of one word in the first character each time it executes steps 305 to 307, and the execution device repeatedly executes steps 305 to 307 multiple times to obtain the recognition results of all words in the first character. Then, the output result of the entire first character can be output.
[0144] Furthermore, if a first character includes only one character to be recognized, or a first character includes only one word to be recognized, the execution device may directly output the recognition result of the entire first character after executing steps 301 to 304 .
[0145] For a more intuitive understanding of this solution, please refer to Figure 6 , Figure 6 A network architecture diagram of a text recognition network provided in an embodiment of the present application. The text recognition structure includes an image feature extraction module, A1, A2 and a recognition module, A1 represents a text feature acquisition module, and A2 represents a feature update module. Figure 6 As shown, the execution device inputs the image to be recognized into the image feature extraction module to obtain the image feature (i.e., the first feature) of the first character in the image to be recognized, and inputs the character corresponding to the first character in the image to be recognized into A1 (i.e., the text feature acquisition module). The character corresponding to the first character in the image to be recognized can be a preset character, or a preset character and a second character, so as to generate the initial feature of the character through the text feature acquisition module, and perform self-attention encoding operation and self-attention decoding operation on the initial feature of the character to obtain the semantic feature of the predicted character. After obtaining the first feature, the execution device will also perform self-attention encoding on the initial feature of the character to obtain the updated feature of the character, and then perform self-attention encoding operation according to the first feature and the updated feature of the character to generate the updated first feature. The execution device inputs the updated first feature and the semantic feature of the predicted character into the recognition module to perform the recognition operation through the recognition module and input the recognition result. Figure 6 The specific implementation of each step in the above description can be found here, and will not be repeated here. It should be understood that in actual situations, more or fewer neural network layers can be set in the text recognition network. Figure 6 This is only an example to facilitate understanding of the present invention and is not intended to limit the present invention.
[0146] In the present implementation, not only the image features of the image to be recognized are obtained, but also the semantic features of the predicted characters are generated according to the second character corresponding to the recognized characters in the first character. The recognition operation is performed according to features of more dimensions, which is beneficial to improving the accuracy of the text recognition results. Moreover, due to factors such as blurry image to be recognized or partial obstruction of characters in the image to be recognized, the accuracy of the features of the blurred characters or obscured characters included in the first feature will be greatly reduced. Based on the semantic information of the recognized characters, the semantic features of the predicted characters are generated. Problems with the image such as blurry image or partial obstruction of characters in the image to be recognized will not affect the accuracy of the predicted characters. The recognition results are generated according to the semantic features of the predicted characters together with the image features, which is beneficial to improving the accuracy of the text recognition results.
[0147] 2. Training Phase
[0148] In the embodiment of the present application, the training phase describes the process of how the training device 220 trains the text recognition network. Figure 7 , Figure 7 A flowchart of a method for training a text recognition network provided in an embodiment of the present application, the method may include:
[0149] 701. The training device obtains an image to be recognized from a training data set.
[0150] In an embodiment of the present application, a training data set is pre-configured on a training device, the training data set includes multiple images to be recognized, and a correct result corresponding to the first character in each image to be recognized, and the training device randomly obtains an image to be recognized from the training data set.
[0151] 702. The training device inputs the image to be recognized into the image feature extraction module, and performs feature extraction on the image to be recognized to generate a first feature corresponding to the first character in the image to be recognized.
[0152] 703. The training device inputs a preset character corresponding to the first character in the image to be recognized into a text feature acquisition module, and performs text prediction based on the preset character to generate a semantic feature of the first predicted character.
[0153] 704. The training device combines the feature of the preset character with the first feature through the feature updating module to generate a fourth feature.
[0154] 705. The training device performs a recognition operation through a recognition module according to the first feature and the semantic feature of the first predicted character to generate a first recognition result.
[0155] 706. The training device inputs a second character corresponding to the recognized character in the first character into a text feature acquisition module, and performs text prediction based on the second character to generate a semantic feature of the first predicted character.
[0156] 707. The training device combines the feature of the second character with the first feature through the feature updating module to generate a seventh feature.
[0157] 708. The training device performs a recognition operation through a recognition module according to the first feature and the semantic feature of the first predicted character to generate a second recognition result.
[0158] In the embodiment of the present application, the specific implementation method of the training device performing steps 702 to 708 is the same as Figure 3 The specific implementation of steps 301 to 307 in the corresponding embodiment is similar, and can be found in Figure 3 The description of steps 301 to 307 in the corresponding embodiment will not be repeated here.
[0159] 709. The training device trains the text recognition network according to the correct result corresponding to the first character in the image to be recognized, the recognition result and the loss function.
[0160] In the embodiment of the present application, after obtaining the recognition result of a first character in the image to be recognized, the training device calculates the function value of the loss function according to the correct result corresponding to the first character in the image to be recognized and the recognition result of the first character in the image to be recognized, and performs gradient differentiation on the function value of the loss function to reversely update the weight parameters of the text recognition network to complete a training of the text recognition network. The training device repeatedly performs the aforementioned steps to achieve iterative training of the text recognition network.
[0161] Specifically, if a first character only includes one character to be recognized, or a first character only includes one word to be recognized, the execution device can directly output the recognition result of the entire first character after executing steps 701 to 705, and the training device calculates the function value of the loss function based on the correct result corresponding to the first character in the image to be recognized and the first recognition result output in step 705.
[0162] If a first character includes multiple characters to be recognized, or a first character includes multiple words to be recognized, the execution device can directly output the recognition result of the entire first character after executing steps 701 to 705 once and executing steps 706 to 709 at least once. The training device calculates the function value of the loss function based on the correct result corresponding to the first character in the image to be recognized, the first recognition result output by step 705, and at least one second recognition result obtained by step 708.
[0163] The loss function indicates the similarity between the correct result corresponding to the first character in the image to be recognized and the recognition result of the first character in the image to be recognized, and the training goal is to narrow the similarity between the correct result corresponding to the first character in the image to be recognized and the recognition result of the first character in the image to be recognized. The loss function can be specifically expressed as a cross entropy loss function, a focal loss function, a center loss function or other types of loss functions, etc., which are not limited here.
[0164] The preset condition may be that the loss function satisfies a convergence condition, or that the number of iterations reaches a preset number.
[0165] In the embodiment of the present application, a training method for a text recognition network is provided, which improves the integrity of the present solution; due to factors such as when the image to be recognized is blurred or some characters in the image to be recognized are blocked, the accuracy of the features of the blurred characters or blocked characters included in the first feature will be greatly reduced. In the training stage, based on the semantic information of the recognized characters, the semantic features of the predicted characters are generated, and the recognition results are generated together with the semantic features of the predicted characters and the image features. Due to image problems such as image blur or some characters in the image to be recognized being blocked, the accuracy of the predicted characters will not be affected, which is conducive to improving the accuracy of the text recognition results output by the trained text recognition network.
[0166] In order to more intuitively understand the beneficial effects brought by the embodiments of the present application, the beneficial effects brought by the embodiments of the present application are demonstrated through experimental data in the following Table 1.
[0167] svt SVTP CT80 OCR 88.2% 77.67% 84.98% Embodiments of the present application 92.4% 84.2% 89.9%
[0168] Table 1
[0169] Referring to Table 1 above, SVT, SVTP and CT80 are three public data sets, respectively. The first row of data in Table 1 indicates the accuracy of the recognition results obtained by using optical character recognition (OCR) technology to perform text recognition on the images in the data sets SVT, SVTP and CT80, respectively. The second row of data in Table 1 indicates the accuracy of the recognition results obtained by using the text recognition network provided in the embodiment of the present application to perform text recognition on the images in the data sets SVT, SVTP and CT80, respectively. Obviously, the accuracy of the recognition results obtained by using the text recognition network provided in the embodiment of the present application is higher.
[0170] Also, please read Figure 8 , Figure 8 A schematic diagram of a beneficial effect of a text recognition network provided in an embodiment of the present application. Figure 8 In the first row of data, when the characters in the image to be recognized are recognized based only on the image features of the image to be recognized, the recognition result obtained is "shcct". When the text recognition network provided in the embodiment of the present application is used to recognize the characters in the image to be recognized, the recognition result obtained is "sheet". Figure 8 The second and third rows of data in the text recognition network can be understood by analogy. Obviously, the recognition result obtained by using the text recognition network provided in the embodiment of the present application has a higher accuracy.
[0171] exist Figures 1 to 8 On the basis of the corresponding embodiments, in order to better implement the above solutions of the embodiments of the present application, the following also provides related devices for implementing the above solutions. Fig. 9 , Fig. 9 A structural diagram of a text recognition network provided for an embodiment of the present application. The text recognition network 900 may include an image feature extraction module 901, a text feature acquisition module 902 and a recognition module 903. The image feature extraction module 901 is used to obtain an image to be recognized, and perform feature extraction on the image to be recognized to generate a first feature corresponding to a first character in the image to be recognized, wherein the first character is a character to be recognized in the image to be recognized; the text feature acquisition module 902 is used to obtain a preset character corresponding to the first character in the image to be recognized, and perform text prediction based on the preset character to generate a semantic feature of the first predicted character; the recognition module 903 is used to perform a recognition operation based on the first feature and the semantic feature of the first predicted character to generate a recognition result corresponding to the first character in the image to be recognized.
[0172] In one possible design, the text feature acquisition module 902 is specifically used to obtain a preset character corresponding to a first character in an image to be recognized when a recognition operation is performed on the image to be recognized for the first time, and to perform text prediction based on the preset character to generate a semantic feature of a second predicted character; the text feature acquisition module 902 is also used to determine a recognition result corresponding to a recognized character in the first character as a second character when a recognition operation has been performed on at least one of the first characters, and to generate a semantic feature of a second predicted character corresponding to the second character.
[0173] In a possible design, the recognition module 903 is further used to perform a recognition operation according to the first feature and the semantic feature of the second predicted character to generate a recognition result corresponding to the first character in the image to be recognized.
[0174] In one possible design, see Fig.10 , Fig.10 A structural diagram of a text recognition network provided for an embodiment of the present application. The text feature acquisition module 902 includes: a first generation submodule 9021, which is used to perform vectorization processing on a preset character to generate a character code of the preset character, and generate a position code of the preset character according to the position of the preset character as the first character in the image to be recognized; a combination submodule 9022, which is used to combine the character code of the preset character and the position code of the preset character to obtain an initial feature of the preset character, and perform a self-attention encoding operation and a self-attention decoding operation according to the initial feature of the preset character to generate a semantic feature of the first predicted character.
[0175] In one possible design, see Fig.10 The recognition module 903 includes: a calculation submodule 9031, which is used to calculate the similarity between the first feature and the semantic feature of the first predicted character; a second generation submodule 9032, which is used to generate a second feature and a third feature according to the first feature, the semantic feature of the first predicted character and the similarity, wherein the second feature is a combination of the semantic feature of the first predicted character on the basis of the first feature, and the third feature is a combination of the first feature on the basis of the semantic feature of the first predicted character; the second generation submodule 9032 is also used to perform a recognition operation according to the second feature and the third feature to generate a recognition result.
[0176] In one possible design, see Fig.10 The text recognition network also includes a feature update module 904, which is used to combine the feature of the preset character with the first feature to generate an updated first feature; a recognition module 903 is specifically used to perform a recognition operation based on the updated first feature and the semantic feature of the first predicted character to generate a recognition result corresponding to the first character in the image to be recognized.
[0177] In one possible design, the feature update module 904 is specifically used to: perform a self-attention encoding operation based on the initial feature of the preset character to obtain the updated feature of the preset character, and perform a self-attention encoding operation based on the first feature and the updated feature of the preset character to generate an updated first feature.
[0178] In one possible design, when the granularity at which the text recognition network performs recognition operations is characters, a first character includes at least one character, and a recognition result output by the text recognition network when performing a recognition operation includes a character; when the granularity at which the text recognition network performs recognition operations is words, a first character includes at least one word, and a recognition result output by the text recognition network when performing a recognition operation is a word including one or more characters.
[0179] It should be noted that the information interaction, execution process, etc. between the modules / units in the text recognition network 900 are the same as those in the present application. Figures 3 to 6 The corresponding method embodiments are based on the same concept. For specific contents, please refer to the description in the method embodiments shown above in this application, which will not be repeated here.
[0180] The present application also provides a training device for a text recognition network. Fig.11 , Fig.11 A structural schematic diagram of a training device for a text recognition network provided in an embodiment of the present application. The text recognition network is a neural network for recognizing characters in an image, and the text recognition network includes an image feature extraction module, a text feature acquisition module, and a recognition module. The training device 1100 for the text recognition network includes: an input unit 1101, a recognition unit 1102, and a training unit 1103. The input unit 1101 is used to input the image to be recognized into the image feature extraction module, perform feature extraction on the image to be recognized, so as to generate a first feature corresponding to the first character in the image to be recognized, wherein the first character is the character to be recognized in the image to be recognized; the input unit 1101 is also used to input the preset character corresponding to the first character in the image to be recognized into the text feature acquisition module, and perform text prediction based on the preset character to generate the semantic feature of the first predicted character; the recognition unit 1102 is used to perform a recognition operation through the recognition module according to the first feature and the semantic feature of the first predicted character to generate a recognition result corresponding to the first character in the image to be recognized; the training unit 1103 is used to train the text recognition network according to the correct result corresponding to the first character in the image to be recognized, the recognition result and the loss function, wherein the loss function indicates the similarity between the correct result corresponding to the first character in the image to be recognized and the recognition result corresponding to the first character in the image to be recognized.
[0181] In one possible design, see Fig.12 , Fig.12 A structural diagram of a training device for a text recognition network provided in an embodiment of the present application. An input unit 1101 is specifically used to input a preset character corresponding to a first character in an image to be recognized into a text feature acquisition module when a recognition operation is performed on the image to be recognized for the first time; the training device 1100 for the text recognition network also includes a generation unit 1104, which is used to determine a recognition result corresponding to a recognized character in the first character as a second character through the text feature acquisition module when a recognition operation has been performed on at least one character in the first character, and to generate a semantic feature of a second predicted character corresponding to the second character.
[0182] In a possible design, the recognition unit 1102 is further used to perform a recognition operation through a recognition module according to the first feature and the semantic feature of the second predicted character to generate a recognition result corresponding to the first character in the image to be recognized.
[0183] In one possible design, the input unit 1101 is specifically used to perform vectorization processing on a preset character through a text feature acquisition module to generate a character code of the preset character, and generate a position code of the preset character according to the position of the preset character as the first character in the image to be recognized; the character code of the preset character and the position code of the preset character are combined through the text feature acquisition module to obtain an initial feature of the preset character, and a self-attention encoding operation and a self-attention decoding operation are performed according to the initial feature of the preset character to generate a semantic feature of the first predicted character.
[0184] In one possible design, the recognition unit 1102 is specifically used to: calculate the similarity between the first feature and the semantic feature of the first predicted character through the recognition module; generate the second feature and the third feature through the recognition module according to the first feature, the semantic feature of the first predicted character and the similarity, wherein the second feature is a combination of the semantic feature of the first predicted character on the basis of the first feature, and the third feature is a combination of the first feature on the basis of the semantic feature of the first predicted character; perform a recognition operation according to the second feature and the third feature through the recognition module to generate a recognition result.
[0185] In one possible design, see Fig.12 , the text recognition network also includes a feature update module. The training device 1100 of the text recognition network also includes a combination unit 1105, which is used to combine the feature of the preset character with the first feature through the feature update module to generate an updated first feature; the recognition unit 1102 is specifically used to perform a recognition operation according to the updated first feature and the semantic feature of the first predicted character through the recognition module to generate a recognition result corresponding to the first character in the image to be recognized.
[0186] In one possible design, the combination unit 1105 is specifically used to perform a self-attention encoding operation according to the initial features of a preset character through a feature updating module to obtain an updated feature of the preset character; and to perform a self-attention encoding operation according to the first feature and the updated features of the preset character through the feature updating module to generate an updated first feature.
[0187] In one possible design, when the granularity at which the text recognition network performs recognition operations is characters, a first character includes at least one character, and a recognition result output by the text recognition network when performing a recognition operation includes a character; when the granularity at which the text recognition network performs recognition operations is words, a first character includes at least one word, and a recognition result output by the text recognition network when performing a recognition operation is a word including one or more characters.
[0188] It should be noted that the information interaction, execution process, etc. between the modules / units in the text recognition network training device 1100 are the same as those in the present application. Figure 7 The corresponding method embodiments are based on the same concept. For specific contents, please refer to the description in the method embodiments shown above in this application, which will not be repeated here.
[0189] The present application also provides an execution device. Fig.13 , Fig.13 A schematic diagram of a structure of an execution device provided in an embodiment of the present application, wherein the execution device 1300 may be deployed with Fig. 9 or Fig.10 The text recognition network 900 described in the corresponding embodiment is used to implement Figures 3 to 6 The functions of the execution device in the corresponding embodiment. Specifically, the execution device 1300 includes: a receiver 1301, a transmitter 1302, a processor 1303 and a memory 1304 (wherein the number of the processor 1303 in the execution device 1300 can be one or more, Fig.13 In the example of FIG. 1301 , the processor 1303 may include an application processor 13031 and a communication processor 13032. In some embodiments of the present application, the receiver 1301, the transmitter 1302, the processor 1303 and the memory 1304 may be connected via a bus or other means.
[0190] The memory 1304 may include a read-only memory and a random access memory, and provides instructions and data to the processor 1303. A portion of the memory 1304 may also include a non-volatile random access memory (NVRAM). The memory 1304 stores processor and operation instructions, executable modules or data structures, or subsets thereof, or extended sets thereof, wherein the operation instructions may include various operation instructions for implementing various operations.
[0191] The processor 1303 controls the operation of the execution device. In a specific application, the various components of the execution device are coupled together through a bus system, wherein the bus system includes not only a data bus but also a power bus, a control bus, and a status signal bus, etc. However, for the sake of clarity, various buses are referred to as bus systems in the figure.
[0192] The method disclosed in the above embodiment of the present application can be applied to the processor 1303, or implemented by the processor 1303. The processor 1303 can be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 1303. The above processor 1303 can be a general processor, a digital signal processor (digital signal processing, DSP), a microprocessor or a microcontroller, and can further include an application specific integrated circuit (application specific integrated circuit, ASIC), a field programmable gate array (field-programmable gate array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The processor 1303 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to execute, or the hardware and software modules in the decoding processor can be combined and executed. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 1304, and the processor 1303 reads the information in the memory 1304 and completes the steps of the above method in combination with its hardware.
[0193] The receiver 1301 can be used to receive input digital or character information and generate signal input related to the relevant settings and function control of the execution device. The transmitter 1302 can be used to output digital or character information through the first interface; the transmitter 1302 can also be used to send instructions to the disk group through the first interface to modify the data in the disk group; the transmitter 1302 can also include a display device such as a display screen.
[0194] In the embodiment of the present application, the application processor 13031 is used to execute Figures 3 to 6 The corresponding embodiment executes the function of the device. It should be noted that the application processor 13031 executes Figures 3 to 6 For the specific implementation methods and beneficial effects of the functions of the execution device in the corresponding embodiments, please refer to Figures 3 to 6 The descriptions in the corresponding method embodiments will not be repeated here one by one.
[0195] The present application also provides a training device. Fig.14 , Fig.14 A schematic diagram of a structure of a training device provided in an embodiment of the present application, wherein the training device 1400 may be deployed with Fig.11 Or 12 corresponds to the text recognition network training device 1100 described in the embodiment, used to implement Figure 7 The function of the corresponding training device. Specifically, the training device 1400 is implemented by one or more servers. The training device 1400 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 1422 (for example, one or more processors) and memory 1432, and one or more storage media 1430 (for example, one or more mass storage devices) storing application programs 1442 or data 1444. Among them, the memory 1432 and the storage medium 1430 can be short-term storage or permanent storage. The program stored in the storage medium 1430 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the training device. Furthermore, the central processing unit 1422 can be configured to communicate with the storage medium 1430 to execute a series of instruction operations in the storage medium 1430 on the training device 1400.
[0196] The training device 1400 may also include one or more power supplies 1426, one or more wired or wireless network interfaces 1450, one or more input and output interfaces 1458, and / or, one or more operating systems 1441, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
[0197] In the embodiment of the present application, the central processor 1422 is used to implement Figure 7 The functions of the training device in the corresponding embodiment. It should be noted that the central processor 1422 executes Figure 7 For the specific implementation of the functions of the training device in the corresponding embodiment and the beneficial effects brought about, please refer to Figure 7 The descriptions in the corresponding method embodiments will not be repeated here one by one.
[0198] The present application also provides a computer-readable storage medium in which a program is stored. When the program is run on a computer, the computer executes the above-mentioned Figures 3 to 6 The steps executed by the execution device in the corresponding embodiment, or executing the above Figure 7 The steps performed by the training device in the corresponding embodiment.
[0199] The present application also provides a computer program product which, when executed on a computer, enables the computer to execute the above Figures 3 to 6 The steps executed by the execution device in the corresponding embodiment, or executing the above Figure 7 The steps performed by the training device in the corresponding embodiment.
[0200] The present application also provides a circuit system, which includes a processing circuit, wherein the processing circuit is configured to perform the above Figures 3 to 6 The steps executed by the execution device in the corresponding embodiment, or executing the above Figure 7 The steps performed by the training device in the corresponding embodiment.
[0201] The execution device or training device provided in the embodiment of the present application may be a chip, which includes: a processing unit and a communication unit. The processing unit may be, for example, a processor, and the communication unit may be, for example, an input / output interface, a pin or a circuit. The processing unit may execute the computer execution instructions stored in the storage unit to enable the chip to execute the above Figures 3 to 6 The steps executed by the execution device in the corresponding embodiment, or executing the above Figure 7 The steps performed by the training device in the corresponding embodiment. Optionally, the storage unit is a storage unit in the chip, such as a register, a cache, etc. The storage unit can also be a storage unit located outside the chip in the wireless access device, such as a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM), etc.
[0202] For details, please refer to Fig.15 , Fig.15 A schematic diagram of the structure of a chip provided in an embodiment of the present application, the chip can be expressed as a neural network processor NPU 150, NPU 150 is mounted on the host CPU (Host CPU) as a coprocessor, and the host CPU assigns tasks. The core part of the NPU is the operation circuit 1503, which is controlled by the controller 1504 to extract matrix data in the memory and perform multiplication operations.
[0203] In some implementations, the operation circuit 1503 includes multiple processing units (Process Engine, PE) inside. In some implementations, the operation circuit 1503 is a two-dimensional systolic array. The operation circuit 1503 can also be a one-dimensional systolic array or other electronic circuits capable of performing mathematical operations such as multiplication and addition. In some implementations, the operation circuit 1503 is a general-purpose matrix processor.
[0204] For example, assume there is an input matrix A, a weight matrix B, and an output matrix C. The operation circuit 1503 takes the corresponding data of the matrix B from the weight memory 1502 and caches it on each PE in the operation circuit. The operation circuit 1503 takes the matrix A data from the input memory 1501 and performs a matrix operation with the matrix B. The partial result or the final result of the matrix is stored in the accumulator 1508.
[0205] The unified memory 1506 is used to store input data and output data. The weight data is directly transferred to the weight memory 1502 through the direct memory access controller (DMAC) 1505. The input data is also transferred to the unified memory 1506 through the DMAC.
[0206] BIU stands for Bus Interface Unit 1510 , which is used for the interaction between the AXI bus and the DMAC and the instruction fetch buffer (IFB) 1509 .
[0207] The bus interface unit 1510 (Bus Interface Unit, BIU for short) is used for the instruction fetch memory 1509 to obtain instructions from the external memory, and is also used for the storage unit access controller 1505 to obtain the original data of the input matrix A or the weight matrix B from the external memory.
[0208] DMAC is mainly used to transfer input data in the external memory DDR to the unified memory 1506 or to transfer weight data to the weight memory 1502 or to transfer input data to the input memory 1501.
[0209] The vector calculation unit 1507 includes multiple operation processing units, and further processes the output of the operation circuit 1503 when necessary, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc. It is mainly used for non-convolutional / fully connected layer network calculations in neural networks, such as Batch Normalization, pixel-level summation, upsampling of feature planes, etc.
[0210] In some implementations, the vector calculation unit 1507 can store the processed output vector to the unified memory 1506. For example, the vector calculation unit 1507 can apply a linear function and / or a nonlinear function to the output of the operation circuit 1503, such as linear interpolation of the feature plane extracted by the convolution layer, and then, for example, a vector of accumulated values to generate an activation value. In some implementations, the vector calculation unit 1507 generates a normalized value, a pixel-level summed value, or both. In some implementations, the processed output vector can be used as an activation input to the operation circuit 1503, for example, for use in a subsequent layer in a neural network.
[0211] An instruction fetch buffer 1509 connected to the controller 1504 is used to store instructions used by the controller 1504;
[0212] Unified memory 1506, input memory 1501, weight memory 1502 and instruction fetch memory 1509 are all on-chip memories. External memories are private to the NPU hardware architecture.
[0213] The operations of each layer in the recurrent neural network may be performed by the operation circuit 1503 or the vector calculation unit 1507 .
[0214] The processor mentioned in any of the above places may be a general-purpose central processing unit, a microprocessor, an ASIC, or one or more integrated circuits for controlling the execution of the program of the above-mentioned first aspect method.
[0215] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.
[0216] Through the description of the above implementation methods, the technical personnel in the relevant field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CLUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation method in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, U disk, mobile hard disk, ROM, RAM, disk or optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0217] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0218] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, a computer, a server, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or a data center that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.< / bos> < / bos>
Claims
1. A text recognition network, characterized in that: The text recognition network is a neural network for recognizing characters in an image, and the text recognition network includes an image feature extraction module, a text feature acquisition module, and a recognition module; The image feature extraction module is used to obtain an image to be recognized and perform feature extraction on the image to be recognized to generate a first feature corresponding to a first character in the image to be recognized, wherein the first character is a character to be recognized in the image to be recognized; The text feature acquisition module is used to acquire a preset character corresponding to the first character in the image to be recognized, and perform text prediction based on the preset character to generate a semantic feature of the first predicted character, wherein the preset character includes a start mark character, and the start mark character is used to instruct the text feature acquisition module to start text prediction; The recognition module is used to perform a recognition operation according to the first feature and the semantic feature of the first predicted character to generate a recognition result corresponding to the first character in the image to be recognized.
2. The network according to claim 1, characterized in that The text feature acquisition module is specifically used to acquire a preset character corresponding to a first character in the image to be recognized when a recognition operation is performed on the image to be recognized for the first time, and perform text prediction based on the preset character to generate a semantic feature of the first predicted character; The text feature acquisition module is also used to determine the recognition result corresponding to the recognized character in the first characters as the second character when the recognition operation has been performed on at least one character in the first characters, and perform text prediction based on the second character to generate a semantic feature of a second predicted character corresponding to the second character.
3. The network according to claim 2, characterized in that The recognition module is further used to perform a recognition operation according to the first feature and the semantic feature of the second predicted character to generate a recognition result corresponding to the first character in the image to be recognized.
4. The network according to any one of claims 1 to 3, characterized in that: The text feature acquisition module comprises: A first generating submodule is used to perform vectorization processing on the preset character to generate a character code of the preset character, and generate a position code of the preset character according to the position of the preset character as the first character in the image to be recognized; A combination submodule is used to combine the character code of the preset character and the position code of the preset character to obtain the initial features of the preset character, and perform self-attention encoding operations and self-attention decoding operations according to the initial features of the preset character to generate the semantic features of the first predicted character.
5. The network according to any one of claims 1 to 3, characterized in that: The identification module comprises: A calculation submodule, used for calculating the similarity between the first feature and the semantic feature of the first predicted character; A second generating submodule is configured to generate a second feature and a third feature according to the first feature, the semantic feature of the first predicted character and the similarity, wherein the second feature is the first feature combined with the semantic feature of the first predicted character, and the third feature is the first feature combined with the semantic feature of the first predicted character; The second generating submodule is further used to perform a recognition operation according to the second feature and the third feature to generate a recognition result.
6. The network according to any one of claims 1 to 3, characterized in that: The text recognition network further includes a feature updating module, wherein the feature updating module is used to: combining the feature of the preset character with the first feature to generate an updated first feature; The recognition module is specifically configured to perform a recognition operation according to the updated first feature and the semantic feature of the first predicted character to generate a recognition result corresponding to the first character in the image to be recognized.
7. The network according to claim 6, characterized in that The feature updating module is specifically used to perform a self-attention encoding operation according to the initial feature of the preset character to obtain the updated feature of the preset character, and to perform a self-attention encoding operation according to the first feature and the updated feature of the preset character to generate the updated first feature.
8. The network according to any one of claims 1 to 3, characterized in that: In the case where the granularity of the recognition operation performed by the text recognition network is characters, a first character includes at least one character, and a recognition result output by the text recognition network after performing one recognition operation includes one character; In the case where the granularity of the recognition operation performed by the text recognition network is words, a first character includes at least one word, and a recognition result output by the text recognition network after performing a recognition operation is a word including one or more characters.
9. A method for training a text recognition network, characterized in that: The text recognition network is a neural network for recognizing characters in an image. The text recognition network includes an image feature extraction module, a text feature acquisition module, and a recognition module. The method includes: Inputting the image to be recognized into the image feature extraction module, performing feature extraction on the image to be recognized to generate a first feature corresponding to a first character in the image to be recognized, wherein the first character is a character to be recognized in the image to be recognized; Inputting a preset character corresponding to a first character in the image to be recognized into the text feature acquisition module, and performing text prediction according to the preset character to generate a semantic feature of the first predicted character, wherein the preset character includes a start mark character, and the start mark character is used to instruct the text feature acquisition module to start text prediction; Performing a recognition operation through the recognition module according to the first feature and the semantic feature of the first predicted character to generate a recognition result corresponding to the first character in the image to be recognized; The text recognition network is trained based on the correct result corresponding to the first character in the image to be recognized, the recognition result and the loss function, wherein the loss function indicates the similarity between the correct result corresponding to the first character in the image to be recognized and the recognition result corresponding to the first character in the image to be recognized.
10. The method according to claim 9, characterized in that The text feature acquisition module is specifically used to acquire a preset character corresponding to a first character in the image to be recognized when a recognition operation is performed on the image to be recognized for the first time, and perform text prediction based on the preset character to generate a semantic feature of the first predicted character; The text feature acquisition module is also used to determine the recognition result corresponding to the recognized character in the first characters as the second character when the recognition operation has been performed on at least one character in the first characters, and perform text prediction based on the second character to generate a semantic feature of a second predicted character corresponding to the second character.
11. The method according to claim 10, characterized in that The recognition module is further used to perform a recognition operation according to the first feature and the semantic feature of the second predicted character to generate a recognition result corresponding to the first character in the image to be recognized.
12. A text recognition method, characterized in that: The method comprises: Inputting the image to be recognized into the image feature extraction module, performing feature extraction on the image to be recognized to generate a first feature corresponding to a first character in the image to be recognized, wherein the first character is a character to be recognized in the image to be recognized; Inputting a preset character corresponding to the first character in the image to be recognized into a text feature acquisition module, and performing text prediction according to the preset character to generate a semantic feature of the first predicted character, wherein the preset character includes a start mark character, and the start mark character is used to instruct the text feature acquisition module to start text prediction; According to the first feature and the semantic feature of the first predicted character, a recognition operation is performed by a recognition module to generate a recognition result corresponding to the first character in the image to be recognized; Wherein, the image feature extraction module, the text feature acquisition module and the recognition module belong to the same text recognition network.
13. The method according to claim 12, characterized in that The step of inputting a preset character corresponding to the first character in the image to be recognized into a text feature acquisition module comprises: In the case of performing a recognition operation on the image to be recognized for the first time, inputting a preset character corresponding to a first character in the image to be recognized into a text feature acquisition module; The method further comprises: In a case where a recognition operation has been performed on at least one of the first characters, the recognition result corresponding to the recognized character in the first characters is determined as a second character by the text feature acquisition module, and text prediction is performed based on the second character to generate a semantic feature of a second predicted character corresponding to the second character.
14. The method according to claim 13, characterized in that The method further comprises: According to the first feature and the semantic feature of the second predicted character, a recognition operation is performed by the recognition module to generate a recognition result corresponding to the first character in the image to be recognized.
15. The method according to any one of claims 12 to 14, characterized in that The step of inputting a preset character corresponding to the first character in the image to be recognized into a text feature acquisition module, and performing text prediction according to the preset character to generate a semantic feature of the first predicted character includes: Performing vectorization processing on the preset character by the text feature acquisition module to generate a character code of the preset character, and generating a position code of the preset character according to the position of the first character of the preset character in the image to be recognized; The character code of the preset character and the position code of the preset character are combined by the text feature acquisition module to obtain the initial feature of the preset character, and a self-attention encoding operation and a self-attention decoding operation are performed according to the initial feature of the preset character to generate the semantic feature of the first predicted character.
16. The method according to any one of claims 12 to 14, characterized in that: The recognition module performs a recognition operation according to the first feature and the semantic feature of the first predicted character to generate a recognition result corresponding to the first character in the image to be recognized, including: Calculating, by the recognition module, a similarity between the first feature and a semantic feature of the first predicted character; According to the first feature, the semantic feature of the first predicted character and the similarity, the recognition module generates a second feature and a third feature, wherein the second feature is the first feature combined with the semantic feature of the first predicted character, and the third feature is the first feature combined with the semantic feature of the first predicted character; The recognition module performs a recognition operation according to the second feature and the third feature to generate a recognition result.
17. The method according to any one of claims 12 to 14, characterized in that The text recognition network also includes a feature updating module, and the method further includes: By means of the feature updating module, the feature of the preset character is combined with the first feature to generate an updated first feature; The recognition module performs a recognition operation according to the first feature and the semantic feature of the first predicted character to generate a recognition result corresponding to the first character in the image to be recognized, including: Through the recognition module, a recognition operation is performed according to the updated first feature and the semantic feature of the first predicted character to generate a recognition result corresponding to the first character in the image to be recognized.
18. The method according to claim 17, characterized in that The step of combining the feature of the preset character with the first feature by the feature updating module to generate an updated first feature includes: By means of the feature updating module, a self-attention encoding operation is performed according to the initial features of the preset character to obtain an updated feature of the preset character; Through the feature updating module, a self-attention encoding operation is performed according to the first feature and the updated feature of the preset character to generate the updated first feature.
19. The method according to any one of claims 12 to 14, characterized in that: In the case where the granularity of the recognition operation performed by the text recognition network is characters, a first character includes at least one character, and a recognition result output by the text recognition network after performing one recognition operation includes one character; In the case where the granularity of the recognition operation performed by the text recognition network is words, a first character includes at least one word, and a recognition result output by the text recognition network after performing a recognition operation is a word including one or more characters.
20. A training device for a text recognition network, characterized in that: The text recognition network is a neural network for recognizing characters in an image. The text recognition network includes an image feature extraction module, a text feature acquisition module and a recognition module. The device includes: An input unit, used to input the image to be recognized into the image feature extraction module, perform feature extraction on the image to be recognized, so as to generate a first feature corresponding to a first character in the image to be recognized, wherein the first character is a character to be recognized in the image to be recognized; The input unit is further used to input a preset character corresponding to the first character in the image to be recognized into the text feature acquisition module, and perform text prediction according to the preset character to generate a semantic feature of the first predicted character, wherein the preset character includes a start mark character, and the start mark character is used to instruct the text feature acquisition module to start text prediction; a recognition unit, configured to perform a recognition operation through the recognition module according to the first feature and the semantic feature of the first predicted character, so as to generate a recognition result corresponding to the first character in the image to be recognized; A training unit is used to train the text recognition network according to the correct result corresponding to the first character in the image to be recognized, the recognition result and the loss function, wherein the loss function indicates the similarity between the correct result corresponding to the first character in the image to be recognized and the recognition result corresponding to the first character in the image to be recognized.
21. The device according to claim 20, characterized in that The input unit is specifically used to input a preset character corresponding to a first character in the image to be recognized into the text feature acquisition module when a recognition operation is performed on the image to be recognized for the first time; The input unit is also used to determine the recognition result corresponding to the recognized character in the first characters as a second character through the text feature acquisition module when the recognition operation has been performed on at least one character in the first characters, and perform text prediction based on the second character to generate a semantic feature of a second predicted character corresponding to the second character.
22. The device according to claim 21, characterized in that The recognition unit is further used to perform a recognition operation through the recognition module according to the first feature and the semantic feature of the second predicted character to generate a recognition result corresponding to the first character in the image to be recognized.
23. An execution device, characterized in that: The invention comprises a processor, the processor is coupled to a memory, the memory stores program instructions, and when the program instructions stored in the memory are executed by the processor, the steps performed by the text recognition network according to any one of claims 1 to 8 are implemented.
24. A training device, characterized in that The method comprises a processor, wherein the processor is coupled to a memory, wherein the memory stores program instructions, and when the program instructions stored in the memory are executed by the processor, the method according to any one of claims 9 to 11 is implemented.
25. A computer-readable storage medium, characterized in that: The invention comprises a program which, when executed on a computer, enables the computer to execute the steps executed by the text recognition network as claimed in any one of claims 1 to 8, or enables the computer to execute the method as claimed in any one of claims 9 to 11.
26. A circuit system, characterized in that: The circuit system comprises a processing circuit configured to execute the steps executed by the text recognition network as claimed in any one of claims 1 to 8, or the processing circuit is configured to execute the method as claimed in any one of claims 9 to 11.
Citation Information
Patent Citations
Natural image character recognition method and system based on deep neural network
CN108898137A
Image processing method, apparatus, electronic device and computer-readable medium
CN109117846A
Display panel
CN109389909A
Character recognition method, device and equipment and readable storage medium
CN111126410A
Text prediction using captured image from an image capture device
US20180217976A1
