Text recognition method, device, equipment and storage medium based on text documents

By combining the optical character recognition engine and the image feature extraction model, segmenting and vectorizing text images, and using the annotation information base to improve the recognition accuracy of text documents, the problem of insufficient text recognition accuracy in the existing technology is solved and more efficient is achieved. recognition effect.

CN113569833BActive Publication Date: 2024-10-18PING AN TECH (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110853330.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-07-27
Publication Date
2024-10-18
Estimated Expiration
2041-07-27

AI Technical Summary

Technical Problem

Existing text document recognition technology has limitations in accuracy. Mistakes during recognition can easily lead to correction errors, resulting in low text recognition accuracy.

Method used

Using a method based on the combination of optical character recognition engine and image feature extraction model, the recognition accuracy of text documents is improved through preprocessing, segmentation, vectorization processing and annotation information database query. Specific steps include receiving text documents for preprocessing, using a two-way long short-term memory recurrent neural network model for text recognition, segmenting text image fragments, inputting the BERT model for image vectorization processing, and obtaining annotation information in the text image information library to determine the target. text message.

Benefits of technology

Significantly improves the character recognition accuracy of text documents, and enhances the model's generalization ability and recognition efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113569833B_ABST
    Figure CN113569833B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of artificial intelligence, and discloses a text document-based text recognition method, device, equipment and storage medium for improving text recognition efficiency. The text document-based text recognition method includes: receiving a text document to be recognized, and preprocessing the text document to obtain a standardized text image; based on a preset optical character recognition engine, performing text recognition on the standardized text image to obtain initial text information corresponding to the standardized text image; segmenting the standardized text image to obtain multiple text image fragments; performing text vectorization processing on multiple text image fragments and initial text information to obtain initial image vectors and initial text vectors; obtaining annotation information corresponding to the initial text vector, and determining the target text information corresponding to each initial image vector according to the annotation information. In addition, the present invention also relates to blockchain technology, and the target text information can be stored in a blockchain node.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of machine learning, and in particular to a text document-based character recognition method, device, equipment and storage medium. Background Art

[0002] Text documents include bill documents, contract documents, academic documents, etc. By recognizing the text in these text documents, valuable data can be extracted to improve the information database.

[0003] Most of the existing text document recognition technologies are based on optical character recognition (OCR) to intelligently recognize text documents, and then correct the recognition results through natural language models to achieve the purpose of text recognition. However, the accuracy of text document recognition in existing technologies is often limited to the capabilities of the model, and errors in recognition can easily lead to errors in correction. It can be seen that the accuracy of existing text document recognition methods still needs to be improved. Summary of the invention

[0004] The present invention provides a text document-based character recognition method, device, equipment and storage medium, which are used to improve the accuracy of text document recognition.

[0005] A first aspect of the present invention provides a text document-based character recognition method, comprising:

[0006] Receiving a text document to be recognized, and preprocessing the text document to obtain a standardized text image;

[0007] Based on a preset optical character recognition engine, performing text recognition on the standardized text image to obtain initial text information corresponding to the standardized text image;

[0008] Segmenting the standardized text image according to initial text information corresponding to the standardized text image to obtain a plurality of text image segments;

[0009] Inputting the multiple text image segments into a trained image feature extraction model to perform image vectorization processing to obtain an initial image vector corresponding to each text image segment, and performing text vectorization processing on the initial text information to obtain an initial text vector corresponding to the initial text information;

[0010] The annotation information corresponding to the initial text vector is obtained in a preset text image information library, and the target text information corresponding to each initial image vector is determined according to the annotation information.

[0011] Optionally, in a first implementation of the first aspect of the present invention, the receiving a text document to be recognized and preprocessing the text document to obtain a standardized text image includes:

[0012] Receiving a text document to be recognized, and converting the text document into an image format to obtain an initialized text image;

[0013] Binarizing the initialized text image to obtain a black and white image;

[0014] Traversing the grayscale value of each pixel in the black-and-white image, and performing noise reduction processing on the grayscale value of each pixel to obtain a noise-reduced image;

[0015] According to a preset image correction algorithm, the noise reduction image is corrected to obtain a standardized text image.

[0016] Optionally, in a second implementation of the first aspect of the present invention, the optical character recognition engine includes a bidirectional long short-term memory recurrent neural network model, and the preset optical character recognition engine performs text recognition on the standardized text image to obtain initial text information corresponding to the standardized text image, including:

[0017] Inputting the text image into the input layer of the bidirectional long short-term memory recurrent neural network model for matrix processing to obtain a first feature matrix of the text image;

[0018] Inputting the first feature matrix into the encoding layer of the bidirectional long short-term memory recurrent neural network model for feature extraction to obtain a second feature matrix;

[0019] Inputting the second feature matrix into the decoding layer of the bidirectional long short-term memory recurrent neural network model for feature decoding to obtain a third feature matrix;

[0020] Inputting the third feature matrix into the fully connected layer of the bidirectional long short-term memory recurrent neural network model for feature classification to obtain a text feature classification label corresponding to the text image;

[0021] The text feature classification label is set as an index, and a preset text dictionary is searched to obtain initial text information corresponding to the standardized text image.

[0022] Optionally, in a third implementation of the first aspect of the present invention, the image feature extraction model includes a bidirectional encoding BERT model, and the inputting the multiple text image segments into the trained image feature extraction model for image vectorization processing to obtain an initial image vector corresponding to each text image segment includes:

[0023] Input the multiple text image segments into the convolutional layer of the bidirectional encoding BERT model for feature extraction to obtain a first feature vector corresponding to each text image segment;

[0024] Input each first feature vector into the excitation layer of the bidirectional encoding BERT model for nonlinear mapping to obtain a plurality of second feature vectors;

[0025] Each second feature vector is input into the pooling layer of the bidirectional encoding BERT model for dimensionality reduction processing to obtain an initial image vector corresponding to each text image segment.

[0026] Optionally, in a fourth implementation manner of the first aspect of the present invention, performing text vectorization processing on the initial text information to obtain an initial text vector corresponding to the initial text information includes:

[0027] Based on a preset word segmentation algorithm, the initial text information is segmented to obtain a word segmentation result;

[0028] Based on a preset one-hot encoding algorithm, sparse vectorization is performed on the word segmentation result to obtain a sparse vector corresponding to the initial text information;

[0029] Based on a preset word embedding algorithm, the sparse vector corresponding to the initial text information is mapped to a dense vector to obtain an initial text vector corresponding to the initial text information.

[0030] Optionally, in a fifth implementation of the first aspect of the present invention, before receiving the text document to be recognized and preprocessing the text document to obtain a standardized text image, the text document-based character recognition method further includes:

[0031] Acquire a sample file in a text document format, and convert the sample file into an image format to obtain a sample image;

[0032] Extracting sample text information from the sample file, and performing word segmentation processing on the sample text information to obtain a word segmentation result;

[0033] Based on the word segmentation result, segment the sample image to obtain a plurality of sample image segments;

[0034] Performing text vectorization processing on the word segmentation result to obtain a sample text vector, and performing image vectorization processing on the multiple sample image segments to obtain a sample image vector;

[0035] According to the sample text information corresponding to the sample text vector, the sample image vector is sequence labeled to obtain the labeling information corresponding to each sample image segment, and a text image information library is generated.

[0036] Optionally, in a sixth implementation manner of the first aspect of the present invention, obtaining annotation information corresponding to the initial text vector in a preset text image information library, and determining target text information corresponding to each initial image vector according to the annotation information includes:

[0037] Searching for a target text vector corresponding to the initial text vector in the text image information library, and obtaining annotation information corresponding to the target text vector;

[0038] According to the annotation information corresponding to the target text vector, the target image vector corresponding to each initial image vector is obtained in the text image information library, and it is determined whether the similarity between the target image vector corresponding to each initial image vector and each initial image vector is less than a preset threshold value;

[0039] If the similarity between the target image vectors corresponding to the initial image vectors and the initial image vectors is less than a preset threshold, the target text information corresponding to the initial image vectors is extracted from the annotation information corresponding to the target image vectors.

[0040] A second aspect of the present invention provides a text document-based character recognition device, comprising:

[0041] A receiving module, used for receiving a text document to be recognized, and preprocessing the text document to obtain a standardized text image;

[0042] A recognition module, used to perform text recognition on the standardized text image based on a preset optical character recognition engine to obtain initial text information corresponding to the standardized text image;

[0043] A segmentation module, configured to segment the standardized text image according to initial text information corresponding to the standardized text image, to obtain a plurality of text image segments;

[0044] A vectorization module is used to input the multiple text image segments into a trained image feature extraction model to perform image vectorization processing to obtain an initial image vector corresponding to each text image segment, and to perform text vectorization processing on the initial text information to obtain an initial text vector corresponding to the initial text information;

[0045] The determination module is used to obtain the annotation information corresponding to the initial text vector in a preset text image information library, and determine the target text information corresponding to each initial image vector according to the annotation information.

[0046] Optionally, in a first implementation manner of the second aspect of the present invention, the receiving module is specifically configured to:

[0047] Receiving a text document to be recognized, and converting the text document into an image format to obtain an initialized text image;

[0048] Binarizing the initialized text image to obtain a black and white image;

[0049] Traversing the grayscale value of each pixel in the black-and-white image, and performing noise reduction processing on the grayscale value of each pixel to obtain a noise-reduced image;

[0050] According to a preset image correction algorithm, the noise reduction image is corrected to obtain a standardized text image.

[0051] Optionally, in a second implementation of the second aspect of the present invention, the optical character recognition engine includes a bidirectional long short-term memory recurrent neural network model, and the recognition module is specifically used for:

[0052] Inputting the text image into the input layer of the bidirectional long short-term memory recurrent neural network model for matrix processing to obtain a first feature matrix of the text image;

[0053] Inputting the first feature matrix into the encoding layer of the bidirectional long short-term memory recurrent neural network model for feature extraction to obtain a second feature matrix;

[0054] Inputting the second feature matrix into the decoding layer of the bidirectional long short-term memory recurrent neural network model for feature decoding to obtain a third feature matrix;

[0055] Inputting the third feature matrix into the fully connected layer of the bidirectional long short-term memory recurrent neural network model for feature classification to obtain a text feature classification label corresponding to the text image;

[0056] The text feature classification label is set as an index, and a preset text dictionary is searched to obtain initial text information corresponding to the standardized text image.

[0057] Optionally, in a third implementation of the second aspect of the present invention, the image feature extraction model includes a bidirectional encoding BERT model, and the vectorization module is used to:

[0058] Input the multiple text image segments into the convolutional layer of the bidirectional encoding BERT model for feature extraction to obtain a first feature vector corresponding to each text image segment;

[0059] Input each first feature vector into the excitation layer of the bidirectional encoding BERT model for nonlinear mapping to obtain a plurality of second feature vectors;

[0060] Each second feature vector is input into the pooling layer of the bidirectional encoding BERT model for dimensionality reduction processing to obtain an initial image vector corresponding to each text image segment.

[0061] Optionally, in a fourth implementation manner of the second aspect of the present invention, the vectorization module is further used to:

[0062] Based on a preset word segmentation algorithm, the initial text information is segmented to obtain a word segmentation result;

[0063] Based on a preset one-hot encoding algorithm, sparse vectorization is performed on the word segmentation result to obtain a sparse vector corresponding to the initial text information;

[0064] Based on a preset word embedding algorithm, the sparse vector corresponding to the initial text information is mapped to a dense vector to obtain an initial text vector corresponding to the initial text information.

[0065] Optionally, in a fifth implementation of the second aspect of the present invention, the text document-based character recognition device further includes:

[0066] A sample acquisition module is used to acquire a sample file in a text document format and convert the sample file into an image format to obtain a sample image;

[0067] A sample word segmentation module is used to extract sample text information from the sample file and perform word segmentation processing on the sample text information to obtain a word segmentation result;

[0068] A sample segmentation module, used for segmenting the sample image based on the word segmentation result to obtain a plurality of sample image segments;

[0069] A sample vectorization module, used to perform text vectorization processing on the word segmentation results to obtain sample text vectors, and perform image vectorization processing on the multiple sample image segments to obtain sample image vectors;

[0070] The sample annotation module is used to perform sequence annotation on the sample image vector according to the sample text information corresponding to the sample text vector, obtain annotation information corresponding to each sample image segment, and generate a text image information library.

[0071] Optionally, in a sixth implementation manner of the second aspect of the present invention, the determining module is specifically configured to:

[0072] Searching for a target text vector corresponding to the initial text vector in the text image information library, and obtaining annotation information corresponding to the target text vector;

[0073] According to the annotation information corresponding to the target text vector, the target image vector corresponding to each initial image vector is obtained in the text image information library, and it is determined whether the similarity between the target image vector corresponding to each initial image vector and each initial image vector is less than a preset threshold value;

[0074] If the similarity between the target image vectors corresponding to the initial image vectors and the initial image vectors is less than a preset threshold, the target text information corresponding to the initial image vectors is extracted from the annotation information corresponding to the target image vectors.

[0075] The third aspect of the present invention provides a text document-based character recognition device, comprising: a memory and at least one processor, wherein the memory stores instructions; the at least one processor calls the instructions in the memory so that the text document-based character recognition device executes the above-mentioned text document-based character recognition method.

[0076] A fourth aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the above-mentioned text document-based word recognition method.

[0077] In the technical solution provided by the present invention, a text document to be recognized is received, and the text document is preprocessed to obtain a standardized text image; based on a preset optical character recognition engine, text recognition is performed on the standardized text image to obtain initial text information corresponding to the standardized text image; according to the initial text information corresponding to the standardized text image, the standardized text image is segmented to obtain a plurality of text image fragments; the plurality of text image fragments are input into a trained image feature extraction model for image vectorization processing to obtain an initial image vector corresponding to each text image fragment, and the initial text information is subjected to text vectorization processing to obtain an initial text vector corresponding to the initial text information; the annotation information corresponding to the initial text vector is obtained in a preset text image information library, and the target text information corresponding to each initial image vector is determined according to the annotation information. In an embodiment of the present invention, the server obtains a text image by pre-processing the text document to be recognized by annotating it, and then performs preliminary text recognition on the text image based on an optical character recognition engine to obtain initial text information. Then, the server segments the text image, and vectorizes the segmented text image segments and the initial text information to obtain initial text vectors and initial image vectors. Finally, the server obtains the annotation information of the initial image vector based on the initial text vector to obtain the target text information. The present invention can improve the accuracy of text recognition in text documents. BRIEF DESCRIPTION OF THE DRAWINGS

[0078] Figure 1 A schematic diagram of an embodiment of a text recognition method based on a text document in an embodiment of the present invention;

[0079] Figure 2 Schematic diagram of another embodiment of the text document-based character recognition method in an embodiment of the present invention;

[0080] Figure 3 A schematic diagram of an embodiment of a text document-based character recognition device in an embodiment of the present invention;

[0081] Figure 4 It is a schematic diagram of another embodiment of a text document-based character recognition device in an embodiment of the present invention;

[0082] Figure 5 The figure is a schematic diagram of an embodiment of a text document-based character recognition device in an embodiment of the present invention. DETAILED DESCRIPTION

[0083] The embodiments of the present invention provide a text document-based character recognition method, device, equipment and storage medium for improving the accuracy of text recognition.

[0084] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" or "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0085] For ease of understanding, the specific process of the embodiment of the present invention is described below. Figure 1 , an embodiment of a text document-based character recognition method in an embodiment of the present invention includes:

