Text recognition method, device, medium and equipment

Feature extraction and encoding of text images through text recognition models, and output character, direction information and position information through multiple output layers, solving the problem of insufficient accuracy in the recognition of diverse typesetting text lines in the prior art, and achieving efficient and fine text recognition and semantic understanding.

CN114724164BActive Publication Date: 2025-03-28BEIJING YOUZHUJU NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210349395.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-01
Publication Date
2025-03-28
Estimated Expiration
2042-04-01

AI Technical Summary

Technical Problem

The prior art processes text lines of diverse typesettings, insufficient recognition accuracy makes it difficult to understand semantics.

Method used

Character, direction information and position information are output by using the text recognition model to be identified, character, direction information and position information are output by combining the coding sub-model and the decoding sub-model, and mapping in different dimensions through multiple output layers.

Benefits of technology

It improves the fineness and accuracy of text recognition, ensures the matching degree of direction information and position information with characters, reduces the data processing volume, improves the efficiency of text recognition, and provides accurate data support for semantic understanding.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114724164B_ABST
    Figure CN114724164B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a text recognition method, apparatus, medium and equipment, the method comprising: obtaining a text image to be recognized; obtaining a character recognition result output by the text recognition model according to the text image and a text recognition model, wherein the character recognition result includes each character contained in the text image, and direction information and position information corresponding to each of the characters; the text recognition model comprises an encoding sub-model, a decoding sub-model and a plurality of output layers, the encoding sub-model is used to extract and encode features of the text image to obtain an encoding vector; the decoding sub-model is used to decode according to the encoding vector to obtain decoding features, the plurality of output layers respectively perform mapping based on the decoding features, and respectively output the characters, the direction information and position information corresponding to the characters to obtain the character recognition result.
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, and in particular, to a text recognition method, device, medium and equipment. Background Art

[0002] OCR (Optical Character Recognition) is a technology commonly used for text recognition in current images. The OCR technology can convert the text in the image into a text format, which can then be further edited and processed by word processing software.

[0003] In the related art, when performing text recognition, the text lines that are horizontally arranged to the right in the image are usually recognized. However, with the diversity of graphic design layouts and the diversity of images, the accuracy of this text recognition method in recognizing text lines with diverse layouts is insufficient, which makes it difficult to understand the semantics of the recognition results. Summary of the invention

[0004] 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.

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

[0006] Obtain the text image to be recognized;

[0007] According to the text image and the text recognition model, obtaining a character recognition result output by the text recognition model, wherein the character recognition result includes each character contained in the text image, and direction information and position information corresponding to each character;

[0008] The text recognition model includes an encoding sub-model, a decoding sub-model and multiple output layers. The encoding sub-model is used to extract and encode features of the text image to obtain an encoding vector; the decoding sub-model is used to decode according to the encoding vector to obtain decoding features. The multiple output layers are respectively mapped based on the decoding features, and respectively output the characters, the direction information and the position information corresponding to the characters to obtain the character recognition results.

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

[0010] An acquisition module, used for acquiring a text image to be recognized;

[0011] A first processing module, configured to obtain a character recognition result output by the text recognition model according to the text image and the text recognition model, wherein the character recognition result includes each character contained in the text image, and direction information and position information corresponding to each character;

[0012] The text recognition model includes an encoding sub-model, a decoding sub-model and multiple output layers. The encoding sub-model is used to extract and encode features of the text image to obtain an encoding vector; the decoding sub-model is used to decode according to the encoding vector to obtain decoding features. The multiple output layers are respectively mapped based on the decoding features, and respectively output the characters, the direction information and the position information corresponding to the characters to obtain the character recognition results.

[0013] 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.

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

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

[0016] 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.

[0017] Through the above technical solution, when performing text recognition on a text image to be recognized, the text image can be feature extracted and encoded based on the text recognition model to obtain corresponding decoding features based on the encoded features, and different dimensions of mapping can be performed based on the same decoding features through multiple output layers, so that the direction information and position information corresponding to the characters can be obtained based on the same decoding features while obtaining the characters for text recognition. On the one hand, the precision and accuracy of text recognition can be improved, and on the other hand, the matching degree of the obtained direction information and position information with the characters can be ensured, reducing the amount of data processing for direction recognition and position recognition, and improving the efficiency of text recognition. In addition, based on the direction information, accurate data support can be provided for the semantic understanding of the text line corresponding to the recognized characters, thereby improving the user experience.

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

[0019] 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:

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

