Text recognition method, device, readable medium and electronic device

By combining character and word granularity features in the text recognition model, the problem of low accuracy in text image recognition is solved, and the recognition accuracy is improved.

CN114067327BActive Publication Date: 2025-01-07BEIJING YOUZHUJU NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111371072.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-18
Publication Date
2025-01-07
Estimated Expiration
2041-11-18

AI Technical Summary

Technical Problem

The existing Transformer model has low recognition of characters in text image recognition, resulting in low recognition accuracy and lack of word granularity features, which affects the accuracy of text image recognition.

Method used

The text recognition model including the encoding sub-model and the character recognition sub-model is adopted. The character encoding feature vector is obtained through the character embedding model, and combined with the word embedding vector, the feature representation of the text image is enhanced, thereby improving the recognition accuracy.

Benefits of technology

By increasing the granularity characteristics of word, the accuracy of text image recognition is improved, and the accurate word embedding vector is obtained using mature word embedding models, which further improves the recognition effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114067327B_ABST
    Figure CN114067327B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a text recognition method, device, readable medium and electronic device, the method comprising: obtaining a text image to be recognized; obtaining the text content corresponding to the text image through a pre-trained text recognition model according to the text image and the text words corresponding to the text image; wherein the text recognition model comprises an encoding sub-model and a character recognition sub-model, the encoding sub-model is used to output a character encoding feature vector corresponding to each character in the text image according to the input text image, and the character recognition sub-model is used to obtain the text content corresponding to the text image according to each character encoding feature vector and the word embedding vector corresponding to the text word. That is to say, when recognizing a text image, the present disclosure adds the features of the word granularity corresponding to the text image, so that the features of the text image are more complete, thereby improving the accuracy of text image recognition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of image processing technology, and in particular, to a text recognition method, device, readable medium and electronic device. Background Art

[0002] With the widespread application of text image recognition technology, people have higher and higher requirements for the accuracy of text image recognition, and need to be able to accurately recognize each character in the text image. In the related art, the text content in the text image is recognized by the Transformer model. However, the Transformer model recognizes each independent character in the text image, resulting in a relatively low accuracy rate of text image recognition. Summary of the invention

[0003] This summary is provided to introduce concepts in a brief form that will be described in detail in the detailed description below. This summary is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.

[0004] In a first aspect, the present disclosure provides a text recognition method, the method comprising:

[0005] Obtain the text image to be recognized;

[0006] According to the correspondence between the text image and the text word text image, obtaining the text content corresponding to the text image through a pre-trained text recognition model;

[0007] Among them, the text recognition model includes an encoding sub-model and a character recognition sub-model, the encoding sub-model is used to output a character encoding feature vector corresponding to each character in the text image according to the input text image, and the character recognition sub-model is used to obtain the text content corresponding to the text image according to each of the character encoding feature vectors and the word embedding vector corresponding to the text word.

[0008] In a second aspect, the present disclosure provides a text recognition device, the device comprising:

[0009] A text image acquisition module, used to acquire a text image to be recognized;

[0010] A text content acquisition module, used to acquire the text content corresponding to the text image through a pre-trained text recognition model according to the text image and the text words corresponding to the text image;

[0011] Among them, the text recognition model includes an encoding sub-model and a character recognition sub-model, the encoding sub-model is used to output a character encoding feature vector corresponding to each character in the text image according to the input text image, and the character recognition sub-model is used to obtain the text content corresponding to the text image according to each of the character encoding feature vectors and the word embedding vector corresponding to the text word.

[0012] In a third aspect, the present disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processing device, implements the steps of the method described in the first aspect of the present disclosure.

[0013] In a fourth aspect, the present disclosure provides an electronic device, including:

[0014] a storage device having a computer program stored thereon;

[0015] A processing device is used to execute the computer program in the storage device to implement the steps of the method described in the first aspect of the present disclosure.

