A text recognition method and system
By constructing a teacher-student model distillation framework and utilizing deep residual networks and bidirectional long short-term memory networks, the number of parameters in the text recognition model for edge devices is reduced, solving the problem of limited storage resources on edge devices and achieving efficient text recognition results.
Patent Information
- Application Number
- CN202210661118.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-13
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2042-06-13
AI Technical Summary
Edge devices have limited storage resources, and traditional deep learning OCR models have too many parameters, resulting in low recognition accuracy and difficulty in application.
A teacher model is constructed using a deep residual network and a bidirectional long short-term memory network, combined with a student model with a deep separable convolutional and fully convolutional structure. The number of parameters is reduced through a distillation training method, and the training dataset is used for text recognition.
While reducing the number of parameters and computational load, the recognition accuracy was improved. The student model maintained a recognition accuracy of up to 95% on edge devices.
Smart Images

Figure CN115019317B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of text recognition, in particular to a text recognition method and system. BACKGROUND
[0002] As one of the most influential inventions of mankind, writing has played an important role in human life. Optical Character Recognition (OCR) is a technology that processes optical images by computer to recognize the text information in the images and convert them into digital format for output. It has a long research history and wide application scenarios, such as electronic document sorting, identity information recognition, industrial automation, digital financial systems, and vehicle license plate recognition. Traditional OCR is based on image processing (binarization, connected component analysis, projection analysis, etc.) and statistical machine learning (Adaboost, SVM), and has achieved good results on printed and scanned documents in the past 20 years. However, with the development of the times and the popularity of mobile devices, the demand for recognizing text in captured images has become mainstream, and the demand for recognizing text in various scenes has become increasingly prominent. Traditional OCR methods using manual feature extraction may fail to recognize text in various scenes. With the continuous improvement of hardware performance, using deep learning methods to replace manual feature extraction has become the mainstream method for OCR. However, with the progress of deep learning OCR technology, the model size is getting larger and larger, such as CRNN with 8.3MB parameters in English scenarios, improved STAR-Net with 48.7MB size, and SRN with up to 910MB parameters using semantic information to improve recognition accuracy. The limited storage resources of edge devices hinder the application of deep learning OCR models in edge devices. Therefore, there is an urgent need for a text recognition deep learning model with high recognition accuracy and small size. SUMMARY
[0003] The purpose of the present application is to provide a text recognition method and system that reduces the parameter quantity and computational quantity while improving the recognition accuracy.
[0004] To achieve the above purpose, the present application provides the following solutions:
[0005] A text recognition method, comprising:
[0006] obtaining a training data set; the training data set is a set of pictures labeled with text labels;
[0007] constructing a teacher model with a deep residual network as a feature extraction module and a bidirectional long short-term memory network as a sequence transformation module; and training the teacher model using the training data set; the teacher model is used to output corresponding labels according to input pictures;
[0008] The feature extraction module is determined by a deep separable convolution, an inverse residual structure with a linear bottleneck, and a Hardswish activation function, and the student model of the sequence transformation module is determined by a full convolution structure;
[0009] A distillation framework is constructed according to the trained teacher model and the student model, and the student model is distilled trained by using the training data set and the trained teacher model;
[0010] The trained student model is tested by using a test data set, and then text recognition is performed by using the tested student model.
[0011] Optionally, the distillation framework is constructed according to the trained teacher model and the student model, and specifically includes:
[0012] The different layers of the trained teacher model and the student model are connected to determine a distillation path; the distillation path includes 4 visual feature distillation paths, 1 sequence feature distillation path, and 1 soft label distillation path.
[0013] The transformation function and the similarity function are determined according to the distillation path.
[0014] Optionally, the student model is distilled trained by using the training data set and the trained teacher model, and specifically includes:
[0015] The distillation training loss function of the student model is determined by using a formula
[0016] wherein, is a loss function on different visual feature distillation paths, i∈[1,4], and α, β, and γ are hyperparameters set before training, is a loss function on the sequence feature distillation path, is a loss function on the soft label distillation path, is a loss function of the trained teacher model.
[0017] Optionally, the trained student model is tested by using a test data set, and then text recognition is performed by using the tested student model, and specifically includes:
[0018] A Raspberry Pi 3B+ is used to build an edge test platform.
[0019] The trained student model and the trained teacher model are tested by using the edge test platform according to the test data set.
[0020] A text recognition system includes:
[0021] The training data set acquisition module is configured to acquire a training data set, wherein the training data set is a set of pictures marked with text labels.
[0022] The teacher model construction and training module is configured to construct a teacher model with a deep residual network as a feature extraction module and a bidirectional long short-term memory network as a sequence transformation module, and train the teacher model by using the training data set, wherein the teacher model is configured to output corresponding labels according to an input picture.
[0023] The student model construction module is configured to construct a student model with a deep separable convolution, an inverse residual structure with a linear bottleneck and a Hardswish activation function determined feature extraction module, and a full convolution structure determined sequence transformation module.
[0024] The student model training module is configured to construct a distillation framework according to the trained teacher model and the student model, and distill train the student model by using the training data set and the trained teacher model.
[0025] The test and recognition module is configured to test the trained student model by using a test data set, and then perform text recognition by using the tested student model.
[0026] Optionally, the student model training module specifically includes:
[0027] The distillation path determination unit is configured to connect different layers of the trained teacher model and the student model to determine a distillation path, wherein the distillation path includes four visual feature distillation paths, one sequence feature distillation path and one soft label distillation path.
[0028] The transformation function and similarity function determination unit is configured to determine a transformation function and a similarity function according to the distillation path.
[0029] Optionally, the student model training module specifically includes:
[0030] The loss function determination unit is configured to determine a loss function of the student model during distillation training by using a formula
[0031] wherein, is a loss function on different visual feature distillation paths, i∈[1,4], and α, β and γ are hyperparameters set before training, is a loss function on the sequence feature distillation path, is a loss function on the soft label distillation path, is a loss function of the trained teacher model.
[0032] Optionally, the test and recognition module specifically includes:
[0033] An edge terminal test platform building unit is configured to build an edge terminal test platform by using a Raspberry Pi 3B+.
[0034] A test unit is configured to test the trained student model and the trained teacher model by using the edge terminal test platform according to the test data set.
[0035] According to the specific embodiments of the present application, the following technical effects are disclosed:
[0036] The text recognition method and system provided by the present application, the teacher model is composed of a deep residual network and a bidirectional long short-term memory network, the feature extraction module of the student model uses a deep separable convolution, an inverse residual structure with a linear bottleneck and a Hardswish activation function, and the sequence transformation module uses a full convolution structure, compared with the recurrent neural network (RNN) and LSTM structure used by the traditional deep learning OCR model, the parameter amount of the convolution structure is less, a distillation framework is constructed according to the trained teacher model and the student model, and the student model is distilled trained by using the training data set and the trained teacher model, so as to improve the recognition accuracy of the student model. BRIEF DESCRIPTION OF DRAWINGS
[0037] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed in the embodiments will be briefly introduced below, and obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0038] Figure 1 A text recognition method flowchart provided by the present application;
[0039] Figure 2 A distillation framework diagram;
[0040] Figure 3 A text recognition system structure diagram provided by the present application. DETAILED DESCRIPTION
[0041] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application, and obviously, the described embodiments are only some embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.
[0042] The application aims to provide a text recognition method and system, which can improve recognition accuracy while reducing parameter quantity and calculation quantity.
[0043] In order to make the above-mentioned purposes, features and advantages of the application more obvious and easy to understand, the application will be further described in detail below in combination with the drawings and specific embodiments.
[0044] Figure 1 A text recognition method provided by the application has the process schematic diagram as shown in Figure 1 The text recognition method provided by the application comprises the following steps.
[0045] S101, obtaining a training data set; the training data set is a picture set labeled with text labels.
[0046] The training data set uses a synthetic data set as the training data set; wherein the synthetic data set is:
[0047] MJSynth (MJ) is a synthetic data set designed for text recognition, containing 8.9 million text pictures.
[0048] SynthText (ST) is another synthetic data set, which is originally designed for scene text detection, but it is also used for STR by cropping word boxes, and has 5.5 million training data after filtering out non-alphanumeric characters.
[0049] S102, constructing a teacher model with a deep residual network (ResNet) as a feature extraction module and a bidirectional long short-term memory network (BiLSTM) as a sequence transformation module; and training the teacher model by using the training data set; the teacher model is used to output corresponding labels according to input pictures.
[0050] The specific structure of the teacher model is shown in Table 1 and Table 2. Since the text quantity of the pictures is different, the size of the pictures is inconsistent, so the size of each picture will be changed to 100x32 before entering the network. When changing, first use the Bicubic interpolation method to scale the length and width of the picture, then convert the picture to a tensor through transforms.ToTensor in Pytorh, and perform normalization with mean and variance of 0.5 to obtain the input grayscale image of the network.
[0051] Table 1
[0052]
[0053]
[0054] Table 2
[0055]
[0056] As shown in Table 1, the ResNet-based feature extraction module includes 7 ordinary convolutional layers and 11 residual modules in total; the feature extraction module has four down-sampling layers, and the step length of the last two down-sampling layers Pool3 and Conv6 is 1x2 instead of 2x2, that is, after four times of down-sampling, the height of the original input picture is halved four times, and the width is halved twice. Considering that most pictures are high and small in width and long in length, the last output feature map is also a rectangular shape with small height and long width, and using a step length of 1x2 can try to ensure that no information is lost in the width direction, which is more suitable for English letter recognition (such as distinguishing i and l mainly through height direction information). As shown in Table 2, the sequence transformation module uses BiLSTM, and the number of unidirectional memory cells is set to 256.
[0057] The training target of the teacher model is to minimize the objective function where D = {X i ,Y i} is the training data set, X i is the training picture, and Y i is the text label. The objective function is the negative log-likelihood of the conditional probability of the text label. During training, the built-in AdaDelta optimizer of pytorch is used to avoid the problem of too small learning rate in the later training period, and the decay rate is set to p = 0.95, and the remaining parameters remain unchanged. The default values are unchanged, pytorch default lr = 1, eps = 1e-08, weight_decay = 0. In addition, the gradient clip mechanism is used in training to prevent the problem of gradient vanishing or explosion during training. When the gradient value exceeds the threshold value 5, it is set to 5. The number of pictures in each batch during training is 192, including 96 pictures selected from MJSynth and SynthText in sequence. After training 2000 times, the model is verified and saved, and after training 300,000 times, the iteration is stopped, and the weight with the highest accuracy is taken as the final result. The recognition accuracy result of the trained teacher model is shown in Table 3, in which the accuracy on IC03 reaches 92.2%, and the average accuracy on the 7 test data sets is 79.8%.
[0058] Table 3
[0059]
[0060] S103, constructing a student model of a sequence transformation module determined by a full convolutional structure, and a feature extraction module determined by a depth separable convolution, an inverse residual structure with a linear bottleneck, and an Hswish activation function.
[0061] The feature extraction module includes 13 layers for feature extraction, and the latter part is a sequence transformation module including 3 layers for completing sequence transformation, and the two parts of the network are connected together through feature map transformation. The specific structure is shown in Table 4 and Table 5, wherein the operator bneck in Table 4 is the basic unit of the feature extraction network, which uses deep separable convolution and reverse residual structure: the reverse residual structure first uses 1x1 convolution on the input feature map for expansion, and the expanded channel number is indicated as the magnification factor in the table; then n x n channel-by-channel convolution is used on the expanded feature map to extract information, n is given after bneck in the table; finally, 1x1 convolution is used to compress the channel number. In the feature extraction module, the 2nd, 5th layers use a 3x3 convolution kernel with a step of 2 to downsample the horizontal direction data of the input feature map, and the 9th, 12th and 13th layers use a 2x2 convolution kernel with a step of 1x2 to downsample the vertical direction data of the input feature map. In addition, except for the 1st, 2nd and 4th layers, the other layers have SE (Squeeze-and-Excite) structure, the 2nd, 3rd and 4th layers use ReLU activation function, and the other layers use HardSwish activation function; in the sequence transformation module, each layer uses a 3x3 convolution network layer with a step of 1 and padding of 1, and each convolution layer is followed by a ReLU activation function. Through the designed full convolution layer structure, the model parameter amount is greatly reduced, and the model parameter amount is 1.37MB.
[0062] Table 4
[0063]
[0064]
[0065] Table 5
[0066]
[0067] S104, constructing a distillation framework according to the trained teacher model and the student model; and distilling training the student model by using the training data set and the trained teacher model.
[0068] The distillation framework is as shown in Figure 2 The dashed line connecting line between the two models is a similarity function for comparing the feature maps of the two networks; the similarity function, the transformation function and the distillation path jointly constitute the distillation framework.
[0069] S104 specifically includes:
[0070] The different layers of the trained teacher model and the student model are connected to determine a distillation path; the distillation path includes 4 visual feature distillation paths L1 to L4, 1 sequence feature distillation path L5, and 1 soft label distillation path L6; that is, the actual input f of the network is determined according to the distillation path t (x), f s (x).
[0071] The visual feature distillation paths L1 to L4 and the sequence feature distillation path L5 are located before the down-sampling layer. Specifically, the paths are located before the 2nd, 5th, 9th, 12th, and 13th layers of the feature extraction module of the student model and before the pool1, pool2, pool3, Conv6, and Conv7 layers of the feature extraction module of the teacher model, which correspond to the paths in Table 6. The soft label distillation path L6 in Table 6 is the output of the sequence transformation module of the student model and the teacher model.
[0072] Table 6
[0073]
[0074] The transformation function Φ is determined according to the distillation path t , Φ s , and the similarity function D F .
[0075] The channel dimensions of the feature maps f t (x), f s (x) are different, and similarity calculation cannot be directly performed. As shown in Table 6, the feature map size of the teacher model in the visual feature distillation path L1 is 100×32×64, and the feature map size of the student model is 100×32×16. The length and width of the two feature maps are consistent, but the channel dimensions are 64 and 16, respectively. The feature map channel dimensions of the two need to be consistent through the transformation function before similarity calculation.
[0076] The feature maps f t (x) and f s (x) are transformed through the convolution transformation in the transformation function, so as to align the channel dimensions of the feature maps and simultaneously extract the text-oriented features. The transformation functions on the distillation paths L1 to L3 are composed of a variable number of depth separable convolutions and average pooling layers. The size of the depth separable convolution SepConv on each visual feature distillation path in the transformation function is 3×3 with a step of 2, and the average pooling AvgPool has a pooling window of 2×2 with a step of 1. The number of depth separable convolutions used on different paths is different. For example, the number of depth convolution kernels of L1 to L3 is distributed as 3, 2, and 1, and the transformation function of L4 only has average pooling. In this way, even if the feature maps ft (x) and f s (x) are different in dimension, and after the transformation function, the dimension of the output feature map is consistent, and the output feature map size of each distillation path is shown in Table 7. Note that in L1 to L3, because the channel dimension of the intermediate layer feature map of the student model and the teacher model is different, the transformation function of the teacher model and the student model is also different, that is, Φ si (x) ≠ Φ ti (x), the specific difference is that the channel dimension of the convolution transformation is different, and the specific value is shown in Table 8.
[0077] In L6, the convolution transformation of L1 to L5 is no longer used, but the calculation of the normalization (Softmax) of the third dimension of the intermediate layer feature map is used as the transformation function. Specifically, it is to transform the third dimension of the feature map with a size of 26x1x36, and the purpose is to get the probability (36 characters are 26 letters + 10 numbers) of each region on the 26x1 feature map. Compared with the true label which only has two values of 0 and 1, the output value is a probability (0 to 1 interval), so this patent calls it a soft label distillation path. Let the feature map be X at this time, and the output be Y i , the formula of Softmax can be written as where X i represents the i-th dimension element of the feature map X, because the third dimension of the feature map needs to be normalized, the final transformation function is written as Note that because the channel dimension of the intermediate layer feature map of the student model and the teacher model is 96, the transformation function of the teacher model and the student model is the same, that is, Φ si (x) = Φ ti (x).
[0078] Table 7
[0079]
[0080]
[0081] Table 8
[0082]
[0083] D F is responsible for calculating the similarity of the intermediate layer features of the two networks. Let the distillation loss of the i-th distillation path be then
[0084] where x is the initial input of the network, f t (x) and f s (x) represent the feature map of the i-th distillation path of the teacher model and the student model, respectively, DFi The different paths i have different similarity functions D Fi As shown in Table 7, in L2 loss is used as the similarity function, and in KL divergence loss is used as the similarity function. Therefore, we have:
[0085]
[0086]
[0087] The loss function of the student model during distillation training is determined by the formula
[0088] wherein, is the loss function on different visual feature distillation paths, i∈[1, 4], and α, β and γ are hyperparameters set before training, is the loss function on the sequence feature distillation path, is the loss function on the soft label distillation path, is the loss function of the trained teacher model.
[0089] L2 loss is used as the similarity function to measure the similarity of the feature maps of the teacher model and the student model, KL divergence loss is used as the similarity function, and the negative log likelihood of the conditional probability of the text label. α is responsible for adjusting the weight of the distillation path
[0090] in the feature extraction module, β is responsible for adjusting the weight of the distillation path in the sequence transformation module, γ is responsible for the weight of the soft label distillation path , and (1-α-β-γ) is responsible for adjusting the weight of the negative log likelihood of the conditional probability of the text label . By definition, a, β, γ∈(0, 1) and α+β+γ<1. During training, α, β and γ are decayed every 500 batches, and the final training values are shown in Table 9. Table 9
[0091]
[0092]
[0093] wherein, the loss of each distillation path is
[0094]
[0095]
[0096]
[0097] The built-in AdaDelta optimizer of pytorch is used to avoid the problem of too small learning rate in the later training, and the decay rate is set to p = 0.95, and the remaining parameters remain unchanged. The default values of pytorch are lr = 1, eps = 1e-08, and weight_decay = 0. In addition, the gradient clipping mechanism is used in training to prevent the problem of gradient vanishing or explosion in the training process. When the gradient value exceeds the threshold 5, it is set to 5. The number of pictures in each batch during training is 192, which contains 96 pictures selected from MJSynth and SynthText in sequence. After training 2000 times, the model is verified and saved, and after training 300,000 times, the iteration is stopped, and the weight with the highest accuracy is taken as the final result.
[0098] S105, using the test data set to test the trained student model, and then using the test completed student model to perform text recognition.
[0099] The test data set is seven data sets widely used in text recognition tasks collected from real scenes, and the final accuracy of the model is the average of the recognition accuracy in each test data set.
[0100] IIIT5K-Words (IIIT) is a data set crawled from Google image search, such as "billboard", "signboard", "house number", "doorplate", "movie poster", etc., of which 3000 pictures constitute a test data set;
[0101] StreetViewText (SVT) contains outdoor street pictures collected from Google Street View, some of which have noise, blur or low resolution, of which 647 pictures are used as a test data set;
[0102] ICDAR2003 (IC03) is created for ICDAR2003 competition, which is used to recognize the scene text captured by the camera, of which 860 pictures are used for the test data set;
[0103] ICDAR2013 (IC13) inherits most of the pictures of IC03, which is created for ICDAR2013 competition. The original 1095 pictures used for evaluation are deleted after deleting the words with non-alphanumeric characters, and the number of pictures used for the test data set is 1015.
[0104] The four test data sets above are all regular pictures, which contain horizontally arranged characters with uniform spacing. The results on such data sets represent relatively simple scenarios in OCR tasks. In addition, the test data set of the present patent includes irregular data sets, which are different from regular data sets and are often more difficult to process in OCR tasks, such as curved and arbitrarily rotated or distorted text:
[0105] ICDAR2015 (IC15) is created for ICDAR2015 competition, and is characterized by low resolution, blur, rotation angle, and noise. The number of pictures in the test data set is 2077.
[0106] SVT Perspective (SVTP) is collected from Google Street View, and the number of pictures in the test data set is 645.
[0107] CUTE80 (CT) is collected from natural scenes, many of which are curved arrangements of text characters. The number of pictures in the test data set is 288.
[0108] There are originally 1100 test pictures in ICDAR2003, and after manual cleaning, the available data is 867; there are originally 1095 data in ICDAR2013, and after manual cleaning, the available data is 857; there are originally 2077 data in ICDAR2015, and after manual cleaning, the available data is 1811.
[0109] S105 specifically comprises:
[0110] A Raspberry Pi 3B+ is used to build an edge test platform; the configuration of the edge test platform is shown in Table 10.
[0111] Table 10
[0112]
[0113] According to the test data set, the trained student model and the trained teacher model are tested by using the edge test platform.
[0114] The test results are shown in Table 11. Comparing the ResNet+BiLSTM teacher model and student model in the first row of the table, it can be seen that the parameter quantity and calculation quantity of the trained student model are reduced by 98% and 97%, respectively. Comparing the three student models using the same teacher model and different training methods, the distillation method proposed in the present application has the highest average accuracy, which is better than the distillation method proposed by Hinton et al., and finally maintains 95% of the accuracy of the teacher model.
[0115] Table 11
[0116]
[0117]
[0118] Figure 3 A text recognition system structure schematic diagram provided by the present application is shown in Figure 3 The text recognition system provided by the present application comprises:
[0119] The training data set acquisition module 301 is used for acquiring a training data set; the training data set is a picture set marked with a text label.
[0120] The teacher model construction and training module 302 is used for constructing a teacher model taking a deep residual network as a feature extraction module and taking a bidirectional long short-term memory network as a sequence transformation module; and training the teacher model by using the training data set; the teacher model is used for outputting a corresponding label according to an input picture.
[0121] The student model construction module 303 is used for constructing a student model taking a deep separable convolution, an inverse residual structure with a linear bottleneck and a HardSwish activation function determined feature extraction module, and a sequence transformation module determined by a full convolution structure.
[0122] The student model training module 304 is used for constructing a distillation framework according to the trained teacher model and the student model; and distilling training the student model by using the training data set and the trained teacher model.
[0123] The test and recognition module 305 is used for testing the trained student model by using a test data set, and then performing text recognition by using the student model after the test.
[0124] The student model training module 304 specifically comprises:
[0125] The distillation path determination unit is used for connecting different layers of the trained teacher model and the student model to determine a distillation path; the distillation path comprises four visual feature distillation paths, one sequence feature distillation path and one soft label distillation path.
[0126] The transformation function and similarity function determination unit is used for determining a transformation function and a similarity function according to the distillation path.
[0127] The student model training module 304 specifically comprises:
[0128] The loss function determination unit is used for determining a loss function of the student model during distillation training by using the formula
[0129] wherein, is the loss function on the different visual feature distillation path, i [1, 4], and a, b and g are hyperparameters set before training, is the loss function on the sequence feature distillation path, is the loss function on the soft label distillation path, is the loss function of the trained teacher model.
[0130] The test and identification module 305 specifically includes:
[0131] The edge end test platform building unit is configured to build an edge end test platform by using a Raspberry Pi 3B+.
[0132] The test unit is configured to test the trained student model and the trained teacher model by using the edge end test platform according to the test data set.
[0133] The embodiments in the specification are described in a progressive manner, and each embodiment focuses on the difference from other embodiments. The same or similar parts of each embodiment can be referred to each other. For the system disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method part.
[0134] The principles and implementation manners of the present application are described by using specific examples in this paper. The above embodiment description is only used to help understand the method of the present application and its core idea. For those skilled in the art, according to the idea of the present application, the specific implementation manner and application range can be changed. In summary, the content of the specification should not be understood as a limitation of the present application.
Claims
1. A text recognition method, characterized in that, include: Obtain the training dataset; The training dataset is a collection of images labeled with text. A teacher model is constructed using a deep residual network as the feature extraction module and a bidirectional long short-term memory network as the sequence transformation module; the teacher model is trained using a training dataset; the teacher model is used to output corresponding labels based on the input image; Construct a student model with a feature extraction module defined by depthwise separable convolution, an inverse residual structure with a linear bottleneck, and a Hardswish activation function, and a sequence transformation module defined by a fully convolutional structure. A distillation framework is constructed based on the trained teacher model and the student model; and the student model is trained by distillation using the training dataset and the trained teacher model. The trained student model is tested using a test dataset, and then the tested student model is used for text recognition. The construction of the distillation framework based on the trained teacher model and the student model specifically includes: The different layers of the trained teacher model and the student model are connected to determine the distillation path; the distillation path includes: 4 visual feature distillation paths, 1 sequence feature distillation path, and 1 soft label distillation path; The transformation function and similarity function are determined based on the distillation path; The process of training the student model using the training dataset and the trained teacher model specifically includes: Using formula Determine the loss function of the student model during distillation training; in, For different visual feature distillation paths, the loss function is i∈[1,4], α, β Both γ and γ are hyperparameters set before training. The loss function is the feature distillation path of the sequence. The loss function is the one used for the soft-label distillation path. The loss function for the trained teacher model.
2. The text recognition method according to claim 1, characterized in that, The step of testing the trained student model using a test dataset, and then using the tested student model for text recognition, specifically includes: Building an edge testing platform using Raspberry Pi 3B+; Based on the test dataset, the trained student model and the trained teacher model are tested using the edge testing platform.
3. A text recognition system, characterized in that, include: The training dataset acquisition module is used to acquire the training dataset; The training dataset is a collection of images labeled with text. The teacher model construction and training module is used to construct a teacher model with a deep residual network as the feature extraction module and a bidirectional long short-term memory network as the sequence transformation module; and to train the teacher model using a training dataset; the teacher model is used to output corresponding labels based on the input image; The student model building module is used to build a student model with a feature extraction module determined by depthwise separable convolution, an inverse residual structure with a linear bottleneck, and a Hardswish activation function, and a sequence transformation module determined by a fully convolutional structure. The student model training module is used to construct a distillation framework based on the trained teacher model and the student model; and to train the student model by distillation using the training dataset and the trained teacher model. The testing and recognition module is used to test the trained student model using a test dataset, and then use the tested student model to perform text recognition. The student model training module specifically includes: The distillation path determination unit is used to connect different layers of the trained teacher model and the student model to determine the distillation path; the distillation path includes: 4 visual feature distillation paths, 1 sequence feature distillation path, and 1 soft label distillation path; A transformation function and similarity function determination unit is used to determine the transformation function and similarity function based on the distillation path; The student model training module specifically includes: Loss function determination unit, used to utilize formula Determine the loss function of the student model during distillation training; in, For different visual feature distillation paths, the loss function is i∈[1,4], α, β Both γ and γ are hyperparameters set before training. The loss function is the feature distillation path of the sequence. The loss function is the one used for the soft-label distillation path. The loss function for the trained teacher model.
4. A text recognition system according to claim 3, characterized in that, The testing and identification module specifically includes: Edge testing platform building unit, used to build an edge testing platform using Raspberry Pi 3B+; The testing unit is used to test the trained student model and the trained teacher model using the edge testing platform based on the test dataset.
Citation Information
Patent Citations
Chinese herbal medicine recognition method and device based on deep learning and storage medium
CN113449776A
Character recognition model training method and device, storage medium and electronic equipment
CN113609965A