[0021] Figure 2 is a schematic diagram of a text image provided according to an embodiment of the present disclosure;

[0022] Figure 3 is a structural schematic diagram of a text recognition model provided according to an embodiment of the present disclosure;

[0023] Figure 4 is a schematic diagram of a training text image and a rotated text image provided according to an embodiment of the present disclosure;

[0024] Figure 5 is a schematic diagram of a display interface provided according to an embodiment of the present disclosure;

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

[0026] Figure 7 A schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present disclosure is shown. 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] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, scope of use, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.

[0034] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, application, server, or storage medium that performs the operation of the technical solution of the present disclosure according to the prompt message.

[0035] As an optional but non-limiting implementation, in response to receiving an active request from the user, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.

[0036] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet the relevant laws and regulations may also be applied to the implementation of the present disclosure.

[0037] At the same time, it is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.

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

[0039] In step 11, a text image to be recognized is obtained.

[0040] As an example, the text image may be an image input by a user, such as a graphic design image. Figure 2 As another example, the text image may be a text image received from an upstream service, which may segment and extract the initial image to obtain sub-images containing text lines in the initial image, and determine each sub-image as a text image. If the upstream service is image segmentation, it may obtain the corresponding text area based on the text area detection technology in the OCR technology, such as NMS (Non Maximum Suppression), etc., to obtain the sub-image, such as Figure 2 A1, A2 and A3 in the image are processed as text images to be recognized.

[0041] In step 12, the text image is input into the text recognition model to obtain a character recognition result output by the text recognition model, wherein the character recognition result includes each character contained in the text image, and direction information and position information corresponding to each character.

[0042] like Figure 3 As shown, it is a structural diagram of a text recognition model provided based on an embodiment of the present disclosure, the text recognition model includes an encoding sub-model 31, a decoding sub-model 32 and multiple output layers 33, the encoding sub-model 31 is used to extract features of the text image and encode it to obtain an encoding vector; the decoding sub-model 32 is used to decode according to the encoding vector to obtain decoding features, and the multiple output layers 33 are respectively mapped based on the decoding features, and respectively output the characters, the direction information and the position information corresponding to the characters to obtain the character recognition results.

[0043] like Figure 3 As shown, the multiple output layers 33 include three output layers, which are respectively denoted as F1, F2 and F3, wherein the F1 layer is used to output characters, the F2 layer is used to output direction information, and the F3 layer is used to output position information.

[0044] As an example, the multiple output layers can respectively output their corresponding sequences, namely, a character sequence, a direction information sequence, and a position information sequence, and the corresponding characters in the three sequences are arranged in the same order. As another example, the multiple output layers can be fused to obtain an output sequence S, and each element Si in the output sequence S contains a character Ci, the direction information Di of the character Ci, and the position information Li of the character Ci. Among them, the direction information can be the orientation information of the character, such as the orientation of up, down, left, and right, and the position information can be the coordinate information of the four vertices of the rectangular box corresponding to the character.

[0045] Therefore, through the above technical solution, when performing text recognition on the text image to be recognized, the text image can be feature extracted and encoded based on the text recognition model to obtain corresponding decoding features based on the encoded features, and different dimensions of mapping can be performed based on the same decoding features through multiple output layers, so that the direction information and position information corresponding to the characters can be obtained based on the same decoding features while obtaining the characters for text recognition. On the one hand, the precision and accuracy of text recognition can be improved, and on the other hand, the matching degree of the obtained direction information and position information with the characters can be ensured, reducing the amount of data processing for direction recognition and position recognition, and improving the efficiency of text recognition. In addition, based on the direction information, accurate data support can be provided for the semantic understanding of the text line corresponding to the recognized characters, thereby improving the user experience.

[0046] In a possible embodiment, the text recognition model can be determined in the following manner:

[0047] A training sample set is obtained, wherein each training sample in the training sample set includes a training text image, a target character corresponding to the training text image, and target direction information and target position information corresponding to each target character.

[0048] As an example, multiple training text images can be obtained from the Internet or a training data set, and the multiple training images can include images in various orientations. Then, annotators can annotate the training text images to obtain the corresponding target characters, target orientation information, and target position information.

[0049] As another example, the training sample set may be determined in the following manner:

[0050] The first training sample in the training sample set is obtained, that is, the training sample annotated by the annotator as described above can be used as the first training sample.

[0051] Afterwards, the training text image in the first training sample is rotated at a predetermined rotation angle to obtain a rotated text image;

[0052] The target direction information and target position information corresponding to the rotated text image are generated based on the rotation angle and the target direction information and target position information corresponding to the training text image in the first training sample.