[0016] Through the above technical solution, a text image to be recognized is obtained; according to the text image and the text words corresponding to the text image, the text content corresponding to the text image is obtained through a pre-trained text recognition model; wherein the text recognition model includes an encoding sub-model and a character recognition sub-model, the encoding sub-model is used to output a character encoding feature vector corresponding to each character in the text image according to the input text image, and the character recognition sub-model is used to obtain the text content corresponding to the text image according to each character encoding feature vector and the word embedding vector corresponding to the text word. That is to say, when recognizing a text image, the present disclosure adds the features of the word granularity corresponding to the text image, so that the features of the text image are more complete, thereby improving the accuracy of text image recognition.

[0017] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale. In the drawings:

[0019] Figure 1 is a flowchart of a text recognition method provided according to an exemplary embodiment of the present disclosure;

[0020] Figure 2is a schematic diagram of a text recognition model provided according to an exemplary embodiment of the present disclosure;

[0021] Figure 3 is a flowchart of a character recognition method provided according to an exemplary embodiment of the present disclosure;

[0022] Figure 4 is a schematic diagram of a text recognition method provided according to an exemplary embodiment of the present disclosure;

[0023] Figure 5 is a block diagram of a text recognition device provided according to an exemplary embodiment of the present disclosure;

[0024] Figure 6 is a block diagram of a second text recognition device provided according to an exemplary embodiment of the present disclosure;

[0025] Figure 7 is a block diagram of a third text recognition device provided according to an exemplary embodiment of the present disclosure;

[0026] Figure 8 It is a block diagram of an electronic device according to an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION

[0027] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0028] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.

[0029] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.

[0030] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0031] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0032] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0033] First, the application scenario of the present invention is explained. Traditional OCR (Optical Character Recognition) technology is divided into two steps: text detection and text recognition. The text image is segmented by text detection to obtain the text area in the text image. The text area sub-image segmented in the text detection step is recognized by text recognition to obtain the text translation information (text content) corresponding to the text image. In the related technology, text recognition based on deep learning mainly includes CTC (Connectionist Temporal Classification) methods represented by CRNN (Convolutional Recurrent Neural Network) and Attention methods represented by Transformer. Among them, the Transformer model consists of an encoder and a decoder. For the input text image, the character embedding model is first used for character embedding encoding, and then the character prediction is performed through several attentions. However, since the character embedding model is based on character granularity, and in the field of NLP (Natural Language Processing), most of the research on embedding coding is based on word granularity (word), which is a word embedding model obtained through massive expected training. Therefore, compared with the word embedding model, the character embedding model is not mature enough and has relatively poor performance, resulting in the character embedding features corresponding to the text image obtained by the character embedding model being not accurate enough, resulting in a relatively low accuracy rate in text image recognition.

[0034] In order to solve the above-mentioned technical problems, the present disclosure provides a text recognition method, device, readable medium and electronic device, which add the features of the word granularity corresponding to the text image when recognizing a text image, so that the features of the text image are more complete, thereby improving the accuracy of text image recognition.

[0035] The present disclosure is described below in conjunction with specific embodiments.

[0036] Figure 1 is a flowchart of a text recognition method provided according to an exemplary embodiment of the present disclosure. Figure 1 As shown, the method may include:

[0037] S101: Obtain a text image to be recognized.

[0038] The text image may be an image corresponding to a line of text obtained after performing text line detection on the target image.

[0039] S102: According to the text image and the text words corresponding to the text image, the text content corresponding to the text image is obtained through a pre-trained text recognition model.

[0040] Among them, the text word can be a word composed of characters corresponding to the text image, and the text word can include at least one, and different text words correspond to different word embedding vectors; the text recognition model can be a model trained based on the Transformer model. The text recognition model can include an encoding sub-model and a character recognition sub-model, the encoding sub-model is used to output a character encoding feature vector corresponding to each character in the text image according to the input text image, and the character recognition sub-model is used to obtain the text content corresponding to the text image according to each character encoding feature vector and the word embedding vector corresponding to the text word. The text recognition model can be trained with reference to the model training method of the prior art, which will not be repeated here.