[0086] 101. Receive a text document to be recognized, and pre-process the text document to obtain a standardized text image;

[0087] It is understandable that the execution subject of the present invention may be a text document-based character recognition device, or a terminal or a server, which is not specifically limited here. The embodiment of the present invention is described by taking a server as the execution subject as an example.

[0088] In this embodiment, the text document to be recognized is a text document in a text format, such as a portable document format PDF document, a word processor application WORD document, a spreadsheet EXCEL document, etc. In order to improve the accuracy of text recognition in text documents, the present invention combines text recognition and image recognition technology to improve the accuracy of text recognition based on text documents. The text document to be recognized may include multiple text documents. The server supports users to upload text documents to be recognized in batches, and pre-processes the text documents to be recognized in batches to make text recognition more efficient.

[0089] In this embodiment, in order to obtain a standardized text image, the server performs a series of preprocessing operations on the text document to be recognized, including recognizing the document format of the text document and paging the text document according to the recognized document format. The server converts the text document into an image format according to the paging result, wherein each page corresponds to a text image, and the paging result includes page number information of each page that increases page by page, which can be used by the server to sequentially splice subsequent text recognition results, thereby ensuring the orderliness of the text.

[0090] In this embodiment, the standardized text image is a text image that conforms to a preset format in terms of image size, image color, image angle, image format, image dimensions, etc. The server's standardization and processing of text documents can reduce the computational cost of subsequent models, thereby improving text recognition efficiency.

