Chinese character recognition method, device, computer equipment and storage medium

Through the adaptive margin loss function and multi-layer convolution sub-network, the problem of inaccurate recognition caused by the wide variety of Chinese characters and differences in handwriting styles in traditional handwritten Chinese character recognition is solved, and the recognition accuracy is improved.

CN112200216BActive Publication Date: 2024-09-24刘丽
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010916543.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-03
Publication Date
2024-09-24
Estimated Expiration
2040-09-03

AI Technical Summary

Technical Problem

Traditional handwritten Chinese character recognition methods have problems with inaccurate recognition, especially the difficulty in distinguishing them due to the wide variety of Chinese characters, similar stroke structures, and differences in handwriting styles.

Method used

A recognition network based on the adaptive margin loss function is used to extract and classify features of the Chinese character images to be recognized through multi-layer convolution sub-networks and expansion sub-networks. Different categories of Chinese characters are given different weights in the adaptive margin loss function. Increased concern about difficulty distinguishing Chinese characters.

Benefits of technology

It improves the recognition accuracy of handwritten Chinese characters, alleviates the recognition problems caused by similar Chinese character structures and blurred handwritten Chinese characters, and achieves accurate recognition of Chinese characters to be recognized.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112200216B
    Figure CN112200216B
Patent Text Reader

Abstract

The present application relates to a Chinese character recognition method, device, computer equipment and storage medium. The method comprises: obtaining a Chinese character image to be recognized; inputting the Chinese character image to be recognized into a preset recognition network, recognizing the Chinese character to be recognized in the Chinese character image to be recognized through the recognition network, and obtaining the category of the Chinese character to be recognized; wherein the recognition network is obtained by training according to sample images and an adaptive margin loss function, and different categories of Chinese characters have different weights in the adaptive margin loss function. The use of this method improves the recognition accuracy of the category to which the Chinese character to be recognized belongs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of image recognition and classification, and in particular to a Chinese character recognition method, apparatus, computer equipment and storage medium. Background Art

[0002] Due to the wide variety of Chinese characters and the similarity of their stroke structures, the recognition of handwritten Chinese characters has always been a widely studied and concerned issue. The recognition of handwritten Chinese characters has also been widely used in daily life. For example, automatic mail sorting, bank bill recognition and many other fields all require the recognition of handwritten Chinese characters.

[0003] In the conventional technology, the method for recognizing handwritten Chinese characters mainly extracts features from images including handwritten Chinese characters, and recognizes the handwritten Chinese characters based on the extracted image features.

[0004] However, the traditional method for recognizing handwritten Chinese characters has the problem of inaccurate recognition. Summary of the invention

[0005] Based on this, it is necessary to provide a Chinese character recognition method, device, computer equipment and storage medium that can improve the recognition accuracy of handwritten Chinese characters in response to the above technical problems.

[0006] A Chinese character recognition method, the method comprising:

[0007] Obtain the Chinese character image to be recognized;

[0008] The image of Chinese characters to be recognized is input into a preset recognition network, and the Chinese characters to be recognized in the image of Chinese characters to be recognized are recognized by the recognition network to obtain the category of the Chinese characters to be recognized; wherein the recognition network is obtained by training based on sample images and an adaptive margin loss function, and different categories of Chinese characters have different weights in the adaptive margin loss function.

[0009] In one embodiment, the recognition network includes a first convolutional subnetwork, a second convolutional subnetwork, a third convolutional subnetwork and an expansion subnetwork; the inputting the Chinese character image to be recognized into a preset recognition network, recognizing the Chinese character to be recognized in the Chinese character image to be recognized by the recognition network, and obtaining the category of the Chinese character to be recognized includes:

[0010] Inputting the Chinese character image to be recognized into the first convolutional subnetwork, performing feature extraction on the Chinese character image to be recognized through the first convolutional subnetwork, and obtaining a first feature map of the Chinese character image to be recognized;

[0011] Inputting the first feature map into the second convolutional subnetwork, and performing feature extraction on the first feature map through the second convolutional subnetwork to obtain a second feature map;

[0012] Inputting the second feature map into the third convolutional subnetwork, and performing feature extraction on the second feature map through the third convolutional subnetwork to obtain a third feature map;

[0013] The third feature map is input into the expansion sub-network, and the third feature map is subjected to feature extraction and classification by the expansion sub-network to obtain the category of the Chinese character to be recognized.

[0014] In one embodiment, the expansion subnetwork includes a first expansion convolution layer, a second expansion convolution layer, a third expansion convolution layer, a fourth expansion convolution layer and a classification layer; wherein the expansion coefficients of the first expansion convolution layer, the second expansion convolution layer, the third expansion convolution layer and the fourth expansion convolution layer are all different.

[0015] In one embodiment, the step of inputting the third feature map into the expansion subnetwork, extracting and classifying the third feature map through the expansion subnetwork, and obtaining the category of the Chinese character to be recognized includes:

[0016] Inputting the third feature map into the first dilated convolutional layer to obtain a fourth feature map;

[0017] Inputting the third feature map into the second dilated convolutional layer to obtain a fifth feature map;

[0018] Inputting the third feature map into the third dilated convolutional layer to obtain a sixth feature map;

[0019] Inputting the third feature map into the fourth dilated convolutional layer to obtain a seventh feature map;

[0020] The fourth feature map, the fifth feature map, the sixth feature map and the seventh feature map are input into the classification layer to obtain the category of the Chinese character to be recognized.

[0021] In one embodiment, the step of inputting the fourth feature map, the fifth feature map, the sixth feature map, and the seventh feature map into the classification layer to obtain the category of the Chinese character to be recognized includes:

