WO2023016111A1 - Key value matching method and apparatus, and readable medium and electronic device - Google Patents
Key value matching method and apparatus, and readable medium and electronic device Download PDFInfo
- Publication number
- WO2023016111A1 WO2023016111A1 PCT/CN2022/101765 CN2022101765W WO2023016111A1 WO 2023016111 A1 WO2023016111 A1 WO 2023016111A1 CN 2022101765 W CN2022101765 W CN 2022101765W WO 2023016111 A1 WO2023016111 A1 WO 2023016111A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- attribute
- data
- attribute value
- relationship
- position information
- Prior art date
Links
- 238000000034 method Methods 0.000 title claims abstract description 78
- 238000010586 diagram Methods 0.000 claims description 90
- 239000011159 matrix material Substances 0.000 claims description 85
- 238000012545 processing Methods 0.000 claims description 19
- 238000012549 training Methods 0.000 claims description 17
- 238000004590 computer program Methods 0.000 claims description 16
- 238000013507 mapping Methods 0.000 claims description 5
- 238000001514 detection method Methods 0.000 abstract description 24
- 230000006870 function Effects 0.000 description 19
- 230000008569 process Effects 0.000 description 7
- 230000003287 optical effect Effects 0.000 description 6
- 238000004891 communication Methods 0.000 description 5
- 238000011176 pooling Methods 0.000 description 4
- 238000004422 calculation algorithm Methods 0.000 description 2
- 239000013307 optical fiber Substances 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 239000004065 semiconductor Substances 0.000 description 2
- 238000012546 transfer Methods 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 238000013434 data augmentation Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000002372 labelling Methods 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000010801 machine learning Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000003062 neural network model Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/50—Information retrieval; Database structures therefor; File system structures therefor of still image data
- G06F16/53—Querying
- G06F16/535—Filtering based on additional data, e.g. user or group profiles
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/50—Information retrieval; Database structures therefor; File system structures therefor of still image data
- G06F16/55—Clustering; Classification
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/22—Matching criteria, e.g. proximity measures
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/045—Combinations of networks
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
Definitions
- the present disclosure relates to the technical field of image processing, and in particular, to a key-value matching method, device, readable medium, and electronic equipment.
- the key-value matching in the document image refers to the process of grouping and extracting the texts constituting the key-value relationship in the document image.
- the name and a certain company form a key-value relationship
- the name and Zhang San form a key-value relationship
- in the image of a graduation certificate, the school and a certain university form a key-value relationship Relationship
- key-value matching is to identify and extract the key-value pairs that form this key-value relationship.
- the current key-value matching methods are usually either based on the positional relationship between the key-value pairs, combining the results of text recognition with a preset relational dictionary for search and matching, or classifying and predicting the key-value pairs to be matched.
- relational dictionary lookup matching or classification prediction matching both have poor generalization and can only be applied to specific scenarios.
- the disclosure provides a key-value matching method, device, readable medium and electronic equipment.
- the present disclosure provides a key-value matching method, the method comprising:
- the present disclosure provides a key-value matching device, the device comprising:
- a first acquiring module configured to acquire first position information of at least one attribute data and second position information of at least one attribute value data in the image to be detected;
- a relationship graph generation module configured to generate a first relationship graph according to the first position information of the at least one attribute data, and generate a second relationship graph according to the second position information of the at least one attribute value data;
- a determination module configured to use the first location information of the at least one attribute data, the second location information of the at least one attribute value data, the first relationship diagram, the second relationship diagram and the image to be detected
- a preset map matching model is input to obtain a matching relationship between the attribute data and the attribute value data.
- the present disclosure provides a computer-readable medium on which a computer program is stored, and when the program is executed by a processing device, the steps of the method described in the first aspect above are realized.
- an electronic device including:
- a processing device configured to execute the computer program in the storage device to implement the steps of the method described in the first aspect above.
- the A second relationship graph corresponding to the second position information of the at least one attribute value data, and the image to be detected is input into a preset graph matching model, so that the preset graph matching model outputs the attribute data and the attribute.
- FIG. 1 is a flow chart of a key-value matching method shown in an exemplary embodiment of the present disclosure
- Fig. 2 is a schematic flow chart of a key-value matching method shown in an exemplary embodiment of the present disclosure
- Fig. 4 is the flow chart of another kind of key-value matching method shown according to the embodiment shown in Fig. 1;
- Fig. 5 is a block diagram of a key value matching device shown in another exemplary embodiment of the present disclosure.
- Fig. 6 is a block diagram of a key-value matching device according to the embodiment shown in Fig. 5;
- Fig. 7 is a block diagram of an electronic device shown in an exemplary embodiment of the present disclosure.
- the term “comprise” and its variations are open-ended, ie “including but not limited to”.
- the term “based on” is “based at least in part on”.
- the term “one embodiment” means “at least one embodiment”; the term “another embodiment” means “at least one further embodiment”; the term “some embodiments” means “at least some embodiments.” Relevant definitions of other terms will be given in the description below.
- the present disclosure can be applied to the process of identifying and extracting key-value pairs in a document image, where the document image can be a business license Image, degree certificate image, graduation certificate image, ID card image and other document images.
- the key-value pair refers to a set of texts with a key-value relationship. For example, in a business license image, the name and a certain company form a key-value relationship. It belongs to a key-value pair; in the ID card image, the name and Zhang San form a key-value relationship and belong to a key-value pair; in the graduation certificate image, the school and a certain university form a key-value relationship and belong to a key-value pair.
- the key-value matching method is either to search and match the result of text recognition with the preset relational dictionary according to the positional relationship between the key-values.
- the value pair data is less, and the scene involved is relatively single, resulting in the situation that the matching key value cannot be found in the dictionary; or the data in the processed key value pair is divided into n categories, and a multi-label detection model is used
- this method usually needs to train different multi-label detection models for different scenarios, and the multi-label detection model in each scene requires a large amount of multi-label annotation data, that is, training the multi-label
- the label detection model needs to invest more labeling costs, and the generalization of the obtained multi-label detection model is weak, which can only be applied to specific scenarios, and cannot be applied to other scenarios other than specific scenarios.
- both relational dictionary lookup matching and classification prediction matching have poor generalization and can only be applied to specific scenarios.
- the present disclosure provides a key value matching method, device, readable medium and electronic equipment.
- the key value matching method obtains the first position information and at least one attribute data of at least one attribute data in the image
- the second location information of the value data generate a first relationship diagram according to the first location information of the at least one attribute data, and generate a second relationship diagram according to the second location information of the at least one attribute value data; the at least one attribute data
- the first position information of the at least one attribute value data, the second position information of the at least one attribute value data, the first relationship graph, the second relationship graph and the image to be detected are input into the preset graph matching model to obtain the attribute data and the attribute value data matching relationship.
- performing key-value matching through the preset graph matching model can not only perform key-value matching for different scenarios, ensure the generalization of the model, but also effectively ensure the accuracy of key-value matching results.
- Fig. 1 is a flow chart of a key-value matching method shown in an exemplary embodiment of the present disclosure; referring to Fig. 1, the method may include:
- Step 101 acquiring first position information of at least one attribute data and second position information of at least one attribute value data in an image to be detected.
- the image to be detected may be a business license image, a degree certificate image, a graduation certificate image, an ID card image and other certificate images.
- the attribute data is the data corresponding to the Key in the key-value pair
- the attribute value data is the data corresponding to the Value in the key-value pair
- the Key and the Value form a key-value pair.
- the category and position of the attribute data and attribute value data in the image to be detected can be detected through the binary classification detection model in the prior art, so as to output the corresponding first attribute data of each attribute data in the image to be detected.
- the position of the first detection frame can be used as the first position information, and the second detection frame can be used as the second position information; in another embodiment, the first The center position of the detection frame is used as the first position information, and the center position of the second detection frame is used as the second position information; in another embodiment, any point on the first detection frame can be used as the first position information. For location information, any point on the second detection frame is used as the second location information.
- Step 102 Generate a first relationship diagram according to the first location information of the at least one attribute data, and generate a second relationship diagram according to the second location information of the at least one attribute value data.
- the first relationship diagram includes the attribute node corresponding to the location of each attribute data and the first connection between different attribute nodes
- the second relationship diagram includes the attribute value node corresponding to the location of each attribute value data , and a second link between nodes with different attribute values.
- the first relational graph may be generated by means of Delaunay triangulation mapping according to the first position information of the at least one attribute data; by means of fully connected mapping according to the second position information of the at least one attribute value data The second relationship graph is generated.
- Delaunay triangulation method (Delaunay triangulation, Delaunay triangulation algorithm) and the fully-connected graph-building method (that is, the establishment of a fully-connected network topology map) are commonly used in the prior art. Figures, the present disclosure will not repeat them here.
- Step 103 inputting the first location information of the at least one attribute data, the second location information of the at least one attribute value data, the first relationship graph, the second relationship graph and the image to be detected into a preset graph matching model, A matching relationship between the attribute data and the attribute value data is obtained.
- the preset image matching model is trained through the following steps S1 to S3:
- the model training sample data includes a plurality of image samples to be detected, the first position information of each attribute data in each image sample to be detected, and the second position information of each attribute value data in the image samples to be detected information, and a first relational graph and a second relational graph corresponding to each image sample to be detected.
- the image sample to be detected includes category annotations for attribute data and attribute value data, and annotation data for the corresponding relationship between attribute data and attribute value data.
- the preset initial network model may include a first initial subnetwork and a second initial subnetwork, and the preset initial network model may be a neural network model or other machine learning algorithm models.
- the first position information of at least one attribute data corresponding to the image sample to be detected, the first relationship graph and the image to be detected can be used as the input of the first initial subnetwork to output the image sample to be detected Corresponding to the first feature corresponding to each attribute node, and using the first position information of at least one attribute data corresponding to the image sample to be detected, the first relationship graph and the image to be detected as the input of the second initial subnetwork , to output the second feature corresponding to each first connection line in the image sample to be detected; the second position information of at least one attribute value data corresponding to the image sample to be detected, the second relationship diagram and the to be detected
- the image is used as the input of the first initial sub-network to output the third feature corresponding to each attribute value node in the image sample to be detected, and the second position of at least one attribute value data corresponding to the image sample to be detected Information, the second relational graph and the image to be detected are used as inputs of the second initial subnetwork to output the fourth feature corresponding to each second
- the depth of the second initial subnetwork is greater than the depth of the first initial subnetwork, that is, the number of hidden layers of the first initial subnetwork is less than that of the second initial subnetwork, and the first feature corresponding to the attribute node and the The third feature corresponding to the attribute value node is output by the shallow network (the first initial sub-network), the second feature corresponding to the first connection and the fourth feature corresponding to the second connection are output by the deep network (the second initial sub-network). network) output.
- the first feature and the third feature are obtained by the shallow network
- the second feature and the fourth feature are obtained by the deep network
- the attribute node, the attribute value node, and the first connected feature can be effectively obtained.
- a pooling layer may be included in the first initial subnetwork and the second initial subnetwork, and when obtaining the first feature, the second feature, the third feature, and the fourth feature, the pooling layer may be Perform average pooling on the extracted features.
- the shape of the feature map is 256 ⁇ 64 ⁇ 64 (the number of channels is 256, the length is 64, and the width is 64).
- the detection frame corresponding to the node can be scaled proportionally, and then Extract features at the corresponding positions, and then average pool the extracted features through the pooling layer to obtain the feature vector (256 ⁇ 1 ⁇ 1) of each detection frame. In this way, the data dimension can be effectively reduced, which can help simplify the network complexity, reduce the calculation amount of the model, and achieve the technical effect of improving the efficiency of the model.
- the third feature corresponding to the value node and the fourth feature corresponding to each second connection line calculate the loss value corresponding to the distance vector between each attribute node and the attribute value node to be matched through the preset loss function, according to the loss value pair
- the preset initial network model is iteratively trained to obtain the preset graph matching model.
- the node similarity matrix can be determined according to the first feature corresponding to each of the attribute nodes and the third feature corresponding to each of the attribute value nodes, and according to the second feature corresponding to each of the first connections
- the feature and the fourth feature corresponding to each of the second connections determine the connection similarity matrix; generate a target relationship matrix according to the node similarity matrix and the connection similarity matrix; obtain the pair corresponding to the target relationship matrix A random matrix; determine a distance vector between each attribute node and the attribute value node to be matched according to the double random matrix; determine the loss value through a preset loss function according to the distance vector.
- the first relational graph may be represented by the first adjacency matrix A1
- the second relational graph may be represented by the second adjacency matrix A2
- the incidence matrices corresponding to the second adjacency matrix A2 are G 2 and H 2 respectively.
- the ⁇ can be a symmetric parameter matrix
- the target relationship matrix M can be determined according to the node similarity matrix M p and the connection similarity matrix M e by the following formula 2:
- vec(x) represents the row-wise expansion of x
- [x] represents the diagonal matrix of x
- the eigenvector V corresponding to the target relationship matrix M can be obtained, and then the eigenvector is double-randomized to obtain the double random matrix S corresponding to the eigenvector V, and the attribute is determined by the following formula 3 according to the double random matrix A vector of distances from the node to each attribute value node:
- ⁇ is a preset coefficient, for example, it can be 200
- S is a double random matrix
- i represents the row number of the double random matrix S
- j represents the column number of the double random matrix S
- S(i, 1...m) Represents the i-th row of the double random matrix S
- the double random matrix S has m rows
- P is the location set of attribute value nodes
- P i is the location of the i-th attribute node
- the loss value corresponding to the distance vector between each attribute node and the attribute value node to be matched can be calculated by the following preset loss function L(d), wherein the preset loss function is as follows:
- ⁇ is a random decimal number.
- the loss value corresponding to the distance vector between each attribute node and the attribute value node to be matched can be obtained.
- the loss value is less than or equal to the preset loss value threshold, it is determined that the model training is over and the optimal Preset graph matching model.
- the preset image matching model obtained through the above training method has strong generalization and can be applied to many different key-value matching scenarios. For example, it can be used for key-value matching of ID card images, and can also be applied Key-value matching in multiple scenarios such as business license images and degree certificate images.
- FIG. 2 is a schematic flow chart of a key-value matching method shown in an exemplary embodiment of the present disclosure.
- images 1 to 4 are included, and the image 1 is an image to be detected.
- the image to be detected includes attribute data Key1 and Key2, and attribute value data Value1 and Value2, respectively obtain the positions of Key1, Key2, Value1, and Value2 in image 1 through the binary classification detection model, thus obtaining the detection in image 2 Frame, each detection frame in image 2 represents the position of the identified attribute data or attribute value data.
- Key1 matches Value1, and Key2 matches Value2 (3 in Figure 2).
- the text information Key1:Value1 and Key2:Value2 (4 in FIG. 2 ) can be obtained through character recognition according to the matching relationship. In this way, the key-value matching is performed through the preset graph matching model, which can effectively ensure the accuracy of the key-value matching result.
- the preset graph matching model outputs the matching relationship between the attribute data and the attribute value data, thus, Using the preset graph matching model for key-value matching can not only perform key-value matching for different scenarios, improve the generalization of the model, but also effectively ensure the accuracy of key-value matching results.
- the preset map matching model in step 103 in FIG. 1 is based on the first location information of the at least one attribute data, the second location information of the at least one attribute value data, and the first relationship through the following steps shown in FIG. Fig. 1, the second relationship diagram and the image to be detected determine the matching relationship between the attribute data and the attribute value data
- Fig. 3 is a flow chart of a key-value matching method according to the embodiment shown in Fig. 1, see Fig. 3 , the preset graph matching model can be used for:
- Step 1031 according to the first position information of the at least one attribute data, obtain the first feature corresponding to each attribute node in the first relationship diagram and the second feature corresponding to each first connection line from the image to be detected , and according to the second position information of the at least one attribute value data, the third feature corresponding to each attribute value node in the second relationship graph and the fourth feature corresponding to each second connection are obtained from the image to be detected .
- the first position information of the at least one attribute data, the first relationship graph and the image to be detected can be used as the input of the first sub-network to output the first feature corresponding to each attribute node
- the first position information of the at least one attribute data, the first relationship graph and the image to be detected are used as the input of the second sub-network to output the second feature corresponding to each first connection line, wherein the first The number of hidden layers of a sub-network is less than that of the second sub-network; the second position information of the at least one attribute value data, the second relationship diagram and the image to be detected are used as the input of the first sub-network, and the output is obtained
- the third feature corresponding to each attribute value node, and the second position information of the at least one attribute value data, the second relationship graph and the image to be detected are used as the input of the second sub-network to output each item of the first sub-network
- the number of hidden layers of the first subnetwork is less than that of the second subnetwork, that is, the depth of the second subnetwork is greater than the depth of the first subnetwork, and the first feature corresponding to the attribute node and the attribute
- the third feature corresponding to the value node is output by the first sub-network (that is, a shallow network with fewer hidden layers), and the second feature corresponding to the first connection and the fourth feature corresponding to the second connection are output by the first sub-network.
- the output of the second sub-network that is, a deep network with more hidden layers).
- the third feature can effectively guarantee the accuracy of the first feature and the third feature, which is conducive to providing a reliable data basis for key-value matching; extracting edges (ie, the first connection and the second connection) through the deep network Features can effectively reduce the amount of data processing and improve the efficiency of model processing.
- Step 1032 according to the first characteristic corresponding to each attribute node and the second characteristic corresponding to each first connection, and the third characteristic corresponding to each attribute value node and the first characteristic corresponding to each second connection.
- a possible implementation may include the following steps shown in S21 to S23:
- the connection similarity matrix M e can be determined by the following formula:
- the ⁇ may be a symmetric parameter matrix, for example, may be a 2 ⁇ 2 symmetric parameter matrix.
- the target relationship matrix M can be determined according to the node similarity matrix M p and the connection similarity matrix M e by the following formula:
- vec(x) represents the row-wise expansion of x
- [x] represents the diagonal matrix of x
- the feature vector V corresponding to the target relationship matrix M can be obtained, and the matching relationship between each attribute data and each attribute value data can be determined according to the feature vector V.
- the feature vector V may continue to be double-randomized to obtain a double-randomized matrix S, and the matching relationship between each attribute data and each attribute value data is determined according to the double-randomized matrix S.
- the process of performing double randomization processing belongs to the prior art.
- the process of performing double randomization processing on the feature vector V reference may be made to the implementation manners in the prior art, which will not be repeated in this disclosure.
- the image to be detected includes 3 attribute data (respectively Key1, Key2, Key3) and 3 attribute value data (respectively Value1, Value2, Value3)
- the obtained double random matrix S is:
- the rows of the matrix represent Key1, Key2, and Key3
- the columns of the matrix represent Value1, Value2, and Value3, which means that the Key1 matches the Value1
- the Key2 matches the Value3
- the Key3 matches the Value2.
- the above technical solution can determine the relationship between the attribute data and the image to be detected according to the first position information of the at least one attribute data, the second position information of the at least one attribute value data, the first relationship diagram, the second relationship diagram and the image to be detected.
- the matching relationship of the attribute value data can effectively guarantee the accuracy of the key-value matching result.
- FIG. 4 is a flowchart of another key-value matching method according to the embodiment shown in FIG. 1. As shown in FIG. 4, the method may also include:
- Step 104 acquiring the first quantity of the attribute data and the second quantity of the attribute value data.
- the first quantity of the attribute data may be the number of detection boxes of Key in the image to be detected
- the second quantity of the attribute value data may be the number of detection boxes of Value in the image to be detected
- Step 105 in the case that the first quantity is not equal to the second quantity, by adding the same attribute data at least one position where the attribute data is located, or adding the same attribute data at at least one position where the attribute value data is located attribute value data such that the attribute data is equal in quantity to the attribute value data.
- a possible implementation method includes: when the first quantity is less than the second quantity, adding the same attribute data at the location of each attribute data, and obtaining twice the first quantity and the second quantity
- the first difference of the second quantity is obtained from at least one of the attribute value data corresponding to the number of target attribute value data of the first difference, and an identical attribute value is added at each position of the target attribute value data data, to obtain twice the first quantity of attribute data, and twice the first quantity of attribute value data;
- step 102 in FIG. 1 may include: generating a first relationship diagram according to the first location information corresponding to the twice the first amount of attribute data;
- the second position information corresponding to the quantity of attribute value data generates a second relationship graph.
- the first quantity of attribute data is a
- the second quantity of attribute value data is b
- directly add a piece of data at the position of each attribute data in the image to be detected namely 2a attribute data are obtained
- 2a-b attribute value data are randomly selected in the image to be detected, and an attribute value data is sequentially added to the position of these attribute value data.
- 2a attribute data and 2a attribute value data are obtained.
- another possible implementation method includes: when the first number is greater than the second number, add an identical attribute value data at the location of each attribute value data, and obtain twice the second The second difference between the quantity and the first quantity, and obtain the target attribute data corresponding to the second difference from at least one of the attribute data, and add the same attribute data at the position of the target attribute data, so as to Twice the second amount of attribute data, and twice the second amount of attribute value data are obtained.
- step 102 in FIG. 1 may include: generating a first relationship diagram according to the first position information corresponding to the twice the second amount of attribute data; The second position information corresponding to the quantity of attribute value data generates a second relationship diagram.
- the first quantity of attribute data is a
- the second quantity of attribute value data is b
- directly add a piece of data at the position of each attribute value data in the image to be detected That is, 2b attribute value data are obtained.
- 2b-a attribute data are randomly selected in the image to be detected, and one attribute data is sequentially added to the position of these attribute data.
- 2b attribute data and 2b attribute value data are obtained.
- the above technical solutions can effectively ensure that the attribute data is equal to the attribute value data, thereby ensuring that each attribute data can be matched to the corresponding attribute value data, which is conducive to expanding the range of images to be detected that can be processed, expanding the The scope of the key-value matching method.
- Fig. 5 is a block diagram of a key value matching device shown in another exemplary embodiment of the present disclosure; referring to Fig. 5, the key value matching device may include:
- a first acquiring module 401 configured to acquire first position information of at least one attribute data and second position information of at least one attribute value data in the image to be detected;
- a relationship diagram generation module 402 configured to generate a first relationship diagram according to the first location information of the at least one attribute data, and generate a second relationship diagram according to the second location information of the at least one attribute value data;
- a determining module 403 configured to input the first position information of the at least one attribute data, the second position information of the at least one attribute value data, the first relationship diagram, the second relationship diagram and the image to be detected into a preset diagram Match the model to obtain the matching relationship between the attribute data and the attribute value data.
- the preset graph matching model by using the first position information of the at least one attribute data, the second position information of the at least one attribute value data, and the first relationship diagram corresponding to the first position information of the at least one attribute data, the at least one attribute
- the second relationship graph corresponding to the second position information of the value data, and the image to be detected are input into the preset graph matching model, so that the preset graph matching model outputs the matching relationship between the attribute data and the attribute value data, thus, Using the preset graph matching model for key-value matching can not only perform key-value matching for different scenarios, improve the generalization of the model, but also effectively ensure the accuracy of key-value matching results.
- the first relationship diagram includes the attribute node corresponding to the location of each attribute data and the first connection between different attribute nodes
- the second relationship diagram includes the attribute corresponding to the location of each attribute value data Value nodes, and the second connection between different attribute value nodes
- the preset graph matching model is used for:
- the first feature corresponding to each attribute node in the first relationship graph and the second feature corresponding to each first connection line are obtained from the image to be detected, and according to The second position information of the at least one attribute value data obtains the third feature corresponding to each attribute value node in the second relationship graph and the fourth feature corresponding to each second connection from the image to be detected;
- the preset graph matching model includes a first subnetwork and a second subnetwork, and the preset graph matching model is used for:
- the first position information of the at least one attribute data, the first relationship graph and the image to be detected are used as the input of the first sub-network to output the first feature corresponding to each attribute node, and the at least one attribute
- the first location information of the data, the first relationship graph and the image to be detected are used as the input of the second subnetwork to output the second feature corresponding to each first connection line, wherein the hidden of the first subnetwork the number of layers is less than the second subnetwork;
- the second position information of the at least one attribute value data, the second relationship graph and the image to be detected are used as the input of the first sub-network to output the third feature corresponding to each attribute value node, and the The second position information of at least one attribute value data, the second relationship diagram and the image to be detected are used as inputs of the second sub-network to output the fourth feature corresponding to each second connection line.
- the preset map matching model is used for:
- connection similarity matrix determining a connection similarity matrix according to the second feature corresponding to each of the first connections and the fourth feature corresponding to each of the second connections
- the relationship graph generation module is used for:
- the second relational graph is generated by a fully connected graphing method according to the second position information of the at least one attribute value data.
- Fig. 6 is a block diagram of a key-value matching device according to the embodiment shown in Fig. 5; referring to Fig. 6, the device may also include:
- the second acquiring module 404 is configured to acquire the first quantity of the attribute data and the second quantity of the attribute value data
- a data adding module 405, configured to add the same attribute data at least one location where the attribute data is located, or at least one location where the attribute value data is located when the first quantity is not equal to the second quantity Add the same attribute value data at the place, so that the quantity of the attribute data and the attribute value data is equal.
- the data addition module is used for:
- the first quantity is less than the second quantity
- the relationship graph generation module is used for:
- a second relationship graph is generated according to the second position information corresponding to the twice the first quantity of attribute value data.
- the data augmentation module is used for:
- the relationship graph generation module is used for:
- a second relationship graph is generated according to the second location information corresponding to the twice the second quantity of attribute value data.
- the above technical solutions can effectively ensure that the attribute data is equal to the attribute value data, thereby ensuring that each attribute data can be matched to the corresponding attribute value data, which is conducive to expanding the range of images to be detected that can be processed, expanding the The scope of the key-value matching method.
- the preset image matching model is trained through the following steps:
- the model training sample data includes a plurality of image samples to be detected, the first position information of each attribute data in each image sample to be detected, and each attribute value data in the image sample to be detected The second position information, and the first relationship diagram and the second relationship diagram corresponding to each image sample to be detected;
- the first feature corresponding to each attribute node and each first connection in the first relationship diagram of the image sample to be detected are obtained from the image sample to be detected through a preset network initial model.
- each attribute value node in the second relationship diagram of the image sample to be detected is obtained from the image sample to be detected through the preset network initial model corresponding to The third feature of and the fourth feature corresponding to each second connecting line;
- the initial network model is set to perform iterative training to obtain the preset image matching model.
- the third feature corresponding to each attribute value node in the relationship diagram and the fourth feature corresponding to each second connection line calculate the loss value corresponding to the distance vector between each attribute node and the attribute value node to be matched through the preset loss function ,include:
- the loss value is determined through a preset loss function according to the distance vector.
- the preset image matching model obtained through the above training method has strong generalization and can be applied to many different key-value matching scenarios. For example, it can be used for key-value matching of ID card images, and can also be applied Key-value matching in multiple scenarios such as business license images and degree certificate images.
- FIG. 7 it shows a schematic structural diagram of an electronic device 600 suitable for implementing the embodiments of the present disclosure.
- the terminal equipment in the embodiment of the present disclosure may include but not limited to such as mobile phone, notebook computer, digital broadcast receiver, PDA (personal digital assistant), PAD (tablet computer), PMP (portable multimedia player), vehicle terminal (such as mobile terminals such as car navigation terminals) and fixed terminals such as digital TVs, desktop computers and the like.
- the electronic device shown in FIG. 7 is only an example, and should not limit the functions and application scope of the embodiments of the present disclosure.
- an electronic device 600 may include a processing device (such as a central processing unit, a graphics processing unit, etc.) 601, which may be randomly accessed according to a program stored in a read-only memory (ROM) 602 or loaded from a storage device 608. Various appropriate actions and processes are executed by programs in the memory (RAM) 603 . In the RAM 603, various programs and data necessary for the operation of the electronic device 600 are also stored.
- the processing device 601, ROM 602, and RAM 603 are connected to each other through a bus 604.
- An input/output (I/O) interface 605 is also connected to the bus 604 .
- the following devices can be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; including, for example, a liquid crystal display (LCD), speaker, vibration an output device 607 such as a computer; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609.
- the communication means 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. While FIG. 7 shows electronic device 600 having various means, it should be understood that implementing or having all of the means shown is not a requirement. More or fewer means may alternatively be implemented or provided.
- embodiments of the present disclosure include a computer program product, which includes a computer program carried on a non-transitory computer readable medium, where the computer program includes program code for executing the method shown in the flowchart.
- the computer program may be downloaded and installed from a network via communication means 609, or from storage means 608, or from ROM 602.
- the processing device 601 When the computer program is executed by the processing device 601, the above-mentioned functions defined in the methods of the embodiments of the present disclosure are performed.
- the above-mentioned computer-readable medium in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two.
- a computer readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, electrical connections with one or more wires, portable computer diskettes, hard disks, random access memory (RAM), read-only memory (ROM), erasable Programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above.
- a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
- a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave carrying computer-readable program code therein. Such propagated data signals may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing.
- a computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which can transmit, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device .
- Program code embodied on a computer readable medium may be transmitted by any appropriate medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
- the server can communicate with any currently known or future-developed network protocol such as HTTP (HyperText Transfer Protocol, Hypertext Transfer Protocol), and can communicate with digital data in any form or medium (such as , communication network) interconnection.
- HTTP HyperText Transfer Protocol
- Examples of communication networks include local area networks ("LANs”), wide area networks ("WANs”), internetworks (e.g., the Internet), and peer-to-peer networks (e.g., adhoc peer-to-peer networks), as well as any currently known or future developed network.
- the above-mentioned computer-readable medium carries one or more programs, and when the above-mentioned one or more programs are executed by the electronic device, the electronic device: acquires the first position information and at least one attribute of at least one attribute data in the image to be detected The second location information of the value data; generate a first relationship diagram according to the first location information of the at least one attribute data, and generate a second relationship diagram according to the second location information of the at least one attribute value data; The first position information of one attribute data, the second position information of the at least one attribute value data, the first relationship graph, the second relationship graph and the image to be detected are input into a preset graph matching model to obtain the The matching relationship between the attribute data and the attribute value data. .
- Computer program code for carrying out operations of the present disclosure may be written in one or more programming languages, or combinations thereof, including but not limited to object-oriented programming languages—such as Java, Smalltalk, C++, and Includes conventional procedural programming languages - such as "C" or similar programming languages.
- the program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server.
- the remote computer may be connected to the user computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (for example, using an Internet service provider to connected via the Internet).
- LAN local area network
- WAN wide area network
- Internet service provider for example, using an Internet service provider to connected via the Internet.
- each block in a flowchart or block diagram may represent a module, program segment, or portion of code that contains one or more logical functions for implementing specified executable instructions.
- the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or they may sometimes be executed in the reverse order, depending upon the functionality involved.
- each block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations can be implemented by a dedicated hardware-based system that performs the specified functions or operations , or may be implemented by a combination of dedicated hardware and computer instructions.
- the modules involved in the embodiments described in the present disclosure may be implemented by software or by hardware.
- the name of the module does not constitute a limitation of the module itself under certain circumstances, for example, the first acquisition module can also be described as "obtaining the first position information and at least one attribute data of at least one attribute data in the image to be detected Second location information for value data".
- FPGAs Field Programmable Gate Arrays
- ASICs Application Specific Integrated Circuits
- ASSPs Application Specific Standard Products
- SOCs System on Chips
- CPLD Complex Programmable Logical device
- a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device.
- a machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium.
- a machine-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing.
- machine-readable storage media would include one or more wire-based electrical connections, portable computer discs, hard drives, random access memory (RAM), read only memory (ROM), erasable programmable read only memory (EPROM or flash memory), optical fiber, compact disk read only memory (CD-ROM), optical storage, magnetic storage, or any suitable combination of the foregoing.
- RAM random access memory
- ROM read only memory
- EPROM or flash memory erasable programmable read only memory
- CD-ROM compact disk read only memory
- magnetic storage or any suitable combination of the foregoing.
- Example 1 provides a key-value matching method, the method comprising:
- Example 2 provides the method of Example 1, the first relationship graph includes the attribute node corresponding to the location of each attribute data and the first connection between different attribute nodes line, the second relationship graph includes an attribute value node corresponding to the location of each attribute value data, and a second connection between different attribute value nodes, and the preset graph matching model is used for:
- the first feature corresponding to each attribute node in the first relationship graph and the first feature corresponding to each first connection line are obtained from the image to be detected.
- the fourth feature determines the matching relationship between the attribute data and the attribute value data.
- Example 3 provides the method of Example 2, the preset graph matching model includes a first sub-network and a second sub-network, and the first sub-network according to the at least one attribute data
- the location information acquires the first feature corresponding to each attribute node in the first relationship graph and the second feature corresponding to each first connection line from the image to be detected, and according to the at least one attribute
- the second position information of the value data acquires the third feature corresponding to each attribute value node in the second relationship graph and the fourth feature corresponding to each second connection from the image to be detected, including:
- the first position information of the at least one attribute data, the first relationship graph and the image to be detected as the input of the first sub-network to output the first feature corresponding to each of the attribute nodes, and
- the first position information of the at least one attribute data, the first relationship diagram and the image to be detected are used as inputs of the second sub-network to output the second feature corresponding to each first connection line, wherein , the number of hidden layers of the first subnetwork is less than that of the second subnetwork;
- the second relationship graph and the image to be detected as the input of the first sub-network to output the third sub-network corresponding to each attribute value node features and use the second position information of the at least one attribute value data, the second relationship diagram and the image to be detected as the input of the second subnetwork to output the fourth corresponding to each second connection line feature.
- Example 4 provides the method of Example 2, according to the first feature corresponding to each of the attribute nodes and the second feature corresponding to each of the first links, and The third feature corresponding to each attribute value node and the fourth feature corresponding to each second connection determine the matching relationship between the attribute data and the attribute value data, including:
- connection similarity matrix determining a connection similarity matrix according to the second feature corresponding to each of the first connections and the fourth feature corresponding to each of the second connections
- a matching relationship between each of the attribute data and each of the attribute value data is determined according to the node similarity matrix and the connection similarity matrix.
- the second relational graph is generated by a fully connected graphing method according to the second position information of the at least one attribute value data.
- Example 6 provides the method of Example 1, generating a first relationship graph according to the first location information of the at least one attribute data, and generating a first relationship graph according to the at least one attribute value data Before generating the second relationship diagram based on the second location information, the method further includes:
- the first quantity is not equal to the second quantity, by adding the same attribute data at at least one location of the attribute data, or adding the same attribute data at at least one location of the attribute value data attribute value data, so that the number of the attribute data and the attribute value data is equal.
- Example 7 provides the method of Example 6. In the case where the first quantity is not equal to the second quantity, by Add the same attribute data, including:
- the first quantity is less than the second quantity
- the generating the first relationship diagram according to the first location information of the at least one attribute data, and generating the second relationship diagram according to the second location information of the at least one attribute value data include:
- a second relationship graph is generated according to the second position information corresponding to the attribute value data twice the first amount.
- Example 8 provides the method of Example 6, adding the same attribute value data at at least one location where the attribute value data is located, so that the attribute data and the attribute The amount of value data is equal and also includes:
- the first number is greater than the second number
- the preset graph matching model generates a first relationship graph according to the first location information of the at least one attribute data, and generates a second relationship graph according to the second location information of the at least one attribute value data, including:
- a second relationship graph is generated according to the second position information corresponding to the twice the second quantity of attribute value data.
- Example 9 provides the method of any one of Examples 1-8, wherein the preset image matching model is trained through the following steps:
- the first feature corresponding to each attribute node in the first relational graph of the image sample to be detected and each first feature corresponding to the first relationship graph of the image sample to be detected are obtained from the image sample to be detected through a preset network initial model.
- the third feature corresponding to the value node and the fourth feature corresponding to each second connection line calculate the loss value corresponding to the distance vector between each attribute node and the attribute value node to be matched through the preset loss function, according to the loss value Iterative training is performed on the preset initial network model to obtain the preset graph matching model.
- Example 10 provides the method shown in Example 9, according to the first feature corresponding to each attribute node in the first relationship graph of the image sample to be detected and each item
- the second feature corresponding to a connection, and the third feature corresponding to each attribute value node in the second relationship graph of the image sample to be detected and the fourth feature corresponding to each second connection line are calculated by a preset loss function
- the loss value corresponding to the distance vector between each attribute node and the attribute value node to be matched including:
- the loss value is determined through a preset loss function according to the distance vector.
- Example 11 provides a key-value matching device, the device comprising:
- a first acquiring module configured to acquire first position information of at least one attribute data and second position information of at least one attribute value data in the image to be detected;
- a determination module configured to use the first location information of the at least one attribute data, the second location information of the at least one attribute value data, the first relationship diagram, the second relationship diagram and the image to be detected
- a preset map matching model is input to obtain a matching relationship between the attribute data and the attribute value data.
- Example 12 provides a computer-readable medium on which a computer program is stored, and when the program is executed by a processing device, the steps of any one of the methods described in Examples 1-10 are implemented .
- Example 13 provides an electronic device, comprising:
- a processing device configured to execute the computer program in the storage device to implement the steps of any one of the methods in Examples 1-10.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- General Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Life Sciences & Earth Sciences (AREA)
- Artificial Intelligence (AREA)
- Evolutionary Computation (AREA)
- Molecular Biology (AREA)
- Computational Linguistics (AREA)
- Databases & Information Systems (AREA)
- Software Systems (AREA)
- Health & Medical Sciences (AREA)
- Biomedical Technology (AREA)
- Biophysics (AREA)
- Mathematical Physics (AREA)
- General Health & Medical Sciences (AREA)
- Computing Systems (AREA)
- Bioinformatics & Cheminformatics (AREA)
- Evolutionary Biology (AREA)
- Bioinformatics & Computational Biology (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Image Analysis (AREA)
Abstract
The present disclosure relates to a key value matching method and apparatus, and a readable medium and an electronic device. The key value matching method comprises: acquiring, from an image to be subjected to detection, first position information of at least one piece of attribute data and second position information of at least one piece of attribute value data; generating a first relationship graph according to the first position information of the at least one piece of attribute data, and generating a second relationship graph according to the second position information of the at least one piece of attribute value data; and inputting, into a preset graph matching model, the first position information of the at least one piece of attribute data, the second position information of the at least one piece of attribute value data, the first relationship graph, the second relationship graph and said image, so as to obtain a matching relationship between the attribute data and the attribute value data. In this way, key value matching is performed by means of a preset graph matching model, such that key value matching can be performed for different scenarios, thereby improving the generalization of the model, and the accuracy of a key value matching result can also be effectively ensured.
Description
相关申请的交叉引用Cross References to Related Applications
本申请基于申请号为202110915753.5、申请日为2021年08月10日,名称为“键值匹配方法、装置、可读介质及电子设备”的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本申请作为参考。This application is based on the Chinese patent application with the application number 202110915753.5 and the filing date on August 10, 2021, entitled "Key value matching method, device, readable medium and electronic equipment", and claims the priority of the Chinese patent application , the entire content of this Chinese patent application is hereby incorporated into this application as a reference.
本公开涉及图像处理技术领域,具体地,涉及一种键值匹配方法、装置、可读介质及电子设备。The present disclosure relates to the technical field of image processing, and in particular, to a key-value matching method, device, readable medium, and electronic equipment.
文档图像中的键值匹配,是指对文档图像中构成键值关系的文本进行组对提取的过程。例如,在营业执照的图像中,名称与某某公司构成键值关系,在身份证的图像中,姓名与张三构成键值关系,在毕业证的图像中,学校与某某大学构成键值关系,键值匹配即对形成这种键值关系中的键值对进行识别和提取。The key-value matching in the document image refers to the process of grouping and extracting the texts constituting the key-value relationship in the document image. For example, in the image of the business license, the name and a certain company form a key-value relationship; in the image of an ID card, the name and Zhang San form a key-value relationship; in the image of a graduation certificate, the school and a certain university form a key-value relationship Relationship, key-value matching is to identify and extract the key-value pairs that form this key-value relationship.
目前的键值匹配方法通常要么是根据键值对之间的位置关系,将文字识别的结果结合预设好的关系字典进行查找匹配,要么是对待匹配的键值对进行分类预测,然而,无论是关系字典查找匹配,还是分类预测匹配都存在泛化性较差,仅能应用于特定场景的问题。The current key-value matching methods are usually either based on the positional relationship between the key-value pairs, combining the results of text recognition with a preset relational dictionary for search and matching, or classifying and predicting the key-value pairs to be matched. However, no matter Whether it is relational dictionary lookup matching or classification prediction matching, both have poor generalization and can only be applied to specific scenarios.
发明内容Contents of the invention
提供该发明内容部分以便以简要的形式介绍构思,这些构思将在后面的具体实施方式部分被详细描述。该发明内容部分并不旨在标识要求保护的技 术方案的关键特征或必要特征,也不旨在用于限制所要求的保护的技术方案的范围。This Summary is provided to introduce a simplified form of concepts that are described in detail later in the Detailed Description. This summary of the invention is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.
本公开提供了一种键值匹配方法、装置、可读介质及电子设备。The disclosure provides a key-value matching method, device, readable medium and electronic equipment.
第一方面,本公开提供一种键值匹配方法,所述方法包括:In a first aspect, the present disclosure provides a key-value matching method, the method comprising:
获取待检测图像中至少一个属性数据的第一位置信息和至少一个属性值数据的第二位置信息;Acquiring first position information of at least one attribute data and second position information of at least one attribute value data in the image to be detected;
根据所述至少一个属性数据的第一位置信息生成第一关系图,并根据所述至少一个属性值数据的第二位置信息生成第二关系图;generating a first relationship graph according to the first location information of the at least one attribute data, and generating a second relationship graph according to the second location information of the at least one attribute value data;
将所述至少一个属性数据的第一位置信息,所述至少一个属性值数据的第二位置信息,所述第一关系图,所述第二关系图以及所述待检测图像输入预设图匹配模型,得到所述属性数据与所述属性值数据的匹配关系。Matching the first location information of the at least one attribute data, the second location information of the at least one attribute value data, the first relationship diagram, the second relationship diagram and the image to be detected model to obtain the matching relationship between the attribute data and the attribute value data.
第二方面,本公开提供一种键值匹配装置,所述装置包括:In a second aspect, the present disclosure provides a key-value matching device, the device comprising:
第一获取模块,用于获取待检测图像中至少一个属性数据的第一位置信息和至少一个属性值数据的第二位置信息;A first acquiring module, configured to acquire first position information of at least one attribute data and second position information of at least one attribute value data in the image to be detected;
关系图生成模块,用于根据所述至少一个属性数据的第一位置信息生成第一关系图,并根据所述至少一个属性值数据的第二位置信息生成第二关系图;A relationship graph generation module, configured to generate a first relationship graph according to the first position information of the at least one attribute data, and generate a second relationship graph according to the second position information of the at least one attribute value data;
确定模块,用于将所述至少一个属性数据的第一位置信息,所述至少一个属性值数据的第二位置信息,所述第一关系图,所述第二关系图以及所述待检测图像输入预设图匹配模型,得到所述属性数据与所述属性值数据的匹配关系。A determination module, configured to use the first location information of the at least one attribute data, the second location information of the at least one attribute value data, the first relationship diagram, the second relationship diagram and the image to be detected A preset map matching model is input to obtain a matching relationship between the attribute data and the attribute value data.
第三方面,本公开提供一种计算机可读介质,其上存储有计算机程序,该程序被处理装置执行时实现以上第一方面所述方法的步骤。In a third aspect, the present disclosure provides a computer-readable medium on which a computer program is stored, and when the program is executed by a processing device, the steps of the method described in the first aspect above are realized.
第四方面,本公开提供一种电子设备,包括:In a fourth aspect, the present disclosure provides an electronic device, including:
存储装置,其上存储有计算机程序;a storage device on which a computer program is stored;
处理装置,用于执行所述存储装置中的所述计算机程序,以实现以上第 一方面所述方法的步骤。A processing device configured to execute the computer program in the storage device to implement the steps of the method described in the first aspect above.
上述技术方案,通过将所述至少一个属性数据的第一位置信息,所述至少一个属性值数据的第二位置信息,所述至少一个属性数据的第一位置信息对应的第一关系图,所述至少一个属性值数据的第二位置信息对应的第二关系图,以及所述待检测图像输入预设图匹配模型,以使所述预设图匹配模型输出得到所述属性数据与所述属性值数据的匹配关系,这样,通过该预设图匹配模型进行键值匹配,不仅能够针对不同场景进行键值匹配,提升模型的泛化性,还能够有效保证键值匹配结果准确性。In the above technical solution, by combining the first location information of the at least one attribute data, the second location information of the at least one attribute value data, and the first relationship diagram corresponding to the first location information of the at least one attribute data, the A second relationship graph corresponding to the second position information of the at least one attribute value data, and the image to be detected is input into a preset graph matching model, so that the preset graph matching model outputs the attribute data and the attribute In this way, key-value matching through the preset graph matching model can not only perform key-value matching for different scenarios, improve the generalization of the model, but also effectively ensure the accuracy of key-value matching results.
本公开的其他特征和优点将在随后的具体实施方式部分予以详细说明。Other features and advantages of the present disclosure will be described in detail in the detailed description that follows.
结合附图并参考以下具体实施方式,本公开各实施例的上述和其他特征、优点及方面将变得更加明显。贯穿附图中,相同或相似的附图标记表示相同或相似的元素。应当理解附图是示意性的,原件和元素不一定按照比例绘制。在附图中:The above and other features, advantages and aspects of the various embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic and that elements and elements are not necessarily drawn to scale. In the attached picture:
图1是本公开一示例性实施例示出的一种键值匹配方法的流程图;FIG. 1 is a flow chart of a key-value matching method shown in an exemplary embodiment of the present disclosure;
图2是本公开一示例性实施例示出的一种键值匹配方法的流程示意图;Fig. 2 is a schematic flow chart of a key-value matching method shown in an exemplary embodiment of the present disclosure;
图3是根据图1所示实施例示出的一种键值匹配方法的流程图;Fig. 3 is a flow chart of a key-value matching method shown according to the embodiment shown in Fig. 1;
图4是根据图1所示实施例示出的另一种键值匹配方法的流程图;Fig. 4 is the flow chart of another kind of key-value matching method shown according to the embodiment shown in Fig. 1;
图5是本公开另一示例性实施例示出的一种键值匹配装置的框图;Fig. 5 is a block diagram of a key value matching device shown in another exemplary embodiment of the present disclosure;
图6是根据图5所示实施例示出的一种键值匹配装置的框图;Fig. 6 is a block diagram of a key-value matching device according to the embodiment shown in Fig. 5;
图7是本公开一示例性实施例示出的一种电子设备的框图。Fig. 7 is a block diagram of an electronic device shown in an exemplary embodiment of the present disclosure.
下面将参照附图更详细地描述本公开的实施例。虽然附图中显示了本公开的某些实施例,然而应当理解的是,本公开可以通过各种形式来实现,而 且不应该被解释为限于这里阐述的实施例,相反提供这些实施例是为了更加透彻和完整地理解本公开。应当理解的是,本公开的附图及实施例仅用于示例性作用,并非用于限制本公开的保护范围。Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the drawings, it should be understood that the disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein; A more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for exemplary purposes only, and are not intended to limit the protection scope of the present disclosure.
应当理解,本公开的方法实施方式中记载的各个步骤可以按照不同的顺序执行,和/或并行执行。此外,方法实施方式可以包括附加的步骤和/或省略执行示出的步骤。本公开的范围在此方面不受限制。It should be understood that the various steps described in the method implementations of the present disclosure may be executed in different orders, and/or executed in parallel. Additionally, method embodiments may include additional steps and/or omit performing illustrated steps. The scope of the present disclosure is not limited in this respect.
本文使用的术语“包括”及其变形是开放性包括,即“包括但不限于”。术语“基于”是“至少部分地基于”。术语“一个实施例”表示“至少一个实施例”;术语“另一实施例”表示“至少一个另外的实施例”;术语“一些实施例”表示“至少一些实施例”。其他术语的相关定义将在下文描述中给出。As used herein, the term "comprise" and its variations are open-ended, ie "including but not limited to". The term "based on" is "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one further embodiment"; the term "some embodiments" means "at least some embodiments." Relevant definitions of other terms will be given in the description below.
需要注意,本公开中提及的“第一”、“第二”等概念仅用于对不同的装置、模块或单元进行区分,并非用于限定这些装置、模块或单元所执行的功能的顺序或者相互依存关系。It should be noted that concepts such as "first" and "second" mentioned in this disclosure are only used to distinguish different devices, modules or units, and are not used to limit the sequence of functions performed by these devices, modules or units or interdependence.
需要注意,本公开中提及的“一个”、“多个”的修饰是示意性而非限制性的,本领域技术人员应当理解,除非在上下文另有明确指出,否则应该理解为“一个或多个”。It should be noted that the modifications of "one" and "multiple" mentioned in the present disclosure are illustrative and not restrictive, and those skilled in the art should understand that unless the context clearly indicates otherwise, it should be understood as "one or more" multiple".
本公开实施方式中的多个装置之间所交互的消息或者信息的名称仅用于说明性的目的,而并不是用于对这些消息或信息的范围进行限制。The names of messages or information exchanged between multiple devices in the embodiments of the present disclosure are used for illustrative purposes only, and are not used to limit the scope of these messages or information.
在介绍本公开的具体实施方式之前,首先对本公开的应用场景进行以下说明,本公开可以应用于对文档图像中的键值对进行识别和提取的过程中,其中,该文档图像可以是营业执照图像,学位证图像,毕业证图像,身份证图像等证件图像,该键值对是指具有键值关系的一组文本,例如,在营业执照图像中,名称与某某公司构成键值关系,属于一个键值对;在身份证图像中,姓名与张三构成键值关系,属于一个键值对;在毕业证图像中,学校与某某大学构成键值关系,属于一个键值对。Before introducing the specific implementation of the present disclosure, the application scenarios of the present disclosure will be explained as follows. The present disclosure can be applied to the process of identifying and extracting key-value pairs in a document image, where the document image can be a business license Image, degree certificate image, graduation certificate image, ID card image and other document images. The key-value pair refers to a set of texts with a key-value relationship. For example, in a business license image, the name and a certain company form a key-value relationship. It belongs to a key-value pair; in the ID card image, the name and Zhang San form a key-value relationship and belong to a key-value pair; in the graduation certificate image, the school and a certain university form a key-value relationship and belong to a key-value pair.
相关技术中,进行键值匹配的方法,要么是根据键值之间的位置关系, 将文字识别的结果结合预设好的关系字典进行查找匹配,这种方法经常会因为关系字典中收集的键值对数据较少,涉及的场景比较单一,而导致无法在字典中查找到匹配的键值的情况;要么是将被处理的键值对中的数据划分为n类,使用一个多标签检测模型去检测图像中的数据,这种方法通常需要针对不同的场景训练不同的多标签检测模型,并且每一个场景下的多标签检测模型都需要大量的多标签标注数据,也就是说,训练该多标签检测模型需要投入的标注成本较多,并且得到的该多标签检测模型的泛化性较弱,仅能应用于特定场景,不能应用特定场景以外的其他场景。很明显,无论是关系字典查找匹配,还是分类预测匹配都存在泛化性较差,仅能应用于特定场景的问题。In related technologies, the key-value matching method is either to search and match the result of text recognition with the preset relational dictionary according to the positional relationship between the key-values. The value pair data is less, and the scene involved is relatively single, resulting in the situation that the matching key value cannot be found in the dictionary; or the data in the processed key value pair is divided into n categories, and a multi-label detection model is used To detect the data in the image, this method usually needs to train different multi-label detection models for different scenarios, and the multi-label detection model in each scene requires a large amount of multi-label annotation data, that is, training the multi-label The label detection model needs to invest more labeling costs, and the generalization of the obtained multi-label detection model is weak, which can only be applied to specific scenarios, and cannot be applied to other scenarios other than specific scenarios. Obviously, both relational dictionary lookup matching and classification prediction matching have poor generalization and can only be applied to specific scenarios.
为了解决以上技术问题,本公开提供了一种键值匹配方法、装置、可读介质及电子设备,该键值匹配方法通过获取待检测图像中至少一个属性数据的第一位置信息和至少一个属性值数据的第二位置信息;根据该至少一个属性数据的第一位置信息生成第一关系图,并根据该至少一个属性值数据的第二位置信息生成第二关系图;将该至少一个属性数据的第一位置信息,该至少一个属性值数据的第二位置信息,该第一关系图,该第二关系图以及该待检测图像输入预设图匹配模型,得到该属性数据与该属性值数据的匹配关系。这样,通过该预设图匹配模型进行键值匹配,不仅能够针对不同场景进行键值匹配,保证模型的泛化性,还能够有效保证键值匹配结果准确性。In order to solve the above technical problems, the present disclosure provides a key value matching method, device, readable medium and electronic equipment. The key value matching method obtains the first position information and at least one attribute data of at least one attribute data in the image The second location information of the value data; generate a first relationship diagram according to the first location information of the at least one attribute data, and generate a second relationship diagram according to the second location information of the at least one attribute value data; the at least one attribute data The first position information of the at least one attribute value data, the second position information of the at least one attribute value data, the first relationship graph, the second relationship graph and the image to be detected are input into the preset graph matching model to obtain the attribute data and the attribute value data matching relationship. In this way, performing key-value matching through the preset graph matching model can not only perform key-value matching for different scenarios, ensure the generalization of the model, but also effectively ensure the accuracy of key-value matching results.
下面结合具体附图对本公开的实施方式进行详细阐述。Embodiments of the present disclosure will be described in detail below in conjunction with specific drawings.
图1是本公开一示例性实施例示出的一种键值匹配方法的流程图;参见图1,该方法可以包括:Fig. 1 is a flow chart of a key-value matching method shown in an exemplary embodiment of the present disclosure; referring to Fig. 1, the method may include:
步骤101,获取待检测图像中至少一个属性数据的第一位置信息和至少一个属性值数据的第二位置信息。 Step 101, acquiring first position information of at least one attribute data and second position information of at least one attribute value data in an image to be detected.
其中,该待检测图像可以是营业执照图像,学位证图像,毕业证图像,身份证图像等证件图像。该属性数据为组成键值对中的Key对应的数据,该 属性值数据为组成键值对中Value对应的数据,Key与Value形成键值对。Wherein, the image to be detected may be a business license image, a degree certificate image, a graduation certificate image, an ID card image and other certificate images. The attribute data is the data corresponding to the Key in the key-value pair, the attribute value data is the data corresponding to the Value in the key-value pair, and the Key and the Value form a key-value pair.
本步骤中,可以通过现有技术中的二分类检测模型对该待检测图像中的属性数据和属性值数据进行类别和位置的检测,以输出得到该待检测图像中每个属性数据对应的第一检测框和每个属性值数据对应的第二检测框,根据该第一检测框确定该第一位置信息,根据该第二检测框确定该第二位置信息。示例地,一种实施方式中:可以将该第一检测框的位置作为该第一位置信息,将该第二检测框作为该第二位置信息;另一种实施方式中,可以将该第一检测框的中心位置作为该第一位置信息,将该第二检测框的中心位置作为该第二位置信息;再一种实施方式中,可以将该第一检测框上的任一点作为该第一位置信息,将该第二检测框上的任一点作为该第二位置信息。In this step, the category and position of the attribute data and attribute value data in the image to be detected can be detected through the binary classification detection model in the prior art, so as to output the corresponding first attribute data of each attribute data in the image to be detected. A detection frame and a second detection frame corresponding to each attribute value data, the first position information is determined according to the first detection frame, and the second position information is determined according to the second detection frame. For example, in one embodiment: the position of the first detection frame can be used as the first position information, and the second detection frame can be used as the second position information; in another embodiment, the first The center position of the detection frame is used as the first position information, and the center position of the second detection frame is used as the second position information; in another embodiment, any point on the first detection frame can be used as the first position information. For location information, any point on the second detection frame is used as the second location information.
步骤102,根据该至少一个属性数据的第一位置信息生成第一关系图,并根据该至少一个属性值数据的第二位置信息生成第二关系图。Step 102: Generate a first relationship diagram according to the first location information of the at least one attribute data, and generate a second relationship diagram according to the second location information of the at least one attribute value data.
其中,该第一关系图包括每个属性数据所在位置对应的属性节点和不同的该属性节点之间的第一连线,该第二关系图包括每个属性值数据所在位置对应的属性值节点,以及不同的属性值节点之间的第二连线。Wherein, the first relationship diagram includes the attribute node corresponding to the location of each attribute data and the first connection between different attribute nodes, and the second relationship diagram includes the attribute value node corresponding to the location of each attribute value data , and a second link between nodes with different attribute values.
本步骤中,可以根据该至少一个属性数据的第一位置信息通过德劳内三角化建图方式生成该第一关系图;根据该至少一个属性值数据的第二位置信息通过全连接建图方式生成该第二关系图。In this step, the first relational graph may be generated by means of Delaunay triangulation mapping according to the first position information of the at least one attribute data; by means of fully connected mapping according to the second position information of the at least one attribute value data The second relationship graph is generated.
需要是说明的是,该德劳内三角化建图方式(Delaunay triangulation,Delaunay三角剖分算法)与该全连接建图(即建立全连接网络拓扑图)方式均为现有技术中常用的建图方式,本公开在此不再赘述。It should be noted that the Delaunay triangulation method (Delaunay triangulation, Delaunay triangulation algorithm) and the fully-connected graph-building method (that is, the establishment of a fully-connected network topology map) are commonly used in the prior art. Figures, the present disclosure will not repeat them here.
步骤103,将该至少一个属性数据的第一位置信息,该至少一个属性值数据的第二位置信息,该第一关系图,该第二关系图以及该待检测图像输入预设图匹配模型,得到该属性数据与该属性值数据的匹配关系。 Step 103, inputting the first location information of the at least one attribute data, the second location information of the at least one attribute value data, the first relationship graph, the second relationship graph and the image to be detected into a preset graph matching model, A matching relationship between the attribute data and the attribute value data is obtained.
其中,该预设图匹配模型通过以下步骤S1至S3训练得到:Wherein, the preset image matching model is trained through the following steps S1 to S3:
S1,获取模型训练样本数据。S1, acquire model training sample data.
其中,该模型训练样本数据包括多个待检测图像样本,每个该待检测图像样本中的每个属性数据的第一位置信息,该待检测图像样本中的每个属性值数据的第二位置信息,以及每个该待检测图像样本对应的第一关系图和第二关系图。Wherein, the model training sample data includes a plurality of image samples to be detected, the first position information of each attribute data in each image sample to be detected, and the second position information of each attribute value data in the image samples to be detected information, and a first relational graph and a second relational graph corresponding to each image sample to be detected.
需要说明的是,该待检测图像样本包括对属性数据和属性值数据的种类标注,以及属性数据和属性值数据对应关系的标注数据。It should be noted that the image sample to be detected includes category annotations for attribute data and attribute value data, and annotation data for the corresponding relationship between attribute data and attribute value data.
S2,根据每个属性数据的第一位置信息通过预设网络初始模型从该待检测图像样本中获取该待检测图像样本的第一关系图中每个属性节点对应的第一特征和每条第一连接对应的第二特征,并根据每个属性值数据的第二位置信息通过该预设网络初始模型从该待检测图像样本中获取该待检测图像样本的第二关系图中每个属性值节点对应的第三特征和每条第二连线对应的第四特征。S2, according to the first position information of each attribute data, obtain the first feature corresponding to each attribute node in the first relationship graph of the image sample to be detected and each first feature corresponding to the first relationship graph of the image sample to be detected through the preset network initial model One connects the corresponding second feature, and obtains each attribute value in the second relationship diagram of the image sample to be detected from the image sample to be detected through the preset network initial model according to the second position information of each attribute value data The third feature corresponding to the node and the fourth feature corresponding to each second link.
其中,该预设网络初始模型可以包括第一初始子网络和第二初始子网络,该预设初始网络模型可以是神经网络模型,也可以是其他机器学习算法模型。Wherein, the preset initial network model may include a first initial subnetwork and a second initial subnetwork, and the preset initial network model may be a neural network model or other machine learning algorithm models.
本步骤中,可以将该待检测图像样本对应的至少一个属性数据的第一位置信息,该第一关系图和该待检测图像作为第一初始子网络的输入,以输出得到该待检测图像样本对应的每个该属性节点对应的第一特征,并将该待检测图像样本对应的至少一个属性数据的第一位置信息,该第一关系图和该待检测图像作为第二初始子网络的输入,以输出得到该待检测图像样本中每条第一连线对应的第二特征;将该待检测图像样本对应的至少一个属性值数据的第二位置信息,该第二关系图和该待检测图像作为该第一初始子网络的输入,以输出得到该待检测图像样本中每个该属性值节点对应的第三特征,并将该待检测图像样本对应的至少一个属性值数据的第二位置信息,该第二关系图和该待检测图像作为第二初始子网络的输入,以输出得到该待检测图像样本中每条第二连线对应的第四特征。In this step, the first position information of at least one attribute data corresponding to the image sample to be detected, the first relationship graph and the image to be detected can be used as the input of the first initial subnetwork to output the image sample to be detected Corresponding to the first feature corresponding to each attribute node, and using the first position information of at least one attribute data corresponding to the image sample to be detected, the first relationship graph and the image to be detected as the input of the second initial subnetwork , to output the second feature corresponding to each first connection line in the image sample to be detected; the second position information of at least one attribute value data corresponding to the image sample to be detected, the second relationship diagram and the to be detected The image is used as the input of the first initial sub-network to output the third feature corresponding to each attribute value node in the image sample to be detected, and the second position of at least one attribute value data corresponding to the image sample to be detected Information, the second relational graph and the image to be detected are used as inputs of the second initial subnetwork to output the fourth feature corresponding to each second link in the image sample to be detected.
其中,该第二初始子网络的深度大于该第一初始子网络的深度,即该第 一初始子网络的隐藏层数量少于该第二初始子网络,该属性节点对应的第一特征和该属性值节点对应的第三特征由浅层网络(第一初始子网络)输出,该第一连线对应的第二特征和该第二连线对应的第四特征由深层网络(第二初始子网络)输出。Wherein, the depth of the second initial subnetwork is greater than the depth of the first initial subnetwork, that is, the number of hidden layers of the first initial subnetwork is less than that of the second initial subnetwork, and the first feature corresponding to the attribute node and the The third feature corresponding to the attribute value node is output by the shallow network (the first initial sub-network), the second feature corresponding to the first connection and the fourth feature corresponding to the second connection are output by the deep network (the second initial sub-network). network) output.
需要说明的是,首先由浅层网络获取该第一特征和该第三特征,由深层网络获取该第二特征和第四特征,能够有效获取到该属性节点,属性值节点,该第一连线,该第二连线对应的图像特征,其次,由于网络深度越浅,距离输入越近,包含的特征细节越多,提取到的特征对节点(该属性节点或属性值节点)的描述越准确,因此,能够有效保证提到到的属性节点的第一特征,以及属性值节点的第三特征的准确性,有利于为键值匹配提供可靠的数据依据;通过深层网络提取边(即第一连线和第二连线)的特征,能够有效减少数据处理量,提升模型处理效率。It should be noted that firstly, the first feature and the third feature are obtained by the shallow network, and the second feature and the fourth feature are obtained by the deep network, so that the attribute node, the attribute value node, and the first connected feature can be effectively obtained. line, the image feature corresponding to the second connection line, and secondly, because the shallower the network depth, the closer the distance to the input, the more feature details it contains, the better the description of the extracted feature to the node (the attribute node or attribute value node) Accurate, therefore, can effectively guarantee the accuracy of the first feature of the mentioned attribute node, and the accuracy of the third feature of the attribute value node, which is conducive to providing a reliable data basis for key-value matching; extracting edges through the deep network (that is, the first The features of the first connection and the second connection) can effectively reduce the amount of data processing and improve the efficiency of model processing.
另外,在该第一初始子网络和该第二初始子网络中可以包括池化层,在获取该第一特征,第二特征,第三特征以及该第四特征时,可以通过该池化层对提取到的特征进行平均池化,例如,特征图的形状为256×64×64(通道数256、长64、宽64),在提取特征时可以将节点对应的检测框等比例缩放,然后在相应的位置提取特征,再将提取的特征通过该池化层进行平均池化,得到每个检测框的特征向量(256×1×1)。这样,能够有效减少数据维度,从而能够有利于简化网络复杂度,减小模型计算量,达到提升模型效率的技术效果。In addition, a pooling layer may be included in the first initial subnetwork and the second initial subnetwork, and when obtaining the first feature, the second feature, the third feature, and the fourth feature, the pooling layer may be Perform average pooling on the extracted features. For example, the shape of the feature map is 256×64×64 (the number of channels is 256, the length is 64, and the width is 64). When extracting features, the detection frame corresponding to the node can be scaled proportionally, and then Extract features at the corresponding positions, and then average pool the extracted features through the pooling layer to obtain the feature vector (256×1×1) of each detection frame. In this way, the data dimension can be effectively reduced, which can help simplify the network complexity, reduce the calculation amount of the model, and achieve the technical effect of improving the efficiency of the model.
S3,根据该待检测图像样本的第一关系图中每个属性节点对应的第一特征和每条第一连接对应的第二特征,以及该待检测图像样本的第二关系图中每个属性值节点对应的第三特征和每条第二连线对应的第四特征,通过预设损失函数计算每个属性节点与待匹配的属性值节点的距离向量对应的损失值,根据该损失值对该预设初始网络模型进行迭代训练,以得到该预设图匹配模型。S3, according to the first feature corresponding to each attribute node in the first relationship graph of the image sample to be detected and the second feature corresponding to each first connection, and each attribute in the second relationship graph of the image sample to be detected The third feature corresponding to the value node and the fourth feature corresponding to each second connection line, calculate the loss value corresponding to the distance vector between each attribute node and the attribute value node to be matched through the preset loss function, according to the loss value pair The preset initial network model is iteratively trained to obtain the preset graph matching model.
本步骤中,可以根据每个所述属性节点对应的第一特征和每个所述属性值节点对应的第三特征确定节点相似度矩阵,并根据每条所述第一连线对应的第二特征和每条所述第二连接对应的第四特征确定连线相似度矩阵;根据所述节点相似度矩阵和所述连线相似度矩阵生成目标关系矩阵;获取所述目标关系矩阵对应的双随机矩阵;根据所述双随机矩阵确定每个属性节点与待匹配的属性值节点的距离向量;根据所述距离向量通过预设损失函数确定所述损失值。In this step, the node similarity matrix can be determined according to the first feature corresponding to each of the attribute nodes and the third feature corresponding to each of the attribute value nodes, and according to the second feature corresponding to each of the first connections The feature and the fourth feature corresponding to each of the second connections determine the connection similarity matrix; generate a target relationship matrix according to the node similarity matrix and the connection similarity matrix; obtain the pair corresponding to the target relationship matrix A random matrix; determine a distance vector between each attribute node and the attribute value node to be matched according to the double random matrix; determine the loss value through a preset loss function according to the distance vector.
示例地,可以通过该第一邻接矩阵A1表示该第一关系图,通过第二邻接矩阵A2表示该第二关系图,通过公式A=GH
T确定该第一邻接矩阵A1对应的关联矩阵分别为G
1和H
1,该第二邻接矩阵A2对应的关联矩阵分别为G
2和H
2。在步骤S2中确定该第一特征为P
1,该第二特征为E
1,该第三特征为P
2,该第四特征为E
2的情况下,可以通过M
p=P
1P
2获取该节点相似度矩阵M
p,并通过以下公式1确定该连线相似度矩阵M
e:
Exemplarily, the first relational graph may be represented by the first adjacency matrix A1, the second relational graph may be represented by the second adjacency matrix A2, and the correlation matrices corresponding to the first adjacency matrix A1 are determined by the formula A=GH T as G 1 and H 1 , and the incidence matrices corresponding to the second adjacency matrix A2 are G 2 and H 2 respectively. When it is determined in step S2 that the first feature is P 1 , the second feature is E 1 , the third feature is P 2 , and the fourth feature is E 2 , it can be obtained by M p =P 1 P 2 The node similarity matrix M p , and the connection similarity matrix M e is determined by the following formula 1:
M
e=[E
1G
1|E
1H
1]Λ[E
2G
2|E
2H
2]
T……公式1
M e =[E 1 G 1 |E 1 H 1 ]Λ[E 2 G 2 |E 2 H 2 ] T ... Formula 1
以上公式1中,该Λ可以是对称参数矩阵;In the above formula 1, the Λ can be a symmetric parameter matrix;
然后,可以通过以下公式2根据该节点相似度矩阵M
p和该连线相似度矩阵M
e确定目标关系矩阵M:
Then, the target relationship matrix M can be determined according to the node similarity matrix M p and the connection similarity matrix M e by the following formula 2:
以上公式2中:vec(x)表示x的按行展开式,[x]表示x的对角阵,
为Kronecker product,克罗内克积。
In the above formula 2: vec(x) represents the row-wise expansion of x, [x] represents the diagonal matrix of x, For Kronecker product, Kronecker product.
进一步地,可以获取该目标关系矩阵M对应的特征向量V,然后该特征向量进行双随机化处理,以得到该特征向量V对应的双随机矩阵S,根据该双随机矩阵通过以下公式3确定属性节点与每个属性值节点的距离向量:Further, the eigenvector V corresponding to the target relationship matrix M can be obtained, and then the eigenvector is double-randomized to obtain the double random matrix S corresponding to the eigenvector V, and the attribute is determined by the following formula 3 according to the double random matrix A vector of distances from the node to each attribute value node:
以上公式3中,α为预设系数,例如可以是200,S为双随机矩阵,i 表示双随机矩阵S的行号,j表示双随机矩阵S的列号,S(i,1…m)表示双随机矩阵S的第i行,该双随机矩阵S共有m行,P为属性值节点的位置集合,P
i为第i个属性节点的位置,
表征第i个属性值节点特征相对于该属性值节点的位置集合P的权重。
In the above formula 3, α is a preset coefficient, for example, it can be 200, S is a double random matrix, i represents the row number of the double random matrix S, j represents the column number of the double random matrix S, S(i, 1...m) Represents the i-th row of the double random matrix S, the double random matrix S has m rows, P is the location set of attribute value nodes, P i is the location of the i-th attribute node, Characterizes the weight of the feature of the i-th attribute value node relative to the position set P of the attribute value node.
接着,可以通过以下预设损失函数L(d)计算每个属性节点与待匹配的属性值节点的距离向量对应的损失值,其中该预设损失函数如下:Next, the loss value corresponding to the distance vector between each attribute node and the attribute value node to be matched can be calculated by the following preset loss function L(d), wherein the preset loss function is as follows:
以上损失函数中,
为根据标注的属性数据所在位置与对应的属性值数据所在位置计算得到目标的距离向量,∈为随机小数。
In the above loss function, In order to obtain the distance vector of the target calculated according to the location of the marked attribute data and the location of the corresponding attribute value data, ∈ is a random decimal number.
训练过程中,可以获取每个属性节点与待匹配的属性值节点的距离向量对应的损失值,在该损失值小于或者等于预设损失值阈值的情况下,确定模型训练结束,得到最优的预设图匹配模型。During the training process, the loss value corresponding to the distance vector between each attribute node and the attribute value node to be matched can be obtained. When the loss value is less than or equal to the preset loss value threshold, it is determined that the model training is over and the optimal Preset graph matching model.
通过以上训练方式得到的预设图匹配模型,其泛化性较强,能够适用于多种不同的键值匹配场景,例如,既可以用于对身份证图像的键值匹配,也可以应用于营业执照图像,学位证图像等多个场景下的键值匹配。The preset image matching model obtained through the above training method has strong generalization and can be applied to many different key-value matching scenarios. For example, it can be used for key-value matching of ID card images, and can also be applied Key-value matching in multiple scenarios such as business license images and degree certificate images.
示例地,如图2所示,图2是本公开一示例性实施例示出的一种键值匹配方法的流程示意图,在该图2中包括图像1至4,该图像1为一个待检测图像,该待检测图像中包括属性数据Key1和Key2,以及属性值数据Value1和Value2,通过二分类检测模型分别获取图像1中Key1,Key2,Value1,Value2的位置,从而得到了该图像2中的检测框,在图像2中每个检测框代表识别到的属性数据或者属性值数据的位置,通过预设图匹配模型后得到了Key1与Value1匹配,Key2与Value2匹配(如图2中的3),根据该匹配关系通过文字识别,从而能够得到该文本信息Key1:Value1,与Key2:Value2(如图2中的4)。这样,通过该预设图匹配模型进行键值匹配,能够有效保证键值匹配结果准确性。For example, as shown in FIG. 2 , FIG. 2 is a schematic flow chart of a key-value matching method shown in an exemplary embodiment of the present disclosure. In FIG. 2 , images 1 to 4 are included, and the image 1 is an image to be detected. , the image to be detected includes attribute data Key1 and Key2, and attribute value data Value1 and Value2, respectively obtain the positions of Key1, Key2, Value1, and Value2 in image 1 through the binary classification detection model, thus obtaining the detection in image 2 Frame, each detection frame in image 2 represents the position of the identified attribute data or attribute value data. After matching the model through the preset image, Key1 matches Value1, and Key2 matches Value2 (3 in Figure 2). The text information Key1:Value1 and Key2:Value2 (4 in FIG. 2 ) can be obtained through character recognition according to the matching relationship. In this way, the key-value matching is performed through the preset graph matching model, which can effectively ensure the accuracy of the key-value matching result.
以上技术方案,通过将该至少一个属性数据的第一位置信息,该至少一个属性值数据的第二位置信息,该至少一个属性数据的第一位置信息对应的第一关系图,该至少一个属性值数据的第二位置信息对应的第二关系图,以及该待检测图像输入预设图匹配模型,以使该预设图匹配模型输出得到该属性数据与该属性值数据的匹配关系,这样,通过该预设图匹配模型进行键值匹配,不仅能够针对不同场景进行键值匹配,提升模型的泛化性,还能够有效保证键值匹配结果准确性。In the above technical solution, through the first position information of the at least one attribute data, the second position information of the at least one attribute value data, the first relationship diagram corresponding to the first position information of the at least one attribute data, the at least one attribute The second relationship graph corresponding to the second position information of the value data, and the image to be detected are input into the preset graph matching model, so that the preset graph matching model outputs the matching relationship between the attribute data and the attribute value data, thus, Using the preset graph matching model for key-value matching can not only perform key-value matching for different scenarios, improve the generalization of the model, but also effectively ensure the accuracy of key-value matching results.
进一步地,图1中步骤103该预设图匹配模型,通过以下图3所示步骤根据该至少一个属性数据的第一位置信息,该至少一个属性值数据的第二位置信息,该第一关系图,该第二关系图以及该待检测图像确定该属性数据与该属性值数据的匹配关系,图3是根据图1所示实施例示出的一种键值匹配方法的流程图,参见图3,该预设图匹配模型,可以用于:Further, the preset map matching model in step 103 in FIG. 1 is based on the first location information of the at least one attribute data, the second location information of the at least one attribute value data, and the first relationship through the following steps shown in FIG. Fig. 1, the second relationship diagram and the image to be detected determine the matching relationship between the attribute data and the attribute value data, and Fig. 3 is a flow chart of a key-value matching method according to the embodiment shown in Fig. 1, see Fig. 3 , the preset graph matching model can be used for:
步骤1031,根据该至少一个属性数据的第一位置信息从该待检测图像中获取该第一关系图中每个该属性节点对应的第一特征和每条该第一连线对应的第二特征,并根据该至少一个属性值数据的第二位置信息从该待检测图像中获取该第二关系图中每个该属性值节点对应的第三特征和每条该第二连接对应的第四特征。 Step 1031, according to the first position information of the at least one attribute data, obtain the first feature corresponding to each attribute node in the first relationship diagram and the second feature corresponding to each first connection line from the image to be detected , and according to the second position information of the at least one attribute value data, the third feature corresponding to each attribute value node in the second relationship graph and the fourth feature corresponding to each second connection are obtained from the image to be detected .
本步骤中,可以将该至少一个属性数据的第一位置信息,该第一关系图和该待检测图像作为第一子网络的输入,以输出得到每个该属性节点对应的第一特征,并将该至少一个属性数据的第一位置信息,该第一关系图和该待检测图像作为第二子网络的输入,以输出得到该每条第一连线对应的第二特征,其中,该第一子网络的隐藏层数量少于该第二子网络;将该至少一个属性值数据的第二位置信息,该第二关系图和该待检测图像作为该第一子网络的输入,以输出得到每个该属性值节点对应的第三特征,并将该至少一个属性值数据的第二位置信息,该第二关系图和该待检测图像作为第二子网络的输入,以输出得到每条第二连线对应的第四特征。In this step, the first position information of the at least one attribute data, the first relationship graph and the image to be detected can be used as the input of the first sub-network to output the first feature corresponding to each attribute node, and The first position information of the at least one attribute data, the first relationship graph and the image to be detected are used as the input of the second sub-network to output the second feature corresponding to each first connection line, wherein the first The number of hidden layers of a sub-network is less than that of the second sub-network; the second position information of the at least one attribute value data, the second relationship diagram and the image to be detected are used as the input of the first sub-network, and the output is obtained The third feature corresponding to each attribute value node, and the second position information of the at least one attribute value data, the second relationship graph and the image to be detected are used as the input of the second sub-network to output each item of the first sub-network The fourth feature corresponding to the two connecting lines.
需要说明的是,该第一子网络的隐藏层数量少于该第二子网络,即该第二子网络的深度大于该第一子网络的深度,该属性节点对应的第一特征和该属性值节点对应的第三特征由第一子网络(即包含的隐藏层较少的浅层网络)输出,该第一连线对应的第二特征和该第二连线对应的第四特征由第二子网络(即包含的隐藏层较多的深层网络)输出。由于网络深度越浅,距离输入越近,包含的特征细节越多,提取到的特征对节点(该属性节点或属性值节点)的描述越准确,因此通过该浅层网络输出该第一特征和第三特征,能够有效保证该第一特征和该第三特征的准确性,有利于为键值匹配提供可靠的数据依据;通过深层网络提取边(即第一连线和第二连线)的特征,能够有效减少数据处理量,提升模型处理效率。It should be noted that the number of hidden layers of the first subnetwork is less than that of the second subnetwork, that is, the depth of the second subnetwork is greater than the depth of the first subnetwork, and the first feature corresponding to the attribute node and the attribute The third feature corresponding to the value node is output by the first sub-network (that is, a shallow network with fewer hidden layers), and the second feature corresponding to the first connection and the fourth feature corresponding to the second connection are output by the first sub-network. The output of the second sub-network (that is, a deep network with more hidden layers). Since the shallower the depth of the network, the closer it is to the input, the more feature details it contains, the more accurate the description of the extracted feature to the node (the attribute node or attribute value node), so the first feature and the attribute value node are output through the shallow network The third feature can effectively guarantee the accuracy of the first feature and the third feature, which is conducive to providing a reliable data basis for key-value matching; extracting edges (ie, the first connection and the second connection) through the deep network Features can effectively reduce the amount of data processing and improve the efficiency of model processing.
步骤1032,根据每个该属性节点对应的第一特征和每条该第一连线对应的第二特征,以及每个该属性值节点对应的第三特征和每条该第二连接对应的第四特征确定该属性数据与该属性值数据的匹配关系。 Step 1032, according to the first characteristic corresponding to each attribute node and the second characteristic corresponding to each first connection, and the third characteristic corresponding to each attribute value node and the first characteristic corresponding to each second connection The four features determine the matching relationship between the attribute data and the attribute value data.
本步骤中,一种可能的实施方式可以包括以下S21至S23所示的步骤:In this step, a possible implementation may include the following steps shown in S21 to S23:
S21,根据每个该属性节点对应的第一特征和每个该属性值节点对应的第三特征确定节点相似度矩阵。S21. Determine a node similarity matrix according to the first feature corresponding to each attribute node and the third feature corresponding to each attribute value node.
本步骤中,在该属性节点对应的该第一特征为P
1,该属性值节点对应的第三特征为P
2的情况下,可以通过M
p=P
1P
2获取该节点相似度矩阵M
p。
In this step, when the first feature corresponding to the attribute node is P 1 , and the third feature corresponding to the attribute value node is P 2 , the node similarity matrix M can be obtained by M p =P 1 P 2 p .
S22,根据每条该第一连线对应的第二特征和每条该第二连接对应的第四特征确定连线相似度矩阵。S22. Determine a connection similarity matrix according to the second feature corresponding to each first connection and the fourth feature corresponding to each second connection.
本步骤中,在该属性节点对应的该第一特征为P
1,该属性值节点对应的第三特征为P
2,该第一连线对应的第二特征为E
1,该第二连接对应的第四特征为E
2的情况下,可以通过以下公式确定该连线相似度矩阵M
e:
In this step, the first characteristic corresponding to the attribute node is P 1 , the third characteristic corresponding to the attribute value node is P 2 , the second characteristic corresponding to the first connection is E 1 , and the second connection corresponds to In the case where the fourth feature of is E 2 , the connection similarity matrix M e can be determined by the following formula:
M
e=[E
1G
1|E
1H
1]Λ[E
2G
2|E
2H
2]
T
M e =[E 1 G 1 |E 1 H 1 ]Λ[E 2 G 2 |E 2 H 2 ] T
以上公式中,该Λ可以是对称参数矩阵,例如可以是2×2的对称参数矩阵。In the above formula, the Λ may be a symmetric parameter matrix, for example, may be a 2×2 symmetric parameter matrix.
S23,根据该节点相似度矩阵和连线相似度矩阵确定每个该属性数据与每个该属性值数据的匹配关系。S23. Determine a matching relationship between each of the attribute data and each of the attribute value data according to the node similarity matrix and the link similarity matrix.
本步骤中,可以通过以下公式根据该节点相似度矩阵M
p和该连线相似度矩阵M
e确定目标关系矩阵M:
In this step, the target relationship matrix M can be determined according to the node similarity matrix M p and the connection similarity matrix M e by the following formula:
以上公式中:vec(x)表示x的按行展开式,[x]表示x的对角阵,
为Kronecker product,克罗内克积。
In the above formula: vec(x) represents the row-wise expansion of x, [x] represents the diagonal matrix of x, For Kronecker product, Kronecker product.
在得到了目标关系矩阵M之后,可以获取该目标关系矩阵M对应的特征向量V,根据该特征向量V确定每个该属性数据与每个属性值数据的匹配关系。After the target relationship matrix M is obtained, the feature vector V corresponding to the target relationship matrix M can be obtained, and the matching relationship between each attribute data and each attribute value data can be determined according to the feature vector V.
可选地,本步骤中可以继续对该特征向量V进行双随机化处理以得到双随机矩阵S,根据该双随机化矩阵S确定每个属性数据与每个属性值数据的匹配关系。其中,进行双随机化处理的过程属于现有技术,在对该特征向量V进行双随机化处理的过程可以参见现有技术中的实施方式,本公开在此不再赘述。Optionally, in this step, the feature vector V may continue to be double-randomized to obtain a double-randomized matrix S, and the matching relationship between each attribute data and each attribute value data is determined according to the double-randomized matrix S. Wherein, the process of performing double randomization processing belongs to the prior art. For the process of performing double randomization processing on the feature vector V, reference may be made to the implementation manners in the prior art, which will not be repeated in this disclosure.
示例地,若该待检测图像中分别包括3个属性数据(分别为Key1,Key2,Key3)和3个属性值数据(分别为Value1,Value2,Value3),若得到的双随机矩阵S为:
其中,该矩阵的行代表Key1,Key2,Key3,该矩阵的列代表Value1,Value2,Value3,则表征该Key1与该Value1匹配,该Key2与该Value3匹配,该Key3与该Value2匹配。
For example, if the image to be detected includes 3 attribute data (respectively Key1, Key2, Key3) and 3 attribute value data (respectively Value1, Value2, Value3), if the obtained double random matrix S is: Wherein, the rows of the matrix represent Key1, Key2, and Key3, and the columns of the matrix represent Value1, Value2, and Value3, which means that the Key1 matches the Value1, the Key2 matches the Value3, and the Key3 matches the Value2.
以上技术方案,能够根据该至少一个属性数据的第一位置信息,该至少一个属性值数据的第二位置信息,该第一关系图,该第二关系图以及该待检测图像确定该属性数据与该属性值数据的匹配关系,能够有效保证键值匹配结果的准确性。The above technical solution can determine the relationship between the attribute data and the image to be detected according to the first position information of the at least one attribute data, the second position information of the at least one attribute value data, the first relationship diagram, the second relationship diagram and the image to be detected. The matching relationship of the attribute value data can effectively guarantee the accuracy of the key-value matching result.
可选地,在图1中步骤102所述的根据该至少一个属性数据的第一位置 信息生成第一关系图,并根据该至少一个属性值数据的第二位置信息生成第二关系图之前,该方法还可以包括以下图4所示步骤,图4是根据图1所示实施例示出的另一种键值匹配方法的流程图,如图4所示,该方法还可以包括:Optionally, before generating the first relationship diagram according to the first location information of the at least one attribute data and generating the second relationship diagram according to the second location information of the at least one attribute value data described in step 102 in FIG. 1 , The method may also include the following steps shown in FIG. 4. FIG. 4 is a flowchart of another key-value matching method according to the embodiment shown in FIG. 1. As shown in FIG. 4, the method may also include:
步骤104,获取该属性数据的第一数量和该属性值数据的第二数量。 Step 104, acquiring the first quantity of the attribute data and the second quantity of the attribute value data.
示例地,该属性数据的第一数量可以是该待检测图像中Key的检测框的数量,该属性值数据的第二数量可以是该待检测图像中Value的检测框的数量。For example, the first quantity of the attribute data may be the number of detection boxes of Key in the image to be detected, and the second quantity of the attribute value data may be the number of detection boxes of Value in the image to be detected.
步骤105,在该第一数量与该第二数量不等的情况下,通过在至少一个该属性数据所在位置处增加相同的属性数据,或,在至少一个该属性值数据所在位置处增加相同的属性值数据,以使该属性数据与该属性值数据的数量相等。 Step 105, in the case that the first quantity is not equal to the second quantity, by adding the same attribute data at least one position where the attribute data is located, or adding the same attribute data at at least one position where the attribute value data is located attribute value data such that the attribute data is equal in quantity to the attribute value data.
本步骤中,一种可能的实施方式包括:在该第一数量小于该第二数量的情况下,在每个属性数据所在位置处增加一个相同的属性数据,并获取两倍的第一数量与该第二数量的第一差值,从至少一个该属性值数据中获取该第一差值对应数量的目标属性值数据,并在每个该目标属性值数据所在位置处增加一个相同的属性值数据,以得到两倍第一数量的属性数据,和两倍第一数量的属性值数据;In this step, a possible implementation method includes: when the first quantity is less than the second quantity, adding the same attribute data at the location of each attribute data, and obtaining twice the first quantity and the second quantity The first difference of the second quantity is obtained from at least one of the attribute value data corresponding to the number of target attribute value data of the first difference, and an identical attribute value is added at each position of the target attribute value data data, to obtain twice the first quantity of attribute data, and twice the first quantity of attribute value data;
相应地,按照以上实施方式,图1中所述的步骤102的实施方式可以包括:根据该两倍第一数量的属性数据对应的第一位置信息生成第一关系图;根据该两倍第一数量的属性值数据对应的第二位置信息生成第二关系图。Correspondingly, according to the above implementation, the implementation of step 102 in FIG. 1 may include: generating a first relationship diagram according to the first location information corresponding to the twice the first amount of attribute data; The second position information corresponding to the quantity of attribute value data generates a second relationship graph.
示例地,若属性数据的第一数量为a,属性值数据的第二数量为b,在该a小于b的情况下,直接在待检测图像中每个属性数据所在位置处增加一个数据,即得到了2a个属性数据,对于属性值数据,则在待检测图像中随机选取2a-b个属性值数据,在这些属性值数据所在的位置上依次增加一个属性值数据。由此便得到了2a个属性数据,也得到了2a个属性值数据。For example, if the first quantity of attribute data is a, and the second quantity of attribute value data is b, in the case where a is less than b, directly add a piece of data at the position of each attribute data in the image to be detected, namely 2a attribute data are obtained, and for attribute value data, 2a-b attribute value data are randomly selected in the image to be detected, and an attribute value data is sequentially added to the position of these attribute value data. Thus, 2a attribute data and 2a attribute value data are obtained.
本步骤中,另一种可能的实施方式包括:在该第一数量大于该第二数量的情况下,在每个属性值数据所在位置处增加一个相同的属性值数据,获取两倍的第二数量与该第一数量的第二差值,并从至少一个该属性数据中获取该第二差值对应数量的目标属性数据,并在该目标属性数据所在位置处增加一个相同的属性数据,以得到两倍第二数量的属性数据,和两倍第二数量的属性值数据。In this step, another possible implementation method includes: when the first number is greater than the second number, add an identical attribute value data at the location of each attribute value data, and obtain twice the second The second difference between the quantity and the first quantity, and obtain the target attribute data corresponding to the second difference from at least one of the attribute data, and add the same attribute data at the position of the target attribute data, so as to Twice the second amount of attribute data, and twice the second amount of attribute value data are obtained.
相应地,按照以上实施方式,图1中所述的步骤102的实施方式可以包括:根据该两倍第二数量的属性数据对应的第一位置信息生成第一关系图;根据该两倍第二数量的属性值数据对应的第二位置信息生成第二关系图。Correspondingly, according to the above implementation, the implementation of step 102 in FIG. 1 may include: generating a first relationship diagram according to the first position information corresponding to the twice the second amount of attribute data; The second position information corresponding to the quantity of attribute value data generates a second relationship diagram.
示例地,若属性数据的第一数量为a,属性值数据的第二数量为b,在该a大于b的情况下,直接在待检测图像中每个属性值数据所在位置处增加一个数据,即得到了2b个属性值数据,对于属性数据,则在待检测图像中随机选取2b-a个属性数据,在这些属性数据所在的位置上依次增加一个属性数据。由此便得到了2b个属性数据,也得到了2b个属性值数据。For example, if the first quantity of attribute data is a, and the second quantity of attribute value data is b, in the case that a is greater than b, directly add a piece of data at the position of each attribute value data in the image to be detected, That is, 2b attribute value data are obtained. For attribute data, 2b-a attribute data are randomly selected in the image to be detected, and one attribute data is sequentially added to the position of these attribute data. Thus, 2b attribute data and 2b attribute value data are obtained.
以上技术方案,能够有效保证该属性数据与该属性值数据的数量相等,从而能够保证每个属性数据均能匹配到相应的属性值数据,有利于扩大可处理的待检测图像的范围,拓展该键值匹配方法的适用范围。The above technical solutions can effectively ensure that the attribute data is equal to the attribute value data, thereby ensuring that each attribute data can be matched to the corresponding attribute value data, which is conducive to expanding the range of images to be detected that can be processed, expanding the The scope of the key-value matching method.
图5是本公开另一示例性实施例示出的一种键值匹配装置的框图;参见图5,该键值匹配装置,可以包括:Fig. 5 is a block diagram of a key value matching device shown in another exemplary embodiment of the present disclosure; referring to Fig. 5, the key value matching device may include:
第一获取模块401,用于获取待检测图像中至少一个属性数据的第一位置信息和至少一个属性值数据的第二位置信息;A first acquiring module 401, configured to acquire first position information of at least one attribute data and second position information of at least one attribute value data in the image to be detected;
关系图生成模块402,用于根据该至少一个属性数据的第一位置信息生成第一关系图,并根据该至少一个属性值数据的第二位置信息生成第二关系图;A relationship diagram generation module 402, configured to generate a first relationship diagram according to the first location information of the at least one attribute data, and generate a second relationship diagram according to the second location information of the at least one attribute value data;
确定模块403,用于将该至少一个属性数据的第一位置信息,该至少一个属性值数据的第二位置信息,该第一关系图,该第二关系图以及该待检测 图像输入预设图匹配模型,得到该属性数据与该属性值数据的匹配关系。A determining module 403, configured to input the first position information of the at least one attribute data, the second position information of the at least one attribute value data, the first relationship diagram, the second relationship diagram and the image to be detected into a preset diagram Match the model to obtain the matching relationship between the attribute data and the attribute value data.
上述技术方案,通过将该至少一个属性数据的第一位置信息,该至少一个属性值数据的第二位置信息,该至少一个属性数据的第一位置信息对应的第一关系图,该至少一个属性值数据的第二位置信息对应的第二关系图,以及该待检测图像输入预设图匹配模型,以使该预设图匹配模型输出得到该属性数据与该属性值数据的匹配关系,这样,通过该预设图匹配模型进行键值匹配,不仅能够针对不同场景进行键值匹配,提升模型的泛化性,还能够有效保证键值匹配结果准确性。In the above technical solution, by using the first position information of the at least one attribute data, the second position information of the at least one attribute value data, and the first relationship diagram corresponding to the first position information of the at least one attribute data, the at least one attribute The second relationship graph corresponding to the second position information of the value data, and the image to be detected are input into the preset graph matching model, so that the preset graph matching model outputs the matching relationship between the attribute data and the attribute value data, thus, Using the preset graph matching model for key-value matching can not only perform key-value matching for different scenarios, improve the generalization of the model, but also effectively ensure the accuracy of key-value matching results.
可选地,该第一关系图包括每个属性数据所在位置对应的属性节点和不同的该属性节点之间的第一连线,该第二关系图包括每个属性值数据所在位置对应的属性值节点,以及不同的属性值节点之间的第二连线,该预设图匹配模型,用于:Optionally, the first relationship diagram includes the attribute node corresponding to the location of each attribute data and the first connection between different attribute nodes, and the second relationship diagram includes the attribute corresponding to the location of each attribute value data Value nodes, and the second connection between different attribute value nodes, the preset graph matching model is used for:
根据该至少一个属性数据的第一位置信息从该待检测图像中获取该第一关系图中每个该属性节点对应的第一特征和每条该第一连线对应的第二特征,并根据该至少一个属性值数据的第二位置信息从该待检测图像中获取该第二关系图中每个该属性值节点对应的第三特征和每条该第二连接对应的第四特征;According to the first position information of the at least one attribute data, the first feature corresponding to each attribute node in the first relationship graph and the second feature corresponding to each first connection line are obtained from the image to be detected, and according to The second position information of the at least one attribute value data obtains the third feature corresponding to each attribute value node in the second relationship graph and the fourth feature corresponding to each second connection from the image to be detected;
根据每个该属性节点对应的第一特征和每条该第一连线对应的第二特征,以及每个该属性值节点对应的第三特征和每条该第二连接对应的第四特征确定该属性数据与该属性值数据的匹配关系。Determine according to the first feature corresponding to each attribute node and the second feature corresponding to each first connection, and the third feature corresponding to each attribute value node and the fourth feature corresponding to each second connection The matching relationship between the attribute data and the attribute value data.
可选地,该预设图匹配模型包括第一子网络和第二子网络,该预设图匹配模型,用于:Optionally, the preset graph matching model includes a first subnetwork and a second subnetwork, and the preset graph matching model is used for:
将该至少一个属性数据的第一位置信息,该第一关系图和该待检测图像作为第一子网络的输入,以输出得到每个该属性节点对应的第一特征,并将该至少一个属性数据的第一位置信息,该第一关系图和该待检测图像作为第二子网络的输入,以输出得到该每条第一连线对应的第二特征,其中,该第 一子网络的隐藏层数量少于该第二子网络;The first position information of the at least one attribute data, the first relationship graph and the image to be detected are used as the input of the first sub-network to output the first feature corresponding to each attribute node, and the at least one attribute The first location information of the data, the first relationship graph and the image to be detected are used as the input of the second subnetwork to output the second feature corresponding to each first connection line, wherein the hidden of the first subnetwork the number of layers is less than the second subnetwork;
将该至少一个属性值数据的第二位置信息,该第二关系图和该待检测图像作为该第一子网络的输入,以输出得到每个该属性值节点对应的第三特征,并将该至少一个属性值数据的第二位置信息,该第二关系图和该待检测图像作为第二子网络的输入,以输出得到每条第二连线对应的第四特征。The second position information of the at least one attribute value data, the second relationship graph and the image to be detected are used as the input of the first sub-network to output the third feature corresponding to each attribute value node, and the The second position information of at least one attribute value data, the second relationship diagram and the image to be detected are used as inputs of the second sub-network to output the fourth feature corresponding to each second connection line.
可选地,该预设图匹配模型,用于:Optionally, the preset map matching model is used for:
根据每个该属性节点对应的第一特征和每个该属性值节点对应的第三特征确定节点相似度矩阵;Determine the node similarity matrix according to the first feature corresponding to each attribute node and the third feature corresponding to each attribute value node;
根据每条该第一连线对应的第二特征和每条该第二连接对应的第四特征确定连线相似度矩阵;determining a connection similarity matrix according to the second feature corresponding to each of the first connections and the fourth feature corresponding to each of the second connections;
根据该节点相似度矩阵和连线相似度矩阵确定每个该属性数据与每个该属性值数据的匹配关系。A matching relationship between each attribute data and each attribute value data is determined according to the node similarity matrix and the connection similarity matrix.
可选地,该关系图生成模块,用于:Optionally, the relationship graph generation module is used for:
根据该至少一个属性数据的第一位置信息通过德劳内三角化建图方式生成该第一关系图;generating the first relationship graph by means of Delaunay triangulation mapping according to the first position information of the at least one attribute data;
根据该至少一个属性值数据的第二位置信息通过全连接建图方式生成该第二关系图。The second relational graph is generated by a fully connected graphing method according to the second position information of the at least one attribute value data.
图6是根据图5所示实施例示出的一种键值匹配装置的框图;参见图6,该装置还可以包括:Fig. 6 is a block diagram of a key-value matching device according to the embodiment shown in Fig. 5; referring to Fig. 6, the device may also include:
第二获取模块404,用于获取该属性数据的第一数量和该属性值数据的第二数量;The second acquiring module 404 is configured to acquire the first quantity of the attribute data and the second quantity of the attribute value data;
数据增加模块405,用于在该第一数量与该第二数量不等的情况下,通过在至少一个该属性数据所在位置处增加相同的属性数据,或,在至少一个该属性值数据所在位置处增加相同的属性值数据,以使该属性数据与该属性值数据的数量相等。A data adding module 405, configured to add the same attribute data at least one location where the attribute data is located, or at least one location where the attribute value data is located when the first quantity is not equal to the second quantity Add the same attribute value data at the place, so that the quantity of the attribute data and the attribute value data is equal.
可选地,该数据增加模块,用于:Optionally, the data addition module is used for:
在该第一数量小于该第二数量的情况下,在每个属性数据所在位置处增加一个相同的属性数据,并获取两倍的第一数量与该第二数量的第一差值,从至少一个该属性值数据中获取该第一差值对应数量的目标属性值数据,并在每个该目标属性值数据所在位置处增加一个相同的属性值数据,以得到两倍第一数量的属性数据,和两倍第一数量的属性值数据;In the case that the first quantity is less than the second quantity, add the same attribute data at the position of each attribute data, and obtain twice the first difference between the first quantity and the second quantity, from at least Obtain the target attribute value data corresponding to the first difference from one attribute value data, and add the same attribute value data at each position of the target attribute value data to obtain twice the first amount of attribute data , and twice the first amount of attribute value data;
相应地,该关系图生成模块,用于:Correspondingly, the relationship graph generation module is used for:
根据该两倍第一数量的属性数据对应的第一位置信息生成第一关系图;generating a first relationship diagram according to the first location information corresponding to the twice the first quantity of attribute data;
根据该两倍第一数量的属性值数据对应的第二位置信息生成第二关系图。A second relationship graph is generated according to the second position information corresponding to the twice the first quantity of attribute value data.
可选地,该数据增加模块,用于:Optionally, the data augmentation module is used for:
在该第一数量大于该第二数量的情况下,在每个属性值数据所在位置处增加一个相同的属性值数据,获取两倍的第二数量与该第一数量的第二差值,并从至少一个该属性数据中获取该第二差值对应数量的目标属性数据,并在该目标属性数据所在位置处增加一个相同的属性数据,以得到两倍第二数量的属性数据,和两倍第二数量的属性值数据;When the first quantity is greater than the second quantity, add the same attribute value data at the position of each attribute value data, obtain twice the second difference between the second quantity and the first quantity, and Acquire the target attribute data corresponding to the second difference from at least one attribute data, and add the same attribute data at the location of the target attribute data to obtain twice the second amount of attribute data, and twice a second quantity of attribute value data;
相应地,相应地,该关系图生成模块,用于:Correspondingly, correspondingly, the relationship graph generation module is used for:
根据该两倍第二数量的属性数据对应的第一位置信息生成第一关系图;generating a first relationship diagram according to the first position information corresponding to the twice the second quantity of attribute data;
根据该两倍第二数量的属性值数据对应的第二位置信息生成第二关系图。A second relationship graph is generated according to the second location information corresponding to the twice the second quantity of attribute value data.
以上技术方案,能够有效保证该属性数据与该属性值数据的数量相等,从而能够保证每个属性数据均能匹配到相应的属性值数据,有利于扩大可处理的待检测图像的范围,拓展该键值匹配方法的适用范围。The above technical solutions can effectively ensure that the attribute data is equal to the attribute value data, thereby ensuring that each attribute data can be matched to the corresponding attribute value data, which is conducive to expanding the range of images to be detected that can be processed, expanding the The scope of the key-value matching method.
可选地,该预设图匹配模型通过以下步骤训练得到:Optionally, the preset image matching model is trained through the following steps:
获取模型训练样本数据,该模型训练样本数据包括多个待检测图像样本,每个该待检测图像样本中的每个属性数据的第一位置信息,该待检测图像样本中的每个属性值数据的第二位置信息,以及每个该待检测图像样本对应的 第一关系图和第二关系图;Acquiring model training sample data, the model training sample data includes a plurality of image samples to be detected, the first position information of each attribute data in each image sample to be detected, and each attribute value data in the image sample to be detected The second position information, and the first relationship diagram and the second relationship diagram corresponding to each image sample to be detected;
根据每个属性数据的第一位置信息通过预设网络初始模型从该待检测图像样本中获取该待检测图像样本的第一关系图中每个属性节点对应的第一特征和每条第一连接对应的第二特征,并根据每个属性值数据的第二位置信息通过该预设网络初始模型从该待检测图像样本中获取该待检测图像样本的第二关系图中每个属性值节点对应的第三特征和每条第二连线对应的第四特征;According to the first position information of each attribute data, the first feature corresponding to each attribute node and each first connection in the first relationship diagram of the image sample to be detected are obtained from the image sample to be detected through a preset network initial model. corresponding to the second feature, and according to the second position information of each attribute value data, each attribute value node in the second relationship diagram of the image sample to be detected is obtained from the image sample to be detected through the preset network initial model corresponding to The third feature of and the fourth feature corresponding to each second connecting line;
根据该待检测图像样本的第一关系图中每个属性节点对应的第一特征和每条第一连接对应的第二特征,以及该待检测图像样本的第二关系图中每个属性值节点对应的第三特征和每条第二连线对应的第四特征,通过预设损失函数计算每个属性节点与待匹配的属性值节点的距离向量对应的损失值,根据该损失值对该预设初始网络模型进行迭代训练,以得到该预设图匹配模型。According to the first feature corresponding to each attribute node in the first relationship graph of the image sample to be detected and the second feature corresponding to each first connection, and each attribute value node in the second relationship graph of the image sample to be detected For the corresponding third feature and the fourth feature corresponding to each second connection line, calculate the loss value corresponding to the distance vector between each attribute node and the attribute value node to be matched through the preset loss function, according to the loss value. The initial network model is set to perform iterative training to obtain the preset image matching model.
可选地,所述根据所述待检测图像样本的第一关系图中每个属性节点对应的第一特征和每条第一连接对应的第二特征,以及所述待检测图像样本的第二关系图中每个属性值节点对应的第三特征和每条第二连线对应的第四特征,通过预设损失函数计算每个属性节点与待匹配的属性值节点的距离向量对应的损失值,包括:Optionally, according to the first feature corresponding to each attribute node in the first relationship graph of the image sample to be detected and the second feature corresponding to each first connection, and the second feature of the image sample to be detected The third feature corresponding to each attribute value node in the relationship diagram and the fourth feature corresponding to each second connection line, calculate the loss value corresponding to the distance vector between each attribute node and the attribute value node to be matched through the preset loss function ,include:
根据每个所述属性节点对应的第一特征和每个所述属性值节点对应的第三特征确定节点相似度矩阵,并根据每条所述第一连线对应的第二特征和每条所述第二连接对应的第四特征确定连线相似度矩阵;Determine the node similarity matrix according to the first feature corresponding to each attribute node and the third feature corresponding to each attribute value node, and determine the node similarity matrix according to the second feature corresponding to each of the first connections and each of the attribute value nodes The fourth feature corresponding to the second connection determines the connection similarity matrix;
根据所述节点相似度矩阵和所述连线相似度矩阵生成目标关系矩阵;generating a target relationship matrix according to the node similarity matrix and the connection similarity matrix;
获取所述目标关系矩阵对应的双随机矩阵;Obtain the double random matrix corresponding to the target relationship matrix;
根据所述双随机矩阵确定每个属性节点与待匹配的属性值节点的距离向量;Determine the distance vector between each attribute node and the attribute value node to be matched according to the double random matrix;
根据所述距离向量通过预设损失函数确定所述损失值。The loss value is determined through a preset loss function according to the distance vector.
通过以上训练方式得到的预设图匹配模型,其泛化性较强,能够适用于多种不同的键值匹配场景,例如,既可以用于对身份证图像的键值匹配,也可以应用于营业执照图像,学位证图像等多个场景下的键值匹配。The preset image matching model obtained through the above training method has strong generalization and can be applied to many different key-value matching scenarios. For example, it can be used for key-value matching of ID card images, and can also be applied Key-value matching in multiple scenarios such as business license images and degree certificate images.
下面参考图7,其示出了适于用来实现本公开实施例的电子设备600的结构示意图。本公开实施例中的终端设备可以包括但不限于诸如移动电话、笔记本电脑、数字广播接收器、PDA(个人数字助理)、PAD(平板电脑)、PMP(便携式多媒体播放器)、车载终端(例如车载导航终端)等等的移动终端以及诸如数字TV、台式计算机等等的固定终端。图7示出的电子设备仅仅是一个示例,不应对本公开实施例的功能和使用范围带来任何限制。Referring now to FIG. 7 , it shows a schematic structural diagram of an electronic device 600 suitable for implementing the embodiments of the present disclosure. The terminal equipment in the embodiment of the present disclosure may include but not limited to such as mobile phone, notebook computer, digital broadcast receiver, PDA (personal digital assistant), PAD (tablet computer), PMP (portable multimedia player), vehicle terminal (such as mobile terminals such as car navigation terminals) and fixed terminals such as digital TVs, desktop computers and the like. The electronic device shown in FIG. 7 is only an example, and should not limit the functions and application scope of the embodiments of the present disclosure.
如图7所示,电子设备600可以包括处理装置(例如中央处理器、图形处理器等)601,其可以根据存储在只读存储器(ROM)602中的程序或者从存储装置608加载到随机访问存储器(RAM)603中的程序而执行各种适当的动作和处理。在RAM 603中,还存储有电子设备600操作所需的各种程序和数据。处理装置601、ROM 602以及RAM 603通过总线604彼此相连。输入/输出(I/O)接口605也连接至总线604。As shown in FIG. 7, an electronic device 600 may include a processing device (such as a central processing unit, a graphics processing unit, etc.) 601, which may be randomly accessed according to a program stored in a read-only memory (ROM) 602 or loaded from a storage device 608. Various appropriate actions and processes are executed by programs in the memory (RAM) 603 . In the RAM 603, various programs and data necessary for the operation of the electronic device 600 are also stored. The processing device 601, ROM 602, and RAM 603 are connected to each other through a bus 604. An input/output (I/O) interface 605 is also connected to the bus 604 .
通常,以下装置可以连接至I/O接口605:包括例如触摸屏、触摸板、键盘、鼠标、摄像头、麦克风、加速度计、陀螺仪等的输入装置606;包括例如液晶显示器(LCD)、扬声器、振动器等的输出装置607;包括例如磁带、硬盘等的存储装置608;以及通信装置609。通信装置609可以允许电子设备600与其他设备进行无线或有线通信以交换数据。虽然图7示出了具有各种装置的电子设备600,但是应理解的是,并不要求实施或具备所有示出的装置。可以替代地实施或具备更多或更少的装置。Typically, the following devices can be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; including, for example, a liquid crystal display (LCD), speaker, vibration an output device 607 such as a computer; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication means 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. While FIG. 7 shows electronic device 600 having various means, it should be understood that implementing or having all of the means shown is not a requirement. More or fewer means may alternatively be implemented or provided.
特别地,根据本公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本公开的实施例包括一种计算机程序产品,其包括承载在非暂态计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通 过通信装置609从网络上被下载和安装,或者从存储装置608被安装,或者从ROM 602被安装。在该计算机程序被处理装置601执行时,执行本公开实施例的方法中限定的上述功能。In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product, which includes a computer program carried on a non-transitory computer readable medium, where the computer program includes program code for executing the method shown in the flowchart. In such an embodiment, the computer program may be downloaded and installed from a network via communication means 609, or from storage means 608, or from ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the methods of the embodiments of the present disclosure are performed.
需要说明的是,本公开上述的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本公开中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本公开中,计算机可读信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读信号介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:电线、光缆、RF(射频)等等,或者上述的任意合适的组合。It should be noted that the above-mentioned computer-readable medium in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. A computer readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, electrical connections with one or more wires, portable computer diskettes, hard disks, random access memory (RAM), read-only memory (ROM), erasable Programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present disclosure, however, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave carrying computer-readable program code therein. Such propagated data signals may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which can transmit, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device . Program code embodied on a computer readable medium may be transmitted by any appropriate medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
在一些实施方式中,服务器可以利用诸如HTTP(HyperText Transfer Protocol,超文本传输协议)之类的任何当前已知或未来研发的网络协议进行通信,并且可以与任意形式或介质的数字数据通信(例如,通信网络)互连。通信网络的示例包括局域网(“LAN”),广域网(“WAN”),网际网(例如,互联网)以及端对端网络(例如,adhoc端对端网络),以及任何当前 已知或未来研发的网络。In some embodiments, the server can communicate with any currently known or future-developed network protocol such as HTTP (HyperText Transfer Protocol, Hypertext Transfer Protocol), and can communicate with digital data in any form or medium (such as , communication network) interconnection. Examples of communication networks include local area networks ("LANs"), wide area networks ("WANs"), internetworks (e.g., the Internet), and peer-to-peer networks (e.g., adhoc peer-to-peer networks), as well as any currently known or future developed network.
上述计算机可读介质可以是上述电子设备中所包含的;也可以是单独存在,而未装配入该电子设备中。The above-mentioned computer-readable medium may be included in the above-mentioned electronic device, or may exist independently without being incorporated into the electronic device.
上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被该电子设备执行时,使得该电子设备:获取待检测图像中至少一个属性数据的第一位置信息和至少一个属性值数据的第二位置信息;根据所述至少一个属性数据的第一位置信息生成第一关系图,并根据所述至少一个属性值数据的第二位置信息生成第二关系图;将所述至少一个属性数据的第一位置信息,所述至少一个属性值数据的第二位置信息,所述第一关系图,所述第二关系图以及所述待检测图像输入预设图匹配模型,得到所述属性数据与所述属性值数据的匹配关系。。The above-mentioned computer-readable medium carries one or more programs, and when the above-mentioned one or more programs are executed by the electronic device, the electronic device: acquires the first position information and at least one attribute of at least one attribute data in the image to be detected The second location information of the value data; generate a first relationship diagram according to the first location information of the at least one attribute data, and generate a second relationship diagram according to the second location information of the at least one attribute value data; The first position information of one attribute data, the second position information of the at least one attribute value data, the first relationship graph, the second relationship graph and the image to be detected are input into a preset graph matching model to obtain the The matching relationship between the attribute data and the attribute value data. .
可以以一种或多种程序设计语言或其组合来编写用于执行本公开的操作的计算机程序代码,上述程序设计语言包括但不限于面向对象的程序设计语言-诸如Java、Smalltalk、C++,还包括常规的过程式程序设计语言——诸如“C”语言或类似的程序设计语言。程序代码可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络——包括局域网(LAN)或广域网(WAN)——连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。Computer program code for carrying out operations of the present disclosure may be written in one or more programming languages, or combinations thereof, including but not limited to object-oriented programming languages—such as Java, Smalltalk, C++, and Includes conventional procedural programming languages - such as "C" or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (for example, using an Internet service provider to connected via the Internet).
附图中的流程图和框图,图示了按照本公开各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,该模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可 以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。The flowchart and block diagrams in the Figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in a flowchart or block diagram may represent a module, program segment, or portion of code that contains one or more logical functions for implementing specified executable instructions. It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or they may sometimes be executed in the reverse order, depending upon the functionality involved. It should also be noted that each block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations, can be implemented by a dedicated hardware-based system that performs the specified functions or operations , or may be implemented by a combination of dedicated hardware and computer instructions.
描述于本公开实施例中所涉及到的模块可以通过软件的方式实现,也可以通过硬件的方式来实现。其中,模块的名称在某种情况下并不构成对该模块本身的限定,例如,第一获取模块还可以被描述为“获取待检测图像中至少一个属性数据的第一位置信息和至少一个属性值数据的第二位置信息”。The modules involved in the embodiments described in the present disclosure may be implemented by software or by hardware. Wherein, the name of the module does not constitute a limitation of the module itself under certain circumstances, for example, the first acquisition module can also be described as "obtaining the first position information and at least one attribute data of at least one attribute data in the image to be detected Second location information for value data".
本文中以上描述的功能可以至少部分地由一个或多个硬件逻辑部件来执行。例如,非限制性地,可以使用的示范类型的硬件逻辑部件包括:现场可编程门阵列(FPGA)、专用集成电路(ASIC)、专用标准产品(ASSP)、片上系统(SOC)、复杂可编程逻辑设备(CPLD)等等。The functions described herein above may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: Field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), System on Chips (SOCs), Complex Programmable Logical device (CPLD) and so on.
在本公开的上下文中,机器可读介质可以是有形的介质,其可以包含或存储以供指令执行系统、装置或设备使用或与指令执行系统、装置或设备结合地使用的程序。机器可读介质可以是机器可读信号介质或机器可读储存介质。机器可读介质可以包括但不限于电子的、磁性的、光学的、电磁的、红外的、或半导体系统、装置或设备,或者上述内容的任何合适组合。机器可读存储介质的更具体示例会包括基于一个或多个线的电气连接、便携式计算机盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦除可编程只读存储器(EPROM或快闪存储器)、光纤、便捷式紧凑盘只读存储器(CD-ROM)、光学储存设备、磁储存设备、或上述内容的任何合适组合。In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media would include one or more wire-based electrical connections, portable computer discs, hard drives, random access memory (RAM), read only memory (ROM), erasable programmable read only memory (EPROM or flash memory), optical fiber, compact disk read only memory (CD-ROM), optical storage, magnetic storage, or any suitable combination of the foregoing.
根据本公开的一个或多个实施例,示例1提供了一种键值匹配方法,所述方法包括:According to one or more embodiments of the present disclosure, Example 1 provides a key-value matching method, the method comprising:
获取待检测图像中至少一个属性数据的第一位置信息和至少一个属性值数据的第二位置信息;Acquiring first position information of at least one attribute data and second position information of at least one attribute value data in the image to be detected;
根据所述至少一个属性数据的第一位置信息生成第一关系图,并根据所 述至少一个属性值数据的第二位置信息生成第二关系图;generating a first relationship diagram according to the first location information of the at least one attribute data, and generating a second relationship diagram according to the second location information of the at least one attribute value data;
将所述至少一个属性数据的第一位置信息,所述至少一个属性值数据的第二位置信息,所述第一关系图,所述第二关系图以及所述待检测图像输入预设图匹配模型,得到所述属性数据与所述属性值数据的匹配关系。Matching the first location information of the at least one attribute data, the second location information of the at least one attribute value data, the first relationship diagram, the second relationship diagram and the image to be detected model to obtain the matching relationship between the attribute data and the attribute value data.
根据本公开的一个或多个实施例,示例2提供了示例1的方法,所述第一关系图包括每个属性数据所在位置对应的属性节点和不同的所述属性节点之间的第一连线,所述第二关系图包括每个属性值数据所在位置对应的属性值节点,以及不同的属性值节点之间的第二连线,所述预设图匹配模型,用于:According to one or more embodiments of the present disclosure, Example 2 provides the method of Example 1, the first relationship graph includes the attribute node corresponding to the location of each attribute data and the first connection between different attribute nodes line, the second relationship graph includes an attribute value node corresponding to the location of each attribute value data, and a second connection between different attribute value nodes, and the preset graph matching model is used for:
根据所述至少一个属性数据的第一位置信息从所述待检测图像中获取所述第一关系图中每个所述属性节点对应的第一特征和每条所述第一连线对应的第二特征,并根据所述至少一个属性值数据的第二位置信息从所述待检测图像中获取所述第二关系图中每个所述属性值节点对应的第三特征和每条所述第二连接对应的第四特征;According to the first position information of the at least one attribute data, the first feature corresponding to each attribute node in the first relationship graph and the first feature corresponding to each first connection line are obtained from the image to be detected. two features, and according to the second position information of the at least one attribute value data, obtain the third feature corresponding to each of the attribute value nodes in the second relationship diagram and each of the first item from the image to be detected The fourth feature corresponding to the two connections;
根据每个所述属性节点对应的第一特征和每条所述第一连线对应的第二特征,以及每个所述属性值节点对应的第三特征和每条所述第二连接对应的第四特征确定所述属性数据与所述属性值数据的匹配关系。According to the first feature corresponding to each of the attribute nodes and the second feature corresponding to each of the first connections, and the third feature corresponding to each of the attribute value nodes and the corresponding to each of the second connections The fourth feature determines the matching relationship between the attribute data and the attribute value data.
根据本公开的一个或多个实施例,示例3提供了示例2的方法,所述预设图匹配模型包括第一子网络和第二子网络,所述根据所述至少一个属性数据的第一位置信息从所述待检测图像中获取所述第一关系图中每个所述属性节点对应的第一特征和每条所述第一连线对应的第二特征,并根据所述至少一个属性值数据的第二位置信息从所述待检测图像中获取所述第二关系图中每个所述属性值节点对应的第三特征和每条所述第二连接对应的第四特征,包括:According to one or more embodiments of the present disclosure, Example 3 provides the method of Example 2, the preset graph matching model includes a first sub-network and a second sub-network, and the first sub-network according to the at least one attribute data The location information acquires the first feature corresponding to each attribute node in the first relationship graph and the second feature corresponding to each first connection line from the image to be detected, and according to the at least one attribute The second position information of the value data acquires the third feature corresponding to each attribute value node in the second relationship graph and the fourth feature corresponding to each second connection from the image to be detected, including:
将所述至少一个属性数据的第一位置信息,所述第一关系图和所述待检测图像作为第一子网络的输入,以输出得到每个所述属性节点对应的第一特 征,并将所述至少一个属性数据的第一位置信息,所述第一关系图和所述待检测图像作为第二子网络的输入,以输出得到所述每条第一连线对应的第二特征,其中,所述第一子网络的隐藏层数量少于所述第二子网络;Using the first position information of the at least one attribute data, the first relationship graph and the image to be detected as the input of the first sub-network to output the first feature corresponding to each of the attribute nodes, and The first position information of the at least one attribute data, the first relationship diagram and the image to be detected are used as inputs of the second sub-network to output the second feature corresponding to each first connection line, wherein , the number of hidden layers of the first subnetwork is less than that of the second subnetwork;
将所述至少一个属性值数据的第二位置信息,所述第二关系图和所述待检测图像作为所述第一子网络的输入,以输出得到每个所述属性值节点对应的第三特征,并将所述至少一个属性值数据的第二位置信息,所述第二关系图和所述待检测图像作为第二子网络的输入,以输出得到每条第二连线对应的第四特征。Using the second position information of the at least one attribute value data, the second relationship graph and the image to be detected as the input of the first sub-network to output the third sub-network corresponding to each attribute value node features, and use the second position information of the at least one attribute value data, the second relationship diagram and the image to be detected as the input of the second subnetwork to output the fourth corresponding to each second connection line feature.
根据本公开的一个或多个实施例,示例4提供了示例2的方法,所述根据每个所述属性节点对应的第一特征和每条所述第一连线对应的第二特征,以及每个所述属性值节点对应的第三特征和每条所述第二连接对应的第四特征确定所述属性数据与所述属性值数据的匹配关系,包括:According to one or more embodiments of the present disclosure, Example 4 provides the method of Example 2, according to the first feature corresponding to each of the attribute nodes and the second feature corresponding to each of the first links, and The third feature corresponding to each attribute value node and the fourth feature corresponding to each second connection determine the matching relationship between the attribute data and the attribute value data, including:
根据每个所述属性节点对应的第一特征和每个所述属性值节点对应的第三特征确定节点相似度矩阵;determining a node similarity matrix according to the first feature corresponding to each attribute node and the third feature corresponding to each attribute value node;
根据每条所述第一连线对应的第二特征和每条所述第二连接对应的第四特征确定连线相似度矩阵;determining a connection similarity matrix according to the second feature corresponding to each of the first connections and the fourth feature corresponding to each of the second connections;
根据所述节点相似度矩阵和连线相似度矩阵确定每个所述属性数据与每个所述属性值数据的匹配关系。A matching relationship between each of the attribute data and each of the attribute value data is determined according to the node similarity matrix and the connection similarity matrix.
根据本公开的一个或多个实施例,示例5提供了示例1的方法,所述根据所述至少一个属性数据的第一位置信息生成第一关系图,并根据所述至少一个属性值数据的第二位置信息生成第二关系图,包括:According to one or more embodiments of the present disclosure, Example 5 provides the method of Example 1, generating a first relationship graph according to the first location information of the at least one attribute data, and generating a first relationship graph according to the at least one attribute value data The second location information generates a second relationship diagram, including:
根据所述至少一个属性数据的第一位置信息通过德劳内三角化建图方式生成所述第一关系图;generating the first relationship graph by means of Delaunay triangulation mapping according to the first position information of the at least one attribute data;
根据所述至少一个属性值数据的第二位置信息通过全连接建图方式生成所述第二关系图。The second relational graph is generated by a fully connected graphing method according to the second position information of the at least one attribute value data.
根据本公开的一个或多个实施例,示例6提供了示例1的方法,在所述 根据所述至少一个属性数据的第一位置信息生成第一关系图,并根据所述至少一个属性值数据的第二位置信息生成第二关系图之前,所述方法还包括:According to one or more embodiments of the present disclosure, Example 6 provides the method of Example 1, generating a first relationship graph according to the first location information of the at least one attribute data, and generating a first relationship graph according to the at least one attribute value data Before generating the second relationship diagram based on the second location information, the method further includes:
获取所述属性数据的第一数量和所述属性值数据的第二数量;acquiring the first quantity of the attribute data and the second quantity of the attribute value data;
在所述第一数量与所述第二数量不等的情况下,通过在至少一个所述属性数据所在位置处增加相同的属性数据,或,在至少一个所述属性值数据所在位置处增加相同的属性值数据,以使所述属性数据与所述属性值数据的数量相等。In the case that the first quantity is not equal to the second quantity, by adding the same attribute data at at least one location of the attribute data, or adding the same attribute data at at least one location of the attribute value data attribute value data, so that the number of the attribute data and the attribute value data is equal.
根据本公开的一个或多个实施例,示例7提供了示例6的方法,所述在所述第一数量与所述第二数量不等的情况下,通过在至少一个所述属性数据所在位置处增加相同的属性数据,包括:According to one or more embodiments of the present disclosure, Example 7 provides the method of Example 6. In the case where the first quantity is not equal to the second quantity, by Add the same attribute data, including:
在所述第一数量小于所述第二数量的情况下,在每个属性数据所在位置处增加一个相同的属性数据,并获取两倍的第一数量与所述第二数量的第一差值,从至少一个所述属性值数据中获取所述第一差值对应数量的目标属性值数据,并在每个所述目标属性值数据所在位置处增加一个相同的属性值数据,以得到两倍第一数量的属性数据,和两倍第一数量的属性值数据;In the case that the first quantity is less than the second quantity, add the same attribute data at the location of each attribute data, and obtain twice the first difference between the first quantity and the second quantity , acquire the target attribute value data corresponding to the first difference from at least one of the attribute value data, and add the same attribute value data at each position of the target attribute value data to obtain twice a first amount of attribute data, and twice the first amount of attribute value data;
相应地,所述根据所述至少一个属性数据的第一位置信息生成第一关系图,并根据所述至少一个属性值数据的第二位置信息生成第二关系图,包括:Correspondingly, the generating the first relationship diagram according to the first location information of the at least one attribute data, and generating the second relationship diagram according to the second location information of the at least one attribute value data include:
根据所述两倍第一数量的属性数据对应的第一位置信息生成第一关系图;generating a first relationship diagram according to first position information corresponding to twice the first quantity of attribute data;
根据所述两倍第一数量的属性值数据对应的第二位置信息生成第二关系图。A second relationship graph is generated according to the second position information corresponding to the attribute value data twice the first amount.
根据本公开的一个或多个实施例,示例8提供了示例6的方法,所述在至少一个所述属性值数据所在位置处增加相同的属性值数据,以使所述属性数据与所述属性值数据的数量相等,还包括:According to one or more embodiments of the present disclosure, Example 8 provides the method of Example 6, adding the same attribute value data at at least one location where the attribute value data is located, so that the attribute data and the attribute The amount of value data is equal and also includes:
在所述第一数量大于所述第二数量的情况下,在每个属性值数据所在位置处增加一个相同的属性值数据,获取两倍的第二数量与所述第一数量的第 二差值,并从至少一个所述属性数据中获取所述第二差值对应数量的目标属性数据,并在所述目标属性数据所在位置处增加一个相同的属性数据,以得到两倍第二数量的属性数据,和两倍第二数量的属性值数据;In the case that the first number is greater than the second number, add the same attribute value data at the location of each attribute value data, and obtain the second difference between the second number and the first number twice value, and obtain the target attribute data corresponding to the second difference from at least one of the attribute data, and add an identical attribute data at the position of the target attribute data to obtain twice the second amount of attribute data, and twice the second amount of attribute value data;
相应地,所述预设图匹配模型根据所述至少一个属性数据的第一位置信息生成第一关系图,并根据所述至少一个属性值数据的第二位置信息生成第二关系图,包括:Correspondingly, the preset graph matching model generates a first relationship graph according to the first location information of the at least one attribute data, and generates a second relationship graph according to the second location information of the at least one attribute value data, including:
根据所述两倍第二数量的属性数据对应的第一位置信息生成第一关系图;generating a first relationship diagram according to first position information corresponding to twice the second quantity of attribute data;
根据所述两倍第二数量的属性值数据对应的第二位置信息生成第二关系图。A second relationship graph is generated according to the second position information corresponding to the twice the second quantity of attribute value data.
根据本公开的一个或多个实施例,示例9提供了示例1-8任一项的方法,所述预设图匹配模型通过以下步骤训练得到:According to one or more embodiments of the present disclosure, Example 9 provides the method of any one of Examples 1-8, wherein the preset image matching model is trained through the following steps:
获取模型训练样本数据,所述模型训练样本数据包括多个待检测图像样本,每个所述待检测图像样本中的每个属性数据的第一位置信息,所述待检测图像样本中的每个属性值数据的第二位置信息,以及每个所述待检测图像样本对应的第一关系图和第二关系图;Obtain model training sample data, the model training sample data includes a plurality of image samples to be detected, the first position information of each attribute data in each of the image samples to be detected, each of the image samples to be detected The second position information of the attribute value data, and the first relationship diagram and the second relationship diagram corresponding to each image sample to be detected;
根据每个属性数据的第一位置信息通过预设网络初始模型从所述待检测图像样本中获取所述待检测图像样本的第一关系图中每个属性节点对应的第一特征和每条第一连接对应的第二特征,并根据每个属性值数据的第二位置信息通过所述预设网络初始模型从所述待检测图像样本中获取所述待检测图像样本的第二关系图中每个属性值节点对应的第三特征和每条第二连线对应的第四特征;According to the first position information of each attribute data, the first feature corresponding to each attribute node in the first relational graph of the image sample to be detected and each first feature corresponding to the first relationship graph of the image sample to be detected are obtained from the image sample to be detected through a preset network initial model. One connects the corresponding second feature, and according to the second position information of each attribute value data, obtains each in the second relationship diagram of the image sample to be detected from the image sample to be detected through the preset network initial model The third characteristic corresponding to the attribute value node and the fourth characteristic corresponding to each second connecting line;
根据所述待检测图像样本的第一关系图中每个属性节点对应的第一特征和每条第一连接对应的第二特征,以及所述待检测图像样本的第二关系图中每个属性值节点对应的第三特征和每条第二连线对应的第四特征,通过预设损失函数计算每个属性节点与待匹配的属性值节点的距离向量对应的损 失值,根据所述损失值对所述预设初始网络模型进行迭代训练,以得到所述预设图匹配模型。According to the first feature corresponding to each attribute node in the first relationship graph of the image sample to be detected and the second feature corresponding to each first connection, and each attribute in the second relationship graph of the image sample to be detected The third feature corresponding to the value node and the fourth feature corresponding to each second connection line, calculate the loss value corresponding to the distance vector between each attribute node and the attribute value node to be matched through the preset loss function, according to the loss value Iterative training is performed on the preset initial network model to obtain the preset graph matching model.
根据本公开的一个或多个实施例,示例10提供了示例9所示的方法,所述根据所述待检测图像样本的第一关系图中每个属性节点对应的第一特征和每条第一连接对应的第二特征,以及所述待检测图像样本的第二关系图中每个属性值节点对应的第三特征和每条第二连线对应的第四特征,通过预设损失函数计算每个属性节点与待匹配的属性值节点的距离向量对应的损失值,包括:According to one or more embodiments of the present disclosure, Example 10 provides the method shown in Example 9, according to the first feature corresponding to each attribute node in the first relationship graph of the image sample to be detected and each item The second feature corresponding to a connection, and the third feature corresponding to each attribute value node in the second relationship graph of the image sample to be detected and the fourth feature corresponding to each second connection line are calculated by a preset loss function The loss value corresponding to the distance vector between each attribute node and the attribute value node to be matched, including:
根据每个所述属性节点对应的第一特征和每个所述属性值节点对应的第三特征确定节点相似度矩阵,并根据每条所述第一连线对应的第二特征和每条所述第二连接对应的第四特征确定连线相似度矩阵;Determine the node similarity matrix according to the first feature corresponding to each attribute node and the third feature corresponding to each attribute value node, and determine the node similarity matrix according to the second feature corresponding to each of the first connections and each of the attribute value nodes The fourth feature corresponding to the second connection determines the connection similarity matrix;
根据所述节点相似度矩阵和所述连线相似度矩阵生成目标关系矩阵;generating a target relationship matrix according to the node similarity matrix and the connection similarity matrix;
获取所述目标关系矩阵对应的双随机矩阵;Obtain the double random matrix corresponding to the target relationship matrix;
根据所述双随机矩阵确定每个属性节点与待匹配的属性值节点的距离向量;Determine the distance vector between each attribute node and the attribute value node to be matched according to the double random matrix;
根据所述距离向量通过预设损失函数确定所述损失值。The loss value is determined through a preset loss function according to the distance vector.
根据本公开的一个或多个实施例,示例11提供了一种键值匹配装置,所述装置包括:According to one or more embodiments of the present disclosure, Example 11 provides a key-value matching device, the device comprising:
第一获取模块,用于获取待检测图像中至少一个属性数据的第一位置信息和至少一个属性值数据的第二位置信息;A first acquiring module, configured to acquire first position information of at least one attribute data and second position information of at least one attribute value data in the image to be detected;
关系图生成模块,用于根据所述至少一个属性数据的第一位置信息生成第一关系图,并根据所述至少一个属性值数据的第二位置信息生成第二关系图;A relationship graph generation module, configured to generate a first relationship graph according to the first position information of the at least one attribute data, and generate a second relationship graph according to the second position information of the at least one attribute value data;
确定模块,用于将所述至少一个属性数据的第一位置信息,所述至少一个属性值数据的第二位置信息,所述第一关系图,所述第二关系图以及所述待检测图像输入预设图匹配模型,得到所述属性数据与所述属性值数据的匹 配关系。A determination module, configured to use the first location information of the at least one attribute data, the second location information of the at least one attribute value data, the first relationship diagram, the second relationship diagram and the image to be detected A preset map matching model is input to obtain a matching relationship between the attribute data and the attribute value data.
根据本公开的一个或多个实施例,示例12提供了一种计算机可读介质,其上存储有计算机程序,该程序被处理装置执行时实现示例1-10中任一项所述方法的步骤。According to one or more embodiments of the present disclosure, Example 12 provides a computer-readable medium on which a computer program is stored, and when the program is executed by a processing device, the steps of any one of the methods described in Examples 1-10 are implemented .
根据本公开的一个或多个实施例,示例13提供了一种电子设备,包括:According to one or more embodiments of the present disclosure, Example 13 provides an electronic device, comprising:
存储装置,其上存储有计算机程序;a storage device on which a computer program is stored;
处理装置,用于执行所述存储装置中的所述计算机程序,以实现示例1-10中任一项所述方法的步骤。A processing device configured to execute the computer program in the storage device to implement the steps of any one of the methods in Examples 1-10.
以上描述仅为本公开的较佳实施例以及对所运用技术原理的说明。本领域技术人员应当理解,本公开中所涉及的公开范围,并不限于上述技术特征的特定组合而成的技术方案,同时也应涵盖在不脱离上述公开构思的情况下,由上述技术特征或其等同特征进行任意组合而形成的其它技术方案。例如上述特征与本公开中公开的(但不限于)具有类似功能的技术特征进行互相替换而形成的技术方案。The above description is only a preferred embodiment of the present disclosure and an illustration of the applied technical principle. Those skilled in the art should understand that the disclosure scope involved in this disclosure is not limited to the technical solution formed by the specific combination of the above-mentioned technical features, but also covers the technical solutions formed by the above-mentioned technical features or Other technical solutions formed by any combination of equivalent features. For example, a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features with similar functions disclosed in this disclosure.
此外,虽然采用特定次序描绘了各操作,但是这不应当理解为要求这些操作以所示出的特定次序或以顺序次序执行来执行。在一定环境下,多任务和并行处理可能是有利的。同样地,虽然在上面论述中包含了若干具体实现细节,但是这些不应当被解释为对本公开的范围的限制。在单独的实施例的上下文中描述的某些特征还可以组合地实现在单个实施例中。相反地,在单个实施例的上下文中描述的各种特征也可以单独地或以任何合适的子组合的方式实现在多个实施例中。In addition, while operations are depicted in a particular order, this should not be understood as requiring that the operations be performed in the particular order shown or performed in sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while the above discussion contains several specific implementation details, these should not be construed as limitations on the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
尽管已经采用特定于结构特征和/或方法逻辑动作的语言描述了本主题,但是应当理解所附权利要求书中所限定的主题未必局限于上面描述的特定特征或动作。相反,上面所描述的特定特征和动作仅仅是实现权利要求书的示例形式。关于上述实施例中的装置,其中各个模块执行操作的具体方式已经在有关该方法的实施例中进行了详细描述,此处将不做详细阐述说明。Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims. Regarding the apparatus in the foregoing embodiments, the specific manner in which each module executes operations has been described in detail in the embodiments related to the method, and will not be described in detail here.
Claims (13)
- 一种键值匹配方法,其特征在于,所述方法包括:A key-value matching method, characterized in that the method comprises:获取待检测图像中至少一个属性数据的第一位置信息和至少一个属性值数据的第二位置信息;Acquiring first position information of at least one attribute data and second position information of at least one attribute value data in the image to be detected;根据所述至少一个属性数据的第一位置信息生成第一关系图,并根据所述至少一个属性值数据的第二位置信息生成第二关系图;generating a first relationship graph according to the first location information of the at least one attribute data, and generating a second relationship graph according to the second location information of the at least one attribute value data;将所述至少一个属性数据的第一位置信息,所述至少一个属性值数据的第二位置信息,所述第一关系图,所述第二关系图以及所述待检测图像输入预设图匹配模型,得到所述属性数据与所述属性值数据的匹配关系。Matching the first location information of the at least one attribute data, the second location information of the at least one attribute value data, the first relationship diagram, the second relationship diagram and the image to be detected model to obtain the matching relationship between the attribute data and the attribute value data.
- 根据权利要求1所述的方法,其特征在于,所述第一关系图包括每个属性数据所在位置对应的属性节点和不同的所述属性节点之间的第一连线,所述第二关系图包括每个属性值数据所在位置对应的属性值节点,以及不同的属性值节点之间的第二连线,所述预设图匹配模型用于:The method according to claim 1, wherein the first relationship graph includes an attribute node corresponding to the location of each attribute data and first connections between different attribute nodes, and the second relationship The graph includes an attribute value node corresponding to the location of each attribute value data, and a second connection between different attribute value nodes, and the preset graph matching model is used for:根据所述至少一个属性数据的第一位置信息从所述待检测图像中获取所述第一关系图中每个所述属性节点对应的第一特征和每条所述第一连线对应的第二特征,并根据所述至少一个属性值数据的第二位置信息从所述待检测图像中获取所述第二关系图中每个所述属性值节点对应的第三特征和每条所述第二连接对应的第四特征;According to the first position information of the at least one attribute data, the first feature corresponding to each attribute node in the first relationship graph and the first feature corresponding to each first connection line are obtained from the image to be detected. two features, and according to the second position information of the at least one attribute value data, obtain the third feature corresponding to each of the attribute value nodes in the second relationship diagram and each of the first item from the image to be detected The fourth feature corresponding to the two connections;根据每个所述属性节点对应的第一特征和每条所述第一连线对应的第二特征,以及每个所述属性值节点对应的第三特征和每条所述第二连接对应的第四特征确定所述属性数据与所述属性值数据的匹配关系。According to the first feature corresponding to each of the attribute nodes and the second feature corresponding to each of the first connections, and the third feature corresponding to each of the attribute value nodes and the corresponding to each of the second connections The fourth feature determines the matching relationship between the attribute data and the attribute value data.
- 根据权利要求2所述的方法,其特征在于,所述预设图匹配模型包括第一子网络和第二子网络,所述根据所述至少一个属性数据的第一位置信 息从所述待检测图像中获取所述第一关系图中每个所述属性节点对应的第一特征和每条所述第一连线对应的第二特征,并根据所述至少一个属性值数据的第二位置信息从所述待检测图像中获取所述第二关系图中每个所述属性值节点对应的第三特征和每条所述第二连接对应的第四特征,包括:The method according to claim 2, wherein the preset image matching model includes a first sub-network and a second sub-network, and the first position information according to the at least one attribute data is obtained from the to-be-detected Obtaining the first feature corresponding to each of the attribute nodes in the first relationship graph and the second feature corresponding to each of the first lines in the image, and according to the second position information of the at least one attribute value data Obtaining the third feature corresponding to each attribute value node in the second relationship diagram and the fourth feature corresponding to each second connection from the image to be detected, including:将所述至少一个属性数据的第一位置信息,所述第一关系图和所述待检测图像作为第一子网络的输入,以输出得到每个所述属性节点对应的第一特征,并将所述至少一个属性数据的第一位置信息,所述第一关系图和所述待检测图像作为第二子网络的输入,以输出得到所述每条第一连线对应的第二特征,其中,所述第一子网络的隐藏层数量少于所述第二子网络;Using the first position information of the at least one attribute data, the first relationship graph and the image to be detected as the input of the first sub-network to output the first feature corresponding to each of the attribute nodes, and The first position information of the at least one attribute data, the first relationship diagram and the image to be detected are used as inputs of the second sub-network to output the second feature corresponding to each first connection line, wherein , the number of hidden layers of the first subnetwork is less than that of the second subnetwork;将所述至少一个属性值数据的第二位置信息,所述第二关系图和所述待检测图像作为所述第一子网络的输入,以输出得到每个所述属性值节点对应的第三特征,并将所述至少一个属性值数据的第二位置信息,所述第二关系图和所述待检测图像作为第二子网络的输入,以输出得到每条第二连线对应的第四特征。Using the second position information of the at least one attribute value data, the second relationship graph and the image to be detected as the input of the first sub-network to output the third sub-network corresponding to each attribute value node features, and use the second position information of the at least one attribute value data, the second relationship diagram and the image to be detected as the input of the second subnetwork to output the fourth corresponding to each second connection line feature.
- 根据权利要求2所述的方法,其特征在于,所述根据每个所述属性节点对应的第一特征和每条所述第一连线对应的第二特征,以及每个所述属性值节点对应的第三特征和每条所述第二连接对应的第四特征确定所述属性数据与所述属性值数据的匹配关系,包括:The method according to claim 2, wherein, according to the first feature corresponding to each of the attribute nodes and the second feature corresponding to each of the first lines, and each of the attribute value nodes The corresponding third feature and the fourth feature corresponding to each of the second connections determine the matching relationship between the attribute data and the attribute value data, including:根据每个所述属性节点对应的第一特征和每个所述属性值节点对应的第三特征确定节点相似度矩阵;determining a node similarity matrix according to the first feature corresponding to each attribute node and the third feature corresponding to each attribute value node;根据每条所述第一连线对应的第二特征和每条所述第二连接对应的第四特征确定连线相似度矩阵;determining a connection similarity matrix according to the second feature corresponding to each of the first connections and the fourth feature corresponding to each of the second connections;根据所述节点相似度矩阵和连线相似度矩阵确定每个所述属性数据与每个所述属性值数据的匹配关系。A matching relationship between each of the attribute data and each of the attribute value data is determined according to the node similarity matrix and the connection similarity matrix.
- 根据权利要求1所述的方法,其特征在于,所述根据所述至少一个属性数据的第一位置信息生成第一关系图,并根据所述至少一个属性值数据的第二位置信息生成第二关系图,包括:The method according to claim 1, characterized in that, the first relationship diagram is generated according to the first position information of the at least one attribute data, and the second relationship graph is generated according to the second position information of the at least one attribute value data. Relationship diagram, including:根据所述至少一个属性数据的第一位置信息通过德劳内三角化建图方式生成所述第一关系图;generating the first relationship graph by means of Delaunay triangulation mapping according to the first position information of the at least one attribute data;根据所述至少一个属性值数据的第二位置信息通过全连接建图方式生成所述第二关系图。The second relational graph is generated by a fully connected graphing method according to the second position information of the at least one attribute value data.
- 根据权利要求1所述的方法,其特征在于,在所述根据所述至少一个属性数据的第一位置信息生成第一关系图,并根据所述至少一个属性值数据的第二位置信息生成第二关系图之前,所述方法还包括:The method according to claim 1, characterized in that, generating a first relationship diagram according to the first position information of the at least one attribute data, and generating a second position information according to the second position information of the at least one attribute value data Before the two relationship diagrams, the method also includes:获取所述属性数据的第一数量和所述属性值数据的第二数量;acquiring the first quantity of the attribute data and the second quantity of the attribute value data;在所述第一数量与所述第二数量不等的情况下,通过在至少一个所述属性数据所在位置处增加相同的属性数据,或,在至少一个所述属性值数据所在位置处增加相同的属性值数据,以使所述属性数据与所述属性值数据的数量相等。In the case that the first quantity is not equal to the second quantity, by adding the same attribute data at at least one location of the attribute data, or adding the same attribute data at at least one location of the attribute value data attribute value data, so that the number of the attribute data and the attribute value data is equal.
- 根据权利要求6所述的方法,其特征在于,所述在所述第一数量与所述第二数量不等的情况下,通过在至少一个所述属性数据所在位置处增加相同的属性数据,包括:The method according to claim 6, characterized in that, in the case where the first quantity is not equal to the second quantity, by adding the same attribute data at at least one position where the attribute data is located, include:在所述第一数量小于所述第二数量的情况下,在每个属性数据所在位置处增加一个相同的属性数据,并获取两倍的第一数量与所述第二数量的第一差值,从至少一个所述属性值数据中获取所述第一差值对应数量的目标属性值数据,并在每个所述目标属性值数据所在位置处增加一个相同的属性值数 据,以得到两倍第一数量的属性数据,和两倍第一数量的属性值数据;In the case that the first quantity is less than the second quantity, add the same attribute data at the location of each attribute data, and obtain twice the first difference between the first quantity and the second quantity , acquire the target attribute value data corresponding to the first difference from at least one of the attribute value data, and add the same attribute value data at each position of the target attribute value data to obtain twice a first amount of attribute data, and twice the first amount of attribute value data;相应地,所述根据所述至少一个属性数据的第一位置信息生成第一关系图,并根据所述至少一个属性值数据的第二位置信息生成第二关系图,包括:Correspondingly, the generating the first relationship diagram according to the first location information of the at least one attribute data, and generating the second relationship diagram according to the second location information of the at least one attribute value data include:根据所述两倍第一数量的属性数据对应的第一位置信息生成第一关系图;generating a first relationship diagram according to first position information corresponding to twice the first quantity of attribute data;根据所述两倍第一数量的属性值数据对应的第二位置信息生成第二关系图。A second relationship graph is generated according to the second position information corresponding to the attribute value data twice the first amount.
- 根据权利要求6所述的方法,其特征在于,所述在至少一个所述属性值数据所在位置处增加相同的属性值数据,以使所述属性数据与所述属性值数据的数量相等,还包括:The method according to claim 6, characterized in that adding the same attribute value data at at least one position where the attribute value data is located, so that the quantity of the attribute data and the attribute value data is equal, and further include:在所述第一数量大于所述第二数量的情况下,在每个属性值数据所在位置处增加一个相同的属性值数据,获取两倍的第二数量与所述第一数量的第二差值,并从至少一个所述属性数据中获取所述第二差值对应数量的目标属性数据,并在所述目标属性数据所在位置处增加一个相同的属性数据,以得到两倍第二数量的属性数据,和两倍第二数量的属性值数据;In the case that the first number is greater than the second number, add the same attribute value data at the location of each attribute value data, and obtain the second difference between the second number and the first number twice value, and obtain the target attribute data corresponding to the second difference from at least one of the attribute data, and add an identical attribute data at the position of the target attribute data to obtain twice the second amount of attribute data, and twice the second amount of attribute value data;相应地,所述预设图匹配模型根据所述至少一个属性数据的第一位置信息生成第一关系图,并根据所述至少一个属性值数据的第二位置信息生成第二关系图,包括:Correspondingly, the preset graph matching model generates a first relationship graph according to the first location information of the at least one attribute data, and generates a second relationship graph according to the second location information of the at least one attribute value data, including:根据所述两倍第二数量的属性数据对应的第一位置信息生成第一关系图;generating a first relationship diagram according to first position information corresponding to twice the second quantity of attribute data;根据所述两倍第二数量的属性值数据对应的第二位置信息生成第二关系图。A second relationship graph is generated according to the second position information corresponding to the twice the second quantity of attribute value data.
- 根据权利要求1-8任一项所述的方法,其特征在于,所述预设图匹 配模型通过以下步骤训练得到:The method according to any one of claims 1-8, wherein the preset image matching model is obtained through the following steps of training:获取模型训练样本数据,所述模型训练样本数据包括多个待检测图像样本,每个所述待检测图像样本中的每个属性数据的第一位置信息,所述待检测图像样本中的每个属性值数据的第二位置信息,以及每个所述待检测图像样本对应的第一关系图和第二关系图;Obtain model training sample data, the model training sample data includes a plurality of image samples to be detected, the first position information of each attribute data in each of the image samples to be detected, each of the image samples to be detected The second position information of the attribute value data, and the first relationship diagram and the second relationship diagram corresponding to each image sample to be detected;根据每个属性数据的第一位置信息通过预设网络初始模型从所述待检测图像样本中获取所述待检测图像样本的第一关系图中每个属性节点对应的第一特征和每条第一连接对应的第二特征,并根据每个属性值数据的第二位置信息通过所述预设网络初始模型从所述待检测图像样本中获取所述待检测图像样本的第二关系图中每个属性值节点对应的第三特征和每条第二连线对应的第四特征;According to the first position information of each attribute data, the first feature corresponding to each attribute node in the first relational graph of the image sample to be detected and each first feature corresponding to the first relationship graph of the image sample to be detected are obtained from the image sample to be detected through a preset network initial model. One connects the corresponding second feature, and according to the second position information of each attribute value data, obtains each in the second relationship diagram of the image sample to be detected from the image sample to be detected through the preset network initial model The third characteristic corresponding to the attribute value node and the fourth characteristic corresponding to each second connecting line;根据所述待检测图像样本的第一关系图中每个属性节点对应的第一特征和每条第一连接对应的第二特征,以及所述待检测图像样本的第二关系图中每个属性值节点对应的第三特征和每条第二连线对应的第四特征,通过预设损失函数计算每个属性节点与待匹配的属性值节点的距离向量对应的损失值,根据所述损失值对所述预设初始网络模型进行迭代训练,以得到所述预设图匹配模型。According to the first feature corresponding to each attribute node in the first relationship graph of the image sample to be detected and the second feature corresponding to each first connection, and each attribute in the second relationship graph of the image sample to be detected The third feature corresponding to the value node and the fourth feature corresponding to each second connection line, calculate the loss value corresponding to the distance vector between each attribute node and the attribute value node to be matched through the preset loss function, according to the loss value Iterative training is performed on the preset initial network model to obtain the preset graph matching model.
- 根据权利要求9所述的方法,其特征在于,所述根据所述待检测图像样本的第一关系图中每个属性节点对应的第一特征和每条第一连接对应的第二特征,以及所述待检测图像样本的第二关系图中每个属性值节点对应的第三特征和每条第二连线对应的第四特征,通过预设损失函数计算每个属性节点与待匹配的属性值节点的距离向量对应的损失值,包括:The method according to claim 9, characterized in that, according to the first feature corresponding to each attribute node in the first relationship graph of the image sample to be detected and the second feature corresponding to each first connection, and The third feature corresponding to each attribute value node in the second relationship graph of the image sample to be detected and the fourth feature corresponding to each second connection line, calculate the relationship between each attribute node and the attribute to be matched by using a preset loss function The loss value corresponding to the distance vector of the value node, including:根据每个所述属性节点对应的第一特征和每个所述属性值节点对应的第三特征确定节点相似度矩阵,并根据每条所述第一连线对应的第二特征和 每条所述第二连接对应的第四特征确定连线相似度矩阵;Determine the node similarity matrix according to the first feature corresponding to each attribute node and the third feature corresponding to each attribute value node, and determine the node similarity matrix according to the second feature corresponding to each of the first connections and each of the attribute value nodes The fourth feature corresponding to the second connection determines the connection similarity matrix;根据所述节点相似度矩阵和所述连线相似度矩阵生成目标关系矩阵;generating a target relationship matrix according to the node similarity matrix and the connection similarity matrix;获取所述目标关系矩阵对应的双随机矩阵;Obtain the double random matrix corresponding to the target relationship matrix;根据所述双随机矩阵确定每个属性节点与待匹配的属性值节点的距离向量;Determine the distance vector between each attribute node and the attribute value node to be matched according to the double random matrix;根据所述距离向量通过预设损失函数确定所述损失值。The loss value is determined through a preset loss function according to the distance vector.
- 一种键值匹配装置,其特征在于,所述装置包括:A key-value matching device, characterized in that the device comprises:第一获取模块,用于获取待检测图像中至少一个属性数据的第一位置信息和至少一个属性值数据的第二位置信息;A first acquiring module, configured to acquire first position information of at least one attribute data and second position information of at least one attribute value data in the image to be detected;关系图生成模块,用于根据所述至少一个属性数据的第一位置信息生成第一关系图,并根据所述至少一个属性值数据的第二位置信息生成第二关系图;A relationship graph generation module, configured to generate a first relationship graph according to the first position information of the at least one attribute data, and generate a second relationship graph according to the second position information of the at least one attribute value data;确定模块,用于将所述至少一个属性数据的第一位置信息,所述至少一个属性值数据的第二位置信息,所述第一关系图,所述第二关系图以及所述待检测图像输入预设图匹配模型,得到所述属性数据与所述属性值数据的匹配关系。A determination module, configured to use the first location information of the at least one attribute data, the second location information of the at least one attribute value data, the first relationship diagram, the second relationship diagram and the image to be detected A preset map matching model is input to obtain a matching relationship between the attribute data and the attribute value data.
- 一种计算机可读介质,其上存储有计算机程序,其特征在于,该程序被处理装置执行时实现权利要求1-10中任一项所述方法的步骤。A computer-readable medium, on which a computer program is stored, wherein the program implements the steps of any one of claims 1-10 when executed by a processing device.
- 一种电子设备,其特征在于,包括:An electronic device, characterized in that it comprises:存储装置,其上存储有计算机程序;a storage device on which a computer program is stored;处理装置,用于执行所述存储装置中的所述计算机程序,以实现权利要求1-10中任一项所述方法的步骤。A processing device configured to execute the computer program in the storage device to implement the steps of the method according to any one of claims 1-10.
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110915753.5 | 2021-08-10 | ||
CN202110915753.5A CN113590857A (en) | 2021-08-10 | 2021-08-10 | Key value matching method and device, readable medium and electronic equipment |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2023016111A1 true WO2023016111A1 (en) | 2023-02-16 |
Family
ID=78256943
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2022/101765 WO2023016111A1 (en) | 2021-08-10 | 2022-06-28 | Key value matching method and apparatus, and readable medium and electronic device |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN113590857A (en) |
WO (1) | WO2023016111A1 (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113590857A (en) * | 2021-08-10 | 2021-11-02 | 北京有竹居网络技术有限公司 | Key value matching method and device, readable medium and electronic equipment |
CN114153959A (en) * | 2021-12-08 | 2022-03-08 | 北京有竹居网络技术有限公司 | Key value matching method and device, readable medium and electronic equipment |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20200160050A1 (en) * | 2018-11-21 | 2020-05-21 | Amazon Technologies, Inc. | Layout-agnostic complex document processing system |
CN112036295A (en) * | 2020-08-28 | 2020-12-04 | 泰康保险集团股份有限公司 | Bill image processing method, bill image processing device, storage medium and electronic device |
CN112699234A (en) * | 2020-12-08 | 2021-04-23 | 上海深杳智能科技有限公司 | General document identification method, system, terminal and storage medium |
US20210192201A1 (en) * | 2019-12-23 | 2021-06-24 | Insurance Services Office, Inc. | Computer Vision Systems and Methods for Information Extraction from Text Images Using Evidence Grounding Techniques |
CN113590857A (en) * | 2021-08-10 | 2021-11-02 | 北京有竹居网络技术有限公司 | Key value matching method and device, readable medium and electronic equipment |
Family Cites Families (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108898186B (en) * | 2018-07-03 | 2020-03-06 | 北京字节跳动网络技术有限公司 | Method and device for extracting image |
CN109165572B (en) * | 2018-08-03 | 2022-02-08 | 百度在线网络技术(北京)有限公司 | Method and apparatus for generating information |
CN111325226B (en) * | 2018-12-14 | 2024-03-08 | 北京京东尚科信息技术有限公司 | Information presentation method and device |
CN110837861B (en) * | 2019-11-06 | 2022-11-29 | 亮风台(上海)信息科技有限公司 | Image matching method, device, equipment and storage medium |
CN111325141B (en) * | 2020-02-18 | 2024-03-26 | 上海商汤临港智能科技有限公司 | Interactive relationship identification method, device, equipment and storage medium |
CN111914729A (en) * | 2020-07-28 | 2020-11-10 | 中国建设银行股份有限公司 | Voucher association method and device, computer equipment and storage medium |
CN112287144B (en) * | 2020-10-29 | 2022-07-05 | 苏州科达科技股份有限公司 | Picture retrieval method, equipment and storage medium |
-
2021
- 2021-08-10 CN CN202110915753.5A patent/CN113590857A/en active Pending
-
2022
- 2022-06-28 WO PCT/CN2022/101765 patent/WO2023016111A1/en unknown
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20200160050A1 (en) * | 2018-11-21 | 2020-05-21 | Amazon Technologies, Inc. | Layout-agnostic complex document processing system |
US20210192201A1 (en) * | 2019-12-23 | 2021-06-24 | Insurance Services Office, Inc. | Computer Vision Systems and Methods for Information Extraction from Text Images Using Evidence Grounding Techniques |
CN112036295A (en) * | 2020-08-28 | 2020-12-04 | 泰康保险集团股份有限公司 | Bill image processing method, bill image processing device, storage medium and electronic device |
CN112699234A (en) * | 2020-12-08 | 2021-04-23 | 上海深杳智能科技有限公司 | General document identification method, system, terminal and storage medium |
CN113590857A (en) * | 2021-08-10 | 2021-11-02 | 北京有竹居网络技术有限公司 | Key value matching method and device, readable medium and electronic equipment |
Non-Patent Citations (2)
Title |
---|
CHENG, MENGLI ET AL.: "One-shot Text Field Labeling using Attention and Belief Propagation for Structure Information Extraction", MM '20: PROCEEDINGS OF THE 28TH ACM INTERNATIONAL CONFERENCE ON MULTIMEDIA, 12 October 2020 (2020-10-12), pages 340 - 348, XP058731004, DOI: 10.1145/3394171.3413511 * |
TANG GUOZHI, XIE LELE, JIN LIANWEN, WANG JIAPENG, CHEN JINGDONG, XU ZHEN, WANG QIANYING, WU YAQIANG, LI HUI: "MatchVIE: Exploiting Match Relevancy between Entities for Visual Information Extraction", 24 June 2021 (2021-06-24), XP055834607, Retrieved from the Internet <URL:https://arxiv.org/pdf/2106.12940.pdf> [retrieved on 20210824] * |
Also Published As
Publication number | Publication date |
---|---|
CN113590857A (en) | 2021-11-02 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2023016111A1 (en) | Key value matching method and apparatus, and readable medium and electronic device | |
WO2022213879A1 (en) | Target object detection method and apparatus, and computer device and storage medium | |
US20190130603A1 (en) | Deep-learning based feature mining for 2.5d sensing image search | |
WO2023103653A1 (en) | Key-value matching method and apparatus, readable medium, and electronic device | |
WO2022033111A1 (en) | Image information extraction method, training method and apparatus, medium, and electronic device | |
WO2022012179A1 (en) | Method and apparatus for generating feature extraction network, and device and computer-readable medium | |
CN111144124B (en) | Training method of machine learning model, intention recognition method, and related device and equipment | |
CN113434716B (en) | Cross-modal information retrieval method and device | |
WO2023077995A1 (en) | Information extraction method and apparatus, and device, medium and product | |
WO2022247562A1 (en) | Multi-modal data retrieval method and apparatus, and medium and electronic device | |
WO2023280106A1 (en) | Information acquisition method and apparatus, device, and medium | |
WO2023005386A1 (en) | Model training method and apparatus | |
CN112883966B (en) | Image character recognition method, device, medium and electronic equipment | |
CN112766284B (en) | Image recognition method and device, storage medium and electronic equipment | |
WO2023103887A1 (en) | Image segmentation label generation method and apparatus, and electronic device and storage medium | |
CN115238582A (en) | Reliability evaluation method, system, equipment and medium for knowledge graph triples | |
CN114494709A (en) | Feature extraction model generation method, image feature extraction method and device | |
CN113610034B (en) | Method and device for identifying character entities in video, storage medium and electronic equipment | |
JP2022541832A (en) | Method and apparatus for retrieving images | |
CN113191257B (en) | Order of strokes detection method and device and electronic equipment | |
WO2022012178A1 (en) | Method for generating objective function, apparatus, electronic device and computer readable medium | |
WO2022028253A1 (en) | Positioning model optimization method, positioning method, positioning device, and storage medium | |
CN110414450A (en) | Keyword detection method, apparatus, storage medium and electronic equipment | |
WO2023130925A1 (en) | Font recognition method and apparatus, readable medium, and electronic device | |
WO2023226819A1 (en) | Data matching method and apparatus, readable medium, and electronic device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 22855096 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |