Formula recognition method, device, storage medium and electronic device

By performing node detection and tree structure construction on formula images, the problem of low formula recognition accuracy is solved, a more efficient formula recognition process is achieved, and an ordered tree structure is returned to facilitate subsequent applications.

CN114764915BActive Publication Date: 2024-09-06BEIJING KAITUO HONGYE HIGH TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210314231.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-28
Publication Date
2024-09-06
Estimated Expiration
2042-03-28

AI Technical Summary

Technical Problem

Formula recognition methods in the prior art have the problem of low recognition accuracy. Especially when processing complex formulas, traditional methods are difficult to accurately restore the formula structure and are slow.

Method used

By obtaining the target image of the formula to be recognized, node detection is performed to determine the type and location information of the operand nodes and operator nodes, the target tree structure is constructed, the tree structure description information is used to determine the formula content, and the formula is converted into a directed graph. Vertex detection and connection prediction problems.

Benefits of technology

The accuracy and speed of formula recognition are improved, and the returned result is an ordered tree, which facilitates subsequent applications such as comparison, and overcomes the problems of low accuracy and slow speed of traditional methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114764915B
    Figure CN114764915B
Patent Text Reader

Abstract

The present disclosure relates to a formula recognition method, device, storage medium and electronic device, the method comprising: obtaining a target image including a formula to be recognized; performing node detection on the target image to obtain the type and position information of each target node included in the target image, the type of the target node including an operand node and an operator node; determining the link relationship between each target node according to the type and position information of each target node, the link relationship including whether there is a connection relationship between the nodes and the type of the connecting edge between two nodes with a connection relationship; constructing a target tree structure according to the link relationship between each target node; determining the content corresponding to the formula to be recognized based on the target tree structure and the tree structure description information. The method disclosed in the present disclosure can improve the accuracy of formula recognition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence technology, and in particular, to a formula recognition method, device, storage medium and electronic device. Background Art

[0002] In recent years, with the rapid development of artificial intelligence, text recognition methods based on artificial intelligence technology have gradually emerged. In text recognition scenarios, in addition to common text recognition, formula recognition is often involved. However, the formula recognition method in the related art has the problem of low recognition accuracy. Summary of the invention

[0003] The purpose of the present disclosure is to provide a formula recognition method, device, storage medium and electronic device to improve the accuracy of formula recognition.

[0004] In order to achieve the above objectives, in a first aspect, the present disclosure provides a formula recognition method, the method comprising:

[0005] Acquire a target image including a formula to be recognized;

[0006] Performing node detection on the target image to obtain the type and position information of each target node included in the target image, wherein the type of the target node includes an operand node and an operator node;

[0007] Determine the link relationship between the target nodes according to the type and position information of the target nodes, wherein the link relationship includes whether there is a connection relationship between the nodes and the type of the connection edge between the two nodes with a connection relationship;

[0008] Constructing a target tree structure according to the link relationship between the target nodes;

[0009] Based on the target tree structure and the tree structure description information, the content corresponding to the formula to be identified is determined.

[0010] Optionally, determining the link relationship between each target node according to the type and position information of each target node includes:

[0011] Performing feature extraction on the type of each target node to obtain a first nested vector corresponding to each target node, and performing feature extraction on the position information of each target node to obtain a second nested vector corresponding to each target node;

[0012] Based on the types of the target nodes, determining a target graph structure composed of the target nodes;

[0013] Based on the first nested vectors corresponding to the target nodes, the second nested vectors corresponding to the target nodes, and the target graph structure, obtaining third nested vectors corresponding to the target nodes;

[0014] Based on the third nested vectors corresponding to the target nodes, obtaining each node pair having a connection relationship;

[0015] The edges of each node pair are classified by using a pre-trained edge classification model to obtain the type of the connection edge between two nodes that have a connection relationship.

[0016] Optionally, the extracting features of the types of the respective target nodes to obtain first nested vectors corresponding to the respective target nodes includes:

[0017] Perform one-hot encoding on the type of each target node to obtain a one-hot vector corresponding to each target node;

[0018] The one-hot vectors corresponding to the target nodes are input into a pre-trained fully connected network to obtain first nested vectors corresponding to the target nodes.

[0019] Optionally, the extracting features of the position information of each target node to obtain a second nested vector corresponding to each target node includes:

[0020] Normalizing the position information of each target node to obtain corresponding normalized position information of each target node;

[0021] The corresponding normalized position information of each target node is processed using a cosine nesting formula to obtain a corresponding second nesting vector of each target node.

[0022] Optionally, the determining, based on the types of the respective target nodes, a target graph structure composed of the respective target nodes comprises:

[0023] The types of the target nodes are processed using a KNN algorithm to obtain a target adjacency matrix, wherein the target adjacency matrix represents a target graph structure composed of the target nodes.

[0024] Optionally, the method further comprises:

[0025] Processing the target adjacency matrix using the transposed matrix of the target adjacency matrix to obtain a symmetric adjacency matrix;

[0026] The obtaining, based on the first nested vectors corresponding to the respective target nodes, the second nested vectors corresponding to the respective target nodes, and the target graph structure, a third nested vector corresponding to the respective target nodes comprises:

[0027] A pre-trained graph convolutional neural network model is used to process the first nested vectors corresponding to each target node, the second nested vectors corresponding to each target node, and the symmetric adjacency matrix to obtain a third nested vector corresponding to each target node.

[0028] Optionally, constructing a target tree structure according to the link relationship between the target nodes includes:

[0029] Determine the hierarchical relationship between two nodes having a connection relationship according to the link relationship between the target nodes;

[0030] The target tree structure is constructed according to the hierarchical relationship between two nodes having a connection relationship and the type of the connection edge.

[0031] In a second aspect, the present disclosure further provides a formula recognition device, the device comprising:

[0032] An acquisition module, used for acquiring a target image including a formula to be recognized;

[0033] A node detection module, used to perform node detection on the target image to obtain the type and position information of each target node included in the target image, wherein the type of the target node includes an operand node and an operator node;

[0034] A link relationship prediction module, used to determine the link relationship between each target node according to the type and position information of each target node, wherein the link relationship includes whether there is a connection relationship between the nodes and the type of the connection edge between two nodes with a connection relationship;

[0035] A target tree construction module, used to construct a target tree structure according to the link relationship between the target nodes;

[0036] A determination module is used to determine the content corresponding to the formula to be identified based on the target tree structure and the tree structure description information.

[0037] In a third aspect, the present disclosure further provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of the method in the first aspect when executed by a processor.

[0038] In a fourth aspect, the present disclosure further provides an electronic device, including:

[0039] a memory having a computer program stored thereon;

[0040] A processor is used to execute the computer program in the memory to implement the steps of the method in the first aspect.

[0041] Through the above technical solution, after obtaining the target image including the formula to be recognized, the target image is node detected to obtain the type and position information of each target node included in the target image, the type of the target node includes an operand node and an operator node, and then the link relationship between each target node is determined according to the type and position information of each target node, the link relationship includes whether there is a connection relationship between the nodes, and the type of the connecting edge of two nodes with a connection relationship, and then the target tree structure is constructed according to the link relationship between each target node, and finally the content corresponding to the formula to be recognized can be determined based on the target tree structure and the tree structure description information. Since the tree structure is used instead of Latex encoding to represent the formula, and after determining the link relationship between each target node, the target tree structure can be constructed according to the link relationship between each target node, which is equivalent to converting the problem definition from a common sequence recognition problem to a vertex detection and connection prediction problem of a directed graph, overcoming the problem of low formula recognition accuracy in the traditional formula recognition method, and also improving the speed of formula recognition. In addition, the result returned in the formula recognition method is an ordered tree, which is convenient for subsequent applications such as comparison.

[0042] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the following specific embodiments, they are used to explain the present disclosure but do not constitute a limitation of the present disclosure. In the accompanying drawings:

[0044] Figure 1 It is a flowchart of a formula recognition method provided by an embodiment of the present disclosure.

[0045] Figure 2 It is a schematic diagram of a formula tree provided by an embodiment of the present disclosure.

[0046] Figure 3 It is another formula tree diagram provided by an embodiment of the present disclosure.

[0047] Figure 4 It is another formula tree diagram provided by an embodiment of the present disclosure.

[0048] Figure 5 It is a flowchart of a specific implementation of step S130 provided in an embodiment of the present disclosure.

[0049] Figure 6 It is a schematic diagram of a process of constructing a target structure tree provided by an embodiment of the present disclosure.

[0050] Figure 7 It is a structural diagram of a formula recognition device provided by an embodiment of the present disclosure.

[0051] Figure 8 It is a structural diagram of another formula recognition device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0052] The specific implementation of the present disclosure is described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation described herein is only used to illustrate and explain the present disclosure, and is not used to limit the present disclosure.