[0022] The fourth feature map, the fifth feature map, the sixth feature map and the seventh feature map are input into the classification layer for feature fusion, and the category of the Chinese character to be recognized is obtained according to the fused features.

[0023] In one of the embodiments, the network structure of each convolutional subnetwork in the first convolutional subnetwork, the second convolutional subnetwork, and the third convolutional subnetwork includes a convolutional layer, a batch normalization layer, and an activation layer.

[0024] In one embodiment, the training process of the recognition network includes:

[0025] Obtaining a sample Chinese character image to be recognized and a label of the sample Chinese character to be recognized in the sample Chinese character image to be recognized;

[0026] Inputting the sample Chinese character image to be recognized into a preset initial recognition network, recognizing the sample Chinese character to be recognized through the initial recognition network, and obtaining a sample category of the sample Chinese character to be recognized;

[0027] The value of the adaptive margin loss function is obtained according to the sample category and the label of the Chinese character to be recognized in the sample, and the initial recognition network is trained according to the value of the adaptive margin loss function to obtain the recognition network.

[0028] A Chinese character recognition device, comprising:

[0029] The first acquisition module is used to acquire the image of the Chinese character to be recognized;

[0030] A recognition module is used to input the Chinese character image to be recognized into a preset recognition network, and recognize the Chinese character to be recognized in the Chinese character image to be recognized through the recognition network to obtain the category of the Chinese character to be recognized; wherein the recognition network is obtained by training based on sample images and an adaptive margin loss function, and different categories of Chinese characters have different weights in the adaptive margin loss function.

[0031] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0032] Obtain the Chinese character image to be recognized;

[0033] The image of Chinese characters to be recognized is input into a preset recognition network, and the Chinese characters to be recognized in the image of Chinese characters to be recognized are recognized by the recognition network to obtain the category of the Chinese characters to be recognized; wherein the recognition network is obtained by training based on sample images and an adaptive margin loss function, and different categories of Chinese characters have different weights in the adaptive margin loss function.

[0034] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:

[0035] Obtain the Chinese character image to be recognized;

[0036] The image of Chinese characters to be recognized is input into a preset recognition network, and the Chinese characters to be recognized in the image of Chinese characters to be recognized are recognized by the recognition network to obtain the category of the Chinese characters to be recognized; wherein the recognition network is obtained by training based on sample images and an adaptive margin loss function, and different categories of Chinese characters have different weights in the adaptive margin loss function.

[0037] The above-mentioned Chinese character recognition method, device, computer equipment and storage medium, the computer equipment inputs the acquired Chinese character image to be recognized into a preset recognition network. Since the recognition network is obtained by training based on sample images and adaptive margin loss functions, and different categories of Chinese characters have different weights in the adaptive margin loss function, in the process of training the recognition network, the recognition network can pay more attention to Chinese characters that are more difficult to distinguish. This can enable the recognition network to alleviate the problem of difficulty in recognition caused by similar Chinese character structures and blurred handwritten Chinese characters to a certain extent. Therefore, the obtained recognition network can accurately recognize the Chinese characters to be recognized in the Chinese character image to be recognized, thereby improving the recognition accuracy of the category to which the Chinese characters to be recognized belong. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 A diagram showing an application environment of a Chinese character recognition method in an embodiment;

[0039] Figure 1a A schematic diagram of handwritten Chinese characters provided in one embodiment;

[0040] Figure 2 A schematic diagram of a flow chart of a Chinese character recognition method in an embodiment;

[0041] Figure 3 is a flow chart of a Chinese character recognition method in another embodiment;

[0042] Figure 4 A schematic diagram of a structure of an identification network in one embodiment;

[0043] Figure 5 is a flow chart of a Chinese character recognition method in another embodiment;

[0044] Figure 6 4 is a structural block diagram of a Chinese character recognition device in one embodiment. DETAILED DESCRIPTION

[0045] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0046] The Chinese character recognition method provided by the embodiments of this application can be applicable to a computer device as shown in Figure 1 the following. The computer device includes a processor and a memory connected through a system bus. A computer program is stored in the memory. When the processor executes the computer program, it can execute the steps of the following method embodiments. Optionally, the computer device may further include a network interface, a display screen, and an input device. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. Optionally, the computer device may be a server, a personal computer, a personal digital assistant, or other terminal devices, such as a tablet computer, a mobile phone, etc., or it may be a cloud or a remote server. The embodiments of this application do not limit the specific form of the computer device.

[0047] There are a large number of Chinese characters with similar stroke structures, making them difficult to recognize. All along, the recognition of handwritten Chinese characters has been a widely concerned and studied topic. The existing Chinese character set encodings currently include: GB2312 encoding, BIG5 encoding, GBK encoding, and GB18030 encoding; among them, GB2312 encoding contains 6,763 Chinese characters; BIG5 encoding includes 13,053 Chinese characters; GBK encoding includes 21,003 Chinese characters; GB18030 encoding includes 27,484 Chinese characters. The two main challenges currently faced in handwritten Chinese character recognition are: 1. Due to the inherent radical structure of Chinese characters, many Chinese characters have the same radical or radical components. For example, the three characters "大", "太", and "犬" only differ by a single dot, and the characters "译", "泽", and "绎" have a common radical. Moreover, the large character set results in a large number of similar Chinese characters; 2. The handwriting styles of different people vary greatly. In many cases, connected strokes can cause difficulties in recognition. As shown in Figure 1a the following, the connected strokes in handwriting make it difficult to distinguish between "芝" and "芒".

[0048] In one embodiment, as shown in Figure 2 the following, a Chinese character recognition method is provided. Taking the application of this method to the computer device in Figure 1 as an example for description, the method includes the following steps:

[0049] S201, obtain an image of the Chinese character to be recognized.