[0041] Figure 2 is a schematic diagram of a text recognition model provided according to an exemplary embodiment of the present disclosure, such as Figure 2 As shown, the dotted box on the left is the encoding sub-model, and the larger dotted box on the right is the character recognition sub-model. The character recognition sub-model may include a decoding sub-model (small dotted box), a linear layer, and a softmax layer. The structure of the encoding sub-model is similar to that of the encoder in the Transformer model, and the structure of the decoding sub-model is similar to that of the decoder in the Transformer model.

[0042] In this step, after obtaining the text image to be recognized, the text image can be input into a pre-trained character embedding model to obtain a character embedding feature vector corresponding to the text image, and then the character embedding feature vector is input into the encoding sub-model, and the character encoding feature vector corresponding to each character in the text image is obtained through the encoding sub-model. Among them, the character embedding model can be a model trained based on CNN (Convolutional Neural Networks), and the character embedding model can be trained with reference to the model training method of the prior art, which will not be repeated here.

[0043] Furthermore, after obtaining the character encoding feature vector corresponding to each character in the text image, the character recognition step can be executed repeatedly until the target character output by the character recognition sub-model is the preset termination character, and the new text character is used as the text content corresponding to the text image. Figure 3 is a flowchart of a character recognition method provided according to an exemplary embodiment of the present disclosure. Figure 3 As shown, the character recognition step may include:

[0044] S1. Obtain the recognized text characters in the text image.

[0045] The recognized text characters in the text image may be all target characters output by the character recognition model.

[0046] S2. Obtain the character decoding feature vector corresponding to the text character.

[0047] After obtaining the recognized text characters in the text image, the character decoding feature vector corresponding to the text characters can be obtained by referring to the output embedding in the Transformer model.

[0048] S3. Get the target word embedding vector corresponding to the target text word.

[0049] The target text word may be a word that is before the target character in the text image and is closest to the target character.

[0050] In a possible implementation, after obtaining the text character, the text word in the text character can be determined, and the text word closest to the target character is used as the target text word. For example, if the text character includes "I", " " (space), "l", "o", "v", "e", " ", "C", and the target character is "C", then the target text word can be "love".

[0051] It should be noted that, taking the above text characters as an example, when the target character is "l", "o", "v" or "e", the target text word is "I". When the target character is "C", the target text word will be updated to "love".

[0052] In another possible implementation, after the character recognition sub-model outputs the target character, it can be determined whether the target character output by the character recognition sub-model is a space. If the target character is a space, the target text word is updated. Continuing with the above text characters as an example, there is a space between the text character "I" and the text character "l", and there is a space between the text character "e" and the text character "C". If the target character output by the character recognition sub-model is any one of "l", "o", "v", and "e", the target text word will not be updated, and the target text word is "I". If the target character output by the character recognition sub-model is a space, the target text word is updated to "love".

[0053] When the target character is not a space, the target character can be used as a pending character and stored. When the target text word needs to be updated, the stored pending character can be obtained, the stored pending character can be used as a new target text word, and the stored pending character can be deleted. For example, when the target character output by the character recognition sub-model is "I", the target text word is not updated, the target character is used as the pending character, and the pending character "I" is stored. Afterwards, when the target character output by the character recognition sub-model is a space, the stored pending character "I" is obtained, the target text word is updated to "I", and the stored pending character "I" is deleted; when the target character output by the character recognition sub-model is "l", the target text word is not updated, the target character is used as the pending character, and the pending character "l" is stored. When the target character output by the character recognition sub-model is "o", "v", or "e", the processing method for the target character "l" can be referred to, and the target text word is not updated. In this way, the stored pending characters include "l", "o", "v", or "e"; afterward, when the target character output by the character recognition sub-model is a space, the stored pending characters "l", "o", "v", or "e" are obtained, and the pending character "love" is used as the new target text word.

[0054] Furthermore, after determining the target text word, the target text word can be input into a pre-trained word embedding model to obtain a target word embedding vector corresponding to the target text word output by the word embedding model. The word embedding model can be a model used in the prior art to obtain a word feature vector.

[0055] S4. Determine a target character vector according to the character decoding feature vector and the target word embedding vector.

[0056] After obtaining the character decoding feature vector corresponding to the text character and the target word embedding vector corresponding to the target word, the character decoding feature vector and the target word embedding vector can be concatenated to obtain the target character vector, or the character decoding feature vector and the target word embedding vector can be added to obtain the target character vector, which is not limited in the present disclosure.

[0057] S5. Input each character encoding feature vector and the target character vector into the character recognition sub-model to obtain the target character output by the character recognition sub-model.

[0058] The character recognition sub-model includes a first decoding sub-model and a second decoding sub-model. Figure 2 Taking the text recognition model shown as an example, the first decoding sub-model may include the bottom multi-head attention layer and Add&Norm layer in the character recognition sub-model, and the second decoding sub-model may include the multi-head attention layer, Add&Norm layer, feedforward network, and Add&Norm layer above the first decoding sub-model.

[0059] After obtaining the target character vector, the target character vector can be input into the first decoding sub-model to obtain the target character feature vector output by the first decoding sub-model, and each character encoding feature vector and the target character feature vector can be input into the second decoding sub-model to obtain the target character output by the second decoding sub-model. Figure 4 is a schematic diagram of a text recognition method provided according to an exemplary embodiment of the present disclosure, such as Figure 4 As shown, after the target character is output through the text recognition model, it can be determined whether the target character is a space. When the target character is not a space, the target character is used as a pending character and stored. For example, the pending character can be stored in a stack. When the target character is a space, the stored pending character is obtained and the pending character is used as a new target text word. After that, the target word embedding vector corresponding to the target text word is obtained, and the target word embedding vector is added to the character decoding feature vector to obtain the target character vector, and the target character vector is input into the first decoding sub-model to obtain the target character feature vector, and the target character feature vector and each character encoding feature vector are input into the second decoding sub-model. Finally, the target character is output through the linear layer and the softmax layer.

[0060] S6. Use the text character and the target character as new text characters.

[0061] After the character recognition sub-model outputs the target character, the text character may be updated, and the text character and the target character are used as a new text character.

[0062] When the target character output by the character recognition sub-model is a preset termination character, the text character can be used as the text content corresponding to the text image. For example, when the target character output by the character recognition sub-model is " / eos", if the text character includes "O", "C", "R", "", "i", "s", "", "g", "r", "e", "a", "t", "!", the text content corresponding to the text image can be "OCR is great!"

[0063] For example, Table 1 is the processing flow of the text recognition model. As shown in Table 1, the first row represents the decoding time of the text recognition model, the second row represents the input of the character recognition model, the third row represents the character encoding feature vector output by the encoding sub-model, the fourth row represents the target word embedding vector corresponding to the target text word, and the fifth row represents the target character output by the text recognition model.

[0064] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 / sos O C R i s g r e a t ! c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 - - - - w1 w1 w1 w2 w2 w2 w2 w2 w2 O C R i s g r e a t ! / eos

[0065] Table 1

[0066] It can be seen from Table 1 that from the 1st moment to the 4th moment, since there is no text word in the decoded text characters, the target word embedding vector from the 1st moment to the 4th moment is empty. After the first space is output at the 5th moment, the target word embedding vector w1 corresponding to the target text word (OCR) is obtained, and after the second space is output, the target word embedding vector is updated to w2 (the target word embedding vector corresponding to the target word "is").

[0067] By adopting the above method, when recognizing text images, the features of each character and each word in the text image are combined. In this way, the features of the text image are more complete, thereby improving the accuracy of text image recognition. At the same time, the word embedding vector corresponding to each word can be obtained through a mature word embedding model, so that the obtained word embedding vector is more accurate, thereby further improving the accuracy of text image recognition.

[0068] Figure 5 is a block diagram of a text recognition device provided according to an exemplary embodiment of the present disclosure. Figure 5 As shown, the device may include:

[0069] The text image acquisition module 501 is used to acquire the text image to be recognized;

[0070] A text content acquisition module 502 is used to acquire the text content corresponding to the text image through a pre-trained text recognition model according to the text image and the text words corresponding to the text image;