[0091] 102. Based on a preset optical character recognition engine, perform text recognition on the standardized text image to obtain initial text information corresponding to the standardized text image;

[0092] In this embodiment, the optical character recognition engine (OCR) refers to an intelligent engine that analyzes and recognizes image files of text materials to obtain text and layout information. The preset optical character recognition engine uses a neural network model for text recognition. The network structure of the optical character recognition engine includes: convolutional neural network CNN + bidirectional long short-term memory recurrent neural network LSTM. Specifically, the server inputs the text image into the initialized CNN to extract image features, and the server then serializes the image features through LSTM. Finally, the server obtains the initial text information in the text image by classifying and labeling the sequence, which greatly improves the efficiency of text recognition and the generalization ability of the model.

[0093] In this embodiment, the optical character recognition engine also introduces an attention mechanism. Specifically, after the server inputs the text image into the initialized CNN for image feature extraction, the attention weight of the new state is calculated by the attention model based on the state of the recurrent neural network RNN ​​and the attention weight of the previous state. After that, the server inputs the CNN features and weights into the RNN, and the server obtains the result by encoding and decoding the CNN features and weights, that is, the initial text information. Since the text image is an image based on a text document and does not have a complex image background, the text recognition accuracy of the server based on the preset optical character recognition engine is relatively high, which provides data guarantee for subsequent sequence annotation.