[0050] Among them, the image of Chinese characters to be recognized is an image including a single Chinese character to be recognized. Optionally, the computer device can first obtain an image containing handwritten Chinese characters, and then segment the handwritten Chinese characters in the image to obtain the image of Chinese characters to be recognized. It can be understood that the computer device can obtain the corresponding number of images of Chinese characters to be recognized according to the number of Chinese characters included in the acquired image containing handwritten Chinese characters. Optionally, the computer device can obtain an image containing handwritten Chinese characters from a Chinese character database. Optionally, the computer device can segment the Chinese characters in the image containing handwritten Chinese characters according to a preset segmentation template to obtain the above-mentioned image of Chinese characters to be recognized, or the image containing handwritten Chinese characters can be input into a preset segmentation model to segment the Chinese characters in the image containing handwritten Chinese characters to obtain the above-mentioned image of Chinese characters to be recognized.

[0051] S202, inputting the image of Chinese characters to be recognized into a preset recognition network, recognizing the Chinese characters to be recognized in the image of Chinese characters to be recognized through the recognition network, and obtaining the category of the Chinese characters to be recognized; wherein the recognition network is obtained by training based on sample images and an adaptive margin loss function, and different categories of Chinese characters have different weights in the adaptive margin loss function.

[0052] Specifically, the computer device inputs the above-obtained Chinese character image to be recognized into a preset recognition network, and recognizes the Chinese character to be recognized in the above-mentioned Chinese character image to be recognized through the recognition network, thereby obtaining the category of the Chinese character to be recognized. Among them, the above-mentioned recognition network is obtained by training according to the sample image and the adaptive margin loss function, and the weights of Chinese characters of different categories in the adaptive margin loss function are different. It can be understood that the recognition of Chinese characters is essentially a classification problem. Each Chinese character is a category. The loss function used in the common classification network is mostly the softmax loss function. However, in the face of a huge number of categories, as well as the differences within various classes and the similarities between classes, the softmax loss function often does not play a good role. In the classification problem, the distance between the classification plane and the data samples on both sides is called the margin. The principle of the support vector machine (SVM) is to find a maximum margin classifier so that the distance from the classification plane to the two category samples is equal. Therefore, in order to improve the classification ability in the classification problem, a margin-based loss function is proposed, such as a large margin loss function, an additional margin loss function, and a large margin cosine loss function, etc. These loss functions basically convert the original softmax loss into a cosine loss through feature normalization, and add a margin in the cosine space. The role of this margin is to maximize the distance from the decision boundary to the training sample in the classifier training, thereby improving the classification ability. However, the existing margin-based loss functions are all fixed margins, that is, the distance from the classification plane to the samples on both sides is the same. However, there are many types of Chinese characters and the stroke structures are similar. In order to improve the recognition accuracy of Chinese characters, if the constraint of the fixed margin can be cancelled and the margin can be adaptively adjusted according to the difficulty of the training samples, more attention can be paid to the Chinese character categories that are more difficult to distinguish, and their proportion in the loss function can be increased. Therefore, the adaptive margin loss function proposed in this application enables the margin to be adjusted accordingly according to different Chinese character categories, so that the Chinese character categories with higher recognition difficulty get higher weights, which to a certain extent alleviates the problem of similar Chinese character structures and blurred handwritten Chinese characters that are difficult to recognize.

[0053] The adaptive margin loss function proposed in the embodiment of the present application is described in detail below:

[0054] The Softmax loss function is the most widely used loss function in deep learning multi-classification tasks. The Softmax loss function is a combination of the Softmax function and the cross-entropy loss. The two together make numerical calculations more stable and simple to derive. The Softmax function, or normalized exponential function, can map the input to the (0,1) interval to obtain the probability that the object to be classified belongs to a certain category. The definition of the Softmax function is, let z be the input of the Softmax layer, f(z) be the output of the Softmax layer, then the probability that the object to be classified belongs to the kth category is: In the formula, j is all categories, so the definition of the Softmax loss function is: L = -∑ k y k log f(z k ), where y=(y0,y1,L,y n ),y i ∈{0,1} is the category label. In the usual multi-classification problem, only one element of y has a value of 1, and the others are all 0. So assuming i is the true category, then z i Only y in the label i =1, based on which the original softmax loss function is defined as: In a neural network, a fully connected layer is usually connected before the loss function layer, that is, the input of the Softmax loss is generally the output of the fully connected layer. Let X be the input of the fully connected layer and W be the coefficient matrix of the fully connected layer. Then z in the Softmax loss function is j It can be expressed as In the formula, is the jth column of W, θ j (0≤θ j ≤π) is the vector W j The angle between ||W and X. In order to simplify the problem, the coefficients and features are normalized, that is, ||W j ||=1,||X||=1, at the same time, in order to improve the classification ability of the model, cos(θ j ) is replaced by cos(θ j )-m, that is, a margin m (m>0) is added in the cosine space. Based on this, the additional margin loss function is obtained as: Where s is the scale factor, and the role of the margin m is to make the training features more compact and centralized. However, in many classification problems, there are simple samples and complex samples. The classification difficulty of some similar categories will be greater than that of others. In addition, the proportion of complex samples in the total number is small, and most samples are simple samples. This will cause the loss of complex samples to be buried in the problem of simple samples, making the final loss function completely dominated by simple samples. Therefore, in order to measure the classification difficulty of samples, the normalized exponential probability of softmax output is used as an indicator: Where p represents the probability that the sample is correctly classified, and the adaptive margin function is defined as: A =α(1-P) γ ,γ>0, where α is the upper limit of the margin. It can be understood that the adaptive margin function has two properties: (1) If a complex sample is far from the center of the category and is misclassified, then p is smaller, making the margin m approach the maximum value α, resulting in more stringent conditions for correct classification and a greater penalty for misclassification. Conversely, for simple samples, p approaches 1, then the margin approaches 0, making the loss equivalent to the softmax loss; (2) The parameter γ can smoothly control the margin effect between simple and complex samples. When γ = 0, m A becomes a fixed margin, and if γ increases, the margin effect increases accordingly. It is worth noting that m A is determined by p, for different samples m A Different, that is, the adaptability between samples is different, so the loss function obtained by replacing the additional margin with the adaptive margin is: It should be noted here that in actual training, α is not a fixed value, but a sigmoid function that increases with the number of iterations. That is to say, at the beginning of training, the loss function is approximately equal to the original softmax loss. As training progresses, the number of iterations increases, and the influence of the margin effect gradually increases, which can ensure the stability of training and accelerate convergence.