[0071] Among them, the text recognition model includes an encoding sub-model and a character recognition sub-model. The encoding sub-model is used to output a character encoding feature vector corresponding to each character in the text image according to the input text image, and the character recognition sub-model is used to obtain the text content corresponding to the text image according to each character encoding feature vector and the word embedding vector corresponding to the text word.

[0072] Optionally, the text word includes at least one, and different text words correspond to different word embedding vectors; the text content acquisition module 502 is further used to:

[0073] The character recognition step is executed cyclically until the target character output by the character recognition sub-model is a preset termination character, and the new text character is used as the text content corresponding to the text image; the character recognition step includes:

[0074] Obtain the recognized text characters in the text image;

[0075] Get the character decoding feature vector corresponding to the text character;

[0076] Obtain a target word embedding vector corresponding to a target text word, where the target text word is a word in the text image that is closest to the target character and precedes the target character;

[0077] Determine a target character vector according to the character decoding feature vector and the target word embedding vector;

[0078] Input each of the character encoding feature vectors and the target character vector into the character recognition sub-model to obtain the target character output by the character recognition sub-model;

[0079] The text character and the target character are used as new text characters.

[0080] Optionally, Figure 6 is a block diagram of a second text recognition device provided according to an exemplary embodiment of the present disclosure, such as Figure 6 As shown, the device may include:

[0081] A space determination module 503 is used to determine whether the target character output by the character recognition sub-model is a space;

[0082] The text word updating module 504 is used to update the target text word when the target character is a space.

[0083] Optionally, Figure 7is a block diagram of a third text recognition device provided according to an exemplary embodiment of the present disclosure, such as Figure 7 As shown, the device may include:

[0084] The character storage module 505 is used for, when the target character is not a space, taking the target character as a pending character and storing the pending character.

[0085] Optionally, the text word updating module 504 is further used to:

[0086] Get the stored pending character;

[0087] The stored pending character is used as a new target text word;

[0088] Delete the stored pending character.

[0089] Optionally, the text content acquisition module 502 is further used to:

[0090] The target text word is input into a pre-trained word embedding model to obtain a target word embedding vector corresponding to the target text word output by the word embedding model.

[0091] Optionally, the character recognition sub-model includes a first decoding sub-model and a second decoding sub-model, and the text content acquisition module 502 is further used to:

[0092] Inputting the target character vector into the first decoding sub-model to obtain the target character feature vector output by the first decoding sub-model;

[0093] Each of the character encoding feature vectors and the target character feature vector is input into the second decoding sub-model to obtain the target character output by the second decoding sub-model.

[0094] By means of the above device, when a text image is recognized, the features of the word granularity corresponding to the text image are added, so that the features of the text image are more complete, thereby improving the accuracy of text image recognition.

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

[0096] Reference below Figure 8, which shows a schematic diagram of the structure of an electronic device (such as a terminal device or a server) 800 suitable for implementing the embodiment of the present disclosure. The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle terminals (such as vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 8 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0097] like Figure 8 As shown, the electronic device 800 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage device 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the electronic device 800 are also stored. The processing device 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.

[0098] Typically, the following devices may be connected to the I / O interface 805: input devices 806 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 807 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 808 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 809. The communication device 809 may allow the electronic device 800 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 8 The electronic device 800 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0099] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 809, or installed from a storage device 808, or installed from a ROM 802. When the computer program is executed by the processing device 801, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0100] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0101] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0102] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0103] The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the electronic device, the electronic device: obtains a text image to be recognized; and obtains the text content corresponding to the text image through a pre-trained text recognition model based on the text image and the text words corresponding to the text image; wherein the text recognition model includes an encoding sub-model and a character recognition sub-model, the encoding sub-model is used to output a character encoding feature vector corresponding to each character in the text image according to the input text image, and the character recognition sub-model is used to obtain the text content corresponding to the text image based on each of the character encoding feature vectors and the word embedding vector corresponding to the text word.

[0104] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0105] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0106] The modules involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of a module does not limit the module itself in some cases. For example, a text image acquisition module may also be described as a "module for acquiring a text image to be recognized".