[0094] 103. Segment the standardized text image according to initial text information corresponding to the standardized text image to obtain a plurality of text image segments;

[0095] In this embodiment, in order to improve the efficiency of text recognition, the server divides the text image into multiple text image segments. Specifically, the server crops and segments the text image according to the sentence segmentation information in the initial text information to obtain text image segments of each sentence in the text image. For example, the server identifies the segmentation points of the text image according to the period in the initial text information, and segments the standardized text image according to the segmentation points to obtain text image segments corresponding to different sentences. The server can also crop and segment the text image according to the segmentation information in the initial text information, which is not specifically limited here.

[0096] 104. Input multiple text image segments into the trained image feature extraction model to perform image vectorization processing to obtain an initial image vector corresponding to each text image segment, and perform text vectorization processing on the initial text information to obtain an initial text vector corresponding to the initial text information;

[0097] In this embodiment, the image feature extraction model is a visual bidirectional encoding VisualBert model trained based on a bidirectional encoder representations from transformers (BERT) model. It is a multimodal application based on BERT. The server combines images and texts in the process of training the model, and can predict the relationship between sentences and images, thereby generating a vectorized representation of the image, that is, an initial image vector. The vectorized processing of text information uses a word embedding vector (Word Embedding), which can map words to a lower dimensional vector space based on the relationship between words to obtain an initial text vector for subsequent text recognition.

[0098] 105. Obtain annotation information corresponding to the initial text vector in a preset text image information library, and determine target text information corresponding to each initial image vector according to the annotation information.

[0099] In this embodiment, the server obtains the annotation information corresponding to the initial text vector in a preset text image information library, and searches for the target image vector corresponding to the initial text vector. Then, the server searches for the initial text information corresponding to the initial text vector in a preset text dictionary based on the annotation information. Finally, the server determines the target text information corresponding to the target image vector based on the text information, that is, the specific text in the text image segment.

[0100] Furthermore, the server stores the target text information in a blockchain database, which is not specifically limited here.

[0101] In an embodiment of the present invention, the server obtains a text image by pre-processing the text document to be recognized by annotating it, and then performs preliminary text recognition on the text image based on an optical character recognition engine to obtain initial text information. Then, the server segments the text image, and vectorizes the segmented text image segments and the initial text information to obtain initial text vectors and initial image vectors. Finally, the server obtains the annotation information of the initial image vector based on the initial text vector to obtain the target text information. The present invention can improve the accuracy of text recognition in text documents.

[0102] See also Figure 2 Another embodiment of the text recognition method based on text documents in the embodiment of the present invention includes:

[0103] 201. Receive a text document to be recognized, and pre-process the text document to obtain a standardized text image;

[0104] Specifically, the server receives a text document to be recognized, and converts the text document into an image format to obtain an initialized text image; the server performs binarization processing on the initialized text image to obtain a black-and-white image; the server traverses the grayscale value of each pixel in the black-and-white image, and performs noise reduction processing on the grayscale value of each pixel to obtain a noise-reduced image; the server corrects the noise-reduced image according to a preset image correction algorithm to obtain a standardized text image.

[0105] In this optional embodiment, the server converts the text document to be recognized into a standardized text image through a series of preprocessing operations, so as to perform subsequent text image recognition, wherein the preprocessing process includes: image binarization, noise reduction and correction, and finally obtains a standardized text image that can be used for image text recognition.

[0106] Furthermore, the server obtains a sample file in a text document format, and converts the sample file into an image format to obtain a sample image; the server extracts sample text information from the sample file, and performs word segmentation on the sample text information to obtain a word segmentation result; the server performs segmentation on the sample image based on the word segmentation result to obtain a plurality of sample image fragments; the server performs text vectorization on the word segmentation result to obtain a sample text vector, and performs image vectorization on the plurality of sample image fragments to obtain a sample image vector; the server performs sequence annotation on the sample image vector according to the sample text information corresponding to the sample text vector, obtains annotation information corresponding to each sample image fragment, and generates a text image information library.

[0107] In this optional embodiment, the server obtains sample files in text document format in batches to generate a text image information library. The text image information library includes a large amount of sample text information, sample text vectors corresponding to the sample text information, sample images, sample image fragments, sample image vectors corresponding to the sample image fragments, and annotation information corresponding to the sample image fragments. The text image information library can be used to retrieve text information of image vectors, thereby recognizing image text.

[0108] 202. Based on a preset optical character recognition engine, perform text recognition on the standardized text image to obtain initial text information corresponding to the standardized text image;