[0055] In this embodiment, the computer device inputs the acquired Chinese character image to be recognized into a preset recognition network. Since the recognition network is trained based on sample images and an adaptive margin loss function, and different categories of Chinese characters have different weights in the adaptive margin loss function, in the process of training the recognition network, the recognition network can pay more attention to Chinese characters that are difficult to distinguish. This can alleviate the problem of difficulty in recognition caused by the similarity of Chinese character structures and the ambiguity of handwritten Chinese characters to a certain extent. Therefore, the obtained recognition network can accurately recognize the Chinese characters to be recognized in the Chinese character image to be recognized, thereby improving the recognition accuracy of the category to which the Chinese characters to be recognized belong.

[0056] In the above scenario where the image of the Chinese character to be recognized is input into a preset recognition network, and the recognition network recognizes the Chinese character to be recognized in the image of the Chinese character to be recognized, the recognition network extracts features from the image of the Chinese character to be recognized, and recognizes the Chinese character to be recognized based on the extracted features. Figure 3 As shown, based on the above embodiment, as an optional implementation, the recognition network includes a first convolution subnetwork, a second convolution subnetwork, a third convolution subnetwork and an expansion subnetwork; the above S203 includes:

[0057] S301, inputting the Chinese character image to be recognized into the first convolutional sub-network, performing feature extraction on the Chinese character image to be recognized through the first convolutional sub-network, and obtaining a first feature map of the Chinese character image to be recognized.

[0058] Specifically, the computer device inputs the above-mentioned Chinese character image to be recognized into the first convolution subnetwork of the recognition network, and extracts features of the Chinese character image to be recognized through the first convolution subnetwork to obtain a first feature map of the Chinese character image to be recognized. Optionally, before the computer device inputs the Chinese character image to be recognized into the recognition network, it can convert the Chinese character image to be recognized into a grayscale image and subtract the mean of the Chinese character image to be recognized to obtain a processed Chinese character image to be recognized, and input the processed Chinese character image to be recognized into the recognition network. Optionally, the size of the Chinese character image to be recognized input into the recognition network can be 96*96, or other sizes, which is not limited in this embodiment. Optionally, the first convolution subnetwork can include a convolution layer and a pooling layer, the convolution layer is used to extract features of the Chinese character image to be recognized, and the pooling layer is used to further reduce the dimensionality of the features extracted by the convolution layer to reduce the amount of calculation, and strengthen the invariance of the image features, so as to increase the robustness of the image in terms of displacement and rotation.

[0059] S302: Input the first feature map into the second convolutional subnetwork, and perform feature extraction on the first feature map through the second convolutional subnetwork to obtain a second feature map.

[0060] Specifically, the computer device inputs the first feature map obtained above into the second convolutional subnetwork of the recognition network, and extracts features from the first feature map through the second convolutional subnetwork to obtain a second feature map. Optionally, the second convolutional subnetwork may also include a convolutional layer and a pooling layer. The number of convolutional layers may be one, two or more. Similarly, the convolutional layer is used to extract features of the second feature map, and the pooling layer is used to further reduce the dimension of the features extracted by the convolutional layer to reduce the amount of calculation and enhance the invariance of the image features, thereby increasing the robustness of the image in terms of displacement, rotation, etc. Optionally, the second convolutional subnetwork may include two convolutional subnetworks with the same convolutional network structure, or may include multiple convolutional subnetworks with the same convolutional network structure.

[0061] S303: Input the second feature map into the third convolutional sub-network, and perform feature extraction on the second feature map through the third convolutional sub-network to obtain a third feature map.

[0062] Specifically, the computer device inputs the second feature map obtained above into the third convolutional subnetwork of the recognition network, and extracts features from the second feature map through the third convolutional subnetwork to obtain a third feature map. Optionally, the third convolutional subnetwork may also include a convolutional layer and a pooling layer. The number of convolutional layers may be one, two or more. Similarly, the convolutional layer is used to extract features of the third feature map, and the pooling layer is used to further reduce the dimension of the features extracted by the convolutional layer to reduce the amount of calculation, and to enhance the invariance of image features, so as to increase the robustness of the image in terms of displacement, rotation, etc.

[0063] S304, inputting the third feature map into the expansion sub-network, extracting and classifying the features of the third feature map through the expansion sub-network, and obtaining the category of the Chinese character to be recognized.