[0053] In the related art, formula recognition methods can include the following two categories:

[0054] 1. Express the formula as a Latex sequence and use an image to sequence type deep learning model for sequence generation.

[0055] 2. Use various single-character detection and recognition methods to detect and recognize individual symbols. After obtaining the category and position information of each symbol, use a series of heuristic rules to deduce the relationship between symbols.

[0056] For the first type of method, the Latex sequence ignores the topological relationship of the position information between the elements in the formula. In addition, the image-to-sequence model uses an attention mechanism in the decoding process, and the time complexity is O(N 2 ), N is the target sequence length. This results in a slow algorithm speed and low parallelism, which makes it impossible to efficiently utilize parallel computing devices. In addition, during the sequence decoding process, errors in the intermediate steps will continue to accumulate, making it easier to identify errors in long sequences.

[0057] For the second type of method, it is difficult to restore the structure of formulas with complex typesetting based on heuristic rules alone. And for different typesetting methods, the rules need to be adjusted accordingly. This type of method generally has a low accuracy rate.

[0058] It can be seen that the formula recognition method in the related art has at least the problem of low recognition accuracy. Therefore, in order to solve the above problem, the inventor proposed the formula recognition method, device, storage medium and electronic device provided by the present disclosure. After obtaining the target image including the formula to be recognized, the target image is subjected to node detection to obtain the type and position information of each target node included in the target image. The type of the target node includes operand nodes and operator nodes. Then, according to the type and position information of each target node, the link relationship between each target node is determined. The link relationship includes whether there is a connection relationship between the nodes and the type of the connection edge between the two nodes with a connection relationship. Then, according to the link relationship between each target node, a target tree structure is constructed. Finally, based on the target tree structure and the tree structure description information, the content corresponding to the formula to be recognized can be determined. Since a tree structure is used instead of Latex code to represent formulas, and after the link relationship between each target node is determined, the target tree structure can be constructed according to the link relationship between each target node. This is equivalent to transforming the problem definition from a common sequence recognition problem to a vertex detection and connection prediction problem of a directed graph. This overcomes the problem of low formula recognition accuracy in traditional formula recognition methods and improves the speed of formula recognition. In addition, the result returned in the formula recognition method is an ordered tree, which is convenient for subsequent applications such as comparison.

[0059] See also Figure 1 , Figure 1 The present invention is a flowchart of a formula recognition method according to an exemplary embodiment of the present invention, which is applied to an electronic device, such as a mobile terminal or a server. The mobile terminal includes: a mobile phone, a notebook, a tablet computer, a desktop computer, a smart TV, etc. The server includes: a local server and a cloud server. The formula recognition method includes steps S110 to S150.

[0060] Specific:

[0061] S110, obtaining a target image including a formula to be recognized.

[0062] S120, performing node detection on the target image to obtain the type and position information of each target node included in the target image. The types of target nodes include operand nodes and operator nodes.

[0063] S130, determining the link relationship between each target node according to the type and position information of each target node, where the link relationship includes whether there is a connection relationship between the nodes and the type of the connection edge between two nodes with a connection relationship.

[0064] S140, constructing a target tree structure according to the link relationship between each target node.

[0065] S150, determining the content corresponding to the formula to be identified based on the target tree structure and the tree structure description information.

[0066] In the disclosed embodiment, a tree data structure (referred to as tree structure or formula tree) may be used to represent formulas instead of Latex encoding. The tree structure description information is introduced below:

[0067] In a tree structure, nodes can include two types: operand nodes and operator nodes.

[0068] The operands can be numbers or symbols, and each operand can be composed of one or more characters, such as 1, 15, n, 2n, etc. Operators are various legal explicit mathematical operation symbols such as addition, subtraction, multiplication, division, various brackets, and various function symbols.

[0069] The edges in the tree structure can be of the following four types.

[0070] Type 1: The parent node is an explicit operator, and the child node is any legal subtree. Type 1 means that the parent node performs a specified type of operation on the child node.

[0071] For example, please refer to Figure 1 , Figure 1 The formula shown is The formula tree shows that in Figure 2 In the tree structure, all edges are of type 1, and the node div represents division or semicolon.

[0072] Type 2: Subscript.

[0073] Type 3: superscripts, exponential operations, superscripts of summation and multiplication symbols.

[0074] Type 4: Implicit operators, such as the omitted multiplication sign.