[0109] Specifically, the server inputs the text image into the input layer of the bidirectional long short-term memory recurrent neural network model for matrix processing to obtain a first feature matrix of the text image; the server inputs the first feature matrix into the encoding layer of the bidirectional long short-term memory recurrent neural network model for feature extraction to obtain a second feature matrix; the server inputs the second feature matrix into the decoding layer of the bidirectional long short-term memory recurrent neural network model for feature decoding to obtain a third feature matrix; the server inputs the third feature matrix into the fully connected layer of the bidirectional long short-term memory recurrent neural network model for feature classification to obtain a text feature classification label corresponding to the text image; the server sets the text feature classification label as an index, searches a preset text dictionary, and obtains the initial text information corresponding to the standardized text image.

[0110] In this optional embodiment, the bidirectional long short-term memory recurrent neural network model Bi-LSTM combines the long short-term memory neural network model LSTM (Long Short-Term Memory) and the recurrent neural network model RNN (Recurrent Neural Network), and adopts a bidirectional encoding mode, so that the bidirectional long short-term memory recurrent neural network model achieves excellent results in image text recognition. The server first inputs the text image into the input layer of the model for matrix processing to convert the text image into a digital matrix to obtain a first feature matrix, and then the server inputs the first feature matrix into the encoding layer for feature extraction, that is, using multiple convolution factors to perform convolution calculation on the first feature matrix to obtain a second feature matrix. The server then inputs the second feature matrix into the decoding layer for feature decoding to obtain a third feature matrix of the forward result, and performs a reverse operation, that is, the server inverts the first feature matrix and then passes it through the encoding layer and the decoding layer to obtain a third feature matrix of the reverse result. Finally, the server inputs the third feature matrices of the forward result and the reverse result into the fully connected layer for feature classification to obtain a text feature classification label corresponding to the text image. The server can find the initial text information corresponding to the text image through the text feature classification label.

[0111] 203. Segment the standardized text image according to initial text information corresponding to the standardized text image to obtain a plurality of text image segments;

[0112] The execution process of step 203 is similar to that of step 103, and will not be described in detail here.

[0113] 204. Input the multiple text image segments into the trained image feature extraction model to perform image vectorization processing to obtain a target image vector corresponding to each text image segment, and perform text vectorization processing on the initial text information to obtain an initial text vector corresponding to the initial text information;

[0114] Specifically, the server inputs multiple text image fragments into the convolution layer of the bidirectional encoding BERT model for feature extraction to obtain a first feature vector corresponding to each text image fragment; the server inputs each first feature vector into the excitation layer of the bidirectional encoding BERT model for nonlinear mapping to obtain multiple second feature vectors; the server inputs each second feature vector into the pooling layer of the bidirectional encoding BERT model for dimensionality reduction to obtain an initial image vector corresponding to each text image fragment.

[0115] In this optional embodiment, the image feature extraction model includes a bidirectional encoding BERT model, which includes a convolutional layer, an excitation layer, and a pooling layer. After the server passes multiple text image fragments through each network layer of the bidirectional encoding BERT model in sequence, it obtains an initial image vector corresponding to the text image fragment, which is used to represent the feature sequence of each text image fragment.

[0116] Optionally, the server can also input multiple text image fragments and initial text information into the trained bimodal recognition ViLBERT model at the same time. The encoding layer of the bimodal recognition ViLBERT model encodes each text image fragment and the initial text information corresponding to each text image fragment respectively, and obtains the encoding result corresponding to each text image fragment and the encoding result of the initial text information corresponding to each text image fragment. After the two modalities are encoded, the server performs co-attention calculation on each encoding result through the co-attention mechanism network of the bimodal recognition ViLBERT model, that is, each encoding result uses its own Query (query understanding, QU) and the value Value and key Key of the encoding result of the other modality to perform attention calculation, and obtains the initial image vector corresponding to each text image fragment and the initial text vector corresponding to the initial text information, where the text image fragment is one modality and the initial text information is another modality.

[0117] Specifically, the server performs word segmentation on the initial text information based on a preset word segmentation algorithm to obtain a word segmentation result; the server performs sparse vectorization on the word segmentation result based on a preset one-hot encoding algorithm to obtain a sparse vector corresponding to the initial text information; the server maps the sparse vector corresponding to the initial text information to a dense vector based on a preset word embedding algorithm to obtain an initial text vector corresponding to the initial text information.

[0118] In this optional embodiment, the preset word segmentation algorithms include: statistical language N-Gram algorithm, conditional random field CRF word segmentation algorithm and shortest path word segmentation algorithm. The server can convert words into sparse vectors that can be understood by the machine through the one-hot encoding algorithm (One-Hot Encoding). The server then maps the sparse vectors into high-dimensional dense vectors based on the word embedding algorithm (Word Embedding), thereby obtaining an initial text vector representing the initial text information.

[0119] 205. Searching for a target text vector corresponding to the initial text vector in a text image information library, and obtaining annotation information corresponding to the target text vector;

[0120] In this embodiment, the server searches for a target text vector corresponding to the initial text vector in the sample text vectors of the text image information library, thereby obtaining the annotation information corresponding to the initial text vector. The server searches a preset text dictionary through the annotation information, and can obtain the text information corresponding to the target text vector, that is, the text information corresponding to the initial text vector. The server can determine the target text information corresponding to the target image vector through the correspondence between the target text vector and the target image vector.

[0121] 206. According to the annotation information corresponding to the target text vector, the target image vector corresponding to each initial image vector is obtained in the text image information library, and it is determined whether the similarity between the target image vector corresponding to each initial image vector and each initial image vector is less than a preset threshold value;