[0064] Specifically, the computer inputs the obtained third feature map into the expansion subnetwork of the recognition network, extracts and classifies the third feature map through the expansion subnetwork, and obtains the category of the Chinese character to be recognized. Optionally, the expansion subnetwork includes a first expansion convolution layer, a second expansion convolution layer, a third expansion convolution layer, a fourth expansion convolution layer and a classification layer; wherein the expansion coefficients of the first expansion convolution layer, the second expansion convolution layer, the third expansion convolution layer, and the fourth expansion convolution layer are different, and it should be noted that the expansion operation of each expansion convolution layer can expand the size of the convolution kernel from k×k to r×(k-1)+1, wherein r is the expansion coefficient. Optionally, the computer device can input the third feature map into the first dilated convolution layer, obtain the fourth feature map through the first dilated convolution layer, input the third feature map into the second dilated convolution layer, obtain the fifth feature map through the second dilated convolution layer, input the third feature map into the third dilated convolution layer, obtain the sixth feature map through the third dilated convolution layer, input the third feature map into the fourth dilated convolution layer, obtain the seventh feature map through the fourth dilated convolution layer, and then input the obtained fourth feature map, fifth feature map, sixth feature map and seventh feature map into the classification layer to obtain the category of the Chinese character to be recognized. Optionally, after the fourth feature map, fifth feature map, sixth feature map and seventh feature map are input into the classification layer, the classification layer can perform feature fusion on the fourth feature map, fifth feature map, sixth feature map and seventh feature map, and obtain the category of the Chinese character to be recognized based on the fused features. It can be understood that since the expansion coefficients of the first expansion convolution layer, the second expansion convolution layer, the third expansion convolution layer, and the fourth expansion convolution layer are all different, each expansion convolution layer can perform feature extraction on the third feature map from different dimensions. Extracting features from the third feature map from different dimensions can enrich the extracted feature information, and extracting features from the third feature map from different dimensions can increase the receptive field of the recognition network. Therefore, the Chinese characters to be recognized can be accurately classified according to the extracted feature information of different dimensions, thereby accurately obtaining the category of the Chinese characters to be recognized.

[0065] In this embodiment, the computer device inputs the image of the Chinese character to be recognized into the first convolutional subnetwork, and the first convolutional subnetwork can accurately extract features of the image of the Chinese character to be recognized, so that the first feature map of the image of the Chinese character to be recognized can be accurately obtained, and then the first feature map with higher accuracy can be input into the second convolutional subnetwork, and the first feature map is accurately extracted through the second convolutional subnetwork to obtain a second feature map with higher accuracy, and then the second feature map with higher accuracy can be input into the third convolutional subnetwork, and the second feature map is accurately extracted through the third convolutional subnetwork to obtain a third feature map with higher accuracy. Since the accuracy of the third feature map is improved, the third feature map can be input into the expansion subnetwork, and the third feature map is accurately extracted and classified through the expansion subnetwork, thereby improving the recognition accuracy of the category to which the Chinese character to be recognized belongs.

[0066] In one embodiment, based on the above embodiment, as an optional implementation, the network structure of each convolutional subnetwork in the first convolutional subnetwork, the second convolutional subnetwork, and the third convolutional subnetwork includes a convolutional layer, a batch normalization layer, and an activation layer.

[0067] Specifically, the network structure of each convolutional subnetwork in the first convolutional subnetwork, the second convolutional subnetwork, and the third convolutional subnetwork included in the above-mentioned recognition network includes a convolutional layer, a batch normalization layer, and an activation layer. Among them, the activation function used in the activation layer is the PReLu activation function. It should be noted that the PReLu activation function used in the activation layer can make the recognition network converge faster. Optionally, the size of the convolution kernel of the convolutional layer can be 3×3, the step size can be 1, and the padding size can be 1.

[0068] In this embodiment, the network structure of each of the first convolutional subnetwork, the second convolutional subnetwork, and the third convolutional subnetwork included in the recognition network includes a convolutional layer, a batch normalization layer, and an activation layer, so that accurate feature extraction can be performed through each convolutional subnetwork, thereby improving the accuracy of the extracted features, and then the category of the Chinese characters to be recognized can be accurately identified based on the features extracted by each convolutional subnetwork; in addition, the activation layer included in the network structure of each convolutional subnetwork can accelerate the convergence speed of the network, making the network converge faster.

[0069] In order to facilitate the understanding of those skilled in the art, the recognition network provided by this application is described in detail below. Figure 4As shown in the figure, the network includes: a first convolutional subnetwork (Block A), three second convolutional subnetworks (Block B), a third convolutional subnetwork (Block C) and an expansion subnetwork (Block D). Among them, the first convolutional subnetwork includes a convolutional layer (conv1) and a pooling layer (pool1), the second convolutional subnetwork includes two convolutional layers (conv2 and conv3) and a pooling layer (pool2), and the third convolutional subnetwork includes three convolutional layers (conv8, conv9 and conv10) and a pooling layer (pool5). It should be noted that the structures of the convolutional layers conv1, conv2...conv10 all include a convolutional layer (Conv), a batch normalization layer (BN) and an activation layer (PReLU), that is, the Conv-BN-PReLU structure; the expansion subnetwork includes the first expansion convolutional layer (conv1) and a pooling layer (pool1). Convolution layer (dilate_conv1), the second dilated convolution layer (dilate_conv2), the third dilated convolution layer (dilate_conv3), the fourth dilated convolution layer (dilate_conv4) and the classification layer (sum_dilate). Furthermore, the classification layer (sum_dilate) includes three fully connected layers (fc1, fc2 and output). Therefore, it can be seen that the overall network of the recognition network includes 10 Conv-BN-PReLU structures, 4 identical dilated convolution layers and 3 fully connected layers, so the recognition network can be named HCCR (Handwritten Chinese Character Recognition) 14 network. For example, please refer to Figure 4 , Figure 4 Assuming the size of the input Chinese character image to be recognized is 96*96, the recognition process of the recognition network on the category to which the Chinese character to be recognized in the Chinese character image belongs is explained.

