Handwriting recognition method, device, electronic equipment and medium

By compressing the original trajectory data of handwriting and using the compressed end-to-end model for recognition, the problem of incorrect segmentation during continuous input is solved and the accuracy and real-time performance of handwriting recognition are improved.

CN112766080BActive Publication Date: 2024-09-06BEIJING SOGOU TECHNOLOGY DEVELOPMENT CO LTD

Patent Information

Application Number
CN202011640989.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-31
Publication Date
2024-09-06
Estimated Expiration
2040-12-31

AI Technical Summary

Technical Problem

Due to the lack of broken pens during continuous input, the existing handwriting recognition technology has a high probability of incorrect segmentation in the segmentation module, resulting in low recognition accuracy.

Method used

By obtaining the original handwritten trajectory data in real time and compressing it, using the compressed end-to-end model for recognition, avoiding incorrect segmentation modules, and using handwritten sequence features for recognition.

Benefits of technology

It effectively improves the accuracy of handwriting recognition, reduces the problem of low recognition accuracy caused by incorrect segmentation, and improves the real-time performance of recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112766080B
    Figure CN112766080B
Patent Text Reader

Abstract

The embodiment of the present invention discloses a handwriting recognition method, which obtains original handwriting trajectory data in real time; compresses the original handwriting trajectory data to obtain compressed handwriting trajectory data; inputs the compressed handwriting trajectory data into a compressed handwriting recognition model for recognition, and obtains a text recognition result corresponding to the original handwriting trajectory data, wherein the handwriting recognition model is trained using the handwriting trajectory data of each training data in a training data set, and the compressed handwriting recognition model is obtained by model compression of the handwriting recognition model. The handwriting recognition method provided by the embodiment of the present invention can solve the problem of low handwriting recognition accuracy caused by incorrect segmentation in the prior art, and can effectively improve the handwriting recognition accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of Internet technology, and in particular to a handwriting recognition method, device, electronic device and medium. Background Art

[0002] With the rapid development of Internet technology, in order to facilitate user input, multiple input methods are usually provided, such as voice input, handwriting input, and pinyin input. When the user uses handwriting input, the handwriting input data will be recognized by the handwriting recognition model to improve the recognition efficiency and provide a better user experience.

[0003] However, in the prior art, a handwriting recognition framework for recognizing handwriting data is usually based on a three-stage architecture of segmentation, combination and re-recognition. When using the handwriting recognition framework for recognition, especially when recognizing connected handwriting such as connected cursive and connected running scripts, since there are no breaks in the connected handwriting, the probability of incorrect segmentation when the segmentation module segments the connected handwriting is very high, which will lead to a low recognition accuracy. Summary of the invention

[0004] The embodiments of the present invention provide a handwriting recognition method, device, electronic device and medium, which can solve the problem of low handwriting recognition accuracy caused by incorrect segmentation in the prior art and can effectively improve the handwriting recognition accuracy.

[0005] A first aspect of an embodiment of the present invention provides a handwriting recognition method, comprising:

[0006] Obtain original handwriting trajectory data in real time;

[0007] Compressing the original handwriting trajectory data to obtain compressed handwriting trajectory data;

[0008] The compressed handwriting trajectory data is input into a compressed handwriting recognition model for recognition, and a text recognition result corresponding to the original handwriting trajectory data is obtained, wherein the handwriting recognition model is trained using the handwriting trajectory data of each training data in the training data set, and the compressed handwriting recognition model is obtained by compressing the handwriting recognition model.

[0009] Optionally, the real-time acquisition of original handwriting trajectory data includes:

[0010] Performing data preprocessing on the handwriting input data acquired in real time, wherein the data preprocessing includes resampling;

[0011] The handwriting original trajectory data is acquired in real time according to the preprocessed handwriting input data.

[0012] Optionally, compressing the original handwriting trajectory data to obtain compressed handwriting trajectory data includes:

[0013] The original handwriting trajectory data is dimensionally compressed to obtain the compressed handwriting trajectory data, wherein the correlation between the data of each dimension in the compressed handwriting trajectory data and the model recognition result of the handwriting recognition model is not less than a set threshold.

[0014] Optionally, the handwriting recognition model is an end-to-end model.

[0015] Optionally, the training step of the handwriting recognition model includes:

[0016] Obtaining a training data set and a pre-selected training model corresponding to the training data set;

[0017] Obtain handwriting trajectory data of each training data in the training data set;

[0018] The pre-selected training model is trained using the handwriting trajectory data of each training data, and the trained pre-selected training model is obtained as the handwriting recognition model.

[0019] Optionally, obtaining a training data set includes:

[0020] Acquire a historical handwriting trajectory data set, wherein the historical handwriting trajectory data set includes one or more of horizontal handwriting trajectory data, vertical handwriting trajectory data, overlapping handwriting trajectory data, and rotated handwriting trajectory data;

[0021] Data enhancement is performed on the handwriting data in the historical handwriting trajectory dataset, and the historical handwriting trajectory dataset after data enhancement is used as a training dataset.

[0022] Optionally, the using the handwriting trajectory data of each training data to train the pre-selected training model to obtain the handwriting recognition model includes:

[0023] Get the difficult samples and simple samples in each training data;

[0024] The pre-selected model is trained by first training the difficult samples and then training the simple samples;

[0025] During the training process of the preselected model, the preselected training model is fine-tuned to obtain the trained preselected training model as the handwriting recognition model.

[0026] Optionally, after training the preselected training model to obtain the trained preselected training model as the handwriting recognition model, the method further includes:

[0027] Model distillation is performed on the trained pre-selected training model to obtain the distilled pre-selected training model, and the distilled pre-selected training model is used as the compressed handwriting recognition model.

[0028] A second aspect of an embodiment of the present invention provides a handwriting recognition device, comprising:

[0029] A handwriting trajectory acquisition module is used to acquire original handwriting trajectory data in real time;

[0030] A compressed trajectory acquisition module, used for compressing the original handwriting trajectory data to obtain compressed handwriting trajectory data;

[0031] A recognition module is used to input the compressed handwriting trajectory data into a compressed handwriting recognition model for recognition, and obtain a text recognition result corresponding to the original handwriting trajectory data, wherein the handwriting recognition model is trained using the handwriting trajectory data of each training data in the training data set, and the compressed handwriting recognition model is obtained by model compression of the handwriting recognition model.

[0032] Optionally, the handwriting trajectory acquisition module is used to perform data preprocessing on handwriting input data acquired in real time, wherein the data preprocessing includes resampling; and acquire the handwriting original trajectory data in real time based on the preprocessed handwriting input data.

[0033] Optionally, the compressed trajectory acquisition module is used to perform dimension compression on the original handwriting trajectory data to obtain the compressed handwriting trajectory data, wherein the correlation between the data of each dimension in the compressed handwriting trajectory data and the model recognition result of the handwriting recognition model is not less than a set threshold.

[0034] Optionally, the handwriting recognition model is an end-to-end model.

[0035] Optionally, also include:

[0036] The model training module is used to obtain a training data set and a pre-selected training model corresponding to the training data set; obtain the handwriting trajectory data of each training data in the training data set; use the handwriting trajectory data of each training data to train the pre-selected training model, and obtain the trained pre-selected training model as the handwriting recognition model.

[0037] Optionally, the model training module includes:

[0038] A training data set acquisition unit is used to acquire a historical handwriting trajectory data set, wherein the historical handwriting trajectory data set includes one or more of horizontal handwriting trajectory data, vertical handwriting trajectory data, overlapping trajectory data and rotated handwriting trajectory data; data enhancement is performed on the handwriting data in the historical handwriting trajectory data set, and the historical handwriting trajectory data set after data enhancement is used as a training data set.

[0039] Optionally, the model training module includes:

[0040] The model training unit is used to obtain difficult samples and simple samples in each training data; the pre-selected model is trained by first training the difficult samples and then training the simple samples; during the training of the pre-selected model, the pre-selected training model is fine-tuned to obtain the trained pre-selected training model as the handwriting recognition model.

[0041] Optionally, also include:

[0042] The compression model acquisition module is used to perform model distillation on the trained preselected training model to obtain the preselected training model after training the preselected training model to serve as the handwriting recognition model, and use the preselected training model after distillation as the compressed handwriting recognition model.

[0043] A third aspect of an embodiment of the present invention provides a device for handwriting recognition, comprising a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors, wherein the one or more programs include steps for the handwriting recognition method as described above.

[0044] A fourth aspect of an embodiment of the present invention provides a machine-readable medium having instructions stored thereon, which, when executed by one or more processors, enables a device to perform the steps of the handwriting recognition method as described above.

[0045] The beneficial effects of the embodiments of the present invention are as follows:

[0046] Based on the above technical solution, after obtaining the original handwriting trajectory data in real time, the original handwriting trajectory data is compressed, and the compressed handwriting trajectory data is used as input. The handwriting sequence features of the compressed handwriting trajectory data are recognized through a compressed end-to-end model to obtain a text recognition result. Compared with the segmentation and combination recognition used in the prior art, when recognizing connected handwriting such as connected cursive script and connected running script, since there is no break in the middle of the connected handwriting, the probability of incorrect segmentation in the segmentation module is very high, resulting in a low recognition accuracy. The use of a compressed handwriting recognition model avoids the incorrect segmentation module, and uses the compressed handwriting trajectory data after the original handwriting trajectory data is compressed as input. The handwriting sequence features are used for recognition, which can effectively reduce the problem of low recognition accuracy caused by incorrect segmentation in the prior art, thereby effectively improving the recognition accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] Figure 1 A method flow chart of a handwriting recognition method in an embodiment of the present invention;

[0048] Figure 2 A method flow chart of a method for training a handwriting recognition model in an embodiment of the present invention;

[0049] Figure 3 A schematic diagram of the structure of a handwriting recognition device in an embodiment of the present invention;

[0050] Figure 4 It is a structural block diagram of a handwriting recognition device used as a device in an embodiment of the present invention;

[0051] Figure 5 It is a structural block diagram of the server in some embodiments of the present invention. DETAILED DESCRIPTION

[0052] In order to better understand the above technical scheme, the technical scheme of the embodiment of the present invention is described in detail below through the accompanying drawings and specific embodiments. It should be understood that the embodiment of the present invention and the specific features in the embodiments are detailed descriptions of the technical scheme of the embodiment of the present invention, rather than limitations on the technical scheme of the present invention. In the absence of conflict, the embodiment of the present invention and the technical features in the embodiments can be combined with each other.

[0053] In response to the technical problem of low efficiency in replying using emoticon pictures, an embodiment of the present invention provides a handwriting recognition method, which is used to obtain original handwriting trajectory data in real time; the original handwriting trajectory data is input into a preset handwriting recognition model for recognition, and a text recognition result corresponding to the original handwriting trajectory data is obtained, wherein the handwriting recognition model is trained using the handwriting trajectory data of each training data in a training data set.

