Training method and device for formula recognition model and device for model training
Through iterative joint training of formula recognition models and super-resolution models, combined with correction and encoding and decoding modules, the problem of low formula recognition accuracy in the existing technology is solved, and the recognition accuracy in complex scenes is significantly improved.
Patent Information
- Application Number
- CN202111156265.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-29
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2041-09-29
AI Technical Summary
Existing formula recognition algorithms have low accuracy when dealing with complex and fuzzy formula recognition scenarios. The staged recognition algorithm has error accumulation problems, and the end-to-end algorithm does not perform well in complex scenarios.
An iterative joint training method based on formula recognition samples and super-resolution models is adopted, the model parameters are adjusted by calculating the joint loss value, and the correction module and encoding and decoding module are combined to improve the recognition accuracy.
Improved the robustness and accuracy of the formula recognition model, especially the recognition accuracy in blurred and distorted scenes.
Smart Images

Figure CN113887170B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent control technology, and in particular to a training method and device for a formula recognition model and a device for model training. Background Art
[0002] Formula recognition technology has a wide range of application needs in education fields such as automatic examination paper grading, photo search, and test paper digitization. The complex two-dimensional structure of the formula itself, the numerous symbols, the similarity of the symbols, and the diversity of their meanings lead to low accuracy in formula recognition.
[0003] In recent years, with the significant improvement of computer computing power and the advent of the big data era, neural network-based formula recognition algorithms have been widely used in various formula recognition scenarios. At present, there are two common formula recognition algorithms: one is a phased recognition algorithm based on the "segmentation-recognition-reprocessing" process, and the other is an end-to-end formula recognition algorithm.
[0004] However, in the staged recognition algorithm, each stage will cause errors, and the errors in each stage will accumulate, resulting in poor final accuracy. In the end-to-end formula recognition algorithm, the recognition effect is poor for complex formula recognition scenarios such as blur and distortion. Summary of the invention
[0005] The embodiments of the present invention provide a training method and device for a formula recognition model and a device for model training, which can improve the robustness and accuracy of the formula recognition model.
[0006] In order to solve the above problems, an embodiment of the present invention discloses a training method for a formula recognition model, the method comprising:
[0007] Obtaining a formula recognition sample and a target label corresponding to the formula recognition sample;
[0008] Based on the formula recognition samples, the formula recognition model and the super-resolution model are iteratively jointly trained; in each round of training, a joint loss value is calculated according to an output result of the formula recognition model, an output result of the super-resolution model, and the target label, and model parameters of the formula recognition model and / or the super-resolution model are adjusted according to the joint loss value;
[0009] When the joint loss value meets the convergence condition, a trained formula recognition model and a super-resolution model are obtained.
[0010] Optionally, the formula recognition model includes a correction module and a coding module, and the coding module is connected in parallel with the super-resolution model.
[0011] Optionally, in each round of training, calculating a joint loss value according to an output result of the formula recognition model, an output result of the super-resolution model, and the target label includes:
[0012] In each round of training, the formula recognition sample is input into the correction module of the formula recognition model for correction processing to obtain the correction result corresponding to the formula recognition sample;
[0013] Inputting the correction result into the encoding and decoding module of the formula recognition model for formula recognition processing to obtain a formula recognition result corresponding to the formula recognition sample;
[0014] Inputting the correction result into the super-resolution model for feature reconstruction processing to obtain the image processing result corresponding to the formula recognition sample;
[0015] The joint loss value is calculated according to the formula recognition result of the formula recognition sample, the image processing result, and the target label.
[0016] Optionally, the target label includes a text label and an image label, and the calculating the joint loss value according to the formula recognition result of the formula recognition sample, the image processing result, and the target label includes:
[0017] Calculating a first loss value of the formula recognition model according to the formula recognition result of the formula recognition sample and the text label;
[0018] Identify the image processing result of the sample and the image label according to the formula, and calculate a second loss value of the super-resolution model;
[0019] The first loss value and the second loss value are weightedly summed to obtain the joint loss value.
[0020] Optionally, the step of inputting the formula recognition sample into a correction module of the formula recognition model for correction processing to obtain a correction result corresponding to the formula recognition sample includes:
[0021] Inputting the formula recognition sample into the positioning network layer of the correction module of the formula recognition model to obtain the control point coordinates corresponding to the formula recognition sample;
[0022] Performing correction processing on the formula recognition sample based on the control point coordinates to obtain the target sampling point corresponding to the formula recognition sample;
[0023] Performing bilinear difference sampling on the target sampling point to obtain a target pixel point corresponding to the target sampling point;
[0024] A correction result corresponding to the sample identified by the formula is generated according to the target pixel point.
[0025] Optionally, the step of inputting the correction result into the encoding and decoding module of the formula recognition model for formula recognition processing to obtain a formula recognition result corresponding to the formula recognition sample includes:
[0026] Inputting the correction result into the coding layer of the coding and decoding module for feature extraction to obtain the feature code corresponding to the formula recognition sample;
[0027] Determine a relative position code corresponding to the feature code;
[0028] The feature code and the relative position code are input into the decoding layer of the encoding and decoding module for decoding processing to obtain the formula recognition result corresponding to the formula recognition sample.
[0029] Optionally, the step of inputting the correction result into the super-resolution model for feature reconstruction to obtain an image processing result corresponding to the formula recognition sample includes:
[0030] Inputting the correction result into the super-resolution basic unit in the super-resolution model to perform feature extraction, so as to obtain image features corresponding to the correction result;
[0031] The image features are upsampled to obtain image processing results corresponding to the formula recognition samples.
[0032] Optionally, obtaining a formula to identify a sample includes:
[0033] Acquire a first image, wherein the first image contains a handwritten formula;
[0034] Performing quality degradation on the first image to obtain a second image;
[0035] A sample pair consisting of the first image and the second image is used as a formula recognition sample.
[0036] On the other hand, an embodiment of the present invention discloses a training device for a formula recognition model, the device comprising:
[0037] A training data acquisition module, used to acquire formula recognition samples and target labels corresponding to the formula recognition samples;
[0038] An iterative joint training module, used for iteratively joint training the formula recognition model and the super-resolution model based on the formula recognition samples; in each round of training, a joint loss value is calculated according to an output result of the formula recognition model, an output result of the super-resolution model, and the target label, and model parameters of the formula recognition model and / or the super-resolution model are adjusted according to the joint loss value;
[0039] The training completion module is used to obtain the trained formula recognition model and super-resolution model when the joint loss value meets the convergence condition.
[0040] Optionally, the formula recognition model includes a correction module and a coding module, and the coding module is connected in parallel with the super-resolution model.
[0041] Optionally, the iterative joint training module includes:
[0042] A correction processing submodule, used for inputting the formula recognition sample into the correction module of the formula recognition model for correction processing in each round of training to obtain a correction result corresponding to the formula recognition sample;
[0043] A formula recognition processing submodule, used for inputting the correction result into the encoding and decoding module of the formula recognition model for formula recognition processing to obtain a formula recognition result corresponding to the formula recognition sample;
[0044] An image processing submodule, used for inputting the correction result into the super-resolution model for feature reconstruction processing to obtain an image processing result corresponding to the formula recognition sample;
[0045] The joint loss value calculation submodule is used to calculate the joint loss value according to the formula recognition result of the formula recognition sample, the image processing result, and the target label.
[0046] Optionally, the target label includes a text label and an image label, and the joint loss value calculation submodule includes:
[0047] A first loss value calculation unit, configured to calculate a first loss value of the formula recognition model according to a formula recognition result of the formula recognition sample and the text label;
[0048] A second loss value calculation unit, used to identify the image processing result of the sample and the image label according to the formula, and calculate a second loss value of the super-resolution model;
[0049] A joint loss value calculation unit is used to perform a weighted summation of the first loss value and the second loss value to obtain the joint loss value.
[0050] Optionally, the correction processing submodule includes:
[0051] A control point coordinate determination unit, used for inputting the formula recognition sample into the positioning network layer of the correction module of the formula recognition model to obtain the control point coordinates corresponding to the formula recognition sample;
[0052] A target sampling point determination unit, configured to perform correction processing on the formula recognition sample based on the control point coordinates to obtain a target sampling point corresponding to the formula recognition sample;
[0053] A target pixel point determination unit, used for performing bilinear difference sampling on the target sampling point to obtain a target pixel point corresponding to the target sampling point;
[0054] A correction result generating unit is used to generate a correction result corresponding to the formula recognition sample according to the target pixel point.
[0055] Optionally, the formula recognition processing submodule includes:
[0056] A coding processing unit, used for inputting the correction result into the coding layer of the coding and decoding module for feature extraction, and obtaining the feature code corresponding to the formula recognition sample;
[0057] A relative position code determining unit, used to determine the relative position code corresponding to the feature code;
[0058] A decoding processing unit is used to input the feature code and the relative position code into the decoding layer of the encoding and decoding module for decoding processing to obtain a formula recognition result corresponding to the formula recognition sample.
[0059] Optionally, the image processing submodule includes:
[0060] A feature extraction unit, used for inputting the correction result into the super-resolution basic unit in the super-resolution model for feature extraction, so as to obtain image features corresponding to the correction result;
[0061] The up-sampling processing unit is used to perform up-sampling processing on the image features to obtain the image processing results corresponding to the formula recognition samples.
[0062] Optionally, the training data acquisition module includes:
[0063] A first image acquisition submodule, used to acquire a first image, wherein the first image contains a handwritten formula;
[0064] A second image generation submodule, configured to perform quality degradation processing on the first image to obtain a second image;
[0065] The formula recognition sample determination submodule is used to use a sample pair consisting of the first image and the second image as a formula recognition sample.
[0066] On the other hand, an embodiment of the present invention discloses a device for model training, which includes a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors. The one or more programs include instructions for executing a training method for a formula recognition model as described above.
[0067] On the other hand, an embodiment of the present invention discloses a machine-readable medium having instructions stored thereon, which, when executed by one or more processors, enables the device to perform one or more of the training methods for the formula recognition model described above.
[0068] The embodiments of the present invention include the following advantages:
[0069] After obtaining the formula recognition sample and the target label corresponding to the formula recognition sample, the embodiment of the present invention performs iterative joint training on the formula recognition model and the super-resolution model based on the formula recognition sample. In each round of training, the joint loss value is calculated according to the output result of the formula recognition model, the output result of the super-resolution model, and the target label, and the model parameters of the formula recognition model and / or the super-resolution model are adjusted according to the joint loss value; when the joint loss value meets the convergence condition, the trained formula recognition model and super-resolution model are obtained. The embodiment of the present invention introduces the super-resolution model to jointly train the formula recognition model, which adds image details to the training process of the formula recognition model, can solve the problem of blurring of the formula recognition sample to be recognized, improves the recognition accuracy of the formula recognition model for blurry images, and is conducive to improving the robustness and accuracy of the formula recognition model. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0071] Figure 1 is a schematic diagram of the structure of a computer system of the present invention;
[0072] Figure 2 It is a flowchart of the steps of an embodiment of a training method of a formula recognition model of the present invention;
[0073] Figure 3 It is a structural schematic diagram of a formula recognition model and a super-resolution model of the present invention;
[0074] Figure 4a is a schematic diagram of a distorted and deformed formula image of the present invention;
[0075] Figure 4b is a schematic diagram of a corrected formula image of the present invention;
[0076] Figure 5 It is a structural block diagram of an embodiment of a training device for a formula recognition model of the present invention;
[0077] Figure 6 is a block diagram of a device 800 for model training of the present invention;
[0078] Figure 7 It is a schematic diagram of the structure of the server in some embodiments of the present invention. DETAILED DESCRIPTION
[0079] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0080] Method Embodiment
[0081] The embodiment of the present invention provides a method for training a formula recognition model, which can be applied to a computer device with data processing capabilities. In an optional embodiment, the method for training a formula recognition model provided by the embodiment of the present invention can be applied to a personal computer, a workstation or a server, that is, formula recognition and training of a formula recognition model can be implemented by a personal computer, a workstation or a server.
[0082] The trained formula recognition model can become a part of the application and be installed in the terminal, so that the terminal can output the formula recognition result when receiving the content to be recognized; or, the trained formula recognition model is set in the background server of the application, so that the terminal with the application installed can realize the formula recognition function with the help of the background server.
[0083] Reference Figure 1, shows a schematic diagram of the structure of a computer system provided by an embodiment of the present invention, the computer system includes a terminal 110 and a server 120. The terminal 110 and the server 120 perform data communication via a communication network. Optionally, the communication network may be a wired network or a wireless network, and the communication network may be at least one of a local area network, a metropolitan area network, and a wide area network.
[0084] The terminal 110 is installed with an application supporting the formula recognition function, which may be an e-book reading application, a web browsing application, a paper marking application, a photo search application, a social application, etc., which is not specifically limited in the embodiment of the present invention.
[0085] Optionally, the terminal 110 may be a mobile terminal such as a smart phone, a smart watch, a tablet computer, a laptop computer, an intelligent robot, or the like, or a terminal such as a desktop computer or a projection computer. The embodiment of the present invention does not limit the type of terminal.
[0086] The server 120 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, and may also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, cloud communications, network services, middleware services, content delivery networks (CDN), and big data and artificial intelligence platforms. In an optional embodiment, the server 120 may be a background server of an application in the terminal 110.
[0087] In some embodiments, the terminal 110 includes a camera component; the terminal 110 obtains picture content through the camera component, and the picture content includes the formula to be recognized, and the terminal 110 sends the picture to the server 120. The server 120 includes a formula recognition module, and the formula recognition module includes a trained formula recognition model; the server 120 receives the picture sent by the terminal 110, recognizes the formula in the picture through the formula recognition model, and sends the recognition result to the terminal 110 for display.
[0088] Alternatively, the terminal 110 includes a formula recognition module, which includes a trained formula recognition model. After acquiring the picture, the terminal recognizes the formula in the picture through the formula recognition model to obtain a recognition result, and displays the recognition result.
[0089] It should be noted that, in the above embodiments, the display method of the terminal includes picture form or text form.
[0090] For the convenience of description, the following embodiments are described by taking the training method of the formula recognition model executed by the server as an example.
[0091] Reference Figure 2 , shows a flowchart of a training method embodiment of a formula recognition model of the present invention, and the method may specifically include the following steps:
[0092] Step 201: Obtain formula recognition samples and target labels corresponding to the formula recognition samples.
[0093] Step 202: Based on the formula recognition samples, the formula recognition model and the super-resolution model are iteratively jointly trained. In each round of training, a joint loss value is calculated according to the output result of the formula recognition model, the output result of the super-resolution model, and the target label, and the model parameters of the formula recognition model and / or the super-resolution model are adjusted according to the joint loss value.
[0094] Step 203: When the joint loss value meets the convergence condition, a trained formula recognition model and a super-resolution model are obtained.
[0095] The formula recognition sample is an image used for training, and the image contains the formula to be recognized. The target label corresponding to the formula recognition sample is the target recognition result corresponding to the formula recognition sample, which is used to verify the accuracy of the output result of the formula recognition model during the training process.
[0096] There are many ways to obtain formula recognition samples and target labels corresponding to the formula recognition samples. For example, existing formula images and formula recognition results on the Internet, formula images and recognition results stored on computer devices, etc. can all be used as formula recognition samples in embodiments of the present invention.
[0097] The formula recognition model is used to recognize the text content corresponding to the formula in the input image data, so the output result of the formula recognition model is the formula recognition result corresponding to the formula recognition sample. The formula recognition model can be constructed based on a pre-set algorithm, which is not specifically limited in the embodiment of the present invention.
[0098] The super-resolution model is used to perform super-resolution reconstruction on the input image data, thereby increasing the pixel density of the image data and providing more image details. The output result of the super-resolution model is the image processing result corresponding to the sample identified by the formula. Similarly, the super-resolution model can select a neural network model that is good at image super-resolution reconstruction in the field, and the embodiment of the present invention does not make specific limitations on this.
[0099] It should be noted that, in an embodiment of the present invention, the formula recognition model and the super-resolution model can be connected in any manner to form a joint neural network model. As an example, the formula recognition model and the super-resolution model can be connected in series, and the formula recognition sample can be jointly processed based on the series-connected formula recognition model and the super-resolution model to obtain the formula recognition result and image processing result of the formula recognition sample. As another example, part of the network layers of the formula recognition model and the super-resolution model can be fused so that the formula recognition model and the super-resolution model share part of the network layers, or part of the network layers of the formula recognition model are connected in parallel with the network layers of the super-resolution model; then, the formula recognition sample is jointly processed based on the fused formula recognition model and the super-resolution model to obtain the formula recognition result and image processing result of the formula recognition sample. Regardless of which joint processing method is used, before the formula recognition model outputs the formula recognition result, the super-resolution model is introduced to add image details to the formula recognition sample to be recognized, so as to improve the recognition accuracy of the formula recognition model in complex scenes such as image blur and image distortion.
[0100] In each round of training, the joint loss value of the formula recognition model and the super-resolution model is calculated according to the output result of the formula recognition model, the output result of the super-resolution model, and the target label corresponding to the formula recognition sample, and the model parameters of the formula recognition model and / or the super-resolution model are adjusted according to the joint loss value until the convergence condition is met to obtain the trained formula recognition model and super-resolution model. The joint loss value can be determined based on the cross entropy between the output result of the formula recognition model and the target label, and the cross entropy between the super-resolution model and the target label. The convergence condition can be that in multiple rounds of training, the joint loss value of the formula recognition model and the super-resolution model is less than a preset threshold, or the error between the joint loss values is less than a preset value.
[0101] It should be noted that the embodiment of the present invention does not specifically limit the size of the formula recognition sample. In order to speed up the model training speed, the formula recognition sample can be preprocessed in advance. Exemplarily, the image height of each formula recognition sample can be uniformly adjusted to a preset height, for example, the image height of each formula recognition sample is fixed to 64 pixels; then, based on the height adjustment ratio of each formula recognition sample, the image width is scaled proportionally. For example, for formula recognition sample A, its image height before preprocessing is 32 pixels and its image width is 128 pixels. The image height of formula recognition sample A is adjusted to 64 pixels, and the image height of formula recognition sample A is stretched by 2 times. Therefore, its image width is also stretched by 2 times and adjusted to 256 pixels. In order to avoid the large difference in the size of the formula recognition samples during the training process, which increases the difficulty of training, the scaled formula recognition samples can be sorted in order from small to large or from large to small according to the image width, and the adjacent N formula recognition samples are taken as a sample group, and the formula recognition samples of the same sample group are synchronously processed.
[0102] Furthermore, since the embodiment of the present invention jointly trains the formula recognition model and the super-resolution model, the super-resolution model requires formula recognition samples that are pairs of high-quality images and low-quality images. Usually, the acquired formula recognition images are high-quality images. Therefore, in the embodiment of the present invention, the formula recognition images can also be degraded to construct training sample pairs that meet the training requirements of the super-resolution model.
[0103] In an optional embodiment of the present invention, the step 201 of obtaining a formula recognition sample includes:
[0104] Step S11, obtaining a first image, wherein the first image contains a handwritten formula;
[0105] Step S12, performing quality degradation processing on the first image to obtain a second image;
[0106] Step S13: taking a sample pair consisting of the first image and the second image as a formula recognition sample.
[0107] The first image is a high-quality image, and the second image is a low-quality image. The image resolution of the high-quality image is greater than the resolution of the low-quality image, and a resolution threshold can be set according to actual needs, and images with image resolutions greater than the resolution threshold are regarded as high-quality images, and images with image resolutions less than the resolution threshold are regarded as low-quality images.
[0108] Exemplarily, the degradation process may include any one of Gaussian blur processing, Gaussian noise processing, downsampling processing, and the like. Among them, Gaussian blur processing, also known as Gaussian smoothing processing, is used to reduce the image noise of the first image and reduce the detail level of the first image. Gaussian noise processing refers to adding additional Gaussian white noise to the first image to increase the blur level of the first image. Downsampling processing mainly achieves image degradation by reducing the number of pixels in the first image. Specifically, bilinear difference sampling, sub-sampling, etc. may be performed on the first image.
[0109] It should be noted that, in practical applications, any image degradation processing method in the art may be used as long as the resolution of the first image can be reduced. The embodiment of the present invention does not limit the specific processing process of the degradation processing.
[0110] In an optional embodiment of the present invention, the formula recognition model includes a correction module and a coding module, and the coding module is connected in parallel with the super-resolution model.
[0111] Reference Figure 3 , shows a schematic diagram of the structure of a formula recognition model and a super-resolution model according to an embodiment of the present invention. Figure 3 , describing the specific training process of iteratively jointly training the formula recognition model and the super-resolution model based on the formula recognition samples in an embodiment of the present invention.
[0112] like Figure 3 As shown, the formula recognition model includes a correction module and a codec module, and the codec module is connected in parallel with the super-resolution model. Therefore, in an embodiment of the present invention, the codec module of the formula recognition model and the super-resolution model can share the output data of the correction module of the formula recognition model.
[0113] In an optional embodiment of the present invention, in each round of training described in step 202, calculating the joint loss value according to the output result of the formula recognition model, the output result of the super-resolution model, and the target label includes:
[0114] Step S21: In each round of training, the formula recognition sample is input into the correction module of the formula recognition model for correction processing to obtain a correction result corresponding to the formula recognition sample;
[0115] Step S22, inputting the correction result into the encoding and decoding module of the formula recognition model for formula recognition processing, and obtaining a formula recognition result corresponding to the formula recognition sample;
[0116] Step S23, inputting the correction result into the super-resolution model for feature reconstruction processing to obtain the image processing result corresponding to the formula recognition sample;
[0117] Step S24, calculating a joint loss value according to the formula recognition result of the formula recognition sample, the image processing result, and the target label.
[0118] The formula recognition sample may be a sample pair consisting of the first image and the second image in the aforementioned steps S11 to S13. Optionally, the formula recognition sample includes a distorted or deformed third image. In the distorted or deformed third image, the formula is offset relative to the horizontal position, or the formula content is distorted or deformed and is difficult to recognize.
[0119] It should be noted that the correction module of the formula recognition model is used to correct the distorted and deformed third image in the formula recognition sample. Figure 4a , showing a distorted, deformed formula image. Figure 4b A corrected formula image is shown. Figure 4a to Figure 4b As shown, after correction, the formula content in the image is more standardized and easier to recognize.
[0120] The encoding and decoding module of the formula recognition model is used to perform formula recognition processing on the correction result corresponding to the formula recognition sample, identify the corresponding formula content in the correction result, and obtain the formula recognition result of the formula recognition sample.
[0121] The super-resolution model is used to reconstruct the features of the correction results of the formula recognition samples, supplement the image details and textures in the correction results, and obtain a high-definition image corresponding to the correction results, that is, an image processing result.
[0122] In an embodiment of the present invention, the correction module in the formula recognition model can solve the problem of formula distortion and deformation in the formula recognition samples to be recognized, reduce the difficulty of formula recognition, and help improve the recognition accuracy of the formula recognition model in the formula distortion scenario; and, by introducing a super-resolution model, the problem of blurring of the formula recognition samples to be recognized can be solved, and by adding image details during the training of the formula recognition model, the recognition accuracy of the formula recognition model for blurred images is improved, which is conducive to improving the robustness and accuracy of the formula recognition model.
[0123] In an optional embodiment of the present invention, the step S21 of inputting the formula recognition sample into the correction module of the formula recognition model for correction processing to obtain the correction result corresponding to the formula recognition sample includes:
[0124] Sub-step S211, inputting the formula recognition sample into the positioning network layer of the correction module of the formula recognition model to obtain the control point coordinates corresponding to the formula recognition sample;
[0125] Sub-step S212: performing correction processing on the formula recognition sample based on the control point coordinates to obtain a target sampling point corresponding to the formula recognition sample;
[0126] Sub-step S213, performing bilinear difference sampling on the target sampling point to obtain a target pixel point corresponding to the target sampling point;
[0127] Sub-step S214: generating a correction result corresponding to the formula recognition sample according to the target pixel point.
[0128] The correction module of the formula recognition model can be composed of three parts: a positioning network layer, a grid generation layer and a sampling layer. The positioning network layer is used to determine the coordinates of the control points corresponding to the formula recognition sample. The control point coordinates are the edge point coordinates on the circumscribed rectangle of the formula content in the formula recognition sample. For example, Figure 4a The formula image shown, all points on its circumscribed rectangle can be used as control points. It should be noted that the control point coordinates corresponding to the formula recognition sample include not only the control point coordinates in the image before correction, but also the control point coordinates in the image after correction. Exemplarily, the control point coordinates in the image after correction can be set directly according to the size of the circumscribed rectangle of the formula content in the image before correction. Among them, in the corrected image, the curvature between each control point in the same direction is zero.
[0129] After obtaining the control point coordinates corresponding to the formula recognition sample, the control point coordinates are input into the grid generation layer, and the grid generation layer corrects the formula recognition sample according to the control point coordinates to determine the positions of the target sampling points corresponding to the formula recognition sample. Among them, the grid generation layer can correct the formula recognition sample based on TPS (Thin Plate Sline) transformation. Specifically, the grid generation layer can determine the positional relationship between the control points in the two images before and after correction, that is, the correction matrix, according to the control point coordinates in the two images before and after correction; then, interpolate other points according to the correction matrix, obtain the corresponding relationship of other points, and determine the target sampling points corresponding to the formula recognition sample, and the target sampling points are the sampling points in the corrected image.
[0130] Then, the target sampling point is sampled by bilinear interpolation through the sampling layer to determine the target pixel point corresponding to the target sampling point, that is, the pixel point corresponding to the target sampling point is taken from the image before correction and filled into the corresponding position of the corrected image to obtain the target pixel point. According to the target pixel point, the correction result corresponding to the formula recognition sample, that is, the corrected formula image, can be generated.
[0131] In the embodiment of the present invention, the correction result output by the correction module of the formula recognition model is the input data of the encoding and decoding module of the formula recognition model and the input data of the super-resolution model.
[0132] In an optional embodiment of the present invention, the step S22 of inputting the correction result into the encoding and decoding module of the formula recognition model for formula recognition processing to obtain the formula recognition result corresponding to the formula recognition sample includes:
[0133] Sub-step S221: input the correction result to the coding layer of the coding and decoding module for feature extraction to obtain the feature code corresponding to the formula recognition sample;
[0134] Sub-step S222, determining the relative position code corresponding to the feature code;
[0135] Sub-step S223: input the feature code and the relative position code to the decoding layer of the encoding and decoding module for decoding processing to obtain a formula recognition result corresponding to the formula recognition sample.
[0136] It should be noted that, in an embodiment of the present invention, the encoding and decoding module of the formula recognition model may include an encoding layer and a decoding layer. In other words, the encoding and decoding module may adopt an end-to-end Encoder-Decoder structure. Among them, the Encoder may adopt a CNN (Convolution nNeural Networks) structure. Exemplarily, under the premise that the accuracy is not greatly affected, the optimal CNN network structure can be determined by NAS (Neural Architecture Search) as the Encoder of the encoding and decoding module. The Decoder of the encoding and decoding module may adopt a 2d-attention mechanism.
[0137] Of course, in practical applications, other network structures may also be used to construct the encoding and decoding module of the formula recognition model. The above is only an exemplary description of the present invention and does not constitute a specific limitation on the embodiments of the present invention.
[0138] The spatial structure of a formula is generally complex, including a variety of positional relationships, such as front-to-back, top-to-bottom, and including. Therefore, in an embodiment of the present invention, after the correction result is subjected to feature extraction by the coding layer of the coding and decoding module, a relative position code may be further added to the extracted feature, and the formula recognition result is jointly determined based on the extracted feature code and the relative position code, so as to more accurately determine the relative positional relationship between the recognized characters and improve the recognition accuracy of the formula recognition model.
[0139] In an optional embodiment of the present invention, the step S23 of inputting the correction result into the super-resolution model for feature reconstruction to obtain the image processing result corresponding to the formula recognition sample includes:
[0140] Sub-step S231, inputting the correction result into the super-resolution basic unit in the super-resolution model to perform feature extraction, so as to obtain image features corresponding to the correction result;
[0141] Sub-step S232: up-sample the image features to obtain image processing results corresponding to the formula recognition samples.
[0142] The super-resolution model may include two parts: a super-resolution basic unit and an upsampling unit. The super-resolution basic unit is used to determine the image features of the correction result and reconstruct the correction result. As an example, the super-resolution basic unit may be constructed based on RCAN (Residual Channel Attention Networks).
[0143] For the correction result, usually multiple feature channels, the super-resolution basic unit can model the interdependence between the feature channels and adaptively rescale the features of each channel, so as to restore the image feature information of the correction result as much as possible.
[0144] It should be noted that since the formula recognition samples of the super-resolution model are sample pairs consisting of high-quality images and low-quality images, among which the low-quality images are usually subjected to image degradation processing, in order to better restore the image feature information of the correction result, the image features output by the super-resolution basic unit can be further upsampled through the upsampling layer of the super-resolution model to further supplement the detail level of the image and obtain the image processing result corresponding to the formula recognition sample, that is, a high-definition formula image.
[0145] In an optional embodiment of the present invention, the target label in step S24 includes a text label and an image label, and the calculation of the joint loss value according to the formula recognition result of the formula recognition sample, the image processing result, and the target label includes:
[0146] Sub-step S241, calculating a first loss value of the formula recognition model according to the formula recognition result of the formula recognition sample and the text label;
[0147] Sub-step S242, identifying the image processing result of the sample and the image label according to the formula, and calculating the second loss value of the super-resolution model;
[0148] Sub-step S243: performing weighted summation on the first loss value and the second loss value to obtain a joint loss value.
[0149] The target label of the formula recognition sample includes an image label and a text label, the image label is used to determine the accuracy of the super-resolution model, and the text label is used to determine the accuracy of the formula recognition model.
[0150] In an embodiment of the present invention, by jointly training the formula recognition sample by the formula recognition model and the super-resolution model, two output results can be obtained, namely, the formula recognition result output by the formula recognition model and the image processing result output by the super-resolution model. During the training process, the loss values of the formula recognition model and the super-resolution model can be calculated respectively, and then the joint loss value is determined based on the loss values of the two models.
[0151] Specifically, according to the formula recognition result and text label of the formula recognition sample, the first loss value of the formula recognition model is calculated; according to the image processing result and image label of the formula recognition sample, the second loss value of the super-resolution model is calculated. The first loss value and the second loss value can both be calculated by cross entropy, which is not specifically limited in the embodiment of the present invention.
[0152] Finally, the first loss value and the second loss value are weighted and summed to obtain the joint loss value of the formula recognition model and the super-resolution model, and the model parameters of the formula recognition model and / or the super-resolution model are adjusted according to the joint loss value until the convergence conditions are met to obtain the trained formula recognition model and the super-resolution model. The weight values of the first loss value and the second loss value can be set according to actual needs, or the weight values of the first loss value and the second loss value can be adjusted according to the output results of the two models in each round of training, and this is not specifically limited in the embodiments of the present invention.
[0153] In summary, after obtaining the formula recognition sample and the target label corresponding to the formula recognition sample, the embodiment of the present invention performs iterative joint training on the formula recognition model and the super-resolution model based on the formula recognition sample. In each round of training, the joint loss value is calculated according to the output result of the formula recognition model, the output result of the super-resolution model, and the target label, and the model parameters of the formula recognition model and / or the super-resolution model are adjusted according to the joint loss value; when the joint loss value meets the convergence condition, the trained formula recognition model and super-resolution model are obtained. The embodiment of the present invention introduces the super-resolution model to jointly train the formula recognition model, which adds image details to the training process of the formula recognition model, can solve the problem of blurring of the formula recognition sample to be recognized, improves the recognition accuracy of the formula recognition model for blurry images, and is conducive to improving the robustness and accuracy of the formula recognition model.
[0154] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0155] Device Embodiment
[0156] Reference Figure 5 , shows a structural block diagram of an embodiment of a training device for a formula recognition model of the present invention, the device may include:
[0157] A training data acquisition module 501 is used to acquire formula recognition samples and target labels corresponding to the formula recognition samples;
[0158] An iterative joint training module 502 is used to iteratively joint train the formula recognition model and the super-resolution model based on the formula recognition samples; in each round of training, a joint loss value is calculated according to the output result of the formula recognition model, the output result of the super-resolution model, and the target label, and the model parameters of the formula recognition model and / or the super-resolution model are adjusted according to the joint loss value;
[0159] The training completion module 503 is used to obtain the trained formula recognition model and super-resolution model when the joint loss value meets the convergence condition.
[0160] Optionally, the formula recognition model includes a correction module and a coding module, and the coding module is connected in parallel with the super-resolution model.
[0161] Optionally, the iterative joint training module includes:
[0162] A correction processing submodule, used for inputting the formula recognition sample into the correction module of the formula recognition model for correction processing in each round of training to obtain a correction result corresponding to the formula recognition sample;
[0163] A formula recognition processing submodule, used for inputting the correction result into the encoding and decoding module of the formula recognition model for formula recognition processing to obtain a formula recognition result corresponding to the formula recognition sample;
[0164] An image processing submodule, used for inputting the correction result into the super-resolution model for feature reconstruction processing to obtain an image processing result corresponding to the formula recognition sample;
[0165] The joint loss value calculation submodule is used to calculate the joint loss value according to the formula recognition result of the formula recognition sample, the image processing result, and the target label.
[0166] Optionally, the target label includes a text label and an image label, and the joint loss value calculation submodule includes:
[0167] A first loss value calculation unit, configured to calculate a first loss value of the formula recognition model according to a formula recognition result of the formula recognition sample and the text label;
[0168] A second loss value calculation unit, used to identify the image processing result of the sample and the image label according to the formula, and calculate a second loss value of the super-resolution model;
[0169] A joint loss value calculation unit is used to perform a weighted summation of the first loss value and the second loss value to obtain the joint loss value.
[0170] Optionally, the correction processing submodule includes:
[0171] A control point coordinate determination unit, used for inputting the formula recognition sample into the positioning network layer of the correction module of the formula recognition model to obtain the control point coordinates corresponding to the formula recognition sample;
[0172] A target sampling point determination unit, configured to perform correction processing on the formula recognition sample based on the control point coordinates to obtain a target sampling point corresponding to the formula recognition sample;
[0173] A target pixel point determination unit, used for performing bilinear difference sampling on the target sampling point to obtain a target pixel point corresponding to the target sampling point;
[0174] A correction result generating unit is used to generate a correction result corresponding to the formula recognition sample according to the target pixel point.
[0175] Optionally, the formula recognition processing submodule includes:
[0176] A coding processing unit, used for inputting the correction result into the coding layer of the coding and decoding module for feature extraction, and obtaining the feature code corresponding to the formula recognition sample;
[0177] A relative position code determining unit, used to determine the relative position code corresponding to the feature code;
[0178] A decoding processing unit is used to input the feature code and the relative position code into the decoding layer of the encoding and decoding module for decoding processing to obtain a formula recognition result corresponding to the formula recognition sample.
[0179] Optionally, the image processing submodule includes:
[0180] A feature extraction unit, used for inputting the correction result into the super-resolution basic unit in the super-resolution model for feature extraction, so as to obtain image features corresponding to the correction result;
[0181] The up-sampling processing unit is used to perform up-sampling processing on the image features to obtain the image processing results corresponding to the formula recognition samples.
[0182] Optionally, the training data acquisition module includes:
[0183] A first image acquisition submodule, used to acquire a first image, wherein the first image contains a handwritten formula;
[0184] A second image generation submodule, configured to perform quality degradation processing on the first image to obtain a second image;
[0185] The formula recognition sample determination submodule is used to use a sample pair consisting of the first image and the second image as a formula recognition sample.
[0186] In summary, after obtaining the formula recognition sample and the target label corresponding to the formula recognition sample, the embodiment of the present invention performs iterative joint training on the formula recognition model and the super-resolution model based on the formula recognition sample. In each round of training, the joint loss value is calculated according to the output result of the formula recognition model, the output result of the super-resolution model, and the target label, and the model parameters of the formula recognition model and / or the super-resolution model are adjusted according to the joint loss value; when the joint loss value meets the convergence condition, the trained formula recognition model and super-resolution model are obtained. The embodiment of the present invention introduces the super-resolution model to jointly train the formula recognition model, which adds image details to the training process of the formula recognition model, can solve the problem of blurring of the formula recognition sample to be recognized, improves the recognition accuracy of the formula recognition model for blurry images, and is conducive to improving the robustness and accuracy of the formula recognition model.
[0187] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0188] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0189] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0190] An embodiment of the present invention provides a device for model training, the device comprising a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors, wherein the one or more programs include instructions for performing the following operations:
[0191] A11. Obtain a formula recognition sample and a target label corresponding to the formula recognition sample;
[0192] A12. Based on the formula recognition samples, iteratively jointly train the formula recognition model and the super-resolution model; in each round of training, calculate a joint loss value according to an output result of the formula recognition model, an output result of the super-resolution model, and the target label, and adjust model parameters of the formula recognition model and / or the super-resolution model according to the joint loss value;
[0193] A13. When the joint loss value satisfies the convergence condition, a trained formula recognition model and a super-resolution model are obtained.
[0194] Optionally, the formula recognition model includes a correction module and a coding module, and the coding module is connected in parallel with the super-resolution model.
[0195] Optionally, in each round of training, calculating a joint loss value according to an output result of the formula recognition model, an output result of the super-resolution model, and the target label includes:
[0196] In each round of training, the formula recognition sample is input into the correction module of the formula recognition model for correction processing to obtain the correction result corresponding to the formula recognition sample;
[0197] Inputting the correction result into the encoding and decoding module of the formula recognition model for formula recognition processing to obtain a formula recognition result corresponding to the formula recognition sample;
[0198] Inputting the correction result into the super-resolution model for feature reconstruction processing to obtain the image processing result corresponding to the formula recognition sample;
[0199] The joint loss value is calculated according to the formula recognition result of the formula recognition sample, the image processing result, and the target label.
[0200] Optionally, the target label includes a text label and an image label, and the calculating the joint loss value according to the formula recognition result of the formula recognition sample, the image processing result, and the target label includes:
[0201] Calculating a first loss value of the formula recognition model according to the formula recognition result of the formula recognition sample and the text label;
[0202] Identify the image processing result of the sample and the image label according to the formula, and calculate a second loss value of the super-resolution model;
[0203] The first loss value and the second loss value are weightedly summed to obtain the joint loss value.
[0204] Optionally, the step of inputting the formula recognition sample into a correction module of the formula recognition model for correction processing to obtain a correction result corresponding to the formula recognition sample includes:
[0205] Inputting the formula recognition sample into the positioning network layer of the correction module of the formula recognition model to obtain the control point coordinates corresponding to the formula recognition sample;
[0206] Performing correction processing on the formula recognition sample based on the control point coordinates to obtain the target sampling point corresponding to the formula recognition sample;
[0207] Performing bilinear difference sampling on the target sampling point to obtain a target pixel point corresponding to the target sampling point;
[0208] A correction result corresponding to the sample identified by the formula is generated according to the target pixel point.
[0209] Optionally, the step of inputting the correction result into the encoding and decoding module of the formula recognition model for formula recognition processing to obtain a formula recognition result corresponding to the formula recognition sample includes:
[0210] Inputting the correction result into the coding layer of the coding and decoding module for feature extraction to obtain the feature code corresponding to the formula recognition sample;
[0211] Determine a relative position code corresponding to the feature code;
[0212] The feature code and the relative position code are input into the decoding layer of the encoding and decoding module for decoding processing to obtain the formula recognition result corresponding to the formula recognition sample.
[0213] Optionally, the step of inputting the correction result into the super-resolution model for feature reconstruction to obtain an image processing result corresponding to the formula recognition sample includes:
[0214] Inputting the correction result into the super-resolution basic unit in the super-resolution model to perform feature extraction, so as to obtain image features corresponding to the correction result;
[0215] The image features are upsampled to obtain image processing results corresponding to the formula recognition samples.
[0216] Optionally, obtaining a formula to identify a sample includes:
[0217] Acquire a first image, wherein the first image contains a handwritten formula;
[0218] Performing quality degradation on the first image to obtain a second image;
[0219] A sample pair consisting of the first image and the second image is used as a formula recognition sample.
[0220] Figure 6 8 is a block diagram of an apparatus 800 for model training according to an exemplary embodiment. For example, the apparatus 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0221] Reference Figure 6, the device 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power component 806 , a multimedia component 808 , an audio component 810 , an input / output (I / O) interface 812 , a sensor component 814 , and a communication component 816 .
[0222] The processing component 802 generally controls the overall operation of the device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.
[0223] The memory 804 is configured to store various types of data to support operations on the device 800. Examples of such data include instructions for any application or method operating on the device 800, contact data, phone book data, messages, pictures, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0224] The power supply component 806 provides power to the various components of the device 800. The power supply component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 800.
[0225] The multimedia component 808 includes a screen that provides an output interface between the device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0226] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC), and when the device 800 is in an operating mode, such as a call mode, a recording mode, and a voice information processing mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 804 or sent via the communication component 816. In some embodiments, the audio component 810 also includes a speaker for outputting audio signals.
[0227] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.
[0228] The sensor assembly 814 includes one or more sensors for providing various aspects of status assessment for the device 800. For example, the sensor assembly 814 can detect the open / closed state of the device 800, the relative positioning of components, such as the display and keypad of the device 800, the sensor assembly 814 can also detect the position change of the voice processing device 800 or a component of the device 800, the presence or absence of user contact with the device 800, the orientation or acceleration / deceleration of the device 800, and the temperature change of the device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 814 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0229] The communication component 816 is configured to facilitate wired or wireless communication between the device 800 and other devices. The device 800 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency information processing (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0230] In an exemplary embodiment, the apparatus 800 may be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to perform the above method.
[0231] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, and the instructions can be executed by the processor 820 of the device 800 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0232] Figure 7 1 is a schematic diagram of the structure of the server in some embodiments of the present invention. The server 1900 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 1922 (for example, one or more processors) and memory 1932, and one or more storage media 1930 (for example, one or more mass storage devices) storing application programs 1942 or data 1944. Among them, the memory 1932 and the storage medium 1930 can be short-term storage or permanent storage. The program stored in the storage medium 1930 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the server. Furthermore, the central processing unit 1922 can be configured to communicate with the storage medium 1930 and execute a series of instruction operations in the storage medium 1930 on the server 1900.
[0233] The server 1900 may also include one or more power supplies 1926, one or more wired or wireless network interfaces 1950, one or more input and output interfaces 1958, one or more keyboards 1956, and / or, one or more operating systems 1941, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
[0234] A non-transitory computer-readable storage medium, when the instructions in the storage medium are executed by a processor of a device (server or terminal), enables the device to perform Figure 2 The training method of the formula recognition model is shown.
[0235] A non-temporary computer-readable storage medium, when the instructions in the storage medium are executed by a processor of a device (server or terminal), enables the device to execute a training method for a formula recognition model, the method comprising: obtaining a formula recognition sample and a target label corresponding to the formula recognition sample; based on the formula recognition sample, iteratively jointly training the formula recognition model and the super-resolution model; in each round of training, calculating a joint loss value according to an output result of the formula recognition model, an output result of the super-resolution model, and the target label, and adjusting model parameters of the formula recognition model and / or the super-resolution model according to the joint loss value; when the joint loss value meets a convergence condition, a trained formula recognition model and super-resolution model are obtained.
[0236] Those skilled in the art will readily appreciate other embodiments of the invention after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses or adaptations of the present invention that follow the general principles of the present invention and include common knowledge or customary techniques in the art that are not disclosed in this disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present invention are indicated by the following claims.
[0237] It should be understood that the present invention is not limited to the exact construction that has been described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.
[0238] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
[0239] The above is a detailed introduction to a training method for a formula recognition model, a training device for a formula recognition model and a device for model training provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the ideas of the present invention, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A training method for a formula recognition model, characterized in that: The method comprises: Acquire a formula recognition sample and a target label corresponding to the formula recognition sample, wherein the target label includes a text label and an image label; Based on the formula recognition samples, the formula recognition model and the super-resolution model are iteratively jointly trained; in each round of training, the formula recognition samples are input into the correction module of the formula recognition model for correction processing to obtain the correction result corresponding to the formula recognition sample; the correction result is input into the encoding and decoding module of the formula recognition model for formula recognition processing to obtain the formula recognition result corresponding to the formula recognition sample; the correction result is input into the super-resolution model for feature reconstruction processing to obtain the image processing result corresponding to the formula recognition sample; according to the formula recognition result of the formula recognition sample and the text label, the first loss value of the formula recognition model is calculated; according to the image processing result of the formula recognition sample and the image label, the second loss value of the super-resolution model is calculated; the first loss value and the second loss value are weightedly summed to obtain a joint loss value, and the model parameters of the formula recognition model and / or the super-resolution model are adjusted according to the joint loss value; wherein the formula recognition model includes a correction module and an encoding and decoding module, and the encoding and decoding module is connected in parallel with the super-resolution model; When the joint loss value meets the convergence condition, a trained formula recognition model and a super-resolution model are obtained.
2. The method according to claim 1, characterized in that The step of inputting the formula recognition sample into the correction module of the formula recognition model for correction processing to obtain a correction result corresponding to the formula recognition sample includes: Inputting the formula recognition sample into the positioning network layer of the correction module of the formula recognition model to obtain the control point coordinates corresponding to the formula recognition sample; Performing correction processing on the formula recognition sample based on the control point coordinates to obtain the target sampling point corresponding to the formula recognition sample; Performing bilinear difference sampling on the target sampling point to obtain a target pixel point corresponding to the target sampling point; A correction result corresponding to the sample identified by the formula is generated according to the target pixel point.
3. The method according to claim 1, characterized in that: The step of inputting the correction result into the encoding and decoding module of the formula recognition model for formula recognition processing to obtain the formula recognition result corresponding to the formula recognition sample includes: Inputting the correction result into the coding layer of the coding and decoding module for feature extraction to obtain the feature code corresponding to the formula recognition sample; Determine a relative position code corresponding to the feature code; The feature code and the relative position code are input into the decoding layer of the encoding and decoding module for decoding processing to obtain the formula recognition result corresponding to the formula recognition sample.
4. The method according to claim 1, characterized in that: The step of inputting the correction result into the super-resolution model for feature reconstruction to obtain the image processing result corresponding to the formula recognition sample includes: Inputting the correction result into the super-resolution basic unit in the super-resolution model to perform feature extraction, so as to obtain image features corresponding to the correction result; The image features are upsampled to obtain image processing results corresponding to the formula recognition samples.
5. The method according to any one of claims 1 to 4, characterized in that: The obtaining of formula recognition samples includes: Acquire a first image, wherein the first image contains a handwritten formula; Performing quality degradation on the first image to obtain a second image; A sample pair consisting of the first image and the second image is used as a formula recognition sample.
6. A training device for a formula recognition model, characterized in that: The device comprises: A training data acquisition module, used to acquire formula recognition samples and target labels corresponding to the formula recognition samples, wherein the target labels include text labels and image labels; an iterative joint training module, for iteratively joint training a formula recognition model and a super-resolution model based on the formula recognition sample; in each round of training, the formula recognition sample is input into the correction module of the formula recognition model for correction processing to obtain a correction result corresponding to the formula recognition sample; the correction result is input into the encoding and decoding module of the formula recognition model for formula recognition processing to obtain a formula recognition result corresponding to the formula recognition sample; the correction result is input into the super-resolution model for feature reconstruction processing to obtain an image processing result corresponding to the formula recognition sample; a first loss value of the formula recognition model is calculated according to the formula recognition result of the formula recognition sample and the text label; a second loss value of the super-resolution model is calculated according to the image processing result of the formula recognition sample and the image label; the first loss value and the second loss value are weighted summed to obtain a joint loss value, and model parameters of the formula recognition model and / or the super-resolution model are adjusted according to the joint loss value; the formula recognition model includes a correction module and an encoding and decoding module, and the encoding and decoding module is connected in parallel with the super-resolution model; The training completion module is used to obtain the trained formula recognition model and super-resolution model when the joint loss value meets the convergence condition.
7. The device according to claim 6, characterized in that The correction processing submodule includes: A control point coordinate determination unit, used for inputting the formula recognition sample into the positioning network layer of the correction module of the formula recognition model to obtain the control point coordinates corresponding to the formula recognition sample; A target sampling point determination unit, configured to perform correction processing on the formula recognition sample based on the control point coordinates to obtain a target sampling point corresponding to the formula recognition sample; A target pixel point determination unit, used for performing bilinear difference sampling on the target sampling point to obtain a target pixel point corresponding to the target sampling point; A correction result generating unit is used to generate a correction result corresponding to the formula recognition sample according to the target pixel point.
8. A device for model training, characterized in that: The device includes a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors. The one or more programs include instructions for executing the training method of the formula recognition model as described in any one of claims 1 to 5.
9. A machine-readable medium having instructions stored thereon, which, when executed by one or more processors, causes a device to execute the method for training a formula recognition model as described in any one of claims 1 to 5.