[0053] The predetermined rotation angle may be 90 degrees, 180 degrees or 270 degrees. Figure 4 The training text image a shown has the direction information of up. When it is rotated 180 degrees around the center, image b is obtained, and its corresponding direction information is down. The training text image c has the direction information of left. When it is rotated 180 degrees around the center, image d is obtained, and its corresponding direction information is right. Thus, the training text image can be rotated to obtain corresponding rotated text images in multiple directions, thereby the training sample set can be diversified based on the existing training text images.

[0054] For example, a portion of the training text images can be randomly selected from the first training sample with a preset probability to generate a rotated text image. In order to facilitate the conversion representation of the target position information corresponding to the rotated text image, each image can be preprocessed, for example, by resizing or padding, so that each image can be converted to a uniform size, and then the coordinates corresponding to the image of the uniform size can be mapped, such as normalized for representation. For example, such as image a, the coordinates of point a1 are (0,0), the coordinates of point a2 are (0,1), the coordinates of point a3 are (1,1), and the coordinates of point a4 are (1,0); for image b, the coordinates of point b1 are (0,0), the coordinates of point b2 are (0,1), the coordinates of point b3 are (1,1), and the coordinates of point b4 are (1,0). Among them, the position information of each character can be calculated by the target position information in the initial training text image after rotation change.

[0055] Afterwards, a second training sample is generated according to the rotated text image, the target direction information and target position information corresponding to the rotated text image, and the target characters corresponding to the training text image in the first training sample; and the first training sample and the second training sample are added to the training sample set.

[0056] In this way, multiple second training samples corresponding to different orientations can be generated based on the initial first training sample, without the need for users to perform excessive labeling, thus reducing the labeling workload. At the same time, more diverse training data can be provided for model training, thereby improving the accuracy and generalization of model training.

[0057] After obtaining the training sample set, the training sample image is used as the input of the model, the target character, target direction information and target position information corresponding to the training text image are used as the target output of the model, and the target loss of the model is determined based on the prediction loss corresponding to each output layer.

[0058] For example, the structure of the model is the structure of the text recognition model described above. Figure 3 Taking the model shown as an example, for the F1 layer, the cross entropy loss can be calculated between the predicted character output by the F1 layer and the target character, so as to obtain the prediction loss corresponding to the F1 layer; for the F2 layer, the cross entropy loss can be calculated between the direction information of each predicted character output by the F2 layer and the target direction information, so as to obtain the prediction loss corresponding to the F2 layer; for the F3 layer, the L1 loss can be calculated between the position information of each predicted character output by the F3 layer and the target position information, so as to obtain the prediction loss corresponding to the F1 layer. Afterwards, the prediction losses corresponding to the multiple output layers can be weighted and summed to obtain the target loss. The weight corresponding to each output layer can be pre-set based on the actual application scenario, and the present disclosure does not limit this.

[0059] For example, the target loss Loss is calculated by the following formula:

[0060]

[0061] Where N represents the total number of characters in a batch size of training text images, i represents the i-th character, and M represents the number of character recognition categories, i.e., the number of categories in the character dictionary. ic represents a sign function, which takes the value 1 if the i-th character belongs to category c, and takes the value 0 otherwise. ic represents the probability that the i-th character is recognized as the c-th class. Similarly, z ij represents the sign function, and takes the value 1 if the direction of the i-th character belongs to category j, otherwise takes the value 0. D represents the number of categories of directions, which may include up, down, left, and right directions. ij represents the probability of the i-th character being recognized as the j-th class. d represents one of the eight values ​​of the horizontal and vertical coordinates of the four coordinate points in the position information. For example, the horizontal coordinate corresponding to the coordinate point in the lower left corner can be selected. In this scenario, x d It represents the horizontal coordinate of the coordinate point of the lower left corner in the target location information, x' d It indicates the horizontal coordinate corresponding to the coordinate point in the lower left corner of the predicted position information. 1 , l 2 , l 3The weights respectively represent the prediction losses of character recognition, direction recognition, and position regression, and can be 1, 1, and 10 by way of example. Those skilled in the art can set them based on actual application scenarios.

[0062] The model is trained according to the target loss, and the trained model is used as the text recognition model.

[0063] For example, the model training can be terminated when the termination condition is met to obtain the text recognition model. If the termination condition is not met, the parameters of the model can be updated by the gradient descent method based on the target loss to obtain an updated model, and the above training steps can be performed again based on the updated model until the termination condition is met. As an example, the termination condition can be that the target loss is less than the loss threshold. As another example, the termination condition can be that the number of model training times reaches the number threshold.