[0054] It can be seen that after obtaining the original handwriting trajectory data in real time, the original handwriting trajectory data is compressed, and the compressed handwriting trajectory data is used as input. The handwriting sequence features of the compressed handwriting trajectory data are recognized through the compressed end-to-end model to obtain the text recognition result; compared with the segmentation and combination recognition used in the prior art, when recognizing connected handwriting such as connected cursive and connected running script, since there is no break in the middle of the connected handwriting, the probability of incorrect segmentation in the segmentation module is very high, resulting in low recognition accuracy. The use of a compressed handwriting recognition model avoids the incorrect segmentation module, and uses the compressed handwriting trajectory data after the original handwriting trajectory data is compressed as input, and uses the handwriting sequence features for recognition, which can effectively reduce the problem of low recognition accuracy caused by incorrect segmentation in the prior art, thereby effectively improving the recognition accuracy.

[0055] like Figure 1 As shown, an embodiment of the present invention provides a handwriting recognition method, comprising the following steps:

[0056] S101, obtaining original handwriting trajectory data in real time;

[0057] S102, compressing the original handwriting trajectory data to obtain compressed handwriting trajectory data;

[0058] S103. Input the compressed handwriting trajectory data into a compressed handwriting recognition model for recognition, and obtain a text recognition result corresponding to the original handwriting trajectory data, wherein the handwriting recognition model is trained using the handwriting trajectory data of each training data in the training data set, and the compressed handwriting recognition model is obtained by compressing the handwriting recognition model.

[0059] Among them, in step S101, the original handwriting trajectory data can be obtained in real time according to the handwriting input data of the user on the display screen of the electronic device. For example, when the user writes a stroke on the display screen, the original handwriting trajectory data of each stroke is obtained according to the handwriting input data of each stroke; in this way, the real-time nature of the obtained original handwriting trajectory data can be ensured.

[0060] In the embodiments of this specification, the electronic device may be, for example, a smart phone, a tablet computer, a laptop computer, an e-book reader, etc.; further, the display screen may be, for example, an LCD screen, an LED screen, an electronic ink screen, etc., and this specification does not impose any specific limitations.

[0061] Specifically, the handwriting input data may include trajectory data of handwriting by a user's electronic pen and trajectory data of handwriting by a user's finger, which is not specifically limited in this specification.

[0062] When obtaining the original handwriting trajectory data in real time, the handwriting input data obtained in real time can be preprocessed, wherein the data preprocessing includes resampling; the original handwriting trajectory data is obtained in real time according to the preprocessed handwriting input data. At this time, the data preprocessing can also include trajectory rotation, resampling and trajectory rotation, resampling, trajectory rotation and trajectory cleaning, etc. And after obtaining the original handwriting trajectory data, the original handwriting trajectory data is compressed to obtain compressed handwriting trajectory data.

[0063] Specifically, data preprocessing generally includes resampling and trajectory rotation, so that when the original handwriting trajectory data is acquired in real time according to the preprocessed handwriting input data, the original handwriting trajectory data is acquired with higher accuracy.

[0064] Specifically, in order to solve the problem of different track point collection frequencies caused by different handwriting speeds of users on different electronic devices, it is necessary to resample the handwriting input data and remove redundant points in the handwriting input data. At this time, the resampling may include angle-based resampling or distance-based resampling, or angle-and-distance-based resampling. For example, redundant points can be removed based on setting conditions such as cos angles less than 20 and 30 degrees, and / or distances less than 4, 5, and 6 pixels. After removing the redundant points, the handwriting input data only retains the handwriting skeleton information; in this way, since the handwriting input data only retains the handwriting skeleton information and removes interfering redundant information, the accuracy of the original handwriting track data acquired in real time is higher, and thus the recognition accuracy is higher in subsequent recognition.

[0065] Furthermore, in order to improve the recognition accuracy of the original handwriting trajectory data obtained due to the user's irregular handwriting, the handwriting input data can be rotated. At this time, the handwriting input data can be rotated by plus or minus 15 degrees and 20 degrees, and then the rotated trajectory data can be resampled to obtain the pre-processed handwriting input data as the original handwriting trajectory data. In this way, the original handwriting trajectory data removes interfering redundant information, and can also reduce the problem of low recognition accuracy caused by the user's irregular handwriting, so that the accuracy of the original handwriting trajectory data can be further improved. Among them, the user's irregular handwriting includes the user writing diagonally and writing upwards.

[0066] After the original handwriting trajectory data is acquired in real time, step S102 is executed.

[0067] In step S102, after the original handwriting trajectory data is acquired in real time, when the original handwriting trajectory data is compressed, the original handwriting trajectory data may be dimensionally compressed to obtain compressed handwriting trajectory data, wherein the correlation between the data of each dimension in the compressed handwriting trajectory data and the model recognition result of the handwriting recognition model is not less than a set threshold. Alternatively, feature selection may be performed on the original handwriting trajectory data to obtain compressed handwriting trajectory data.

[0068] Specifically, a dimensionality reduction method such as the principal component analysis (PCA) method can be used to find the main features that can represent the original features of the original handwriting trajectory data, ensure that the correlation between the data of each dimension retained and the model recognition result is not less than a set threshold, and obtain compressed handwriting trajectory data based on the data of each dimension retained. The threshold can be set according to actual needs. For example, the K features with the highest correlation with the model recognition result can be selected and retained. The threshold can be set according to the feature with the lowest correlation among the K features, where K is an integer not less than 2.

[0069] Since the correlation between the data of each dimension in the compressed handwriting trajectory data and the model recognition result is not less than the set threshold, the compressed handwriting trajectory data contains the main features representing the original features of the original handwriting trajectory data. In this way, when the compressed handwriting trajectory input is input into the compressed handwriting recognition model for recognition, the recognition accuracy can be ensured.