[0122] In this embodiment, the server reads the corresponding target image vector from the sample image vector of the text image information library through the target text vector, and then determines whether the similarity between the target image vector and the initial image vector is less than a preset threshold by calculating the similarity between the target image vector and the initial image vector, that is, determines whether the similarity between the target image vector and the initial image vector is less than the preset threshold. If the similarity between the target image vector and the initial image vector is less than the preset threshold, it means that the target text information corresponding to the target image vector can be used as the final recognition result. Otherwise, it means that the target text information corresponding to the target image vector cannot be used as the final recognition result. The server will continue to match the target image vector in the text image information library until all sample image vectors in the text image information library are matched, or the target image vector is matched.

[0123] 207. If the similarity between the target image vectors corresponding to the initial image vectors and the initial image vectors is less than a preset threshold, extracting the target text information corresponding to the initial image vectors from the annotation information corresponding to the target image vectors.

[0124] In this embodiment, the server can find the target text information carried by the annotation information, that is, the specific text in the text image segment, in a preset text dictionary through the annotation information corresponding to the target image vector. Optionally, after the server extracts the target text information, it can also compare the target text information with the initial text information. When different sentence pairs appear, the server performs natural language processing on the different sentence pairs, determines the target sentence in the sentence pair that conforms to the natural language expression, and outputs the target sentence as the final recognition result to the user.

[0125] In an embodiment of the present invention, the server obtains a target text vector in a text image information library based on an initial text vector, and then obtains a target image vector based on the target text vector. Then, the server determines the target text information by judging the difference between the initial image vector and the target image vector. The present invention can improve the recognition efficiency and accuracy of text documents.

[0126] The above describes the text recognition method based on text documents in the embodiment of the present invention. The following describes the text recognition device based on text documents in the embodiment of the present invention. Figure 3 In one embodiment of the present invention, a text document-based character recognition device includes:

[0127] The receiving module 301 is used to receive a text document to be recognized and pre-process the text document to obtain a standardized text image;

[0128] The recognition module 302 is used to perform text recognition on the standardized text image based on a preset optical character recognition engine to obtain initial text information corresponding to the standardized text image;

[0129] A segmentation module 303 is used to segment the standardized text image according to the initial text information corresponding to the standardized text image to obtain a plurality of text image segments;

[0130] A vectorization module 304 is used to input the multiple text image segments into the trained image feature extraction model to perform image vectorization processing to obtain an initial image vector corresponding to each text image segment, and perform text vectorization processing on the initial text information to obtain an initial text vector corresponding to the initial text information;

[0131] The determination module 305 is used to obtain the annotation information corresponding to the initial text vector in a preset text image information library, and determine the target text information corresponding to each initial image vector according to the annotation information.

[0132] Furthermore, the target text information is stored in a blockchain database, which is not specifically limited here.

[0133] In an embodiment of the present invention, the server obtains a text image by pre-processing the text document to be recognized by annotating it, and then performs preliminary text recognition on the text image based on an optical character recognition engine to obtain initial text information. Then, the server segments the standardized text image, and vectorizes the segmented text image segments and the initial text information to obtain initial text vectors and initial image vectors. Finally, the server obtains the annotation information of the initial image vector based on the initial text vector to obtain the target text information. The present invention can improve the text recognition accuracy of text documents.

[0134] See also Figure 4 Another embodiment of the text document-based character recognition device in the embodiment of the present invention includes:

[0135] The receiving module 301 is used to receive a text document to be recognized and pre-process the text document to obtain a standardized text image;

[0136] The recognition module 302 is used to perform text recognition on the standardized text image based on a preset optical character recognition engine to obtain initial text information corresponding to the standardized text image;

[0137] A segmentation module 303 is used to segment the standardized text image according to the initial text information corresponding to the standardized text image to obtain a plurality of text image segments;

[0138] A vectorization module 304 is used to input the multiple text image segments into the trained image feature extraction model to perform image vectorization processing to obtain an initial image vector corresponding to each text image segment, and perform text vectorization processing on the initial text information to obtain an initial text vector corresponding to the initial text information;

[0139] The determination module 305 is used to obtain the annotation information corresponding to the initial text vector in a preset text image information library, and determine the target text information corresponding to each initial image vector according to the annotation information.

[0140] Optionally, the receiving module 301 is specifically used for:

[0141] Receiving a text document to be recognized, and converting the text document into an image format to obtain an initialized text image;

[0142] Binarizing the initialized text image to obtain a black and white image;

[0143] Traversing the grayscale value of each pixel in the black-and-white image, and performing noise reduction processing on the grayscale value of each pixel to obtain a noise-reduced image;

[0144] According to a preset image correction algorithm, the noise reduction image is corrected to obtain a standardized text image.

[0145] Optionally, the optical character recognition engine includes a bidirectional long short-term memory recurrent neural network model, and the recognition module 302 is specifically used for:

[0146] Inputting the text image into the input layer of the bidirectional long short-term memory recurrent neural network model for matrix processing to obtain a first feature matrix of the text image;

[0147] Inputting the first feature matrix into the encoding layer of the bidirectional long short-term memory recurrent neural network model for feature extraction to obtain a second feature matrix;

[0148] Inputting the second feature matrix into the decoding layer of the bidirectional long short-term memory recurrent neural network model for feature decoding to obtain a third feature matrix;

[0149] Inputting the third feature matrix into the fully connected layer of the bidirectional long short-term memory recurrent neural network model for feature classification to obtain a text feature classification label corresponding to the text image;

[0150] The text feature classification label is set as an index, and a preset text dictionary is searched to obtain initial text information corresponding to the standardized text image.

[0151] Optionally, the image feature extraction model includes a bidirectional encoding BERT model, and the vectorization module 304 is used to:

[0152] Input the multiple text image segments into the convolutional layer of the bidirectional encoding BERT model for feature extraction to obtain a first feature vector corresponding to each of the text image segments;

[0153] Input each of the first feature vectors into the excitation layer of the bidirectional encoding BERT model for nonlinear mapping to obtain a plurality of second feature vectors;