[0075] Among them, for type 2, type 3 and type 4, they can be converted into a rooted tree after obtaining the edges to maintain the consistency of the tree structure. Figure 3 , Figure 3 The formula x is shown 2 Schematic diagram of the graph structure before and after the supplementation operator.

[0076] For another example, please refer to Figure 4 , Figure 4 The formula shown is The formula tree shows that in Figure 4 In the tree structure, the edges include three types of edges: type 1 to type 3. The type of edge can be represented by the number on each edge. Figure 4As shown, the number 1 on the side represents type 1, the number 2 on the side represents type 2, the number 3 on the side represents type 3, up represents superscript, bracket represents parentheses, comb represents combination operator, and sigma represents summation operator.

[0077] In addition, in some embodiments, the type of edge can also be distinguished by the color of the edge. For example, if the type of edge is type 1, the edge can be set to black, if the type of edge is type 2, the edge can be set to green, if the type of edge is type 3, the edge can be set to yellow, etc.

[0078] It should be noted that in the embodiments of the present disclosure, the tree structure may have the following properties:

[0079] 1. For any legal formula, the leaf node must be an operand.

[0080] 2. For any non-root node, there is only one parent node.

[0081] 3. The total number of edges is equal to the total number of nodes minus 1.

[0082] 4. For any operator, the number of child nodes is known and depends on the operator type. For example, addition must have two child nodes.

[0083] 5. The depth of the node indicates the priority of operation. The greater the depth, the higher the priority of operation.

[0084] After the tree structure is defined, any formula can be represented by the tree structure. After the tree structure is obtained, the content of the formula to be identified can be determined by further combining the tree structure description information.

[0085] From the properties of the aforementioned formula, it can be seen that the composition of the formula is determined by the operands, operators and the relative position information relationship between the operands and operators in the formula. Therefore, in order to extract the features of the formula in the image, in the embodiment of the present disclosure, node detection can be first performed on the target image to obtain the type and position information of each target node included in the target image.

[0086] Furthermore, after obtaining the type and position information of each target node included in the target image, in order to construct the target tree structure, the link relationship between each node in the tree structure can be determined according to the type and position information of each target node included in the target image. Furthermore, after determining the link relationship between each node in the tree structure, the target tree structure can be constructed.

[0087] In some implementations, the location information of the target nodes may be the relative location relationship between the target nodes. For example, in the formula (x+a) nIn the figure, “n” is located at the upper right of “(x+a)”, and “a” is located to the right of “x” and “+” and is at the same height as “x” and “+”.

[0088] In other implementations, the location information of the target nodes may be the coordinate location range of each target node.

[0089] By adopting the above technical scheme, after obtaining the target image including the formula to be recognized, the target image is node detected to obtain the type and position information of each target node included in the target image, the type of the target node includes the operand node and the operator node, and then the link relationship between each target node is determined according to the type and position information of each target node, the link relationship includes whether there is a connection relationship between the nodes, and the type of the connecting edge of two nodes with a connection relationship, and then the target tree structure is constructed according to the link relationship between each target node, and finally the content corresponding to the formula to be recognized can be determined based on the target tree structure and the tree structure description information. Since the tree structure is used instead of Latex encoding to represent the formula, and after determining the link relationship between each target node, the target tree structure can be constructed according to the link relationship between each target node, which is equivalent to converting the problem definition from a common sequence recognition problem to a vertex detection and connection prediction problem of a directed graph, overcoming the problem of low formula recognition accuracy in the traditional formula recognition method, and also improving the speed of formula recognition. In addition, the result returned in the formula recognition method is an ordered tree, which is convenient for subsequent applications such as comparison.

[0090] In some implementations, node detection may be performed on the target image using a pre-trained neural network model. In this case, performing node detection on the target image to obtain the type and position information of each target node included in the target image may include the following steps:

[0091] The target image is input into a pre-trained node detection model to obtain a first recognition result output by the node detection model. The first recognition result includes each target node and the type and position information of each target node.

[0092] In the disclosed embodiments, the pre-trained node detection model can be implemented by any object detection or instance segmentation algorithm, such as MASK-RCNN.

[0093] In some embodiments, Figure 5 As shown, in step S130, determining the link relationship between each target node according to the type and location information of each target node may include the following steps:

[0094] S131, extracting features from the type of each target node to obtain a first nested vector corresponding to each target node, and extracting features from the position information of each target node to obtain a second nested vector corresponding to each target node.