[0070] In the above scenario where the image of the Chinese character to be recognized is input into a preset recognition network, the recognition network is a pre-trained network. In one embodiment, Figure 5 As shown, based on the above embodiment, as an optional implementation manner, the training process of the above recognition network includes:

[0071] S501, obtaining a sample Chinese character image to be recognized and a label of the sample Chinese character to be recognized in the sample Chinese character image to be recognized.

[0072] Specifically, the computer device first obtains a sample image of Chinese characters to be recognized and a label of the sample Chinese characters to be recognized in the sample image of Chinese characters to be recognized. Optionally, the computer device may first obtain a sample image containing handwritten Chinese characters, and then segment the handwritten Chinese characters in the sample image to obtain a sample image of Chinese characters to be recognized. It can be understood that the computer device can obtain a corresponding number of sample images of Chinese characters to be recognized according to the number of Chinese characters included in the obtained sample image containing handwritten Chinese characters. Optionally, the computer device may obtain a sample image containing handwritten Chinese characters from a Chinese character database. Optionally, the computer device may segment the Chinese characters in the sample image containing handwritten Chinese characters according to a preset segmentation template to obtain the above-mentioned sample image of Chinese characters to be recognized, or the sample image containing handwritten Chinese characters may be input into a preset segmentation model, and the Chinese characters in the sample image containing handwritten Chinese characters may be segmented to obtain the above-mentioned sample image of Chinese characters to be recognized. Optionally, the computer device may obtain the label of the sample Chinese characters to be recognized in the sample image of Chinese characters to be recognized from the above-mentioned Chinese character database. Exemplarily, the computer device may obtain sample Chinese character images to be recognized and labels of sample Chinese characters to be recognized in the sample Chinese character images to be recognized from the CASIA-HWDB1.0 and CASIA-HWDB1.1 handwritten Chinese character datasets.

[0073] S502, inputting the sample Chinese character image to be recognized into a preset initial recognition network, recognizing the sample Chinese character to be recognized through the initial recognition network, and obtaining the sample category of the sample Chinese character to be recognized.

[0074] Specifically, the computer device inputs the acquired sample Chinese character image to be recognized into a preset initial recognition network, and recognizes the sample Chinese character to be recognized through the initial recognition network to obtain the sample category of the sample Chinese character to be recognized. It should be noted here that the network structure of the preset initial recognition network is the same as the network structure of the recognition network described in the above embodiment, and this embodiment will not be repeated here. Taking the training set CASIA-HWDB1.0 and CASIA-HWDB1.1 used by the computer device as an example, the training set includes 2.67 million training samples, which are divided into 3755 categories, each category represents a Chinese character, and when the computer device trains the initial recognition network, the sample category of the sample Chinese character to be recognized obtained can be any of these 3755 categories.

[0075] S503, obtaining a value of an adaptive margin loss function according to the sample category and the label of the Chinese character to be recognized in the sample, and training an initial recognition network according to the value of the adaptive margin loss function to obtain a recognition network.

[0076] Specifically, the computer device obtains the value of the adaptive margin loss function according to the sample category of the sample Chinese characters to be recognized and the label of the sample Chinese characters to be recognized, and trains the initial recognition network according to the value of the adaptive margin loss function until the value of the adaptive margin loss function reaches a stable value, thereby obtaining the above-mentioned recognition network. Among them, the computer device can obtain the value of the adaptive margin loss function according to the sample category of the sample Chinese characters to be recognized and the label of the sample Chinese characters to be recognized, as well as the formula of the adaptive margin loss function in S202 above. It should be noted that in actual testing, taking the test set including 22 samples as an example, the trained recognition network obtained a recognition accuracy rate of 97.45% on the test set.

[0077] In this embodiment, the computer device inputs the acquired sample Chinese character image to be recognized into a preset initial recognition network, and the initial recognition network can recognize the sample Chinese character to be recognized to obtain the sample category of the sample Chinese character to be recognized. In this way, the computer device can obtain the value of the adaptive margin loss function according to the labels of the sample Chinese character to be recognized in the sample Chinese character image with a large amount of data and the obtained sample category of the sample Chinese character to be recognized, and then according to the obtained value of the adaptive margin loss function, the initial recognition network can be accurately trained, thereby improving the accuracy of the obtained recognition network.

[0078] To facilitate understanding by those skilled in the art, the Chinese character recognition method provided by the present application is described in detail below. The method may include:

[0079] S601, obtaining an adaptive margin loss function according to the Softmax loss function.

[0080] S602, constructing an initial recognition network; wherein the initial recognition network includes a first convolutional subnetwork, three second convolutional subnetworks, a third convolutional subnetwork and an expansion subnetwork; the first convolutional subnetwork includes a convolutional layer and a pooling layer; the second convolutional subnetwork includes two convolutional layers and a pooling layer, the third convolutional subnetwork includes three convolutional layers and a pooling layer, and the structure of each convolutional layer is a Conv-BN-PReLU structure; the expansion subnetwork includes a first expansion convolutional layer, a second expansion convolutional layer, a third expansion convolutional layer, a fourth expansion convolutional layer and a classification layer; and the expansion coefficients of each expansion convolutional layer in the first expansion convolutional layer, the second expansion convolutional layer, the third expansion convolutional layer and the fourth expansion convolutional layer are all different.

[0081] S603, obtaining a sample Chinese character image to be recognized and a label of the sample Chinese character to be recognized in the sample Chinese character image to be recognized.

[0082] S604, inputting the sample Chinese character image to be recognized into a preset initial recognition network, recognizing the sample Chinese character to be recognized through the initial recognition network, and obtaining a sample category of the sample Chinese character to be recognized.

[0083] S605, obtaining a value of an adaptive margin loss function according to the sample category and the label of the Chinese character to be recognized in the sample, and training an initial recognition network according to the value of the adaptive margin loss function to obtain a recognition network.