[0070] In the embodiments of the present specification, after the original handwriting trajectory data is dimensionally compressed to obtain compressed handwriting trajectory data, in the subsequent recognition process using the compressed handwriting recognition model, after feature selection, the unit dimension of the hidden layer of the compressed handwriting recognition model will be greatly reduced, for example, from 512 dimensions to 256 dimensions or 128 dimensions, etc. When the dimension is reduced, its computational efficiency will be significantly improved, thereby improving the real-time recognition of the compressed handwriting recognition model.

[0071] After the compressed handwriting trajectory data is acquired, step S103 is executed.

[0072] Before executing step S103, a handwriting recognition model needs to be trained in advance, and then the trained handwriting recognition model is compressed to obtain a compressed handwriting recognition model. After the handwriting recognition model is trained, the compressed handwriting trajectory data is input into the compressed handwriting recognition model for recognition to obtain a text recognition result, wherein the handwriting recognition model is trained using the handwriting trajectory data of each training data in the training data set, and the compressed handwriting recognition model is obtained by compressing the handwriting recognition model.

[0073] In the embodiments of this specification, the handwriting recognition model is an end-to-end model, so that the input of the handwriting recognition model is compressed handwriting trajectory data, and the output is a text recognition result, which can effectively overcome the defects of using multiple modules for recognition in the prior art.

[0074] At this time, since the handwriting recognition model is trained using the handwriting trajectory data of each training data in the training data set, and the compressed handwriting trajectory data is obtained by dimensional compression of the original handwriting trajectory data, it can ensure that the compressed handwriting trajectory data maintains a large similarity with the trained handwriting trajectory data, so that when the compressed handwriting trajectory data is input into the handwriting recognition model for recognition, the recognition accuracy can be effectively improved. Moreover, since the correlation between the data of each dimension in the compressed handwriting trajectory data and the model recognition result is not less than the set threshold, the compressed handwriting trajectory data contains the main features representing the original features of the original handwriting trajectory data, so that when the compressed handwriting trajectory is input into the compressed handwriting recognition model for recognition, the recognition accuracy can be ensured.

[0075] In the embodiment of this specification, when training a handwriting recognition model, Figure 2 As shown, the training steps of the handwriting recognition model include:

[0076] S201, obtaining a training data set and a pre-selected training model corresponding to the training data set;

[0077] S202, obtaining handwriting trajectory data of each training data in the training data set;

[0078] S203, using the handwriting trajectory data of each training data to train the pre-selected training model, and obtain the trained pre-selected training model as the handwriting recognition model.

[0079] Among them, in step 201, a large number of users' handwriting trajectory data can be collected, all or part of the collected handwriting trajectory data can be used as a training data set, and a model can be selected from at least one model whose recognition accuracy for the training data set is greater than a preset threshold as a pre-selected training model, usually a model with the highest recognition accuracy is selected as the pre-selected training model. Of course, a model with the second highest or third highest recognition accuracy can also be selected as the pre-selected training model. For example, after obtaining the training data set, the recognition accuracy of the existing models A1, A2, A3 and A4 for the training data set is 85%, 70%, 65% and 92% respectively. If the preset threshold is 75%, since 92%>85%>75%, a model is randomly selected from A1 and A4 as the pre-selected training model; of course, in order to shorten the time of the subsequent training process, A4 with the highest recognition accuracy can be selected as the pre-selected training model.

[0080] In an embodiment of the present specification, when obtaining a training data set, a historical handwriting trajectory data set can also be obtained, wherein the historical handwriting trajectory data set includes one or more of horizontal handwriting trajectory data, vertical handwriting trajectory data, overlapping trajectory data, and rotated handwriting trajectory data; part or all of the data in the obtained historical handwriting trajectory data set can be used as a training data set.

[0081] Specifically, the program can generate multiple types of data, such as 5 and 6 types, to simulate real free writing scenarios, including horizontal line writing, vertical writing, overlapping writing and rotated writing, etc., thereby generating horizontal handwriting trajectory data, vertical handwriting trajectory data, overlapping writing trajectory data and rotated handwriting trajectory data, etc.; based on the horizontal handwriting trajectory data, vertical handwriting trajectory data, overlapping writing trajectory data and rotated handwriting trajectory data, etc., the historical handwriting trajectory data is obtained.

[0082] In the embodiments of this specification, after obtaining the historical handwriting trajectory data set, the handwriting data in the historical handwriting trajectory data set can also be data enhanced, and the historical handwriting trajectory data set after data enhancement is used as a training data set. In this case, the training data set contains more and richer training data. On the basis of more and richer training data, the model training effect can be improved, so that the accuracy of the handwriting recognition model trained using the training data will also be higher.

[0083] After the training data set is obtained, step S202 is performed.

[0084] In step S202, data preprocessing may be performed on each training data in the training data set; and handwriting trajectory data of each training data after preprocessing is obtained. The data preprocessing includes at least one of resampling and trajectory rotation. At this time, the data preprocessing may include resampling or trajectory rotation, or resampling and trajectory rotation, or resampling, trajectory rotation, trajectory cleaning, etc.

[0085] Specifically, data preprocessing generally includes resampling and trajectory rotation, so that when handwriting trajectory data of each training data is obtained according to each preprocessed training data, the obtained handwriting trajectory data of each training data has higher accuracy.

[0086] In the embodiments of this specification, the specific implementation of step S202 can refer to the description of the above step S102, and for the sake of brevity of the specification, it will not be repeated here.

[0087] After the handwriting trajectory data of each training data is acquired, step S203 is executed.