[0064] Therefore, through the above technical scheme, character recognition, direction recognition and position regression can be trained and predicted through one model, so that the model parameters can meet the update requirements of multiple output features when updated, and can obtain direction information and position information while outputting characters. In the process of model training, not only the prediction loss of character recognition can be determined, but also the prediction loss of direction information and position information can be determined. Combining the above three to update the model parameters can constrain character recognition based on the prediction of direction information and position information, thereby improving the accuracy and efficiency of model training and broadening the application scenarios of the trained text recognition model.

[0065] In a possible embodiment, before the step of obtaining a character recognition result output by the text recognition model according to the text image and the text recognition model, the method further includes:

[0066] The text image is preprocessed to obtain a target text image of the text image at a preset size. For example, the preprocessing may be a scaling operation and / or a padding operation, so that the text image can be processed to a preset size, facilitating uniform processing of the image.

[0067] Afterwards, the coordinates corresponding to the target text image are mapped to the target range to obtain the target coordinate information of the target text image. The target range can be [0,1], which can be the length and width of the target text image being mapped to the target range, that is, the coordinates of the four vertices of the target text image are (0,0), (0,1), (1,1), (1,0) respectively.

[0068] The exemplary implementation of obtaining the character recognition result output by the text recognition model according to the text image and the text recognition model may include:

[0069] The target text image under the target coordinate information is input into the text recognition model to obtain a character recognition result output by the text recognition model.

[0070] For example, the target text image under the target coordinate information can be input into the text recognition model, and then the standardized target text image can be recognized based on the text recognition model, thereby ensuring the accuracy of the recognized characters and improving the recognition efficiency. In addition, the position information of each character can be determined based on the target coordinate information, ensuring the matching consistency between the determined position information and the target text image, thereby ensuring the accuracy of the character recognition result.

[0071] In a possible embodiment, the multiple output layers include a character output layer, a direction output layer, and a position output layer;

[0072] The exemplary implementation of obtaining the character recognition result output by the text recognition model according to the text image and the text recognition model may include:

[0073] The text image is input into the encoding sub-model of the text recognition model to obtain the encoding features. The encoding sub-model may include an encoder of a CNN (Convolutional Neural Networks) and a Transformer model, wherein the CNN network is used to extract features from the text image, and the encoder may encode the extracted features to obtain the encoding vector. The structural settings of the CNN network and the encoder may be set based on the commonly used structures in the art and user requirements, and will not be described in detail here.

[0074] In the process of the decoding sub-model decoding the coding features, the decoding sub-features obtained based on each decoding step are input into the character output layer to obtain the character corresponding to the current decoding step. Wherein, the decoding sub-model can be a decoder of the Transformer model, and the decoder decodes based on the output result of the previous decoding step and the coding vector when decoding, so that the corresponding character can be obtained at each decoding step. Wherein, the character output layer can be a cross entropy classification layer, which is used to classify based on the decoding sub-features, and determine the character indicated by the classification as the character corresponding to the decoding step. Accordingly, after the decoding of each decoding step is completed, the characters decoded by each decoding step can be spliced ​​to obtain the character corresponding to the text image.

[0075] The decoding sub-features obtained in each decoding step are concatenated to obtain the decoding feature; the decoding feature is input into the direction output layer to obtain the direction information corresponding to each of the characters; the decoding feature is input into the position output layer to obtain the position information corresponding to each of the characters.

[0076] For example, the decoding sub-features output by the decoding sub-model at each decoding step can be saved and gradually spliced ​​together, so that the decoding features spliced ​​together by the decoding sub-features of each decoding step can be obtained. In this embodiment, in order to reduce the amount of data calculation, a feature mapping can be performed based on the decoding features and the direction output layer, so that the direction information corresponding to each character corresponding to the decoding feature can be obtained at one time, wherein the arrangement order of the characters in the direction information is the same as the decoding order of the characters. Similarly, a feature mapping can be performed based on the decoding features and the position output layer, and the position information corresponding to each character corresponding to the decoding feature can be obtained at one time, wherein the arrangement order of the characters in the position information is the same as the decoding order of the characters.

[0077] Therefore, through the above technical solution, on the basis of character recognition, mapping can be performed separately in combination with the decoding features in the character recognition process to obtain the direction information and position information corresponding to each character. While ensuring that the direction information and position information match the character one by one, the amount of data calculation for direction prediction and position prediction can be further reduced, and the data processing efficiency can be improved, thereby enhancing the user experience.