[0107] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0108] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0109] According to one or more embodiments of the present disclosure, Example 1 provides a text recognition method, which includes: obtaining a text image to be recognized; obtaining text content corresponding to the text image through a pre-trained text recognition model based on the text image and the text words corresponding to the text image; wherein the text recognition model includes an encoding sub-model and a character recognition sub-model, the encoding sub-model is used to output a character encoding feature vector corresponding to each character in the text image according to the input text image, and the character recognition sub-model is used to obtain the text content corresponding to the text image based on each of the character encoding feature vectors and the word embedding vector corresponding to the text word.

[0110] According to one or more embodiments of the present disclosure, Example 2 provides the method of Example 1, wherein the text words include at least one, and different text words correspond to different word embedding vectors; the obtaining of the text content corresponding to the text image according to each of the character encoding feature vectors and the word embedding vector corresponding to the text word includes: looping through the character recognition step until the target character output by the character recognition sub-model is a preset termination character, and taking the new text character as the text content corresponding to the text image; the character recognition step includes: obtaining the recognized text characters in the text image; obtaining the character decoding feature vector corresponding to the text character; obtaining the target word embedding vector corresponding to the target text word, the target text word being the word in the text image that is closest to the target character before the target character; determining the target character vector according to the character decoding feature vector and the target word embedding vector; inputting each of the character encoding feature vectors and the target character vector into the character recognition sub-model to obtain the target character output by the character recognition sub-model; taking the text character and the target character as new text characters.

[0111] According to one or more embodiments of the present disclosure, Example 3 provides the method of Example 2, which further includes: determining whether the target character output by the character recognition sub-model is a space; and updating the target text word when the target character is a space.

[0112] According to one or more embodiments of the present disclosure, Example 4 provides the method of Example 3, wherein the method further includes: when the target character is not a space, taking the target character as a pending character and storing the pending character.

[0113] According to one or more embodiments of the present disclosure, Example 5 provides the method of Example 4, wherein updating the target text word comprises: acquiring the stored pending characters; using the stored pending characters as new target text words; and deleting the stored pending characters.

[0114] According to one or more embodiments of the present disclosure, Example 6 provides the method of Example 2, wherein obtaining the target word embedding vector corresponding to the target text word includes: inputting the target text word into a pre-trained word embedding model to obtain the target word embedding vector corresponding to the target text word output by the word embedding model.

[0115] According to one or more embodiments of the present disclosure, Example 7 provides a method of any one of Examples 2 to 6, wherein the character recognition submodel includes a first decoding submodel and a second decoding submodel, and the inputting each of the character encoding feature vectors and the target character vector into the character recognition submodel to obtain the target character output by the character recognition submodel includes: inputting the target character vector into the first decoding submodel to obtain the target character feature vector output by the first decoding submodel; and inputting each of the character encoding feature vectors and the target character feature vector into the second decoding submodel to obtain the target character output by the second decoding submodel.

[0116] According to one or more embodiments of the present disclosure, Example 8 provides a text recognition device, which includes: a text image acquisition module, used to acquire a text image to be recognized; a text content acquisition module, used to acquire the text content corresponding to the text image through a pre-trained text recognition model based on the text image and the text words corresponding to the text image; wherein the text recognition model includes an encoding sub-model and a character recognition sub-model, the encoding sub-model is used to output a character encoding feature vector corresponding to each character in the text image according to the input text image, and the character recognition sub-model is used to acquire the text content corresponding to the text image based on each of the character encoding feature vectors and the word embedding vector corresponding to the text word.

[0117] According to one or more embodiments of the present disclosure, Example 9 provides a computer-readable medium having a computer program stored thereon, which implements the steps of the method described in any one of Examples 1 to 7 when executed by a processing device.

[0118] According to one or more embodiments of the present disclosure, Example 10 provides an electronic device, comprising: a storage device on which a computer program is stored; and a processing device for executing the computer program in the storage device to implement the steps of the method described in any one of Examples 1 to 7.

[0119] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.

[0120] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0121] Although the subject matter has been described in language specific to structural features and / or method logic actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims. Regarding the device in the above embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.

Claims