[0095] In the disclosed embodiment, the type and location information of each target node may be converted into corresponding embedding vectors, namely, a first embedding vector and a second embedding vector, wherein the first embedding vector is used to express the type of the target node in the form of a vector, and the second embedding vector is used to express the location information of the target node in the form of a vector.

[0096] In some implementations, performing feature extraction on the type of each target node to obtain a first nested vector corresponding to each target node may include the following steps:

[0097] The type of each target node is one-hot encoded to obtain the one-hot vector corresponding to each target node; the one-hot vector corresponding to each target node is input into a pre-trained fully connected network to obtain the first nested vector corresponding to each target node.

[0098] Among them, unique hot encoding is also called One-Hot encoding.

[0099] In some implementations, performing feature extraction on the position information of each target node to obtain a second nested vector corresponding to each target node may include the following steps:

[0100] The position information of each target node is normalized to obtain the corresponding normalized position information of each target node; the corresponding normalized position information of each target node is processed using the cosine nesting formula to obtain the corresponding second nested vector of each target node.

[0101] S132, based on the type of each target node, determine the target graph structure composed of each target node.

[0102] In some implementations, the KNN algorithm may be used to process the type of each target node to obtain a target adjacency matrix, where the target adjacency matrix represents a target graph structure composed of each target node.

[0103] In some implementations, when the KNN algorithm is used to obtain the target graph structure, a uniform K value may be used to obtain the neighborhood, or K values ​​of different sizes may be used for different types of nodes.

[0104] In other embodiments, when the target graph structure is obtained using the KNN algorithm, different sizes of neighborhoods can be preset for different types of nodes, and the neighborhoods are sampled according to the distance. For example, for the node + (representing the plus operator), N nearest vertices on both sides are selected as neighborhoods (N is a hyperparameter), and for brackets, only the vertices between the left and right brackets are selected as neighborhoods.

[0105] S133, based on the first nested vector corresponding to each target node, the second nested vector corresponding to each target node, and the target graph structure, obtain a third nested vector corresponding to each target node.

[0106] In some embodiments, a pre-trained neural network model may be used to process the first nested vector corresponding to each target node, the second nested vector corresponding to each target node, and the target graph structure to obtain a third nested vector corresponding to each target node.

[0107] Among them, the pre-trained neural network model can be a neural network model based on spatial domain convolution or a graph convolutional neural network model (GCN) based on graph convolution.

[0108] In some embodiments, when the pre-trained neural network model is a graph convolutional neural network model, such as a graph convolutional network composed of several layers of GCN networks, considering that the GCN network is a frequency domain graph convolutional network, the target graph structure input to the GCN network must be an undirected graph. In this case, the type of each target node is processed using the KNN algorithm to obtain a target adjacency matrix. After the target adjacency matrix represents the target graph structure composed of each target node, the method of the embodiment of the present disclosure may further include the following steps:

[0109] The target adjacency matrix is ​​processed using the transposed matrix of the target adjacency matrix to obtain a symmetric adjacency matrix.

[0110] In the disclosed embodiment, considering that the graph obtained by the KNN algorithm may be an asymmetric directed graph, it is necessary to convert it into an undirected graph. Specifically, the adjacency matrix obtained by KNN of the nodes and its transposed matrix can be element-by-element ORed to obtain a symmetric adjacency matrix.

[0111] Correspondingly, based on the first nested vectors corresponding to each target node, the second nested vectors corresponding to each target node, and the target graph structure, the step of obtaining the third nested vectors corresponding to each target node may include: using a pre-trained graph convolutional neural network model to process the first nested vectors corresponding to each target node, the second nested vectors corresponding to each target node, and the symmetric adjacency matrix to obtain the third nested vectors corresponding to each target node.

[0112] S134, obtaining each node pair having a connection relationship based on the third nested vector corresponding to each target node.

[0113] In the disclosed embodiment, after obtaining the third nested vector corresponding to each target node, node pairs (similar to Cartesian products) may be constructed between all nodes.

[0114] S135, using a pre-trained edge classification model, classify the edges of each node pair to obtain the type of the connecting edge between two nodes that have a connection relationship.

[0115] In the embodiment of the present disclosure, a pre-trained edge classification model may be used to classify the edges of each node pair to obtain the type of the connecting edge between two nodes in a connection relationship, where the type is, for example, type 1, type 2, or type 3 in the above embodiment.

[0116] In the disclosed embodiment, except for the nodes with connection relationships, other nodes do not have connection relationships. Since the results of the connection relationship between the nodes and the types of the connecting edges between the two nodes with connection relationships are obtained, the link relationship between each target node is determined.