[0154] Each of the second feature vectors is input into the pooling layer of the bidirectional encoding BERT model for dimensionality reduction processing to obtain an initial image vector corresponding to each text image segment.

[0155] Optionally, the vectorization module 304 is further used for:

[0156] Based on a preset word segmentation algorithm, the initial text information is segmented to obtain a word segmentation result;

[0157] Based on a preset one-hot encoding algorithm, sparse vectorization is performed on the word segmentation result to obtain a sparse vector corresponding to the initial text information;

[0158] Based on a preset word embedding algorithm, the sparse vector corresponding to the initial text information is mapped to a dense vector to obtain an initial text vector corresponding to the initial text information.

[0159] Optionally, the text document-based character recognition device further includes:

[0160] The sample acquisition module 306 is used to acquire a sample file in a text document format and convert the sample file into an image format to obtain a sample image;

[0161] The sample word segmentation module 307 is used to extract the sample text information in the sample file and perform word segmentation processing on the sample text information to obtain a word segmentation result;

[0162] A sample segmentation module 308, configured to segment the sample image based on the word segmentation result to obtain a plurality of sample image segments;

[0163] A sample vectorization module 309 is used to perform text vectorization processing on the word segmentation result to obtain a sample text vector, and perform image vectorization processing on the multiple sample image segments to obtain a sample image vector;

[0164] The sample annotation module 310 is used to perform sequence annotation on the sample image vector according to the sample text information corresponding to the sample text vector, obtain annotation information corresponding to each sample image segment, and generate a text image information library.

[0165] Optionally, the determining module 305 is specifically configured to:

[0166] Searching for a target text vector corresponding to the initial text vector in the text image information library, and obtaining annotation information corresponding to the target text vector;

[0167] According to the annotation information corresponding to the target text vector, the target image vector corresponding to each initial image vector is obtained in the text image information library, and it is determined whether the similarity between the target image vector corresponding to each initial image vector and each initial image vector is less than a preset threshold value;

[0168] If the similarity between the target image vectors corresponding to the initial image vectors and the initial image vectors is less than a preset threshold, the target text information corresponding to the initial image vectors is extracted from the annotation information corresponding to the target image vectors.

[0169] In an embodiment of the present invention, the server obtains a target text vector in a text image information library based on an initial text vector, and then obtains a target image vector based on the target text vector. Then, the server determines the target text information by judging the difference between the initial image vector and the target image vector. The present invention can improve the recognition efficiency and accuracy of text documents.

[0170] above Figure 3 and Figure 4 The text document-based character recognition apparatus in the embodiment of the present invention is described in detail from the perspective of modular functional entities. The text document-based character recognition apparatus in the embodiment of the present invention is described in detail from the perspective of hardware processing.

[0171] Figure 51 is a schematic diagram of the structure of a text document-based character recognition device provided by an embodiment of the present invention. The text document-based character recognition device 500 may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 510 (for example, one or more processors) and a memory 520, and one or more storage media 530 (for example, one or more mass storage devices) storing application programs 533 or data 532. Among them, the memory 520 and the storage medium 530 may be temporary storage or permanent storage. The program stored in the storage medium 530 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the XXX device 500. Furthermore, the processor 510 may be configured to communicate with the storage medium 530 to execute a series of instruction operations in the storage medium 530 on the text document-based character recognition device 500.

[0172] The text document-based character recognition device 500 may also include one or more power supplies 540, one or more wired or wireless network interfaces 550, one or more input and output interfaces 560, and / or one or more operating systems 531, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, etc. Those skilled in the art will appreciate that Figure 5 The illustrated structure of the text document-based character recognition device does not constitute a limitation on the text document-based character recognition device, and may include more or less components than those illustrated, or may combine certain components, or may have different component arrangements.

[0173] The present invention also provides a text document-based character recognition device, wherein the computer device includes a memory and a processor, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the processor executes the steps of the text document-based character recognition method in the above-mentioned embodiments.

[0174] The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. Instructions are stored in the computer-readable storage medium. When the instructions are executed on a computer, the computer executes the steps of the text document-based text recognition method.

[0175] Furthermore, the computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.

[0176] The blockchain referred to in this invention is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.

[0177] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0178] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program codes.

[0179] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A text recognition method based on text documents, It is characterized in that The text document-based character recognition method comprises: Receiving a text document to be recognized, and preprocessing the text document to obtain a standardized text image; Based on a preset optical character recognition engine, performing text recognition on the standardized text image to obtain initial text information corresponding to the standardized text image; Segmenting the standardized text image according to initial text information corresponding to the standardized text image to obtain a plurality of text image segments; Inputting the multiple text image segments into a trained image feature extraction model to perform image vectorization processing to obtain an initial image vector corresponding to each text image segment, and performing text vectorization processing on the initial text information to obtain an initial text vector corresponding to the initial text information; Acquire the annotation information corresponding to the initial text vector in a preset text image information library, and determine the target text information corresponding to each initial image vector according to the annotation information; Before receiving the text document to be recognized and preprocessing the text document to obtain a standardized text image, the text document-based character recognition method further includes: Acquire a sample file in a text document format, and convert the sample file into an image format to obtain a sample image; Extracting sample text information from the sample file, and performing word segmentation processing on the sample text information to obtain a word segmentation result; Based on the word segmentation result, segment the sample image to obtain a plurality of sample image segments; Performing text vectorization processing on the word segmentation result to obtain a sample text vector, and performing image vectorization processing on the multiple sample image segments to obtain a sample image vector; According to the sample text information corresponding to the sample text vector, the sample image vector is sequence labeled to obtain the labeling information corresponding to each sample image segment, and a text image information library is generated; The step of acquiring the annotation information corresponding to the initial text vector in a preset text image information library, and determining the target text information corresponding to each initial image vector according to the annotation information, includes: Searching for a target text vector corresponding to the initial text vector in the text image information library, and obtaining annotation information corresponding to the target text vector; According to the annotation information corresponding to the target text vector, the target image vector corresponding to each initial image vector is obtained in the text image information library, and it is determined whether the similarity between the target image vector corresponding to each initial image vector and each initial image vector is less than a preset threshold value; If the similarity between the target image vectors corresponding to the initial image vectors and the initial image vectors is less than a preset threshold, the target text information corresponding to the initial image vectors is extracted from the annotation information corresponding to the target image vectors.