[0088] In step S103, when using the handwriting trajectory data of each training data to train the pre-selected training model, the difficult samples can be trained first and then the simple samples, and the pre-selected training model can be fine-tuned during the training process, and finally a model that meets the constraints is obtained as the trained pre-selected training model, and the trained pre-selected training model is used as the handwriting recognition model.

[0089] Specifically, the difficult samples and simple samples in each training data can be first obtained; then the pre-selected model is trained by first training the difficult samples and then training the simple samples; during the training of the pre-selected model, the pre-selected training model is fine-tuned to obtain a trained pre-selected training model, and the trained pre-selected training model is used as a handwriting recognition model.

[0090] In the embodiments of this specification, the pre-selected training model can be a GRU (Gated Recurrent Unit) neural network, a long short-term memory network (Long Short-Term Memory, referred to as LSTM), an attention network, an encoder-decoder network, and a quasi-recurrent neural network (Quasi-Recurrent Neural Network, referred to as QRNN), etc.

[0091] Specifically, when fine-tuning the pre-selected training model during the training process, the network in the pre-selected training model can be adjusted to a combination of a network for extracting Bessel features and a QRNN network or a combination of a network for extracting Bessel features and a GRU network. The difference is that the QRNN structure has a faster recognition speed. For example, a combination of a network for extracting differential features and a BLSTM network or a combination of the original trajectory, a one-dimensional convolutional layer and a BLSTM network can be used. The difference is that the latter adds a convolutional layer to extract features, which has better effects but costs more time.

[0092] Of course, when fine-tuning the pre-selected training model during the training process, the network in the pre-selected training model can also be adjusted to a combination of a GRU / LSTM network and a fully connected layer, a combination of an attention network and an encoder-decoder network, etc. This manual does not impose specific restrictions.

[0093] In this way, the pre-selected training model can be fine-tuned during the training process, and the network in the pre-selected training model can be quickly replaced with other networks, so that a better network can be found more quickly to shorten the fine-tuning time and improve the training efficiency. Then, a model that meets the constraints can be trained more quickly as the trained pre-selected training model, and the trained pre-selected training model can be used as a handwriting recognition model.

[0094] In the embodiments of the present specification, the constraint conditions may include at least one of the following conditions: the recognition accuracy is greater than the set accuracy, the error rate is greater than the set precision, the recall rate is greater than the set recall rate, and the loss function is solved.

[0095] Since the training data set is obtained by data enhancement of the handwriting data in the historical handwriting trajectory data set, the training data set contains more and richer training data; and when the pre-selected training model is used for training, the method of training the difficult samples first and then the simple samples is used, and fine-tuning is used in the training process. At this time, since the method of training the difficult samples first and then the simple samples is used, the model improves the recognition accuracy of the model for simple samples through fine-tuning in the later stage on the basis of improving the recognition accuracy of difficult samples, thereby ensuring that the recognition accuracy of the final end-to-end model recognition is higher. That is, it is possible to improve the recognition accuracy of difficult samples on the basis of ensuring the recognition accuracy of simple samples.

[0096] Thus, in step S103, after the compressed handwriting trajectory data is acquired in real time, the compressed handwriting trajectory data is input into the end handwriting recognition model trained by steps S201-S203 for recognition, and the recognized text is used as the text recognition result. Since the end handwriting recognition model trained by steps S201-S203 can improve the recognition accuracy for difficult samples on the basis of ensuring the recognition accuracy for simple samples, the accuracy of the text recognition result recognized after the compressed handwriting trajectory data is input is also high.

[0097] In the embodiment of the present specification, after the trained pre-selected training model is obtained through training in steps S201-S203, it is also necessary to compress the trained pre-selected training model to obtain a compressed pre-selected training model, and use the compressed pre-selected training model as a compressed handwriting recognition model; in this way, when executing step S103, the compressed handwriting trajectory data is input into the compressed pre-selected training model for recognition to obtain a text recognition result.

[0098] Since the compressed handwriting trajectory data is obtained by compressing the dimension of the original handwriting trajectory data, in the subsequent recognition process using the compressed handwriting recognition model, after feature selection, the unit dimension of the hidden layer of the compressed handwriting recognition model will be greatly reduced, for example, from 512 dimensions to 256 dimensions or 128 dimensions, etc. When the dimension is reduced, its computational efficiency will be significantly improved, thereby improving the real-time performance of the compressed handwriting recognition model.

[0099] Specifically, model compression methods include quantization (linear quantization and nonlinear quantization), distillation, pruning (structured and unstructured), NAS and matrix decomposition, etc. In this way, model compression can be used to compress the trained pre-selected training model, so that the compressed pre-selected training model is smaller, and the end-to-end model is smaller, and its computational and storage amounts will also be reduced, thereby meeting the requirements for deployment on mobile terminals.

[0100] In the embodiments of the present specification, the model compression method preferably uses model distillation. In this case, the trained pre-selected training model can be subjected to model distillation to obtain a distilled pre-selected training model, and the distilled pre-selected training model can be used as a compressed handwriting recognition model; the compressed handwriting trajectory data is then input into the compressed handwriting recognition model for recognition to obtain the text recognition result.

[0101] Specifically, model distillation includes methods such as feature-based distillation, logits-based distillation, and relationship-based distillation. After distillation, the model parameter volume can be reduced from 8M to 3M, and the accuracy is not reduced. In this way, the end-to-end model is smaller and the recognition accuracy is not reduced. After model distillation, nonlinear quantization processing can also be used. If the 3M parameter volume model is stored on the mobile terminal, each parameter is stored as a float type, and the model size is 3M×4byte=12M, which usually exceeds the conventional storage of the mobile terminal. After nonlinear quantization processing, the model parameters can be stored as int 8 type, that is, the final storage size is 3M×1byte=3M, which can meet the requirements of deployment on the mobile terminal. In this way, the model complexity after distillation is smaller, but the small model with basically unchanged accuracy is used as a compressed handwriting recognition model.