[0117] In some implementations, in step S140, constructing a target tree structure according to the link relationship between each target node may include the following steps:

[0118] According to the link relationship between each target node, the hierarchical relationship between two nodes with a connection relationship is determined; according to the hierarchical relationship between the two nodes with a connection relationship and the type of the connecting edge, the target tree structure is constructed.

[0119] Among them, the hierarchical relationship can be understood as the relationship between the corresponding parent node and child node between two target nodes.

[0120] In the disclosed embodiment, the final link relationship determination process is different in the training process and in the reasoning process. In the training process, we represent the sample tree structure as a directed graph, and the edges in the graph are directed edges from child nodes to parent nodes. That is, the training target is the adjacency matrix of the sample tree structure.

[0121] During the inference process, the target tree structure is constructed iteratively from bottom to top. During the iteration, a set of subtree root nodes is maintained, and parent nodes are continuously predicted for these root nodes until the size of the set is reduced to 1, and then the root nodes that originally meet the conditions are removed from the set. In the initialization phase, all leaf nodes are regarded as the root nodes of independent subtrees and added to the set.

[0122] In some implementations, the process of constructing the target tree structure may refer to the following pseudo code:

[0123]

[0124] In the above code, find_parent() connects node and all nodes in rest_set in parallel to form a vector set, node is denoted as x, and the i-th node in rest_set is denoted as y i , we get the set {z i =concat(x,y i )|i∈[1,N]}. N is the total number of nodes in rest_set. i It is sent to the classification network to obtain the category confidence, and the node corresponding to the index i with the highest score is the target parent node.

[0125] For example, see Figure 6 , Figure 6 The formula is shown The corresponding iterative process of target structure tree construction.

[0126] The following introduces the application scenarios of the formula recognition method of the embodiment of the present disclosure. The formula recognition method of the embodiment of the present disclosure can be applied to scenarios such as homework correction, text copying in images, and automatic calculation.

[0127] It should be noted that the relevant models applied in the above embodiments, such as node detection models, edge classification models, classification networks for determining category confidence, etc., can be trained according to model training methods in related technologies, such as supervised and unsupervised model training methods, which are not elaborated in the embodiments of the present disclosure.

[0128] It should be noted that the above process description is relatively simple, and the detailed description of the relevant processes can refer to the aforementioned embodiments, which will not be repeated here.

[0129] See also Figure 7 An exemplary embodiment of the present disclosure further provides a formula recognition device 700, which is applied to an electronic device. The device 700 includes an acquisition module 710, a node detection module 720, a link relationship prediction module 730, a target tree construction module 740, and a determination module 750, wherein:

[0130] An acquisition module 710 is used to acquire a target image including a formula to be recognized;

[0131] A node detection module 720 is used to perform node detection on the target image to obtain the type and position information of each target node included in the target image, where the type of the target node includes an operand node and an operator node;

[0132] The link relationship prediction module 730 is used to determine the link relationship between each target node according to the type and position information of each target node, wherein the link relationship includes whether there is a connection relationship between the nodes and the type of the connection edge between two nodes with a connection relationship;

[0133] A target tree construction module 740 is used to construct a target tree structure according to the link relationship between the target nodes;

[0134] The determination module 750 is used to determine the content corresponding to the formula to be identified based on the target tree structure and the tree structure description information.

[0135] In some implementations, the link relationship prediction module 730 includes:

[0136] A feature extraction submodule, used to perform feature extraction on the type of each target node to obtain a first nested vector corresponding to each target node, and to perform feature extraction on the position information of each target node to obtain a second nested vector corresponding to each target node;

[0137] A graph structure determination submodule, used for determining a target graph structure composed of the target nodes based on the types of the target nodes;

[0138] A third nested vector determination submodule, configured to obtain a third nested vector corresponding to each target node based on the first nested vector corresponding to each target node, the second nested vector corresponding to each target node, and the target graph structure;

[0139] A node pair determination submodule, used for obtaining each node pair having a connection relationship based on the third nested vector corresponding to each target node;

[0140] The edge type determination submodule is used to classify the edges of each node pair using a pre-trained edge classification model to obtain the type of the connection edge between two nodes that have a connection relationship.

[0141] In some embodiments, the feature extraction submodule is further used to perform one-hot encoding on the type of each target node to obtain a one-hot vector corresponding to each target node; and input the one-hot vector corresponding to each target node into a pre-trained fully connected network to obtain a first nested vector corresponding to each target node.