[0078] In a possible embodiment, the method may further include:

[0079] The character recognition result and the text image are displayed on a display interface, wherein each character is displayed in a display area corresponding to the text image in the display interface, and direction information of the character is displayed at a target position corresponding to each character, and a position identifier is displayed in the text image based on the position information of each character.

[0080] like Figure 5 , which is a schematic diagram of a display interface provided according to an embodiment of the present disclosure, wherein H1 represents a text image, H2 represents a display area corresponding to the text image, and each character corresponding to the text image can be displayed in the display area. For example, the direction information of each character can be displayed below the character, so that the display of the character and the direction information can correspond to each other one by one, which is convenient for users to view.

[0081] As an example, the position identifier may be an identification frame, which may be a rectangular frame, a circular frame, or the like. Among them, as described above, the text image may be mapped to the target range, so that the coordinates of the four vertices corresponding to the character can be determined based on the position information of the output character. Then, the coordinates of the four vertices can be mapped to the corresponding positions in the text image, and then a rectangular frame can be drawn, as Figure 5 shown by the dashed rectangular frame in. Similarly, the center point coordinates can be determined based on the coordinates of the four vertices, and a circular frame or an elliptical frame can also be drawn based on the center point coordinates. Its manifestation form can be set according to the actual application scenario, and the present disclosure does not limit it.

[0082] Thus, through the above technical solution, the character recognition result of the text image can be displayed for the user in the display interface, which is convenient for the user to view. At the same time, by displaying the position identifier, a clear character indication can be provided for the user in a timely manner, so that the user can determine whether the character recognition result is accurate, which is convenient for the user to judge the character recognition result timely and accurately, and improves the user experience.

[0083] In a possible embodiment, the method further includes:

[0084] Splicing the characters based on the direction information corresponding to each character to obtain a text sequence corresponding to the text image.

[0085] Exemplarily, the splicing order corresponding to each direction information may be preset. For example, when the direction information is up and left, the characters may be spliced in the order of the recognized characters. When the direction information is down and right, the characters may be spliced in the reverse order of the recognized characters. Exemplarily, the decoded characters are "hao zhen qi kong tian jin", and the direction information is down, then the characters can be spliced in the reverse order of the decoding order to obtain the text sequence "Today the air is really good".

[0086] Performing target processing on the text sequence to obtain target features, where the target processing includes language conversion processing and / or speech synthesis processing;

[0087] Outputting the target features.

[0088] The text sequence obtained through the above example is a text sequence that conforms to natural language processing, and the text sequence can be further processed accordingly. For example, language conversion can be performed based on the text sequence, and a commonly used translator in the field can be called to apply to the text image translation scenario, and the target language of the conversion can be set according to the actual application scenario. As another example, speech synthesis can be performed based on the text sequence, such as synthesis based on TTS (Text To Speech) technology, so that voice prompts can be provided to the user. As another example, after language conversion is performed based on the text sequence, speech synthesis can be performed based on the converted features to further expand the application scenarios and enhance the user experience.

[0089] The present disclosure also provides a text recognition device, such as Figure 6 As shown, the device 10 comprises:

[0090] An acquisition module 100 is used to acquire a text image to be recognized;

[0091] A first processing module 200 is used to obtain a character recognition result output by the text recognition model according to the text image and the text recognition model, wherein the character recognition result includes each character contained in the text image, and direction information and position information corresponding to each character;

[0092] The text recognition model includes an encoding sub-model, a decoding sub-model and multiple output layers, wherein the encoding sub-model is used to extract and encode the features of the text image to obtain an encoding vector; the decoding sub-model is used to decode according to the encoding vector to obtain a decoding feature, and the multiple output layers are respectively mapped based on the decoding features to output the characters, the direction information and the position information corresponding to the characters to obtain the character recognition results.

[0093] Optionally, the text recognition model is determined by a training module, and the training module includes:

[0094] An acquisition submodule is used to acquire a training sample set, wherein each training sample in the training sample set includes a training text image, a target character corresponding to the training text image, and target direction information and target position information corresponding to each target character;

[0095] A determination submodule is used to use the training sample image as the input of the model, the target character, target direction information and target position information corresponding to the training text image as the target output of the model, and determine the target loss of the model based on the prediction loss corresponding to each output layer;

[0096] The training submodule is used to train the model according to the target loss and use the trained model as the text recognition model.

[0097] Optionally, the training sample set is determined by:

[0098] Obtain the first training sample in the training sample set;

[0099] Rotating the training text image in the first training sample at a predetermined rotation angle to obtain a rotated text image;

[0100] generating target direction information and target position information corresponding to the rotated text image based on the rotation angle and the target direction information and target position information corresponding to the training text image in the first training sample;

[0101] generating a second training sample according to the rotated text image, target direction information and target position information corresponding to the rotated text image, and target characters corresponding to the training text image in the first training sample;

[0102] The first training sample and the second training sample are added to the training sample set.

[0103] Optionally, the device further comprises:

[0104] A display module is used to display the character recognition results and the text image on a display interface, wherein each character is displayed in a display area corresponding to the text image in the display interface, and the direction information of the character is displayed at a target position corresponding to each character, and a position identifier is displayed in the text image based on the position information of each character.

[0105] Optionally, the device further comprises:

[0106] A splicing module, used for splicing the characters based on the direction information corresponding to each of the characters to obtain a text sequence corresponding to the text image;

[0107] A second processing module, configured to perform target processing based on the text sequence to obtain target features, wherein the target processing includes language conversion processing and / or speech synthesis processing;

[0108] An output module is used to output the target features.

[0109] Optionally, the device further comprises:

[0110] A third processing module is used for preprocessing the text image to obtain a target text image of the text image at a preset size before the first processing module obtains the character recognition result output by the text recognition model according to the text image and the text recognition model;

[0111] A mapping module, used to map the coordinates corresponding to the target text image to a target range to obtain target coordinate information of the target text image;

[0112] The first processing module is used for:

[0113] The target text image under the target coordinate information is input into the text recognition model to obtain a character recognition result output by the text recognition model.

[0114] Optionally, the multiple output layers include a character output layer, a direction output layer and a position output layer;

[0115] The first processing module is used for:

[0116] The text image is input into the encoding sub-model of the text recognition model to obtain the encoding feature; in the process of the decoding sub-model decoding the encoding feature, the decoding sub-feature obtained based on each decoding step is input into the character output layer to obtain the character corresponding to the current decoding step; the decoding sub-features obtained in each decoding step are concatenated to obtain the decoding feature; the decoding feature is input into the direction output layer to obtain the direction information corresponding to each of the characters; the decoding feature is input into the position output layer to obtain the position information corresponding to each of the characters.

[0117] Reference below Figure 7 , which shows a schematic diagram of the structure of an electronic device 600 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, laptop 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 7 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.

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

[0119] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 7 The electronic device 600 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.

[0120] 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 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0121] 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.

[0122] 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.

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

[0124] 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; obtains a character recognition result output by the text recognition model based on the text image and the text recognition model, wherein the character recognition result includes each character contained in the text image, and the direction information and position information corresponding to each of the characters; the text recognition model includes an encoding sub-model, a decoding sub-model and multiple output layers, the encoding sub-model is used to extract features from the text image and encode it to obtain an encoding vector; the decoding sub-model is used to decode according to the encoding vector to obtain decoding features, and the multiple output layers are respectively mapped based on the decoding features, and the characters, the direction information and position information corresponding to the characters are respectively output to obtain the character recognition results.

[0125] 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).

[0126] 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.

[0127] 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, an acquisition module may also be described as a "module for acquiring a text image to be recognized."

[0128] 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 chip (SOCs), complex programmable logic devices (CPLDs), and the like.

[0129] 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.

[0130] According to one or more embodiments of the present disclosure, Example 1 provides a text recognition method, wherein the method includes:

[0131] Obtain the text image to be recognized;

[0132] According to the text image and the text recognition model, obtaining a character recognition result output by the text recognition model, wherein the character recognition result includes each character contained in the text image, and direction information and position information corresponding to each character;

[0133] The text recognition model includes an encoding sub-model, a decoding sub-model and multiple output layers. The encoding sub-model is used to extract and encode features of the text image to obtain an encoding vector; the decoding sub-model is used to decode according to the encoding vector to obtain decoding features. The multiple output layers are respectively mapped based on the decoding features, and respectively output the characters, the direction information and the position information corresponding to the characters to obtain the character recognition results.

[0134] According to one or more embodiments of the present disclosure, Example 2 provides the method of Example 1, wherein the text recognition model is determined in the following manner:

[0135] Acquire a training sample set, wherein each training sample in the training sample set includes a training text image, a target character corresponding to the training text image, and target direction information and target position information corresponding to each target character;