[0102] For example, the pre-selected training model is a complex model, specifically a 4-layer bidirectional LSTM+2FC (fully connected layer)+CTC LOSS. The logits-based distillation method is used to distill the complex model to obtain a small model of 2-layer unidirectional LSTM+1FC+CTC LOSS. The number of parameters is reduced by more than half, and the amount of calculation is also reduced accordingly, so that the requirement of making a model prediction for each transaction is met, and real-time streaming output is realized.

[0103] In this way, since the compressed handwriting trajectory data is obtained by dimensionally compressing the original handwriting trajectory data, in the subsequent recognition process using the compressed handwriting recognition model, after feature selection, the unit dimension of the hidden layer of the compressed handwriting recognition model will be greatly reduced, and the model parameter amount of the compressed handwriting recognition model will be reduced. When the unit dimension of the hidden layer is greatly reduced and the model parameter amount is reduced, the computational efficiency of the compressed handwriting recognition model will be increased. When the computational efficiency is increased, the real-time recognition can be effectively ensured.

[0104] The beneficial effects of the embodiments of the present invention are as follows:

[0105] Based on the above technical solution, after obtaining the original handwriting trajectory data in real time, the original handwriting trajectory data is compressed, and the compressed handwriting trajectory data is used as input. The handwriting sequence features of the compressed handwriting trajectory data are recognized through a compressed end-to-end model to obtain a text recognition result. Compared with the segmentation and combination recognition used in the prior art, when recognizing connected handwriting such as connected cursive script and connected running script, since there is no break in the middle of the connected handwriting, the probability of incorrect segmentation in the segmentation module is very high, resulting in a low recognition accuracy. The use of a compressed handwriting recognition model avoids the incorrect segmentation module, and uses the compressed handwriting trajectory data after the original handwriting trajectory data is compressed as input. The handwriting sequence features are used for recognition, which can effectively reduce the problem of low recognition accuracy caused by incorrect segmentation in the prior art, thereby effectively improving the recognition accuracy.

[0106] Moreover, since the compressed handwriting trajectory data is obtained by dimensional compression of the original handwriting trajectory data, in the subsequent recognition process using the compressed handwriting recognition model, after feature selection, the unit dimension of the hidden layer of the compressed handwriting recognition model will be greatly reduced, and the model parameter amount of the compressed handwriting recognition model will be reduced. When the unit dimension of the hidden layer is greatly reduced and the model parameter amount is reduced, the computational efficiency of the compressed handwriting recognition model will be increased. When the computational efficiency is increased, the real-time recognition can be effectively ensured.

[0107] Device Embodiment

[0108] Reference Figure 3 , shows a structural block diagram of an embodiment of a handwriting recognition device of the present invention, which may specifically include:

[0109] The handwriting trajectory acquisition module 301 is used to acquire the original handwriting trajectory data in real time;

[0110] A compressed trajectory acquisition module 302 is used to compress the original handwriting trajectory data to obtain compressed handwriting trajectory data;

[0111] The recognition module 303 is used to input the compressed handwriting trajectory data into the compressed handwriting recognition model for recognition, and obtain the text recognition result corresponding to the original handwriting trajectory data, wherein the handwriting recognition model is trained using the handwriting trajectory data of each training data in the training data set, and the compressed handwriting recognition model is obtained by model compression of the handwriting recognition model.

[0112] In an optional embodiment, the handwriting trajectory acquisition module 301 is used to perform data preprocessing on the handwriting input data acquired in real time, wherein the data preprocessing includes resampling; and acquire the handwriting original trajectory data in real time according to the preprocessed handwriting input data.

[0113] In an optional embodiment, the compressed trajectory acquisition module 302 is used to perform dimension compression on the original handwriting trajectory data to obtain the compressed handwriting trajectory data, wherein the correlation between the data of each dimension in the compressed handwriting trajectory data and the model recognition result of the handwriting recognition model is not less than a set threshold.

[0114] In an optional embodiment, the handwriting recognition model is an end-to-end model.

[0115] In an optional embodiment, the device further includes:

[0116] The model training module is used to obtain a training data set and a pre-selected training model corresponding to the training data set; obtain the handwriting trajectory data of each training data in the training data set; use the handwriting trajectory data of each training data to train the pre-selected training model, and obtain the trained pre-selected training model as the handwriting recognition model.

[0117] In an optional embodiment, the model training module includes:

[0118] A training data set acquisition unit is used to acquire a historical handwriting trajectory data set, wherein the historical handwriting trajectory data set includes one or more of horizontal handwriting trajectory data, vertical handwriting trajectory data, overlapping trajectory data and rotated handwriting trajectory data; data enhancement is performed on the handwriting data in the historical handwriting trajectory data set, and the historical handwriting trajectory data set after data enhancement is used as a training data set.

[0119] In an optional embodiment, the model training module includes:

[0120] The model training unit is used to obtain difficult samples and simple samples in each training data; the pre-selected model is trained by first training the difficult samples and then training the simple samples; during the training of the pre-selected model, the pre-selected training model is fine-tuned to obtain the trained pre-selected training model as the handwriting recognition model.

[0121] In an optional embodiment, the device further includes:

[0122] The compression model acquisition module is used to perform model distillation on the trained preselected training model to obtain the preselected training model after training the preselected training model to serve as the handwriting recognition model, and use the preselected training model after distillation as the compressed handwriting recognition model.

[0123] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0124] The various embodiments of the present invention are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the various embodiments can be referred to in detail.

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

[0126] Figure 4 9 is a block diagram of a handwriting recognition device as a device according to an exemplary embodiment. For example, the device 900 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0127] Reference Figure 4 , the device 900 may include one or more of the following components: a processing component 902 , a memory 904 , a power component 906 , a multimedia component 908 , an audio component 910 , an input / output (I / O) interface 912 , a sensor component 914 , and a communication component 916 .

[0128] The processing component 902 generally controls the overall operation of the device 900, such as operations associated with display, incoming calls, data communications, camera operations, and recording operations. The processing component 902 may include one or more processors 920 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 902 may include one or more modules to facilitate the interaction between the processing component 902 and other components. For example, the processing component 902 may include a multimedia module to facilitate the interaction between the multimedia component 908 and the processing component 902.

[0129] The memory 904 is configured to store various types of data to support operations on the device 900. Examples of such data include instructions for any application or method operating on the device 900, contact data, caller book data, messages, pictures, videos, etc. The memory 904 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0130] The power supply component 906 provides power to the various components of the device 900. The power supply component 906 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 900.

[0131] The multimedia component 908 includes a screen that provides an output interface between the device 900 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide motion action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 908 includes a front camera and / or a rear camera. When the device 900 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0132] The audio component 910 is configured to output and / or input audio signals. For example, the audio component 910 includes a microphone (MIC), and when the device 900 is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 904 or sent via the communication component 916. In some embodiments, the audio component 910 also includes a speaker for outputting audio signals.

[0133] I / O interface 912 provides an interface between processing component 902 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.

[0134] The sensor assembly 914 includes one or more sensors for providing various aspects of status assessment for the device 900. For example, the sensor assembly 914 can detect the open / closed state of the device 900, the relative positioning of components, such as the display and keypad of the device 900, and the sensor assembly 914 can also detect the position change of the device 900 or a component of the device 900, the presence or absence of user contact with the device 900, the orientation or acceleration / deceleration of the device 900, and the temperature change of the device 900. The sensor assembly 914 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 914 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 914 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0135] The communication component 916 is configured to facilitate wired or wireless communication between the device 900 and other devices. The device 900 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 916 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 916 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0136] In an exemplary embodiment, the apparatus 900 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above method.

[0137] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 904 including instructions, and the instructions can be executed by the processor 920 of the device 900 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0138] Figure 51 is a block diagram of the structure of the server in some embodiments of the present invention. The server 1900 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 1922 (for example, one or more processors) and memory 1932, and one or more storage media 1930 (for example, one or more mass storage devices) storing application programs 1942 or data 1944. Among them, the memory 1932 and the storage medium 1930 can be short-term storage or permanent storage. The program stored in the storage medium 1930 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the server. Furthermore, the central processing unit 1922 can be configured to communicate with the storage medium 1930 and execute a series of instruction operations in the storage medium 1930 on the server 1900.

[0139] The server 1900 may also include one or more power supplies 1926, one or more wired or wireless network interfaces 1950, one or more input and output interfaces 1958, one or more keyboards 1956, and / or, one or more operating systems 1941, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.

[0140] A non-temporary computer-readable storage medium. When the instructions in the storage medium are executed by a processor of a device (equipment or server), the device is able to execute a handwriting recognition method to obtain original handwriting trajectory data in real time; compress the original handwriting trajectory data to obtain compressed handwriting trajectory data; input the compressed handwriting trajectory data into a compressed handwriting recognition model for recognition, and obtain a text recognition result corresponding to the original handwriting trajectory data, wherein the handwriting recognition model is trained using the handwriting trajectory data of each training data in a training data set, and the compressed handwriting recognition model is obtained by model compression of the handwriting recognition model.

[0141] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1A process or multiple processes and / or boxes Figure 1 A device that has the functions specified in one or more boxes.

[0142] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0143] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0144] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.

[0145] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A handwriting recognition method, characterized in that: include: Acquiring original handwriting trajectory data in real time, including: performing data preprocessing on the handwriting input data acquired in real time, wherein the data preprocessing includes resampling and trajectory rotation, the resampling is angle-based resampling or distance-based resampling, or the resampling is angle-based and distance-based resampling; acquiring the original handwriting trajectory data in real time according to the preprocessed handwriting input data; The original handwriting trajectory data is compressed to obtain compressed handwriting trajectory data, which includes using a principal component analysis method to find and retain the main features representing the original features of the original handwriting trajectory data, ensuring that the correlation between the data of each dimension retained and the model recognition result of the handwriting recognition model is not less than a set threshold, and obtaining compressed handwriting trajectory data according to the data of each dimension retained, wherein the set threshold is to select and retain K features with the highest correlation with the model recognition result, and is set according to a feature with the lowest correlation among the K features, wherein K is an integer not less than 2; Input the compressed handwriting trajectory data into the compressed handwriting recognition model for recognition, and obtain the text recognition result corresponding to the original handwriting trajectory data, wherein the handwriting recognition model is trained using the handwriting trajectory data of each training data in the training data set, and the compressed handwriting recognition model is obtained by model compression of the handwriting recognition model, and the compressed handwriting trajectory data obtained by compressing the original handwriting trajectory data is used as the input of the compressed handwriting recognition model, and the handwriting sequence feature is used for recognition; Each time the original handwriting trajectory data of a stroke is obtained, the text recognition result is obtained once.