[0142] In some embodiments, the feature extraction submodule is also used to normalize the position information of each target node to obtain the corresponding normalized position information of each target node; use the cosine nested formula to process the corresponding normalized position information of each target node to obtain the corresponding second nested vector of each target node.

[0143] In some implementations, the graph structure determination submodule is further used to process the types of the target nodes using a KNN algorithm to obtain a target adjacency matrix, wherein the target adjacency matrix represents a target graph structure composed of the target nodes.

[0144] In some embodiments, the device 700 further includes: a symmetric adjacency matrix determination module, which is used to process the target adjacency matrix using the transposed matrix of the target adjacency matrix to obtain a symmetric adjacency matrix. In this case, the third nested vector determination submodule is also used to process the first nested vector corresponding to each target node, the second nested vector corresponding to each target node, and the symmetric adjacency matrix using a pre-trained graph convolutional neural network model to obtain a third nested vector corresponding to each target node.

[0145] In some implementations, the target tree construction module 740 includes:

[0146] A hierarchical relationship determination submodule, used to determine the hierarchical relationship between two nodes having a connection relationship according to the link relationship between the target nodes;

[0147] The target tree construction submodule is used to construct the target tree structure according to the hierarchical relationship between two nodes with a connection relationship and the type of the connection edge.

[0148] 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.

[0149] Figure 8 FIG. 8 is a block diagram of an electronic device 800 according to an exemplary embodiment. Figure 8 As shown, the electronic device 800 may include: a processor 801 and a memory 802. The electronic device 800 may also include one or more of a multimedia component 803, an input / output (I / O) interface 804, and a communication component 805.

[0150] The processor 801 is used to control the overall operation of the electronic device 800 to complete all or part of the steps in the above-mentioned formula recognition method. The memory 802 is used to store various types of data to support the operation of the electronic device 800, and these data may include, for example, instructions for any application or method used to operate on the electronic device 800, and application-related data, such as contact data, sent and received messages, pictures, audio, video, etc. The memory 802 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, referred to as EPROM), programmable read-only memory (Programmable Read-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic memory, flash memory, magnetic disk or optical disk. The multimedia component 803 may include a screen and an audio component. The screen may be, for example, a touch screen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may be further stored in the memory 802 or sent through the communication component 805. The audio component also includes at least one speaker for outputting audio signals. The I / O interface 804 provides an interface between the processor 801 and other interface modules, and the above-mentioned other interface modules may be keyboards, mice, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 805 is used for wired or wireless communication between the electronic device 800 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, 4G, NB-IOT, eMTC, or other 5G, etc., or a combination of one or more of them, is not limited here. Therefore, the corresponding communication component 805 may include: Wi-Fi module, Bluetooth module, NFC module, etc.

[0151] In an exemplary embodiment, the electronic device 800 can be implemented by one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), controllers, microcontrollers, microprocessors or other electronic components to execute the above-mentioned formula recognition method.

[0152] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, and when the program instructions are executed by a processor, the steps of the above-mentioned formula recognition method are implemented. For example, the computer-readable storage medium can be the above-mentioned memory 802 including program instructions, and the above-mentioned program instructions can be executed by the processor 801 of the electronic device 800 to complete the above-mentioned formula recognition method.

[0153] In another exemplary embodiment, a computer program product is also provided. The computer program product includes a computer program executable by a programmable device. The computer program has a code portion for executing the above formula recognition method when executed by the programmable device.

[0154] The preferred embodiments of the present disclosure are described in detail above in conjunction with the accompanying drawings; however, the present disclosure is not limited to the specific details in the above embodiments. Within the technical concept of the present disclosure, a variety of simple modifications can be made to the technical solution of the present disclosure, and these simple modifications all fall within the protection scope of the present disclosure.

[0155] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present disclosure will not further describe various possible combinations.

[0156] In addition, various embodiments of the present disclosure may be arbitrarily combined, and as long as they do not violate the concept of the present disclosure, they should also be regarded as the contents disclosed by the present disclosure.

Claims