[0136] The training sample image is used as the input of the model, the target character, target direction information and target position information corresponding to the training text image are used as the target output of the model, and the target loss of the model is determined based on the prediction loss corresponding to each output layer;

[0137] The model is trained according to the target loss, and the trained model is used as the text recognition model.

[0138] According to one or more embodiments of the present disclosure, Example 3 provides the method of Example 2, wherein the training sample set is determined in the following manner:

[0139] Obtain the first training sample in the training sample set;

[0140] Rotating the training text image in the first training sample at a predetermined rotation angle to obtain a rotated text image;

[0141] generating target direction information and target position information corresponding to the rotated text image based on the rotation angle and the target direction information and target position information corresponding to the training text image in the first training sample;

[0142] generating a second training sample according to the rotated text image, target direction information and target position information corresponding to the rotated text image, and target characters corresponding to the training text image in the first training sample;

[0143] The first training sample and the second training sample are added to the training sample set.

[0144] According to one or more embodiments of the present disclosure, Example 4 provides the method of Example 1, wherein the method further includes:

[0145] The character recognition result and the text image are displayed on a display interface, wherein each character is displayed in a display area corresponding to the text image in the display interface, and direction information of the character is displayed at a target position corresponding to each character, and a position identifier is displayed in the text image based on the position information of each character.

[0146] According to one or more embodiments of the present disclosure, Example 5 provides the method of Example 1, wherein the method further includes:

[0147] splicing the characters based on the direction information corresponding to each of the characters to obtain a text sequence corresponding to the text image;

[0148] Performing target processing based on the text sequence to obtain target features, wherein the target processing includes language conversion processing and / or speech synthesis processing;

[0149] The target feature is output.

[0150] According to one or more embodiments of the present disclosure, Example 6 provides the method of Example 1, wherein, before the step of obtaining a character recognition result output by the text recognition model according to the text image and the text recognition model, the method further includes:

[0151] Preprocessing the text image to obtain a target text image of the text image at a preset size;

[0152] Mapping the coordinates corresponding to the target text image to the target range to obtain target coordinate information of the target text image;

[0153] The step of obtaining a character recognition result output by the text recognition model according to the text image and the text recognition model comprises:

[0154] The target text image under the target coordinate information is input into the text recognition model to obtain a character recognition result output by the text recognition model.

[0155] According to one or more embodiments of the present disclosure, Example 7 provides the method of Example 1, wherein the multiple output layers include a character output layer, a direction output layer, and a position output layer;

[0156] The step of obtaining a character recognition result output by the text recognition model according to the text image and the text recognition model comprises:

[0157] Inputting the text image into the encoding sub-model of the text recognition model to obtain the encoding feature;

[0158] In the process of decoding the encoding feature by the decoding sub-model, the decoding sub-feature obtained based on each decoding step is input into the character output layer to obtain the character corresponding to the current decoding step;

[0159] Concatenating the decoding sub-features obtained in each decoding step to obtain the decoding feature;

[0160] Inputting the decoded features into the direction output layer to obtain the direction information corresponding to each of the characters;

[0161] The decoded features are input into the position output layer to obtain the position information corresponding to each of the characters.

[0162] According to one or more embodiments of the present disclosure, Example 8 provides a text recognition device, wherein the device includes:

[0163] An acquisition module, used for acquiring a text image to be recognized;

[0164] A first processing module, configured to obtain a character recognition result output by the text recognition model according to the text image and the text recognition model, wherein the character recognition result includes each character contained in the text image, and direction information and position information corresponding to each character;

[0165] The text recognition model includes an encoding sub-model, a decoding sub-model and multiple output layers. The encoding sub-model is used to extract and encode features of the text image to obtain an encoding vector; the decoding sub-model is used to decode according to the encoding vector to obtain decoding features. The multiple output layers are respectively mapped based on the decoding features, and respectively output the characters, the direction information and the position information corresponding to the characters to obtain the character recognition results.

[0166] 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 any of the methods described in Examples 1-7 when executed by a processing device.

[0167] According to one or more embodiments of the present disclosure, Example 10 provides an electronic device, including:

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

[0169] A processing device is used to execute the computer program in the storage device to implement the steps of any one of the methods described in Examples 1-7.

[0170] 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.

[0171] 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.