[0084] S606, obtaining the image of the Chinese character to be recognized.

[0085] S607, inputting the image of the Chinese character to be recognized into a preset recognition network, recognizing the Chinese character to be recognized in the image of the Chinese character to be recognized through the recognition network, and obtaining the category of the Chinese character to be recognized.

[0086] It should be noted that for the description in the above S601-S607, reference may be made to the relevant description in the above embodiment, and the effects are similar, which will not be repeated in this embodiment.

[0087] It should be understood that although Figure 2-5 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2-5 At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.

[0088] In one embodiment, Figure 6 As shown, a Chinese character recognition device is provided, comprising: a first acquisition module and a recognition module, wherein:

[0089] The first acquisition module is used to acquire the image of the Chinese character to be recognized.

[0090] The recognition module is used to input the image of Chinese characters to be recognized into a preset recognition network, and recognize the Chinese characters to be recognized in the image of Chinese characters to be recognized through the recognition network to obtain the category of the Chinese characters to be recognized; wherein the recognition network is obtained by training based on sample images and an adaptive margin loss function, and different categories of Chinese characters have different weights in the adaptive margin loss function.

[0091] The Chinese character recognition device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.

[0092] On the basis of the above embodiment, optionally, the above recognition network includes a first convolution subnetwork, a second convolution subnetwork, a third convolution subnetwork and an expansion subnetwork; the recognition module includes: a first acquisition unit, a second acquisition unit, a third acquisition unit and a recognition unit, wherein:

[0093] The first acquisition unit is used to input the Chinese character image to be recognized into the first convolutional sub-network, perform feature extraction on the Chinese character image to be recognized through the first convolutional sub-network, and obtain a first feature map of the Chinese character image to be recognized.

[0094] The second acquisition unit is used to input the first feature map into the second convolutional subnetwork, and extract features from the first feature map through the second convolutional subnetwork to obtain a second feature map.

[0095] The third acquisition unit is used to input the second feature map into the third convolutional sub-network, and perform feature extraction on the second feature map through the third convolutional sub-network to obtain a third feature map.

[0096] The recognition unit is used to input the third feature map into the expansion subnetwork, extract and classify the features of the third feature map through the expansion subnetwork, and obtain the category of the Chinese character to be recognized.

[0097] Optionally, the expansion subnetwork includes a first expansion convolution layer, a second expansion convolution layer, a third expansion convolution layer, a fourth expansion convolution layer and a classification layer; wherein the expansion coefficients of the first expansion convolution layer, the second expansion convolution layer, the third expansion convolution layer, and the fourth expansion convolution layer are all different.

[0098] Optionally, the network structure of each convolutional subnetwork in the first convolutional subnetwork, the second convolutional subnetwork, and the third convolutional subnetwork includes a convolutional layer, a batch normalization layer, and an activation layer.

[0099] The Chinese character recognition device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.

[0100] On the basis of the above embodiments, optionally, the recognition unit is specifically used to input the third feature map into the first dilated convolution layer to obtain a fourth feature map; input the third feature map into the second dilated convolution layer to obtain a fifth feature map; input the third feature map into the third dilated convolution layer to obtain a sixth feature map; input the third feature map into the fourth dilated convolution layer to obtain a seventh feature map; input the fourth feature map, the fifth feature map, the sixth feature map and the seventh feature map into the classification layer to obtain the category of the Chinese character to be recognized.

[0101] The Chinese character recognition device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.

[0102] On the basis of the above embodiment, optionally, the recognition unit is specifically used to input the fourth feature map, the fifth feature map, the sixth feature map and the seventh feature map into the classification layer for feature fusion, and obtain the category of the Chinese character to be recognized according to the fused features.

[0103] The Chinese character recognition device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.

[0104] On the basis of the above embodiment, optionally, the above device further includes: a second acquisition module, a third acquisition module and a training module, wherein:

[0105] The second acquisition module is used to acquire the sample Chinese character image to be recognized and the label of the sample Chinese character to be recognized in the sample Chinese character image to be recognized.

[0106] The third acquisition module is used to input the sample Chinese character image to be recognized into a preset initial recognition network, recognize the sample Chinese character to be recognized through the initial recognition network, and obtain the sample category of the sample Chinese character to be recognized.

[0107] The training module is used to obtain the value of the adaptive margin loss function according to the sample category and the label of the Chinese character to be recognized in the sample, and train the initial recognition network according to the value of the adaptive margin loss function to obtain the recognition network.

[0108] The Chinese character recognition device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.

[0109] The specific definition of the Chinese character recognition device can be found in the definition of the Chinese character recognition method above, which will not be repeated here. Each module in the above-mentioned Chinese character recognition device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0110] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:

[0111] Obtain the Chinese character image to be recognized;

[0112] The image of Chinese characters to be recognized is input into a preset recognition network, and the Chinese characters to be recognized in the image of Chinese characters to be recognized are recognized by the recognition network to obtain the category of the Chinese characters to be recognized; wherein the recognition network is obtained by training based on sample images and an adaptive margin loss function, and different categories of Chinese characters have different weights in the adaptive margin loss function.

[0113] The implementation principle and technical effect of the computer device provided in the above embodiment are similar to those of the above method embodiment, and will not be repeated here.

[0114] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:

[0115] Obtain the Chinese character image to be recognized;

[0116] The image of Chinese characters to be recognized is input into a preset recognition network, and the Chinese characters to be recognized in the image of Chinese characters to be recognized are recognized by the recognition network to obtain the category of the Chinese characters to be recognized; wherein the recognition network is obtained by training based on sample images and an adaptive margin loss function, and different categories of Chinese characters have different weights in the adaptive margin loss function.