1. A formula recognition method, characterized in that: include: Acquire a target image including a formula to be recognized; Performing node detection on the target image to obtain the type and position information of each target node included in the target image, wherein the type of the target node includes an operand node and an operator node; Determine the link relationship between the target nodes according to the type and position information of the target nodes, wherein the link relationship includes whether there is a connection relationship between the nodes and the type of the connection edge between the two nodes with a connection relationship; Constructing a target tree structure according to the link relationship between the target nodes; Based on the target tree structure and the tree structure description information, determining the content corresponding to the formula to be identified; Determining the link relationship between the target nodes according to the type and location information of the target nodes includes: Performing feature extraction on the type of each target node to obtain a first nested vector corresponding to each target node, and performing feature extraction on the position information of each target node to obtain a second nested vector corresponding to each target node; Based on the types of the target nodes, determining a target graph structure composed of the target nodes; Based on the first nested vectors corresponding to the target nodes, the second nested vectors corresponding to the target nodes, and the target graph structure, obtaining third nested vectors corresponding to the target nodes; Based on the third nested vectors corresponding to the target nodes, obtaining each node pair having a connection relationship; The edges of each node pair are classified by using a pre-trained edge classification model to obtain the type of the connection edge between two nodes that have a connection relationship.

2. The formula recognition method according to claim 1, characterized in that: The extracting features of the types of the target nodes to obtain first nested vectors corresponding to the target nodes includes: Perform one-hot encoding on the type of each target node to obtain a one-hot vector corresponding to each target node; The one-hot vectors corresponding to the target nodes are input into a pre-trained fully connected network to obtain first nested vectors corresponding to the target nodes.

3. The formula recognition method according to claim 1, characterized in that: The feature extraction of the position information of each target node to obtain a second nested vector corresponding to each target node includes: Normalizing the position information of each target node to obtain corresponding normalized position information of each target node; The corresponding normalized position information of each target node is processed using a cosine nesting formula to obtain a corresponding second nesting vector of each target node.

4. The formula recognition method according to claim 1, characterized in that: The step of determining a target graph structure composed of the target nodes based on the types of the target nodes includes: The types of the target nodes are processed using a KNN algorithm to obtain a target adjacency matrix, wherein the target adjacency matrix represents a target graph structure composed of the target nodes.

5. The formula recognition method according to claim 4, characterized in that: The method further comprises: Processing the target adjacency matrix using the transposed matrix of the target adjacency matrix to obtain a symmetric adjacency matrix; The obtaining, based on the first nested vectors corresponding to the respective target nodes, the second nested vectors corresponding to the respective target nodes, and the target graph structure, a third nested vector corresponding to the respective target nodes comprises: A pre-trained graph convolutional neural network model is used to process the first nested vectors corresponding to each target node, the second nested vectors corresponding to each target node, and the symmetric adjacency matrix to obtain a third nested vector corresponding to each target node.

6. The formula recognition method according to claim 1, characterized in that: The step of constructing a target tree structure according to the link relationship between the target nodes includes: Determine the hierarchical relationship between two nodes having a connection relationship according to the link relationship between the target nodes; The target tree structure is constructed according to the hierarchical relationship between two nodes having a connection relationship and the type of the connection edge.

7. A formula recognition device, characterized in that: include: An acquisition module, used for acquiring a target image including a formula to be recognized; A node detection module, used to perform node detection on the target image to obtain the type and position information of each target node included in the target image, wherein the type of the target node includes an operand node and an operator node; A link relationship prediction module, used to determine the link relationship between each target node according to the type and position information of each target node, wherein the link relationship includes whether there is a connection relationship between the nodes and the type of the connection edge between two nodes with a connection relationship; A target tree construction module, used to construct a target tree structure according to the link relationship between the target nodes; A determination module, used to determine the content corresponding to the formula to be identified based on the target tree structure and the tree structure description information; The link relationship prediction module comprises: A feature extraction submodule, used to perform feature extraction on the type of each target node to obtain a first nested vector corresponding to each target node, and to perform feature extraction on the position information of each target node to obtain a second nested vector corresponding to each target node; A graph structure determination submodule, used to determine a target graph structure composed of the target nodes based on the types of the target nodes; A third nested vector determination submodule, configured to obtain a third nested vector corresponding to each target node based on the first nested vector corresponding to each target node, the second nested vector corresponding to each target node, and the target graph structure; A node pair determination submodule, used for obtaining each node pair having a connection relationship based on the third nested vector corresponding to each target node; The edge type determination submodule is used to classify the edges of each node pair using a pre-trained edge classification model to obtain the type of the connection edge between two nodes that have a connection relationship.

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

9. An electronic device, characterized in that: include: a memory having a computer program stored thereon; A processor, configured to execute the computer program in the memory to implement the steps of the method according to any one of claims 1 to 6.