[0172] 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 recognition model, obtaining a character recognition result output by the text recognition model, wherein the character recognition result includes each character contained in the text image, and direction information and position information corresponding to each character; The text recognition model includes an encoding sub-model, a decoding sub-model and a plurality of output layers, wherein the encoding sub-model is used to extract features from the text image and encode it to obtain an encoding vector; the decoding sub-model is used to decode according to the encoding vector to obtain decoding features, and the plurality of output layers are respectively mapped based on the decoding features to respectively output the characters, the direction information and the position information corresponding to the characters to obtain the character recognition results; Wherein, the multiple output layers include a character output layer, a direction output layer and a position output layer; The step of obtaining a character recognition result output by the text recognition model according to the text image and the text recognition model comprises: Inputting the text image into the encoding sub-model of the text recognition model to obtain the encoding vector; In the process of decoding the encoding vector by the decoding sub-model, the decoding sub-features obtained at each decoding step are input into the character output layer to obtain the character corresponding to the current decoding step; Concatenating the decoding sub-features obtained in each decoding step to obtain the decoding feature; Inputting the decoded features into the direction output layer to obtain the direction information corresponding to each of the characters; The decoded features are input into the position output layer to obtain the position information corresponding to each of the characters.

2. The method according to claim 1, characterized in that: The text recognition model is determined in the following way: Acquire a training sample set, wherein each training sample in the training sample set includes a training text image, a target character corresponding to the training text image, and target direction information and target position information corresponding to each target character; The training sample image is used as the input of the model, the target character, target direction information and target position information corresponding to the training text image are used as the target output of the model, and the target loss of the model is determined based on the prediction loss corresponding to each output layer; The model is trained according to the target loss, and the trained model is used as the text recognition model.

3. The method according to claim 2, characterized in that The training sample set is determined by: Obtain the first training sample in the training sample set; Rotating the training text image in the first training sample at a predetermined rotation angle to obtain a rotated text image; generating target direction information and target position information corresponding to the rotated text image based on the rotation angle and the target direction information and target position information corresponding to the training text image in the first training sample; generating a second training sample according to the rotated text image, target direction information and target position information corresponding to the rotated text image, and target characters corresponding to the training text image in the first training sample; The first training sample and the second training sample are added to the training sample set.

4. The method according to claim 1, characterized in that: The method further comprises: The character recognition result and the text image are displayed on a display interface, wherein each character is displayed in a display area corresponding to the text image in the display interface, and direction information of the character is displayed at a target position corresponding to each character, and a position identifier is displayed in the text image based on the position information of each character.

5. The method according to claim 1, characterized in that The method further comprises: splicing the characters based on the direction information corresponding to each of the characters to obtain a text sequence corresponding to the text image; Performing target processing based on the text sequence to obtain target features, wherein the target processing includes language conversion processing and / or speech synthesis processing; The target feature is output.

6. The method according to claim 1, characterized in that Before the step of obtaining the character recognition result output by the text recognition model according to the text image and the text recognition model, the method further comprises: Preprocessing the text image to obtain a target text image of the text image at a preset size; Mapping the coordinates corresponding to the target text image to the target range to obtain target coordinate information of the target text image; The step of obtaining a character recognition result output by the text recognition model according to the text image and the text recognition model comprises: The target text image under the target coordinate information is input into the text recognition model to obtain a character recognition result output by the text recognition model.

7. A text recognition device, characterized in that: The device comprises: An acquisition module, used for acquiring a text image to be recognized; A first processing module, configured to obtain a character recognition result output by the text recognition model according to the text image and the text recognition model, wherein the character recognition result includes each character contained in the text image, and direction information and position information corresponding to each character; The text recognition model includes an encoding sub-model, a decoding sub-model and a plurality of output layers, wherein the encoding sub-model is used to extract features from the text image and encode it to obtain an encoding vector; the decoding sub-model is used to decode according to the encoding vector to obtain decoding features, and the plurality of output layers are respectively mapped based on the decoding features to respectively output the characters, the direction information and the position information corresponding to the characters to obtain the character recognition results; The multiple output layers include a character output layer, a direction output layer and a position output layer; The first processing module is used for: The text image is input into the encoding sub-model of the text recognition model to obtain the encoding vector; in the process of the decoding sub-model decoding the encoding vector, the decoding sub-features obtained based on each decoding step are input into the character output layer to obtain the character corresponding to the current decoding step; the decoding sub-features obtained in each decoding step are concatenated to obtain the decoding features; the decoding features are input into the direction output layer to obtain the direction information corresponding to each of the characters; the decoding features are input into the position output layer to obtain the position information corresponding to each of the 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

  • Image recognition method and device, terminal and storage medium

    CN111444908A

  • Text recognition method, image recognition classification method, and document recognition processing method

    WO2022057707A1