[0117] The computer-readable storage medium provided in the above embodiment has similar implementation principles and technical effects as those of the above method embodiment, and will not be described in detail here.

[0118] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).

[0119] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0120] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A Chinese character recognition method, characterized in that: The method comprises: Obtain the Chinese character image to be recognized; Inputting the Chinese character image to be recognized into a preset recognition network, recognizing the Chinese character to be recognized in the Chinese character image to be recognized through the recognition network, and obtaining the category of the Chinese character to be recognized; wherein the recognition network is obtained by training according to sample images and an adaptive margin loss function, and different categories of Chinese characters have different weights in the adaptive margin loss function; The recognition network includes a first convolution subnetwork, a second convolution subnetwork, a third convolution subnetwork and an expansion subnetwork; the Chinese character image to be recognized is input into a preset recognition network, and the Chinese character to be recognized in the Chinese character image to be recognized is recognized by the recognition network to obtain the category of the Chinese character to be recognized, including: Inputting the Chinese character image to be recognized into the first convolutional subnetwork, performing feature extraction on the Chinese character image to be recognized through the first convolutional subnetwork, and obtaining a first feature map of the Chinese character image to be recognized; Inputting the first feature map into the second convolutional subnetwork, and performing feature extraction on the first feature map through the second convolutional subnetwork to obtain a second feature map; Inputting the second feature map into the third convolutional subnetwork, and performing feature extraction on the second feature map through the third convolutional subnetwork to obtain a third feature map; The third feature map is input into the expansion sub-network, and the third feature map is subjected to feature extraction and classification by the expansion sub-network to obtain the category of the Chinese character to be recognized.

2. The method according to claim 1, characterized in that: The expansion subnetwork includes a first expansion convolution layer, a second expansion convolution layer, a third expansion convolution layer, a fourth expansion convolution layer and a classification layer; wherein the expansion coefficients of the first expansion convolution layer, the second expansion convolution layer, the third expansion convolution layer and the fourth expansion convolution layer are all different.

3. The method according to claim 2, characterized in that The step of inputting the third feature map into the expansion sub-network, extracting and classifying the third feature map through the expansion sub-network, and obtaining the category of the Chinese character to be recognized includes: Inputting the third feature map into the first dilated convolutional layer to obtain a fourth feature map; Inputting the third feature map into the second dilated convolutional layer to obtain a fifth feature map; Inputting the third feature map into the third dilated convolutional layer to obtain a sixth feature map; Inputting the third feature map into the fourth dilated convolutional layer to obtain a seventh feature map; The fourth feature map, the fifth feature map, the sixth feature map and the seventh feature map are input into the classification layer to obtain the category of the Chinese character to be recognized.

4. The method according to claim 3, characterized in that The step of inputting the fourth feature map, the fifth feature map, the sixth feature map and the seventh feature map into the classification layer to obtain the category of the Chinese character to be recognized comprises: The fourth feature map, the fifth feature map, the sixth feature map and the seventh feature map are input into the classification layer for feature fusion, and the category of the Chinese character to be recognized is obtained according to the fused features.

5. The method according to claim 1, characterized in that The network structure of each convolutional subnetwork in the first convolutional subnetwork, the second convolutional subnetwork, and the third convolutional subnetwork includes a convolutional layer, a batch normalization layer, and an activation layer.

6. The method according to claim 1, characterized in that The training process of the recognition network includes: Obtaining a sample Chinese character image to be recognized and a label of the sample Chinese character to be recognized in the sample Chinese character image to be recognized; Inputting the sample Chinese character image to be recognized into a preset initial recognition network, recognizing the sample Chinese character to be recognized through the initial recognition network, and obtaining a sample category of the sample Chinese character to be recognized; The value of the adaptive margin loss function is obtained according to the sample category and the label of the Chinese character to be recognized in the sample, and the initial recognition network is trained according to the value of the adaptive margin loss function to obtain the recognition network.

7. A Chinese character recognition device, characterized in that: The device comprises: The first acquisition module is used to acquire the image of the Chinese character to be recognized; A recognition module, used for inputting the Chinese character image to be recognized into a preset recognition network, recognizing the Chinese character to be recognized in the Chinese character image to be recognized through the recognition network, and obtaining the category of the Chinese character to be recognized; wherein the recognition network is obtained by training according to the sample image and the adaptive margin loss function, and different categories of Chinese characters have different weights in the adaptive margin loss function; The recognition network includes a first convolution subnetwork, a second convolution subnetwork, a third convolution subnetwork and an expansion subnetwork; the recognition module includes: A first acquisition unit is used to input the Chinese character image to be recognized into the first convolutional sub-network, and perform feature extraction on the Chinese character image to be recognized through the first convolutional sub-network to obtain a first feature map of the Chinese character image to be recognized; A second acquisition unit, configured to input the first feature map into the second convolutional subnetwork, and perform feature extraction on the first feature map through the second convolutional subnetwork to obtain a second feature map; a third acquisition unit, configured to input the second feature map into the third convolutional subnetwork, and perform feature extraction on the second feature map through the third convolutional subnetwork to obtain a third feature map; The recognition unit is used to input the third feature map into the expansion sub-network, extract and classify the features of the third feature map through the expansion sub-network, and obtain the category of the Chinese character to be recognized.

8. The device according to claim 7, characterized in that The expansion subnetwork includes a first expansion convolution layer, a second expansion convolution layer, a third expansion convolution layer, a fourth expansion convolution layer and a classification layer; wherein the expansion coefficients of the first expansion convolution layer, the second expansion convolution layer, the third expansion convolution layer and the fourth expansion convolution layer are all different.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.