2. The method according to claim 1, characterized in that The handwriting recognition model is an end-to-end model.

3. The method according to claim 2, characterized in that The training steps of the handwriting recognition model include: Obtaining a training data set and a pre-selected training model corresponding to the training data set; Obtain handwriting trajectory data of each training data in the training data set; The pre-selected training model is trained using the handwriting trajectory data of each training data, and the trained pre-selected training model is obtained as the handwriting recognition model.

4. The method according to claim 3, characterized in that The step of obtaining a training data set includes: Acquire a historical handwriting trajectory data set, wherein the historical handwriting trajectory data set includes one or more of horizontal handwriting trajectory data, vertical handwriting trajectory data, overlapping handwriting trajectory data, and rotated handwriting trajectory data; Data enhancement is performed on the handwriting data in the historical handwriting trajectory dataset, and the historical handwriting trajectory dataset after data enhancement is used as a training dataset.

5. The method according to claim 4, characterized in that The method of training the pre-selected training model using the handwriting trajectory data of each training data to obtain the handwriting recognition model includes: Get the difficult samples and simple samples in each training data; Training the pre-selected training model by first training the difficult samples and then training the simple samples; During the training process of the pre-selected training model, the pre-selected training model is fine-tuned to obtain the trained pre-selected training model as the handwriting recognition model.

6. The method according to any one of claims 3 to 5, characterized in that: After training the pre-selected training model to obtain the trained pre-selected training model as the handwriting recognition model, the method further includes: Model distillation is performed on the trained pre-selected training model to obtain the distilled pre-selected training model, and the distilled pre-selected training model is used as the compressed handwriting recognition model.

7. A handwriting recognition device, characterized in that: include: A handwriting trajectory acquisition module is used to acquire original handwriting trajectory data in real time; Specifically used for performing data preprocessing on handwriting input data acquired in real time, wherein the data preprocessing includes resampling and trajectory rotation, the resampling is angle-based resampling or distance-based resampling, or the resampling is angle-based and distance-based resampling; according to the preprocessed handwriting input data, the handwriting original trajectory data is acquired in real time; A compressed trajectory acquisition module is used to compress the original handwriting trajectory data to obtain compressed handwriting trajectory data, which includes using a principal component analysis method to find the main features representing the original features of the original handwriting trajectory data and retaining them, ensuring that the correlation between the data of each dimension retained and the model recognition result of the handwriting recognition model is not less than a set threshold, and obtaining compressed handwriting trajectory data based on the data of each dimension retained, wherein the set threshold is to select K features with the highest correlation with the model recognition result for retention, and is set according to a feature with the lowest correlation among the K features, wherein K is an integer not less than 2; A recognition module, used for inputting the compressed handwriting trajectory data into a compressed handwriting recognition model for recognition, and obtaining a text recognition result corresponding to the original handwriting trajectory data, wherein the handwriting recognition model is trained using the handwriting trajectory data of each training data in the training data set, and the compressed handwriting recognition model is obtained by model compression of the handwriting recognition model, and the compressed handwriting trajectory data obtained by compressing the original handwriting trajectory data is used as the input of the compressed handwriting recognition model, and the handwriting sequence feature is used for recognition; Each time the original handwriting trajectory data of a stroke is obtained, the text recognition result is obtained once.

8. The device according to claim 7, characterized in that The handwriting recognition model is an end-to-end model.

9. The device according to claim 8, characterized in that Also includes: A model training module, used to obtain a training data set and a pre-selected training model corresponding to the training data set; Obtain handwriting trajectory data of each training data in the training data set; The pre-selected training model is trained using the handwriting trajectory data of each training data, and the trained pre-selected training model is obtained as the handwriting recognition model.

10. The device according to claim 9, characterized in that The model training module includes: A training data set acquisition unit is used to acquire a historical handwriting trajectory data set, wherein the historical handwriting trajectory data set includes one or more of horizontal handwriting trajectory data, vertical handwriting trajectory data, overlapping trajectory data and rotated handwriting trajectory data; data enhancement is performed on the handwriting data in the historical handwriting trajectory data set, and the historical handwriting trajectory data set after data enhancement is used as a training data set.

11. The device according to claim 10, characterized in that The model training module includes: The model training unit is used to obtain difficult samples and simple samples in each training data; train the pre-selected training model by first training the difficult samples and then training the simple samples; during the training of the pre-selected training model, fine-tune the pre-selected training model to obtain the trained pre-selected training model as the handwriting recognition model.

12. The device according to any one of claims 9 to 11, characterized in that: Also includes: The compression model acquisition module is used to perform model distillation on the trained preselected training model to obtain the preselected training model after training the preselected training model to serve as the handwriting recognition model, and use the preselected training model after distillation as the compressed handwriting recognition model.

13. A device for handwriting recognition, characterized in that: The invention comprises a memory, a processor, and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the processor to implement the method steps as claimed in any one of claims 1 to 6.

14. A machine-readable medium having instructions stored thereon, which when executed by one or more processors implement the method of one or more of claims 1-6.

Citation Information

Patent Citations

  • Dimension reduction method of handwritten digital image

    CN104573727A

  • Handwritten character recognition method

    CN104850837A

  • Dynamic input and recognition method for Chinese characters in computer

    CN1082732A

  • Handwritten Chinese character recognition method, device and equipment and storage medium

    CN109670559A

  • Input method and device and machine readable medium

    CN109992124A

Cited By

  • Handwriting recognition method and apparatus, electronic device, and medium

    EP4273742B1

  • Handwriting recognition method and apparatus, electronic device, and medium

    WO2022142212A1