1. A text recognition method, characterized in that: The method comprises: Obtain the text image to be recognized; According to the text image and the text words corresponding to the text image, obtaining the text content corresponding to the text image through a pre-trained text recognition model; The text recognition model includes an encoding sub-model and a character recognition sub-model, wherein the encoding sub-model is used to output a character encoding feature vector corresponding to each character in the text image according to the input text image, and the character recognition sub-model is used to obtain the text content corresponding to the text image according to each character encoding feature vector and a word embedding vector corresponding to the text word; The text word includes at least one, and different text words correspond to different word embedding vectors; and obtaining the text content corresponding to the text image according to each of the character encoding feature vectors and the word embedding vector corresponding to the text word includes: The character recognition step is executed cyclically until the target character output by the character recognition sub-model is a preset termination character, and the new text character is used as the text content corresponding to the text image; the character recognition step includes: Obtaining recognized text characters in the text image; Obtaining a character decoding feature vector corresponding to the text character; Obtaining a target word embedding vector corresponding to a target text word, wherein the target text word is a word in the text image that is closest to the target character and precedes the target character; Determine a target character vector according to the character decoding feature vector and the target word embedding vector; Input each of the character encoding feature vectors and the target character vector into the character recognition sub-model to obtain the target character output by the character recognition sub-model; The text character and the target character are used as new text characters.

2. The method according to claim 1, characterized in that The method further comprises: Determining whether the target character output by the character recognition sub-model is a space; In the case where the target character is a space, the target text word is updated.

3. The method according to claim 2, characterized in that The method further comprises: In the case that the target character is not a space, the target character is used as a pending character and the pending character is stored.

4. The method according to claim 3, characterized in that The updating of the target text word comprises: Obtain the stored pending character; Using the stored pending character as a new target text word; Delete the stored pending character.

5. The method according to claim 1, characterized in that The acquiring of the target word embedding vector corresponding to the target text word comprises: The target text word is input into a pre-trained word embedding model to obtain a target word embedding vector corresponding to the target text word output by the word embedding model.

6. The method according to any one of claims 1 to 5, characterized in that: The character recognition sub-model includes a first decoding sub-model and a second decoding sub-model, and the step of inputting each of the character encoding feature vectors and the target character vector into the character recognition sub-model to obtain the target character output by the character recognition sub-model includes: Inputting the target character vector into the first decoding sub-model to obtain a target character feature vector output by the first decoding sub-model; Each of the character encoding feature vectors and the target character feature vector is input into the second decoding sub-model to obtain the target character output by the second decoding sub-model.

7. A text recognition device, characterized in that: The device comprises: A text image acquisition module, used to acquire a text image to be recognized; A text content acquisition module, used to acquire the text content corresponding to the text image through a pre-trained text recognition model according to the text image and the text words corresponding to the text image; The text recognition model includes an encoding sub-model and a character recognition sub-model, wherein the encoding sub-model is used to output a character encoding feature vector corresponding to each character in the text image according to the input text image, and the character recognition sub-model is used to output the text content corresponding to the text image according to each character encoding feature vector and a word embedding vector corresponding to the text word; The text word includes at least one, and different text words correspond to different word embedding vectors; the text content acquisition module is also used to cyclically execute the character recognition step until the target character output by the character recognition sub-model is a preset termination character, and the new text character is used as the text content corresponding to the text image; the character recognition step includes: Obtaining recognized text characters in the text image; Obtaining a character decoding feature vector corresponding to the text character; Obtaining a target word embedding vector corresponding to a target text word, wherein the target text word is a word in the text image that is closest to the target character and precedes the target character; Determine a target character vector according to the character decoding feature vector and the target word embedding vector; Input each of the character encoding feature vectors and the target character vector into the character recognition sub-model to obtain the target character output by the character recognition sub-model; The text character and the target character are used as new text characters.

8. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processing device, the steps of the method described in any one of claims 1 to 6 are implemented.

9. An electronic device, characterized in that: include: a storage device having a computer program stored thereon; A processing device, configured to execute the computer program in the storage device to implement the steps of the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Text recognition method and device, and storage medium

    CN111753600A

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

    CN111753822A