An OCR recognition method and recognition system based on a domestic platform
By building the deep learning framework and caffe framework of the domestic platform, the problem of limited OCR recognition research on the domestic platform is solved, autonomous controllability and efficient recognition are achieved, the recognition accuracy and efficiency are improved, and it is suitable for different platforms and Application scenarios.
Patent Information
- Application Number
- CN202011515483.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-21
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2040-12-21
AI Technical Summary
OCR recognition research on domestic platforms is limited by technical incompatibility caused by different architectures, lack of independent controllability and confidentiality, and the existing system has low compatibility with different application scenarios, high manual verification costs, and low recognition efficiency.
Through data set annotation and organization, we build a deep learning framework for the domestic platform, use the caffe framework to build an OCR recognition network structure, conduct model training and application, realize image processing and recognition result output, and use cross-platform tools to build a graphical interface to support domestic production. OCR recognition of the platform.
It achieves independent controllability and confidentiality under the localized platform, reduces manual verification costs, and improves recognition accuracy and efficiency. It is especially effective in recognizing text printed by dot matrix printers, with a recognition accuracy rate of 96%, and Supports porting to different platforms.
Smart Images

Figure CN112633268B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of pattern recognition and computer vision, and in particular to an OCR recognition method and a recognition system thereof based on a domestic platform. Background Art
[0002] In recent years, computer vision technology has developed rapidly, and OCR recognition of image text has become a hot topic. At present, there are many OCR recognition studies in the context of conventional text recognition, text recognition in natural scenes, ID card recognition in the security field, and bill bank card recognition in the financial field, and mature applications have been achieved. The implementation of OCR recognition technology mainly relies on deep learning frameworks, such as TensorFlow, caffe, and Paddle. In the framework, a recognition network model is built, and the model is optimized and trained through a large amount of data, so as to realize text recognition through the model. At present, the application platforms of deep learning frameworks are Windows platform and Linux platform, based on x86 and AMD architectures, both of which are platforms developed abroad. The CPU of the domestic platform uses a chip developed by Feiteng, which uses the self-developed ARMv8 architecture. The x86 and other architectures use complex instruction set computers, and ARMv8 uses reduced instruction set computers. The difference between the two leads to different underlying instructions on different platforms, and the software of both platforms cannot be used directly. This also leads to almost no research on OCR recognition based on domestic systems and hardware platforms. Most of the domestic software and hardware systems in government affairs, finance and other industries cannot use OCR technology to improve production efficiency. In order to achieve better technical confidentiality and technical autonomy and controllability. Aiming at the insufficiency of deep learning research on domestic platforms and the need to process OCR recognition on domestic platforms, the present invention recompiles and transplants frameworks on different platforms to meet the framework requirements of OCR recognition, and proposes an OCR recognition method and application based on domestic platforms.
[0003] After long-term practice by the applicant, it was found that the following deficiencies exist in the existing technology: 1. Due to the different architectures of different platforms, the OCR recognition research on the domestic platform cannot directly use the framework of the foreign platform for OCR recognition research. When using foreign platforms directly, there are problems with the confidentiality and controllability of technology and data information. 2. Units using domestic equipment are required to manually perform inspection and extraction when text verification and information extraction are required, which not only has high labor costs but also low efficiency. 3. The existing OCR recognition system is not highly compatible with different application scenarios, has high requirements for image quality, and also requires clear and coherent printed fonts. In some application scenarios, such as invoices, deposit slips, etc., the dot matrix printers used for text printing are different from ordinary laser printers, which affects the recognition accuracy. Summary of the invention
[0004] Purpose of the invention: To provide an OCR recognition method based on a domestic platform to solve the problems involved in the background technology.
[0005] Technical solution: An OCR recognition method based on a domestic platform, including the following steps:
[0006] Step 1: Dataset annotation and organization: First, organize the characters that need to be recognized, then create a data set based on the collected characters, and finally perform data augmentation on all the data;
[0007] Step 2: Building the recognition model: First, build the image processing tool of the domestic platform to establish a deep learning framework and build the OCR recognition network structure;
[0008] Step 3, recognition model training: first use the compiled image processing tool to normalize the image size of the training data, then modify the written prototxt file, add the setting parameters and preparation files for model training, including image path, label path, back propagation learning rate, and finally set the training parameters for training. During the training process, the parameters of the network structure will be continuously iteratively optimized according to the back propagation training results. Finally, the training is completed and the optimal parameters of the network structure are saved in the form of a binary file, that is, the trained model file;
[0009] Step 4: Application of recognition model: Send the processed image to the trained network structure for calculation, match the best matching label result after the model calculation, retrieve the label result in the constructed label file and output the OCR recognition result.
[0010] As a preferred solution, the characters include: 6763 Chinese characters in the first-level and second-level character libraries of the GB2312 national standard code; 682 commonly used characters including numbers, general symbols, Latin letters, Greek letters, Russian letters, phonetic symbols and phonetic letters; and 20 more commonly used uncommon Chinese characters in personal names collected from banks and government agencies.
[0011] As a preferred solution, the data set synthesis method is as follows: the synthetic data is generated by a generation tool, and given the text font type and font size, image data containing Chinese characters and corresponding data labels are randomly generated from the corpus; the annotated data is annotated by data fields intercepted in scenarios such as passbooks, invoices, and deposit certificates.
[0012] As a preferred solution, the data augmentation method is: by rotating, stretching, adding background methods, the diversity of the data is improved, and finally a data set is generated, including a training set and a test set. The label files of the training set and the test set are respectively saved in the train.txt and test.txt files.
[0013] As a preferred solution, the domestic platform uses the domestic Feiteng FT-2000 chip as the CPU, combined with the domestic UOS operating system.
[0014] As a preferred solution, the OCR recognition network structure includes: compiling and installing the image processing ggimage framework and the deep learning framework caffe;
[0015] Among them, the deep learning framework caffe includes two convolution layers Conv1 and Conv2, three inception structure layers inception_3a, inception_3b and inception_3c. The convolution features are added by the Eltwise layer and output by the mean-pooling layer; the output is changed by the transpose layer Transpose layer and then input into two bidirectional LSTM layers. The time series features extracted by the bidirectional LSTM layer are output by a fully connected layer InnerProduct layer to the CTC loss function layer, and the final result is calculated and passed to the output layer.
[0016] As a preferred solution, the recognition model training method comprises the following steps:
[0017] First, the training image data is normalized, and then the solver.prototxt file is written, which includes the training parameter settings; a test is performed every 1000 iterations, and the model is saved at the same time. After the solver.prototxt file is written, it is called on a device with high video memory for training. Finally, the optimal parameters of the network structure are saved in the caffemodel file in the form of a binary file.
[0018] As a preferred solution, the recognition model application includes the following steps:
[0019] The image processing ggimage framework is used to read the image to be recognized for normalization. The processed image is sent to the optimal model composed of the deploy.prototxt file and the caffemodel file through the caffe framework interface for calculation. The most matching label result after the matching model calculation is retrieved in the constructed label file and the OCR recognition result is output.
[0020] As a preferred solution, the OCR recognition method further includes
[0021] Step 5: Output recognition results: Use cross-platform tools to build a graphical interface, which includes the functions of reading the image to be recognized in the file and displaying the recognition results.
[0022] The present invention also provides a recognition system of an OCR recognition method based on a domestic platform, based on the Feiteng FT-2000 chip and the domestic UOS operating system; including the following modules:
[0023] The dataset annotation and organization module is used to organize the characters that need to be recognized, then create a dataset based on the collected characters, and finally perform data augmentation on all the data;
[0024] The recognition model building module is used to build the image processing tools of the domestic platform to establish a deep learning framework and build the OCR recognition network structure;
[0025] The recognition model training module is used to use the compiled image processing tool to normalize the image size of the training data. Secondly, the written prototxt file is modified to add the setting parameters and preparation files for model training, including image path, label path, back propagation learning rate, and finally set the training parameters for training. During the training process, the parameters of the network structure will be continuously iteratively optimized according to the back propagation training results. Finally, the training is completed and the optimal parameters of the network structure are saved in the form of a binary file, that is, the trained model file.
[0026] The recognition model application module is used to send the processed images into the trained network structure for calculation, match the most matching label results after the model calculation, retrieve the label results in the constructed label file and output the OCR recognition results.
[0027] Beneficial effects: The present invention relates to an OCR recognition method based on a domestic platform, which has the following advantages compared with the prior art:
[0028] 1. The present invention is based on an OCR recognition system under a domestic platform, which breaks away from the control of foreign technology and achieves confidentiality and independent controllability of technology.
[0029] 2. The present invention realizes automatic extraction of bill information, reduces the time and labor costs of manual verification and input of information, and greatly improves work efficiency;
[0030] 3. The present invention adopts a deep learning model for OCR recognition, which speeds up the information recognition speed and recognition accuracy in the domestic platform. At the same time, the model training data set includes data printed by a dot matrix printer, and has high robustness for font recognition of passbooks, invoices, and deposit certificates.
[0031] 4. The test shows that the recognition accuracy of the present invention reaches 96%, and the effect is better in the recognition of text printed by a dot matrix printer. The packaged program can be transplanted on different domestic platforms without any problems.
[0032] 5. Since the labeled data is obtained through data fields intercepted in actual scenarios such as passbooks, invoices, and deposit certificates, the intercepted data is annotated. The generation tool developed based on Python's PIL library is used to generate synthetic data. It not only has good graphics processing effects and high data accuracy, but is also suitable for domestic platforms.
[0033] 6. The underlying languages of the image processing ggimage framework and the deep learning framework caffe of the present invention are both written in C++, which supports cross-platform use and facilitates transplantation between different platforms.
[0034] In summary, the present invention achieves confidentiality and technical autonomy and controllability, and has good text recognition effect and high robustness in font recognition for passbooks, invoices, and deposit slips. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 It is a system flow chart of the present invention.
[0036] Figure 2 It is a schematic diagram of the interface of the cross-platform tool in the present invention. DETAILED DESCRIPTION
[0037] In the following description, a large number of specific details are provided to provide a more thorough understanding of the present invention. However, it is apparent to those skilled in the art that the present invention can be implemented without one or more of these details. In other examples, in order to avoid confusion with the present invention, some technical features well known in the art are not described.
[0038] As attached Figure 1 As shown, an OCR recognition system based on a domestic platform is based on the Feiteng FT-2000 chip and the domestic UOS operating system; it includes: a data set annotation and organization module, a recognition model building module, a recognition model training module and a recognition model application module.
[0039] Among them, the data set annotation and sorting module first sorts the Chinese characters that need to be recognized, and the specific selection is based on the actual application scenario. Secondly, the data set is made based on the collected characters. The data set includes synthetic data and self-annotated data. The data size is the same, of which synthetic data accounts for 80% and annotated data accounts for 20%. Finally, all data are augmented to increase data diversity.
[0040] The recognition model building module first builds the image processing tools and deep learning framework of the domestic platform, using the domestic Feiteng FT-2000 chip, on which the UOS operating system is installed. The image processing uses the internal ggimage framework, which can meet the performance requirements under the Feiteng FT-2000 hardware architecture. The deep learning framework uses the caffe framework, and the source code of the components required for the caffe framework compilation is modified to complete the compilation and construction of the deep learning framework. The OCR recognition network structure is built, and the network structure is written into a prototxt file that can be read by caffe. Specifically, the network structure consists of a CNN network and a double-layer LSTM network. The CNN network extracts the convolution features of the training image, which is composed of a simplified inception network. The double-layer LATM network extracts the sequence features in the image convolution features, and finally the output result of the network structure is obtained by the loss function CTC calculation.
[0041] Identify the model training module. This module uses the constructed network model to train the data. First, use the compiled image processing tool to normalize the image size of the training data. Secondly, modify the written prototxt file, add the setting parameters and preparation files for model training, including image path, label path, and back propagation learning rate. Finally, set the training parameters for training. During the training process, the parameters of the network structure will be continuously iteratively optimized according to the back propagation training results. Finally, the training is completed, and the optimal parameters of the network structure are saved in the form of a binary file, that is, the trained model file.
[0042] Model application module: This module calls the trained model file through the program and performs simple applications. First, write a calling program, use the image tool to read the image to be identified and process it in a unified size. The processed image is sent to the trained network structure through the caffe framework for calculation, and the most matching label result after the matching model calculation is retrieved from the constructed label file and the OCR recognition result is output. Secondly, build a graphical operation interface, which includes the functions of reading the image to be identified in the file and displaying the recognition result. Finally, package the dynamic library and operating environment required by the model and tool to realize the portability of the recognition method on the domestic platform.
[0043] Based on the above OCR recognition system, a method for OCR recognition based on a domestic platform is specifically described, including the following steps:
[0044] Step 1: Dataset annotation and organization: First, organize the characters that need to be recognized, then create a data set based on the collected characters, and finally perform data augmentation on all the data;
[0045] Step 11: Arrange the characters to be recognized. This embodiment includes 6763 Chinese characters in the first-level and second-level character libraries of GB2312 national standard code; 682 characters of commonly used characters such as numbers, general symbols, Latin letters, Greek letters, Russian letters, phonetic symbols and phonetic letters; 20 relatively common Chinese characters in names collected from banks and government agencies. A total of 7465 training characters.
[0046] Step 12, data set synthesis, specifically, synthetic data is generated by a generation tool. The generation tool is developed based on Python's PIL library, and a Chinese character list is made based on the sorted characters to be trained and a corpus is randomly generated. Given the text font type, font size and font file, image data containing Chinese characters and corresponding data labels are randomly generated from the corpus; annotated data is annotated by data fields intercepted in actual scenarios, such as passbooks, invoices, deposit certificates, etc.
[0047] Step 13: Data augmentation: By rotating, stretching, and adding background methods, the diversity of the data is improved, and finally a 2 million data set is generated, including 1.98 million training sets and 20,000 test sets. The label files of the training set and test set are saved in the train.txt and test.txt files respectively.
[0048] Step 2: Building the recognition model: First, build the image processing tool of the domestic platform to establish a deep learning framework and build the OCR recognition network structure;
[0049] Step 21. Build the environment on the domestic platform. Specifically, the domestic Feiteng FT-2000 chip is used as the CPU. The CPU integrates 4 self-developed processor cores FTC663, with a maximum frequency of 3.0GHz and a maximum power consumption of 10W. It is equipped with 16G memory and 256G solid-state hard disk. The output device uses an LCD display and is equipped with a domestic UOS operating system. The difference between the domestic platform and the Windows platform is that the domestic platform uses the ARMv8 architecture, while the Windows platform uses the X86 architecture. The difference between the two architectures leads to differences in the operation of the underlying instruction set. Therefore, the commonly used deep learning framework under the X86 and AMD architectures cannot be used in the ARMv8 architecture. The framework tools that need to be used need to be compiled separately for different instruction sets. Compile and install the image processing ggimage framework and the deep learning framework caffe on this system. Among them, the image processing ggimage framework is a self-developed image processing tool. The tool packages and encapsulates basic functions such as image reading, preprocessing, cropping, matrix transformation, etc. It is written in C++ and supports cross-platform use. The underlying language of the deep learning framework caffe is C++. The framework only provides deep learning layers and optimized computing functions to facilitate porting between different platforms. Caffe needs to compile and install necessary components, including glog, gflags, boost, hdf5, leveldb, lmdb, protobuf and snappy. By writing and modifying the makefile file, different components can be compiled on the localized platform.
[0050] Step 22. The network model is constructed in the caffe framework, and the model structure is written in the deploy.prototxt file that can be read by caffe. Specifically, the structure includes two layers of convolution layers Conv1 and Conv2, three layers of inception structure layers inception_3a, inception_3b and inception_3c, and the convolution features are added by the Eltwise layer and output by the mean-pooling layer. The output is input into two bidirectional LSTM layers after the feature dimension is changed by the transpose layer. The time series features extracted by the bidirectional LSTM layer are output by a fully connected layer InnerProduct layer to the CTC loss function layer, and the result is finally calculated and passed to the output layer. The calculation method of the loss function L is:
[0051] L(S)=-∑ (x,z)∈S lnp(z|x),
[0052] Among them, p(z|x) represents the probability of output sequence z given input x, and S is the training set data.
[0053] Step 3: Recognition model training
[0054] Step 31, modify the configuration file. Specifically, modify the written deploy.prototxt file, modify the size of the network input data, and in this embodiment, unify the image input size to 280*32. Add the image file and label file path required for training, and add the back propagation learning rate. Finally, save the file again as train.prototxt file.
[0055] Step 32, model training, first normalize the training image data, and unify the image size to 280*32. Then write the solver.prototxt file, which includes the training parameter settings. The training parameters are set to batch_size=256. The maximum number of iterations T=200000 times, the basic learning rate r=0.001, the learning parameter momentum=0.9, and weight_decay=0.0002. Among them, batch_size is the amount of data trained for each batch. After testing, taking 256 can ensure a good training speed. Selecting a smaller batch_size will lead to slow training speed and model non-convergence problems. Although selecting a larger batch_size can speed up the training speed, it may cause the final model to be of low accuracy. The maximum number of iterations T is the number of iterations for each batch_size, and the calculation method is
[0056]
[0057] Where S is the total amount of training data, and batch_size is the amount of data trained for each batch.
[0058] train That is, all data will be trained once, and the entire training process requires 8 cycles of training on the data. The accuracy of the model is tested on the test set every 1000 iterations, and the model is saved at the same time. The end of training is determined by whether the model converges. The loss function parameters are adjusted in each training batch according to the learning rate r, and the model generated when the optimal loss function value after the gradient descent iteration is obtained is selected as the optimal model. After writing the solver.prototxt file, call the file on a device with high video memory for training, and the optimal parameters of the final network structure are saved in the caffemodel file in the form of a binary file.
[0059] Step 4: Model application
[0060] Step 41: Establish the application model and use the image processing ggimage framework to read the image to be identified for normalization. The ggimage framework is a self-developed image processing tool that includes basic image processing. It supports cross-platform use. The normalization method is:
[0061] x'=(xx min ) / (x max -x min ),
[0062] Where x' is the normalized value, x is the value to be normalized, and x min is the minimum value in the sample, x max is the maximum value in the sample.
[0063] The processed image is sent to the optimal model composed of the deploy.prototxt file and the caffemodel file through the caffe framework interface for calculation. The best matching label result after matching model calculation is retrieved in the constructed label file and the OCR recognition result is output.
[0064] Step 42: Use a cross-platform tool to build a graphical interface, which includes functions of reading the image to be recognized in the file and displaying the recognition result. The cross-platform interface is as follows: Figure 2 Finally, the dynamic library and operating environment required by the model and the tool are packaged. The recognition accuracy of the invention is 96% after testing, and the effect is good in the recognition of text printed by a dot matrix printer. The packaged program can be transplanted on different domestic platforms without any problems.
[0065] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present invention will not further describe various possible combinations.
Claims
1. An OCR recognition method based on a domestic platform, characterized in that: The steps include: Step 1: Dataset annotation and organization: First, organize the characters that need to be recognized, then create a data set based on the collected characters, and finally perform data augmentation on all the data; Step 2: Building the recognition model: First, build the image processing tool of the domestic platform to establish a deep learning framework and build the OCR recognition network structure; The domestic platform uses the domestic Feiteng FT-2000 chip as the CPU, with the domestic UOS operating system; The OCR recognition network structure includes: compiling and installing the image processing ggimage framework and the deep learning framework caffe; the components that need to be compiled and installed in caffe include glog, gflags, boost, hdf5, leveldb, lmdb, protobuf and snappy, and different components are compiled on the localized platform by writing and modifying the makefile file; the deep learning framework caffe includes two convolution layers Conv1 layer and Conv2 layer, three inception structure layers inception_3a layer, inception_3b layer and inception_3c layer, and the convolution features are added by the Eltwise layer and output by the mean-pooling layer; the output is input into two bidirectional LSTM layers after the feature dimension is changed by the transpose layer Transpose layer, and the temporal features extracted by the bidirectional LSTM layer are output by a fully connected layer InnerProduct layer to the CTC loss function layer for calculation, and then the calculation result is passed to the output layer; Step 3, recognition model training: first use the compiled image processing tool to normalize the image size of the training data, then modify the written prototxt file, add the setting parameters and preparation files for model training, including image path, label path, back propagation learning rate, test once every 1000 iterations, and save the model once. After writing the solver.prototxt file, call the file on a device with high video memory for training. During the training process, the parameters of the network structure will be iteratively optimized according to the back propagation training results. Finally, the training is completed, and the optimal parameters of the network structure are saved in the caffemodel file in the form of a binary file; Step 4: Application of recognition model: Send the processed image to the trained network structure for calculation to obtain the most matching label result, retrieve the label result in the constructed label file and output the OCR recognition result.
2. The OCR recognition method based on the domestic platform according to claim 1 is characterized in that: The characters include: 6763 Chinese characters in the first-level and second-level character libraries of the GB2312 national standard code; 682 commonly used characters including numbers, general symbols, Latin letters, Greek letters, Russian letters, phonetic symbols and phonetic letters; and 20 more commonly used uncommon Chinese characters in personal names collected from banks and government agencies.
3. The OCR recognition method based on the domestic platform according to claim 1 is characterized in that: The data set synthesis method is as follows: synthetic data is generated by a generation tool, given a text font type and font size, randomly generating image data containing Chinese characters and corresponding data labels from a corpus; the annotated data is data fields intercepted from passbooks, invoices, and deposit certificates, and the intercepted data fields are annotated.
4. The OCR recognition method based on the domestic platform according to claim 3 is characterized in that: The data augmentation method is: improving the diversity of data by rotating, stretching, and adding background methods, and finally generating a data set, including a training set and a test set. The label files of the training set and the test set are respectively saved in the train.txt and test.txt files.
5. The OCR recognition method based on the domestic platform according to claim 1 is characterized in that: The recognition model application comprises the following steps: The image processing ggimage framework is used to read the image to be recognized and normalize it. The processed image is sent to the optimal model composed of the deploy.prototxt file and the caffemodel file through the caffe framework interface to calculate and obtain the most matching label result. The label result is retrieved in the constructed label file and the OCR recognition result is output.
6. The OCR recognition method based on the domestic platform according to claim 1 is characterized in that: The OCR recognition method further includes: Step 5: Output recognition results: Use cross-platform tools to build a graphical interface, which includes the functions of reading the image to be recognized in the file and displaying the recognition results.
7. An OCR recognition system based on a domestic platform, characterized in that: Includes the following modules: The dataset annotation and organization module is used to organize the characters that need to be recognized, then create a dataset based on the collected characters, and finally perform data augmentation on all the data; The recognition model building module is used to build the image processing tools of the domestic platform to establish a deep learning framework and build the OCR recognition network structure; The domestic platform uses the domestic Feiteng FT-2000 chip as the CPU, with the domestic UOS operating system; The OCR recognition network structure includes: compiling and installing the image processing ggimage framework and the deep learning framework caffe; the components that need to be compiled and installed in caffe include glog, gflags, boost, hdf5, leveldb, lmdb, protobuf and snappy, and different components are compiled on the localized platform by writing and modifying the makefile file; the deep learning framework caffe includes two convolution layers Conv1 layer and Conv2 layer, three inception structure layers inception_3a layer, inception_3b layer and inception_3c layer, and the convolution features are added by the Eltwise layer and output by the mean-pooling layer; the output is input into two bidirectional LSTM layers after the feature dimension is changed by the transpose layer Transpose layer, and the temporal features extracted by the bidirectional LSTM layer are output by a fully connected layer InnerProduct layer to the CTC loss function layer for calculation, and then the calculation result is passed to the output layer; Identify the model training module, which is used to use the compiled image processing tool to normalize the image size of the training data. Then modify the written prototxt file, add the setting parameters and preparation files for model training, including image path, label path, back propagation learning rate, and perform a test every 1000 iterations. Save the model at the same time. After writing the solver.prototxt file, call the file on a device with high video memory for training. During the training process, the parameters of the network structure will be iteratively optimized according to the back propagation training results. Finally, the training is completed, and the optimal parameters of the network structure are saved in the caffemodel file in the form of a binary file. The recognition model application module is used to send the processed images into the trained network structure for calculation, obtain the most matching label result, retrieve the label result in the constructed label file and output the OCR recognition result.