2. The text document-based character recognition method according to claim 1, It is characterized in that The receiving of a text document to be recognized and preprocessing of the text document to obtain a standardized text image includes: Receiving a text document to be recognized, and converting the text document into an image format to obtain an initialized text image; Binarizing the initialized text image to obtain a black and white image; Traversing the grayscale value of each pixel in the black-and-white image, and performing noise reduction processing on the grayscale value of each pixel to obtain a noise-reduced image; According to a preset image correction algorithm, the noise reduction image is corrected to obtain a standardized text image.

3. The text recognition method based on text documents according to claim 1, It is characterized in that The optical character recognition engine includes a bidirectional long short-term memory recurrent neural network model. The preset optical character recognition engine performs text recognition on the standardized text image to obtain initial text information corresponding to the standardized text image, including: Inputting the text image into the input layer of the bidirectional long short-term memory recurrent neural network model for matrix processing to obtain a first feature matrix of the text image; Inputting the first feature matrix into the encoding layer of the bidirectional long short-term memory recurrent neural network model for feature extraction to obtain a second feature matrix; Inputting the second feature matrix into the decoding layer of the bidirectional long short-term memory recurrent neural network model for feature decoding to obtain a third feature matrix; Inputting the third feature matrix into the fully connected layer of the bidirectional long short-term memory recurrent neural network model for feature classification to obtain a text feature classification label corresponding to the text image; The text feature classification label is set as an index, and a preset text dictionary is searched to obtain initial text information corresponding to the standardized text image.

4. The text recognition method based on text documents according to claim 1, It is characterized in that The image feature extraction model includes a bidirectional encoding BERT model, and the inputting of the plurality of text image segments into the trained image feature extraction model for image vectorization processing to obtain an initial image vector corresponding to each text image segment includes: Input the multiple text image segments into the convolutional layer of the bidirectional encoding BERT model for feature extraction to obtain a first feature vector corresponding to each text image segment; Input each first feature vector into the excitation layer of the bidirectional encoding BERT model for nonlinear mapping to obtain a plurality of second feature vectors; Each second feature vector is input into the pooling layer of the bidirectional encoding BERT model for dimensionality reduction processing to obtain an initial image vector corresponding to each text image segment.

5. The text document-based character recognition method according to claim 1, It is characterized in that The performing text vectorization processing on the initial text information to obtain an initial text vector corresponding to the initial text information includes: Based on a preset word segmentation algorithm, the initial text information is segmented to obtain a word segmentation result; Based on a preset one-hot encoding algorithm, sparse vectorization is performed on the word segmentation result to obtain a sparse vector corresponding to the initial text information; Based on a preset word embedding algorithm, the sparse vector corresponding to the initial text information is mapped to a dense vector to obtain an initial text vector corresponding to the initial text information.

6. A text recognition device based on text documents, It is characterized in that The text document-based character recognition device comprises: A receiving module, used for receiving a text document to be recognized, and preprocessing the text document to obtain a standardized text image; A recognition module, configured to perform text recognition on the standardized text image based on a preset optical character recognition engine to obtain initial text information corresponding to the standardized text image; A segmentation module, configured to segment the standardized text image according to initial text information corresponding to the standardized text image, to obtain a plurality of text image segments; A vectorization module is used to input the multiple text image segments into a trained image feature extraction model to perform image vectorization processing to obtain an initial image vector corresponding to each text image segment, and to perform text vectorization processing on the initial text information to obtain an initial text vector corresponding to the initial text information; A determination module, used to obtain the annotation information corresponding to the initial text vector in a preset text image information library, and determine the target text information corresponding to each initial image vector according to the annotation information; The device also includes a generation module, which is used to obtain a sample file in a text document format, and convert the sample file into an image format to obtain a sample image; extract sample text information from the sample file, and perform word segmentation processing on the sample text information to obtain a word segmentation result; based on the word segmentation result, perform segmentation processing on the sample image to obtain a plurality of sample image fragments; perform text vectorization processing on the word segmentation result to obtain a sample text vector, and perform image vectorization processing on the plurality of sample image fragments to obtain a sample image vector; perform sequence annotation on the sample image vector according to the sample text information corresponding to the sample text vector, obtain annotation information corresponding to each sample image fragment, and generate a text image information library; The determination module is also used to: search for a target text vector corresponding to the initial text vector in the text image information library, and obtain annotation information corresponding to the target text vector; obtain a target image vector corresponding to each initial image vector in the text image information library according to the annotation information corresponding to the target text vector, and respectively determine whether the similarity between the target image vector corresponding to each initial image vector and each initial image vector is less than a preset threshold; if the similarity between the target image vector corresponding to each initial image vector and each initial image vector is less than a preset threshold, extract the target text information corresponding to each initial image vector from the annotation information corresponding to the target image vector.

7. A text recognition device based on text documents, It is characterized in that The text document-based character recognition device comprises: a memory and at least one processor, wherein instructions are stored in the memory; The at least one processor calls the instructions in the memory to enable the text document-based text recognition device to execute the text document-based text recognition method as described in any one of claims 1-5.

8. A computer-readable storage medium having instructions stored thereon, It is characterized in that When the instructions are executed by the processor, the text document-based character recognition method as described in any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Text recognition method and system

    CN112862024A

  • Chinese machine reading understanding method and device, electronic equipment and storage medium

    CN113051371A