Table universal recognition method and apparatus, device, and medium
By obtaining the gap information and sampling position of the table, extracting sub-feature maps, and using the Transformer network to identify the table structure, it solves the problem of dependence on table lines and intersections in the existing technology, achieves accurate identification of wired and wireless tables, and improves The universality of recognition.
Patent Information
- Application Number
- PCT/CN2023/125907
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-03-06
- Filing Date
- 2023-10-23
- Publication Date
- 2024-09-12
AI Technical Summary
Existing table recognition algorithms rely too much on table lines and intersection information, and cannot accurately identify table structures in discontinuous table lines, different color separations, or wireless table scenarios.
By obtaining the horizontal and vertical gap information of the table, the sampling position is determined, the sub-feature map is extracted, the Transformer network is used to predict the coordinate values, and the dividing lines are merged to identify the table structure, reducing the dependence on table lines and intersections.
In the case of incomplete table line or intersection information, the table structure can be accurately identified. It is suitable for wired and wireless tables, improving the versatility and accuracy of identification.
Smart Images

Figure CN2023125907_12092024_PF_FP_ABST
Abstract
Description
Universal table recognition method, device, equipment and medium
[0001] This application is based on the Chinese invention patent application with application number "202310203359.8" filed on March 6, 2023, and named "Universal Form Identification Method, Device, Equipment and Medium", and claims its priority. Technical Field
[0002] The present application relates to the field of artificial intelligence technology, and in particular to a universal table recognition method, device, equipment and medium. Background Art
[0003] The current mainstream table recognition algorithms are mainly based on two ideas: table line segmentation and key point detection.
[0004] Table line segmentation mainly uses convolutional networks to extract the image features of horizontal and vertical lines, and then calculates the intersection of horizontal and vertical lines through post-processing to obtain the position and coordinate values of each cell in the table.
[0005] The key point detection method calculates the cell coordinates by detecting the positions of the vertices and center points of the cells in the table, and then restores the structure of the table. Compared with table line segmentation, this method is less dependent on table image information and only requires information about the intersection points of the horizontal and vertical lines of the table and the center positions of the cells.
[0006] The inventors discovered that the disadvantage of table line segmentation is its over-reliance on table line information. This method cannot accurately identify the table structure when the table lines are discontinuous due to poor printing, or when cells are separated by different colors rather than lines. Key point detection can address the limitations of table line segmentation to some extent, but it also fails to produce accurate results in scenarios where the image features at the intersection are unclear, the cell area is too large, there are too many empty cells without text, and there are no lines in the table.
[0007] It can be seen that the problem with the above two methods is that they are overly limited to focusing on local image information in the table. When the table lines or intersections are incomplete or even non-existent, they cannot accurately recognize the table.
[0008] Summary of the Invention
[0009] Based on this, it is necessary to provide a universal table recognition method, device, equipment and medium for accurately identifying tables in response to the above technical problems.
[0010] In a first aspect, a universal table recognition method is provided, comprising:
[0011] Get the horizontal gap information and vertical gap information of the table;
[0012] Determine a longitudinal sampling position of the transverse gap information according to the longitudinal gap information, and determine a transverse sampling position of the longitudinal gap information according to the transverse gap information;
[0013] Extracting the entire column information of the horizontal gap information according to the vertical sampling position to obtain a vertical sub-feature map, and extracting the entire row information of the vertical gap information according to the horizontal sampling position to obtain a horizontal sub-feature map;
[0014] According to the horizontal sub-feature graph and the vertical sub-feature graph, the table structure of the table is identified.
[0015] Optionally, determining a longitudinal sampling position of the transverse gap information according to the longitudinal gap information includes:
[0016] Determining a preset reference number of longitudinal reference point positions from the transverse gap information according to the longitudinal gap information;
[0017] The preset reference number of longitudinal reference point positions are used as longitudinal sampling positions.
[0018] Optionally, determining a preset reference number of longitudinal reference point positions from the transverse gap information according to the longitudinal gap information includes:
[0019] Obtaining a horizontal vector through the horizontal gap information, wherein the horizontal vector includes the coordinate value of each position point of the table in the horizontal direction;
[0020] Suppressing the position points whose coordinate values of adjacent position points in the horizontal vector are less than a preset distance, so as to retain the position points with larger coordinate values among the adjacent position points;
[0021] From the suppressed horizontal vector, a preset reference number of position points are selected as the longitudinal reference point positions.
[0022] Optionally, determining a preset reference number of longitudinal reference point positions from the transverse gap information includes:
[0023] A preset reference number of longitudinal reference point positions are determined equidistantly from the transverse gap information.
[0024] Optionally, identifying a table structure of the table according to the horizontal sub-feature graph and the vertical sub-feature graph includes:
[0025] Selecting a preset number of sampling points from each column of the longitudinal sub-feature graph as first sampling points, and selecting a preset number of sampling points from each row of the horizontal sub-feature graph as second sampling points;
[0026] Predicting the coordinate value of each first sampling point using a first transformer network, and predicting the coordinate value of each second sampling point using a second transformer network;
[0027] Aggregate the coordinate values of all first sampling points corresponding to each column to obtain a vertical dividing line, and aggregate the coordinate values of all second sampling points corresponding to each row to obtain a horizontal dividing line;
[0028] Identify the table structure based on the horizontal and vertical dividing lines.
[0029] Optionally, identifying the table structure of the table based on the horizontal dividing lines and the vertical dividing lines includes:
[0030] Merge the horizontal and vertical dividing lines to obtain the initial cell area of the table;
[0031] Scale the coordinates of the initial cell area of the table so that the scaled initial cell area has the same size as the original feature map of the table;
[0032] According to the coordinate values of the scaled initial cell area, the original feature map is segmented to obtain multiple segmented feature map blocks;
[0033] Fuse the text features of the table with the corresponding segmentation feature blocks to obtain fused features;
[0034] Each fused feature is input into the graph neural network to obtain the table structure of the table.
[0035] Optionally, obtaining horizontal gap information and vertical gap information of the table includes:
[0036] Get the table image of the table;
[0037] The image information of the table image is extracted through the pre-trained object detection network to obtain the original feature map;
[0038] The original feature map is input into the horizontal feature extraction module and the vertical feature extraction module respectively to obtain the horizontal gap information and the vertical gap information of the table.
[0039] In a second aspect, a universal table recognition device is provided, comprising:
[0040] An acquisition module, used to obtain horizontal gap information and vertical gap information of a table;
[0041] a determination module, configured to determine a longitudinal sampling position based on the transverse gap information and to determine a transverse sampling position based on the longitudinal gap information;
[0042] An extraction module is used to extract the entire column information of the horizontal gap information according to the longitudinal sampling position to obtain a longitudinal sub-feature map, and to extract the entire row information of the longitudinal gap information according to the transverse sampling position to obtain a transverse sub-feature map;
[0043] The recognition module is used to recognize the table structure of the table according to the horizontal sub-feature map and the vertical sub-feature map.
[0044] In a third aspect, a computer device is provided, comprising a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, wherein the processor executes the computer-readable instructions to implement the following steps:
[0045] Get the horizontal gap information and vertical gap information of the table;
[0046] Determining a longitudinal sampling position of the transverse gap information according to the longitudinal gap information, and determining a transverse sampling position of the longitudinal gap information according to the transverse gap information;
[0047] Extracting the entire column information of the horizontal gap information according to the vertical sampling position to obtain a vertical sub-feature map, and extracting the entire row information of the vertical gap information according to the horizontal sampling position to obtain a horizontal sub-feature map;
[0048] A table structure of the table is identified according to the horizontal sub-feature graph and the vertical sub-feature graph.
[0049] Optionally, when the processor executes the computer-readable instructions, it specifically implements the following steps:
[0050] determining a preset reference number of longitudinal reference point positions from the transverse gap information according to the longitudinal gap information;
[0051] The preset reference number of longitudinal reference point positions are used as the longitudinal sampling positions.
[0052] Optionally, when the processor executes the computer-readable instructions, it specifically implements the following steps:
[0053] Obtaining a transverse vector using the transverse gap information, wherein the transverse vector includes a coordinate value of each position point of the table in the transverse direction;
[0054] Suppressing position points in the horizontal vector whose coordinate values of adjacent position points are less than a preset distance, so as to retain position points with larger coordinate values among the adjacent position points;
[0055] A preset reference number of position points are screened out from the horizontal vector that has undergone the suppression process as longitudinal reference point positions.
[0056] Optionally, when the processor executes the computer-readable instructions, it specifically implements the following steps:
[0057] A preset reference number of longitudinal reference point positions are determined equidistantly from the transverse gap information.
[0058] Optionally, when the processor executes the computer-readable instructions, it specifically implements the following steps:
[0059] Selecting a preset number of sampling points from each column of the longitudinal sub-feature graph as first sampling points, and selecting a preset number of sampling points from each row of the horizontal sub-feature graph as second sampling points;
[0060] Predicting the coordinate value of each of the first sampling points using a first transformer network, and predicting the coordinate value of each of the second sampling points using a second transformer network;
[0061] Aggregating the coordinate values of all the first sampling points corresponding to each column to obtain a longitudinal dividing line, and aggregating the coordinate values of all the second sampling points corresponding to each row to obtain a transverse dividing line;
[0062] The table structure of the table is identified according to the horizontal dividing line and the vertical dividing line.
[0063] Optionally, when the processor executes the computer-readable instructions, it specifically implements the following steps:
[0064] Merging the horizontal dividing line and the vertical dividing line to obtain an initial cell area of the table;
[0065] Scaling the coordinates of the initial cell area of the table so that the scaled initial cell area has the same size as the original feature map of the table;
[0066] Segmenting the original feature map according to the coordinate values of the scaled initial cell area to obtain a plurality of segmented feature map blocks;
[0067] Fusing the text features of the table with the corresponding segmented feature blocks to obtain fused features;
[0068] Each of the fused features is input into a graph neural network to obtain a table structure of the table.
[0069] In a fourth aspect, a readable storage medium storing computer-readable instructions is provided, wherein when the computer-readable instructions are executed by one or more processors, the one or more processors are caused to perform the following steps:
[0070] Get the horizontal gap information and vertical gap information of the table;
[0071] Determining a longitudinal sampling position of the transverse gap information according to the longitudinal gap information, and determining a transverse sampling position of the longitudinal gap information according to the transverse gap information;
[0072] Extracting the entire column information of the horizontal gap information according to the vertical sampling position to obtain a vertical sub-feature map, and extracting the entire row information of the vertical gap information according to the horizontal sampling position to obtain a horizontal sub-feature map;
[0073] A table structure of the table is identified according to the horizontal sub-feature graph and the vertical sub-feature graph.
[0074] Optionally, when the computer-readable instructions are executed by one or more processors, the one or more processors are caused to specifically perform the following steps:
[0075] determining a preset reference number of longitudinal reference point positions from the transverse gap information according to the longitudinal gap information;
[0076] The preset reference number of longitudinal reference point positions are used as the longitudinal sampling positions.
[0077] Optionally, when the computer-readable instructions are executed by one or more processors, the one or more processors are caused to specifically perform the following steps:
[0078] Obtaining a transverse vector using the transverse gap information, wherein the transverse vector includes a coordinate value of each position point of the table in the transverse direction;
[0079] Suppressing position points in the horizontal vector whose coordinate values of adjacent position points are less than a preset distance, so as to retain position points with larger coordinate values among the adjacent position points;
[0080] A preset reference number of position points are screened out from the horizontal vector that has undergone the suppression process as longitudinal reference point positions.
[0081] Optionally, when the computer-readable instructions are executed by one or more processors, the one or more processors are caused to specifically perform the following steps:
[0082] A preset reference number of longitudinal reference point positions are determined equidistantly from the transverse gap information.
[0083] Optionally, when the computer-readable instructions are executed by one or more processors, the one or more processors are caused to specifically perform the following steps:
[0084] Selecting a preset number of sampling points from each column of the longitudinal sub-feature graph as first sampling points, and selecting a preset number of sampling points from each row of the horizontal sub-feature graph as second sampling points;
[0085] Predicting the coordinate value of each of the first sampling points using a first transformer network, and predicting the coordinate value of each of the second sampling points using a second transformer network;
[0086] Aggregating the coordinate values of all the first sampling points corresponding to each column to obtain a longitudinal dividing line, and aggregating the coordinate values of all the second sampling points corresponding to each row to obtain a transverse dividing line;
[0087] The table structure of the table is identified according to the horizontal dividing line and the vertical dividing line.
[0088] Optionally, when the computer-readable instructions are executed by one or more processors, the one or more processors are caused to specifically perform the following steps:
[0089] Merging the horizontal dividing line and the vertical dividing line to obtain an initial cell area of the table;
[0090] Scaling the coordinates of the initial cell area of the table so that the scaled initial cell area has the same size as the original feature map of the table;
[0091] Segmenting the original feature map according to the coordinate values of the scaled initial cell area to obtain a plurality of segmented feature map blocks;
[0092] Fusing the text features of the table with the corresponding segmented feature blocks to obtain fused features;
[0093] Each of the fused features is input into a graph neural network to obtain a table structure of the table.
[0094] In one of the solutions provided above, since the global layout features, that is, the gap features, are extracted by extracting the image information features in the table picture, the dependence on the table lines or intersections is very low. When such information is incomplete or even does not exist, correct structural recognition can still be performed. It can also be applied to the recognition of wireless tables. It is a universal method that can perform structural recognition on both wired and wireless tables at the same time. It has high versatility and greater application value.
[0095] The details of one or more embodiments of the disclosure are set forth in the accompanying drawings and the description below, and other features and advantages of the disclosure will be apparent from the description, the drawings, and the claims. BRIEF DESCRIPTION OF THE DRAWINGS
[0096] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0097] FIG1 is a flow chart of a general table recognition method according to an embodiment of the present application;
[0098] FIG2 is a schematic diagram of a processing process of a general table recognition method according to an embodiment of the present application;
[0099] FIG3 is a schematic diagram of a process for extracting sub-feature graphs in an embodiment of the present application;
[0100] FIG4 is a schematic structural diagram of a universal table recognition device according to an embodiment of the present application;
[0101] FIG5 is a schematic structural diagram of a computer device in an embodiment of the present application. DETAILED DESCRIPTION
[0102] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0103] The embodiments of the present application provide a universal table recognition method, apparatus, device, and storage medium that are less dependent on table lines or intersections, and can still correctly recognize the structure even when such information is incomplete or even non-existent. The method is also applicable to the recognition of an unlimited number of tables, that is, it can recognize both wireless and wired tables, thereby improving the versatility of table recognition. The universal table recognition method provided by the present application is described below.
[0104] In one embodiment, as shown in FIG1 , a universal table recognition method is provided, and the method includes the following steps:
[0105] S10: Acquire horizontal gap information and vertical gap information of the table.
[0106] In traditional solutions, the disadvantage of table line segmentation is that it relies too much on the information of table lines. When the table lines are discontinuous due to unclear printing, or different colors rather than table lines are used to separate cells, this method cannot accurately identify the table structure. Key point detection can solve the limitations of the table line segmentation method to a certain extent, but in scenarios where the image features at the intersection are not obvious, the cell area is too large, there are too many empty cells without text, and there are no wireless tables, the key point detection method is also unable to achieve or obtain accurate results. In this embodiment, in order to solve the problems existing in the above method, after obtaining the table image of the table to be identified, the table image will be recognized first to obtain the image information of the table, and the original feature map S of the table will be obtained through the image information, and then the horizontal gap information R and the vertical gap information C will be identified using the original feature map.
[0107] It should be noted that the horizontal gap information R and vertical gap information C of the table represent the horizontal and vertical characteristics of the table in the horizontal and vertical directions, respectively. For example, if the table is a wired table, then the horizontal gap information R may include the identified horizontal line position information and / or horizontal gap position information, and the vertical gap information C may include the identified vertical line position information and / or vertical gap position information; if the table is a wireless table, then the horizontal gap information R may include the identified horizontal gap position information, and the vertical gap information C may include the identified vertical gap position information. In other words, regardless of whether the identified table is a wireless or wired table, the features reflecting the horizontal and vertical characteristics of the table can be identified. It is also worth noting that this approach is different from the method of identifying intersection coordinates or table lines. It only identifies the horizontal gap information R and vertical gap information C of the table as a whole, and does not directly rely on the intersection coordinates or table lines.
[0108] S20: Determine a longitudinal sampling position of the transverse gap information according to the longitudinal gap information, and determine a transverse sampling position of the longitudinal gap information according to the transverse gap information.
[0109] S30: extracting the entire column information of the horizontal gap information according to the vertical sampling position to obtain a vertical sub-feature map, and extracting the entire row information of the vertical gap information according to the horizontal sampling position to obtain a horizontal sub-feature map.
[0110] S40: Identify the table structure of the table according to the horizontal sub-feature graph and the vertical sub-feature graph.
[0111] After determining the horizontal gap information R and the longitudinal gap information C in the table, the longitudinal sampling position of the horizontal gap information R can be determined according to the longitudinal gap information C, and the transverse sampling position of the longitudinal gap information C can be determined according to the horizontal gap information R. Finally, sampling is performed based on the two sampling positions to obtain the longitudinal sub-feature map C` and the transverse sub-feature map R`.
[0112] It can be understood that if there are table lines in the table, then the place where the longitudinal gap is most obvious is likely to correspond to the original table diagram where there is horizontal line information. If there are no table lines in the table, then the place where the longitudinal gap is most obvious is likely to correspond to the original table diagram where there is horizontal line information. Similarly, if there are table lines in the table, then the place where the transverse gap is most obvious is likely to correspond to the original table diagram where there is vertical line information. If there are no table lines in the table, then the place where the transverse gap is most obvious is likely to correspond to the original table diagram where there is vertical line information. Based on this feature, in an embodiment of the present application, the longitudinal sampling position of the transverse gap information R is determined according to the longitudinal gap information C, and the transverse sampling position of the longitudinal gap information C is determined according to the transverse gap information R. Finally, based on these two different sampling positions, the longitudinal sub-feature map R' and the transverse sub-feature map C' can be obtained.
[0113] It can be seen that the vertical sub-feature map R' reflects the column information of the table, while the horizontal sub-feature map C' reflects the row information of the table. Therefore, the cell area of the table can be identified based on the vertical sub-feature map R' and the horizontal sub-feature map C' to obtain the table structure.
[0114] It can be seen that in this embodiment, a general table recognition method is provided, which first obtains the horizontal gap information R and the vertical gap information C of the table; determines the vertical sampling position / horizontal sampling position according to the vertical gap information C / horizontal gap information R, respectively, extracts the vertical sub-feature map R' according to the vertical sampling position, and extracts the horizontal sub-feature map C' according to the horizontal sampling position; finally, identifies the table structure according to the horizontal sub-feature map C' and the vertical sub-feature map R'. Since the embodiment of the present application utilizes the image information features extracted from the table picture to extract the global typesetting features, that is, the gap features, the degree of dependence on the table lines or intersections is very low, and correct structural recognition can still be performed when such information is incomplete or even non-existent. It can also be applied to the recognition of wireless tables. It is a general method that can perform structural recognition on both wired and wireless tables at the same time. It has high versatility and greater application value.
[0115] It should be noted that, in conjunction with the above embodiment, in step S20, that is, determining the longitudinal sampling position of the transverse gap information based on the longitudinal gap information, and determining the transverse sampling position of the longitudinal gap information based on the transverse gap information, the reference point position can be arbitrarily or selectively selected based on the coordinate value of the gap information, and the specific process is not limited. The following takes the process of determining the longitudinal sampling position as an example to describe the detailed process.
[0116] To facilitate understanding of the above processing process, the complete implementation process is described in detail below in conjunction with Figures 2 and 3, the following other embodiments and the above embodiment.
[0117] In one embodiment, step S10, i.e., obtaining the horizontal gap information and the vertical gap information of the table, includes:
[0118] S11: Acquire a table image of a table;
[0119] S12: Extract image information of the table image through the pre-trained object detection network to obtain the original feature map;
[0120] S13: Inputting the original feature map into the horizontal feature extraction module and the vertical feature extraction module respectively to obtain the horizontal gap information and the vertical gap information of the table.
[0121] As shown in Figure 2, in this embodiment, it is necessary to first obtain the table image corresponding to the identified table, and then extract the image information of the table image through the pre-trained target detection network to obtain the original feature map. Exemplarily, in one embodiment, as shown in Figure 2, the image information of the table image can be extracted through the ResNet-18 backbone network and the Feature Pyramid Networks (FPN) layer to obtain the original feature map S with a size of W×H. It should be noted that in addition to the ResNet-18 backbone network and the FPN layer to extract the original feature map, other feature extraction modules can also be used, such as using other backbone networks and / or feature layers, etc., which are not limited in the embodiments of the present application. Then, the original feature map S is respectively input into the horizontal feature extraction module and the vertical feature extraction module, so as to obtain the horizontal gap information and vertical gap information of the table, respectively, wherein the horizontal feature extraction module and the vertical feature extraction module can be implemented by a convolutional network.
[0122] In this embodiment, a specific processing method for extracting horizontal gap information and vertical gap information is provided. While improving the feasibility of the solution, the process of extracting the original feature map by the ResNet-18 backbone network and the FPN layer maintains the original image size and does not compress the original image. The traditional solution compresses the feature map when predicting on the feature map of the table image and restores the predicted result to the original size of the map. This process will cause a loss in coordinate accuracy, so that the predicted table structure deviates slightly from the actual structure. The prediction of the table structure in the present invention is performed on the original image size, so the recognition result will be more accurate.
[0123] In one embodiment, step S20, i.e., determining the longitudinal sampling position of the transverse gap information according to the longitudinal gap information, includes:
[0124] S21: Determine a preset reference number of longitudinal reference point positions from the transverse gap information according to the longitudinal gap information.
[0125] S22: Using a preset reference number of longitudinal reference point positions as longitudinal sampling positions.
[0126] In this embodiment, based on the longitudinal gap information C, a preset reference number of longitudinal reference point positions are determined from the transverse gap information R as longitudinal sampling positions, wherein the preset reference number is an empirical value. Exemplarily, the preset reference number can be 8, 10, 15, etc., and is not specifically limited.
[0127] As can be seen, in this embodiment, extracting the entire column of horizontal gap information using the determined vertical sampling position as the reference point can greatly improve processing efficiency by maximizing the amount of data required to process the vertical sub-feature map in the next step. Specifically, this process determines which columns need to be extracted to form a small feature map that best reflects the column information in the table. This information can then be used to predict the correct result.
[0128] Similarly, in one embodiment, step S20, i.e., determining the horizontal sampling position of the vertical gap information according to the horizontal gap information, includes:
[0129] S23: Determine a preset reference number of transverse reference point positions from the longitudinal gap information according to the transverse gap information.
[0130] S24: Using a preset reference number of horizontal reference point positions as horizontal sampling positions.
[0131] It can be understood that the processing process and details of steps S22 to S24 correspond to the aforementioned steps S21 to S22, wherein, in this embodiment, based on the horizontal gap information R, a preset reference number of horizontal reference point positions is determined from the longitudinal gap information C as the horizontal sampling position, wherein the preset reference number is an empirical value, and illustratively, the preset reference number can be 8, 10, 15, etc., and is not specifically limited. Exemplarily, both the horizontal / vertical reference point positions can be 10, that is, 10 sampling position reference points are included respectively. It can be seen that in this embodiment, the entire row information of the longitudinal gap information is extracted according to the determined horizontal sampling position as the reference point position, which can greatly improve the processing efficiency for the next step of processing the amount of processing data for the horizontal sub-feature map. That is: in this process, which rows need to be taken out to form a small feature map that best reflects the row information in the table, and the correct result can be predicted later through this information.
[0132] It should be noted that, in combination with the above embodiments, in step S21 or step S22, that is, the process of determining the longitudinal reference point position and determining the transverse reference point position, the embodiments of the present application respectively provide two different processing methods with corresponding characteristics. Here, taking the determination of the longitudinal reference point position as an example, these two different methods are described in detail.
[0133] The first method
[0134] Determining a preset reference number of longitudinal reference point positions from the transverse gap information according to the longitudinal gap information includes:
[0135] S211: Sum the horizontal gap information along the width direction of the table to obtain a horizontal vector, wherein the horizontal vector includes the coordinate value of each position point of the table in the horizontal direction;
[0136] S212: suppressing the position points in the horizontal vector whose coordinate values of the adjacent position points are less than a preset distance, so as to retain the position points with larger coordinate values among the adjacent position points.
[0137] S213: Filtering a preset reference number of position points from the suppressed horizontal vector as longitudinal reference point positions.
[0138] This embodiment is the first method of determining the position of the longitudinal reference point. In this embodiment, as shown in Figures 2 and 3, the transverse gap information must first be summed along the width direction of the table to obtain a transverse vector, wherein the transverse vector includes the coordinate value of each position point in the table in the transverse direction. Position points whose coordinate values of adjacent position points are less than a preset distance in the transverse vector are suppressed to retain the position points with larger coordinate values among the adjacent position points. The preset distance is an empirical value and is not specifically limited. From the suppressed transverse vector, a preset reference number of position points are screened out as the longitudinal reference point positions. For example, in Figure 3, the position points with the 10 maximum values are screened out as the reference points of R, and the entire column where the 10 reference point positions are located in R is taken out, and finally a longitudinal sub-feature map R` with a size of 10×H is obtained.
[0139] Similarly, the process of determining the position of the horizontal reference point is similar to the process of determining the position of the vertical reference point, that is, the vertical gap information must first be summed along the height direction of the table to obtain a vertical vector, wherein the vertical vector includes the coordinate value of each position point in the table in the vertical direction. The position points whose coordinate values of adjacent position points are less than the preset distance in the vertical vector are suppressed to retain the position points with larger coordinate values among the adjacent position points. Similarly, the preset distance is an empirical value and is not specifically limited. From the suppressed vertical vector, a preset reference number of position points are selected as the horizontal reference point positions. For example, in Figure 3, the position points with the 10 maximum values are selected as the reference points of C, and the entire row of the 10 reference point positions in C is taken out, and finally a horizontal sub-feature map C` with a size of W×10 is obtained.
[0140] It should be noted that this step primarily prepares the next processing network (such as the Transformer in Figure 3) for extracting sub-feature maps. Since the Transformer is computationally intensive, the input data needs to be filtered to reduce computational complexity. Specifically, the rows and columns of the original feature map S need to be extracted to form a small feature map that best reflects the row and column information in the table. The Transformer can predict the correct result based solely on this information. As shown in Figure 3, if the table contains lines, then the areas where the vertical line features are most pronounced (the white columnar features in the lower left image of Figure 3) are likely to correspond to horizontal lines in the original table. Therefore, using this as a reference, useful information can be more accurately extracted from the row feature map (upper left image of Figure 3) (the small feature map formed by combining the vertical dashed line in the upper left image of Figure 3 and the upper right image of Figure 3, i.e., the vertical sub-feature map). The processing of the horizontal sub-feature maps is similar. This process aims to achieve more accurate sampling and subsequently reduce the processing load of the Transformer.
[0141] Second method
[0142] It is worth emphasizing that the purpose of this reference point is to sample more accurately. In fact, it is also possible to take 10 columns / rows at equal intervals from the horizontal / vertical gap information. The positions of the vertical reference points of a preset reference number can be determined at equal intervals from the horizontal gap information, and the positions of the horizontal reference points of a preset reference number can be determined at equal intervals from the vertical gap information. There is no specific limitation.
[0143] For example, a wireless table does not have table line features. That is to say, in other implementations, it is actually possible to take 10 columns / rows at equal intervals in the row or column feature map (for example, a wireless table does not have table line features), the only difference is the accuracy. The purpose of taking 10 reference points is that during the inference process, the Transformer will only make predictions at these positions. For example, for the 10×H sub-feature map in the upper left corner of Figure 3, the Transformer will predict 100 values on each column (which becomes K after processing), and finally obtain K broken lines, each of which consists of 10 points (i.e., dividing lines), which are used to adapt to the deformation and missing of the table image, and improve applicability.
[0144] In one embodiment, in step S40, identifying the table structure of the table based on the horizontal sub-feature graph and the vertical sub-feature graph includes:
[0145] S41: selecting a preset number of sampling points from each column of the longitudinal sub-feature graph as first sampling points, and selecting a preset number of sampling points from each row of the horizontal sub-feature graph as second sampling points;
[0146] S42: using a first transformer network to predict the coordinate value of each first sampling point, and using a second transformer network to predict the coordinate value of each second sampling point;
[0147] S43: Aggregating the coordinate values of all first sampling points corresponding to each column to obtain a vertical dividing line, and aggregating the coordinate values of all second sampling points corresponding to each row to obtain a horizontal dividing line;
[0148] S44: Identify the table structure of the table according to the horizontal dividing line and the vertical dividing line.
[0149] In this embodiment, the processing of horizontal and vertical dividing lines is performed by first predicting the coordinate value of each determined sampling point using two transformer networks, and then aggregating the coordinate values of the sampling points to obtain the corresponding coordinate dividing lines.
[0150] For the horizontal dividing lines, a preset number of sampling points are first selected from each column of the vertical sub-feature map R'. For example, 100 equally spaced first sampling points are selected from each column of the vertical sub-feature map R'. The first transformer network (transformer1) then predicts the coordinates of each first sampling point in each column to obtain all the horizontal dividing lines. The number 100 is merely illustrative and does not limit the present invention.
[0151] Similarly, for the vertical dividing lines, a preset number of sampling points are first selected from each row of the horizontal sub-feature map C' as second sampling points. For example, 100 second sampling points are selected at equal intervals from each row of the horizontal sub-feature map C'. Then, the second transformer network (transformer2) is used to predict the coordinates of each second sampling point in each row, thereby obtaining all the vertical dividing lines. The number 100 is merely an example and does not limit the present embodiment.
[0152] That is, during inference, the Transformer network only makes predictions for the rows and columns identified by these sub-feature maps. For example, for the 10×H vertical sub-feature map in the upper left corner of Figure 3, the Transformer predicts 100 values for each column, which are then processed into K values, ultimately resulting in K polylines, each consisting of 10 points (i.e., separators).
[0153] It should be noted that when the Transformer network predicts coordinate values, the two sub-feature maps serve as the key and value parts in the encoder of the two Transformer networks, respectively. Then, 100 sampling points are selected at equal intervals in each column / row of the vertical sub-feature map R' and the horizontal sub-feature map C' as the query in the Transformer network decoder. The query is sent to the decoder, and a linear layer is connected to the output layer of the decoder to predict the coordinate value corresponding to each sampling point. For ease of understanding, combined with Figure 3, taking row prediction as an example (the upper half of Figure 2), assume that the number of channels of the original feature map S is D. Then the size of the vertical sub-feature map R' is 10×H×D, which is the key and value. After taking out the 100 first sampling points and splicing them together, a 100×D matrix can be obtained, which is the query. The process for predicting the coordinates of the first sampling point is as follows: Combine the first two dimensions of Key and Value into a single dimension (10*H×D). Perform matrix multiplication between Query and Key to obtain a matrix of size (100×10*H). This matrix is then multiplied with Value to obtain a result of size (100×D). The result is then passed through a linear layer. Repeat these steps three times, and the final result is passed through a linear layer to predict the y-coordinate value of each of the 100 points. Aggregate the coordinate results of the 100 points, merge adjacent coordinates into a single point, and finally obtain the horizontal separator, i.e., the horizontal separator. Similarly, the corresponding vertical separator can be obtained.
[0154] It should be noted that the above 100 sampling points are only for illustrative purposes and do not limit the embodiments of the present application.
[0155] It can be seen that in this embodiment, the coordinate values of the sampling points in the sub-feature map are predicted by two Transformer networks, and the position of the dividing line is obtained by aggregation, which effectively identifies the position of the dividing line and improves the accuracy of the table cell area.
[0156] It is also worth noting that, in one embodiment, the present invention requires that the two Transformer networks be trained first so that the loss between the output separation line and the predicted separation line meets the requirements before it can be applied to separation line recognition. During the training process, after respectively calculating the predicted horizontal and vertical separation lines, the loss between the horizontal and vertical separation lines and the preset label values can be determined, i.e., L horizontal 、L vertical For example, Smooth L1Loss can be used for calculation as follows:
[0157] Among them, f(xi) is the predicted value and yi is the true value;
[0158] For example, when making row predictions, the 10 red dotted lines (10 reference points) in the upper left corner of Figure 3 correspond to the horizontal coordinate position (x) of the original image. Transformer predicts several y values on this column. After post-processing, the coordinates (xi, yi*) of the points that make up each dividing line are finally obtained. The labels are manually marked lines. When calculating Smooth L1Loss, the Smooth L1Loss between the predicted yi* (i.e., f(xi)) and the true coordinate yi of the label line at xi is calculated; when making column predictions, the rows and columns are just the opposite, and the Smooth L1Loss between xi* and xi is calculated, so as to use the Smooth L1Loss when calculating row / column predictions, which meets the required conditions.
[0159] It should be noted that the training of models such as the two Transformer networks will not be described in detail here.
[0160] It should also be noted that after identifying the table structure based on the horizontal and vertical dividing lines, the cell area of the table can be identified. However, the above dividing lines are the most fine-grained segmentation of the entire table, that is, even if some cells are large cells formed by merging several cells, they will be cut into the smallest unit cells after the above processing. Therefore, in order to accurately identify the table structure, another network is required to learn which cells should be merged into a grid, and then merge and fill them with text, as shown in the following example:
[0161] In one embodiment, in S44, identifying the table structure of the table based on the horizontal dividing lines and the vertical dividing lines includes:
[0162] S441: Merge the horizontal dividing line and the vertical dividing line to obtain the initial cell area of the table;
[0163] S442: scaling the coordinates of the initial cell area of the table so that the scaled table has the same size as the original feature map of the table;
[0164] S443: Segment the original feature map according to the coordinate values of the scaled cell area to obtain a plurality of segmented feature map blocks;
[0165] S444: Fusing the text features of the table with the corresponding segmentation feature blocks to obtain fused features;
[0166] S445: Input each fused feature into the graph neural network to obtain the table structure of the table.
[0167] In this embodiment, the horizontal dividing line and the vertical dividing line are first merged to obtain the initial cell area of the table, that is, the horizontal and vertical dividing lines are integrated to obtain each cell area, and then the cell coordinate size is scaled to the same size as the original feature map S, and then the original feature map S is segmented according to the scaled coordinate value to obtain multiple segmentation feature blocks, and each segmentation feature block after segmentation is used as one of the inputs of each node in the graph convolutional neural network (Graph Convolutional Network, GCN). And as shown in Figure 2, the text features in the table are identified by the text detection network and the convolutional recurrent neural network through the table image. Exemplarily, the text detection network can be a differentiable binarization network (Real-time Scene Text Detection with Differentiable Binarization, DBNet) or other text detection networks, which are not specifically limited. After the text features in the table are fused with the segmented image blocks, they are sent to the GCN network.
[0168] It should be noted that the GCN network is used to predict which two cells in the identified cells should be merged into one cell. The GCN network is trained and ready for use. The training process requires calculating the matching loss, i.e., L group It can be understood that the GCN network learns an adjacency matrix to record the relationship between each cell and other cells in the identified cell area. 1 means there is a relationship, that is, it should be merged into one grid, and 0 means no relationship, that is, it should not be merged. group This is the cross entropy loss between the GCN-predicted adjacency matrix and the label's adjacency matrix. Therefore, to calculate this loss, we also need to prepare an adjacency matrix for the label data, which records the relationship between each small cell and other cells. Finally, using the trained GCN network, combined with text features and segmented image blocks, we merge the coordinates of the cells that need to be merged and fill the corresponding cells with the text recognition content to obtain the final table structure.
[0169] It is worth noting that, during training, the final loss can be expressed as follows: total =λ1L horizontal +(1-λ1)L vertical +λL group ;
[0170] The overall network architecture must satisfy the above-mentioned final loss requirements. λ1 is the weight coefficient and can be configured.
[0171] In summary, combined with the above embodiments, the processing process of the final embodiment can be shown in Figure 2. First, the original table image is sent to the ResNet-18+FPN network to extract and fuse the features of the image at different scales. Since the rows and columns of the table are then divided, and the features required by the two are different, two convolutional networks are required to further extract the horizontal and vertical features respectively, exchange the information of the above two feature maps, and determine the sampling position of the column / row feature map through the row / column feature map. The 10 columns and rows with the most obvious features in the vertical features and horizontal features are selected as the reference points of the horizontal features and vertical features respectively. Finally, the entire column / row is taken out as a new sub-feature map. This process mainly considers the intersection of rows and columns as the main position for dividing cells. At the position where the column features are most obvious in the image, its row features can best serve as the basis for dividing cells.
[0172] The two sub-feature maps are then used as the Transformer's key and value, respectively. 100 points are evenly spaced from the columns and rows of each sub-feature map as the query. These queries, along with the key and value, form the decoder. A linear layer is then applied to the decoder output to predict the ordinate and abscissa of each sampled point. Each Transformer generates 10×100 ordinates and abscissas. Coordinates with similar coordinates are merged to obtain the final row and column separators, i.e., the horizontal and vertical separators. Finally, fine-grained cell divisions are generated based on these separators. The cell coordinates are then scaled to the size of the original feature map S, and the feature map is segmented based on the scaled cell coordinates. Meanwhile, DBNet and CRNN are used to detect and recognize text in the table. The text information is embedded and fused with the corresponding cell's sliced image features. Each fused cell is used as a node to construct a graph convolutional network to predict relationships between cells. The resulting merged table recognition result is obtained.
[0173] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0174] In one embodiment, a universal table recognition device is provided, which corresponds one-to-one to the universal table recognition method in the above embodiment. As shown in Figure 4, the universal table recognition device includes an acquisition module 101, a determination module 102, an extraction module 103, and a recognition module 104. The functional modules are described in detail as follows:
[0175] An acquisition module 101 is used to acquire horizontal gap information and vertical gap information of a table;
[0176] a determination module 102 for determining a longitudinal sampling position based on the transverse gap information and determining a transverse sampling position based on the longitudinal gap information;
[0177] Extraction module 103, configured to extract the entire column information of the horizontal gap information according to the vertical sampling position to obtain a vertical sub-feature map, and extract the entire row information of the vertical gap information according to the horizontal sampling position to obtain a horizontal sub-feature map;
[0178] The identification module 104 is configured to identify the table structure of the table according to the horizontal sub-feature graph and the vertical sub-feature graph.
[0179] In one embodiment, the determination module 102 is configured to:
[0180] Determining a preset reference number of longitudinal reference point positions from the transverse gap information according to the longitudinal gap information;
[0181] The preset reference number of longitudinal reference point positions are used as longitudinal sampling positions.
[0182] In one embodiment, the determination module 102 is configured to:
[0183] Obtaining a horizontal vector through the horizontal gap information, wherein the horizontal vector includes the coordinate value of each position point of the table in the horizontal direction;
[0184] Suppressing the position points whose coordinate values of adjacent position points in the horizontal vector are less than a preset distance, so as to retain the position points with larger coordinate values among the adjacent position points;
[0185] From the suppressed horizontal vector, a preset reference number of position points are selected as the longitudinal reference point positions.
[0186] In one embodiment, the determination module 102 is configured to:
[0187] A preset reference number of longitudinal reference point positions are determined equidistantly from the transverse gap information.
[0188] In one embodiment, the identification module 104 is configured to:
[0189] Selecting a preset number of sampling points from each column of the longitudinal sub-feature graph as first sampling points, and selecting a preset number of sampling points from each row of the horizontal sub-feature graph as second sampling points;
[0190] Predicting the coordinate value of each first sampling point using a first transformer network, and predicting the coordinate value of each second sampling point using a second transformer network;
[0191] Aggregate the coordinate values of all first sampling points corresponding to each column to obtain a vertical dividing line, and aggregate the coordinate values of all second sampling points corresponding to each row to obtain a horizontal dividing line;
[0192] Identify the table structure based on the horizontal and vertical dividing lines.
[0193] In one embodiment, the identification module 104 is configured to:
[0194] Merge the horizontal and vertical dividing lines to obtain the initial cell area of the table;
[0195] Scale the coordinates of the initial cell area of the table so that the scaled table has the same size as the original feature map of the table;
[0196] According to the coordinate values of the scaled cell area, the original feature map is segmented to obtain multiple segmented feature map blocks;
[0197] Fuse the text features of the table with the corresponding segmentation feature blocks to obtain fused features;
[0198] Each fused feature is input into the graph neural network to obtain the table structure of the table.
[0199] In one embodiment, the acquisition module 101 is used to:
[0200] Get the table image of the table;
[0201] The image information of the table image is extracted through the pre-trained object detection network to obtain the original feature map;
[0202] The original feature map is input into the horizontal feature extraction module and the vertical feature extraction module respectively to obtain the horizontal gap information and the vertical gap information of the table.
[0203] It can be seen that in this embodiment, a universal table recognition device is provided, which first obtains the horizontal gap information R and the vertical gap information C of the table; determines the vertical sampling position / horizontal sampling position according to the vertical gap information C / horizontal gap information R, respectively, extracts the vertical sub-feature map C' according to the vertical sampling position, and extracts the horizontal sub-feature map R' according to the horizontal sampling position; finally, identifies the table structure of the table according to the horizontal sub-feature map R' and the vertical sub-feature map C'. Since the embodiment of the present application utilizes the image information features extracted from the table picture to extract the global typesetting features, that is, the gap features, the degree of dependence on the table lines or intersections is very low, and correct structural recognition can still be performed when such information is incomplete or even non-existent. It can also be applied to the recognition of wireless tables. It is a universal method that can simultaneously perform structural recognition on wired and wireless tables. It has high versatility and greater application value.
[0204] The specific definition of the universal table recognition device can be found in the definition of the universal table recognition method above and will not be repeated here. The various modules in the universal table recognition device can be implemented in whole or in part through software, hardware, or a combination thereof. The aforementioned modules can be embedded in or independent of the processor in the computer device in hardware form, or can be stored in the memory of the computer device in software form, so that the processor can call and execute the corresponding operations of the aforementioned modules.
[0205] In one embodiment, a computer device is provided, and its internal structure diagram can be shown in Figure 5. The computer device includes a processor, a memory, and a network interface connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a readable storage medium and an internal memory. The non-volatile storage medium stores an operating system and computer-readable instructions. The internal memory provides an environment for the operation of the operating system and computer-readable instructions in the readable storage medium. The network interface of the computer device is used to communicate with an external device via a network connection to obtain a table image. When the computer-readable instructions are executed by the processor, a general table recognition method of the above embodiment is implemented. The readable storage medium provided in this embodiment includes a non-volatile readable storage medium and a volatile readable storage medium.
[0206] In one embodiment, a computer device is provided, comprising a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor. When the processor executes the computer-readable instructions, the following steps are implemented:
[0207] Get the horizontal gap information and vertical gap information of the table;
[0208] Determine a longitudinal sampling position of the transverse gap information according to the longitudinal gap information, and determine a transverse sampling position of the longitudinal gap information according to the transverse gap information;
[0209] Extracting the entire column information of the horizontal gap information according to the vertical sampling position to obtain a vertical sub-feature map, and extracting the entire row information of the vertical gap information according to the horizontal sampling position to obtain a horizontal sub-feature map;
[0210] According to the horizontal sub-feature graph and the vertical sub-feature graph, the table structure of the table is identified.
[0211] In one embodiment, when the processor executes the computer-readable instructions, the processor specifically implements the following steps:
[0212] determining a preset reference number of longitudinal reference point positions from the transverse gap information according to the longitudinal gap information;
[0213] The preset reference number of longitudinal reference point positions are used as the longitudinal sampling positions.
[0214] In one embodiment, when the processor executes the computer-readable instructions, the processor specifically implements the following steps:
[0215] Obtaining a transverse vector using the transverse gap information, wherein the transverse vector includes a coordinate value of each position point of the table in the transverse direction;
[0216] Suppressing position points in the horizontal vector whose coordinate values of adjacent position points are less than a preset distance, so as to retain position points with larger coordinate values among the adjacent position points;
[0217] A preset reference number of position points are screened out from the horizontal vector that has undergone the suppression process as longitudinal reference point positions.
[0218] In one embodiment, when the processor executes the computer-readable instructions, the processor specifically implements the following steps:
[0219] A preset reference number of longitudinal reference point positions are determined equidistantly from the transverse gap information.
[0220] In one embodiment, when the processor executes the computer-readable instructions, the processor specifically implements the following steps:
[0221] Selecting a preset number of sampling points from each column of the longitudinal sub-feature graph as first sampling points, and selecting a preset number of sampling points from each row of the horizontal sub-feature graph as second sampling points;
[0222] Predicting the coordinate value of each of the first sampling points using a first transformer network, and predicting the coordinate value of each of the second sampling points using a second transformer network;
[0223] Aggregating the coordinate values of all the first sampling points corresponding to each column to obtain a longitudinal dividing line, and aggregating the coordinate values of all the second sampling points corresponding to each row to obtain a transverse dividing line;
[0224] The table structure of the table is identified according to the horizontal dividing line and the vertical dividing line.
[0225] In one embodiment, when the processor executes the computer-readable instructions, the processor specifically implements the following steps:
[0226] Merging the horizontal dividing line and the vertical dividing line to obtain an initial cell area of the table;
[0227] Scaling the coordinates of the initial cell area of the table so that the scaled initial cell area has the same size as the original feature map of the table;
[0228] Segmenting the original feature map according to the coordinate values of the scaled initial cell area to obtain a plurality of segmented feature map blocks;
[0229] Fusing the text features of the table with the corresponding segmented feature blocks to obtain fused features;
[0230] Each of the fused features is input into a graph neural network to obtain a table structure of the table.
[0231] In one embodiment, one or more computer-readable storage media storing computer-readable instructions are provided. The computer-readable storage media provided in this embodiment include non-volatile computer-readable storage media and volatile computer-readable storage media. The computer-readable storage media store computer-readable instructions that, when executed by one or more processors, implement the following steps:
[0232] Get the horizontal gap information and vertical gap information of the table;
[0233] Determine a longitudinal sampling position of the transverse gap information according to the longitudinal gap information, and determine a transverse sampling position of the longitudinal gap information according to the transverse gap information;
[0234] Extracting the entire column information of the horizontal gap information according to the vertical sampling position to obtain a vertical sub-feature map, and extracting the entire row information of the vertical gap information according to the horizontal sampling position to obtain a horizontal sub-feature map;
[0235] According to the horizontal sub-feature graph and the vertical sub-feature graph, the table structure of the table is identified.
[0236] In one embodiment, when the computer-readable instructions are executed by one or more processors, the one or more processors are caused to specifically perform the following steps:
[0237] determining a preset reference number of longitudinal reference point positions from the transverse gap information according to the longitudinal gap information;
[0238] The preset reference number of longitudinal reference point positions are used as the longitudinal sampling positions.
[0239] In one embodiment, when the computer-readable instructions are executed by one or more processors, the one or more processors are caused to specifically perform the following steps:
[0240] Obtaining a transverse vector using the transverse gap information, wherein the transverse vector includes a coordinate value of each position point of the table in the transverse direction;
[0241] Suppressing position points in the horizontal vector whose coordinate values of adjacent position points are less than a preset distance, so as to retain position points with larger coordinate values among the adjacent position points;
[0242] A preset reference number of position points are screened out from the horizontal vector that has undergone the suppression process as longitudinal reference point positions.
[0243] In one embodiment, when the computer-readable instructions are executed by one or more processors, the one or more processors are caused to specifically perform the following steps:
[0244] A preset reference number of longitudinal reference point positions are determined equidistantly from the transverse gap information.
[0245] In one embodiment, when the computer-readable instructions are executed by one or more processors, the one or more processors are caused to specifically perform the following steps:
[0246] Selecting a preset number of sampling points from each column of the longitudinal sub-feature graph as first sampling points, and selecting a preset number of sampling points from each row of the horizontal sub-feature graph as second sampling points;
[0247] Predicting the coordinate value of each of the first sampling points using a first transformer network, and predicting the coordinate value of each of the second sampling points using a second transformer network;
[0248] Aggregating the coordinate values of all the first sampling points corresponding to each column to obtain a longitudinal dividing line, and aggregating the coordinate values of all the second sampling points corresponding to each row to obtain a transverse dividing line;
[0249] The table structure of the table is identified according to the horizontal dividing line and the vertical dividing line.
[0250] In one embodiment, when the computer-readable instructions are executed by one or more processors, the one or more processors are caused to specifically perform the following steps:
[0251] Merging the horizontal dividing line and the vertical dividing line to obtain an initial cell area of the table;
[0252] Scaling the coordinates of the initial cell area of the table so that the scaled initial cell area has the same size as the original feature map of the table;
[0253] Segmenting the original feature map according to the coordinate values of the scaled initial cell area to obtain a plurality of segmented feature map blocks;
[0254] Fusing the text features of the table with the corresponding segmented feature blocks to obtain fused features;
[0255] Each of the fused features is input into a graph neural network to obtain a table structure of the table.
[0256] In one embodiment, a computer program product is further provided. The computer-readable instruction product includes computer-readable instructions. When the computer-readable instructions are executed by a processor, the following steps are implemented:
[0257] Get the horizontal gap information and vertical gap information of the table;
[0258] Determine a longitudinal sampling position of the transverse gap information according to the longitudinal gap information, and determine a transverse sampling position of the longitudinal gap information according to the transverse gap information;
[0259] Extracting the entire column information of the horizontal gap information according to the vertical sampling position to obtain a vertical sub-feature map, and extracting the entire row information of the vertical gap information according to the horizontal sampling position to obtain a horizontal sub-feature map;
[0260] According to the horizontal sub-feature graph and the vertical sub-feature graph, the table structure of the table is identified.
[0261] Those skilled in the art will understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing related hardware through computer-readable instructions. The computer-readable instructions can be stored in a non-volatile readable storage medium or a volatile readable storage medium. When the computer-readable instructions are executed, they can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0262] Those skilled in the art will clearly understand that for the sake of convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0263] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present application, and should all be included in the scope of protection of the present application.
Claims
1. A universal table recognition method, comprising: Get the horizontal gap information and vertical gap information of the table; Determine a longitudinal sampling position of the transverse gap information according to the longitudinal gap information, and determine a transverse sampling position of the longitudinal gap information according to the transverse gap information; Extracting the entire column information of the horizontal gap information according to the vertical sampling position to obtain a vertical sub-feature map, and extracting the entire row information of the vertical gap information according to the horizontal sampling position to obtain a horizontal sub-feature map; A table structure of the table is identified according to the horizontal sub-feature graph and the vertical sub-feature graph.
2. The universal table recognition method according to claim 1, wherein the step of determining the longitudinal sampling position of the transverse gap information according to the longitudinal gap information comprises: Determining a preset reference number of longitudinal reference point positions from the transverse gap information according to the longitudinal gap information; The preset reference number of longitudinal reference point positions are used as the longitudinal sampling positions.
3. The universal table recognition method according to claim 2, wherein the step of determining a preset reference number of longitudinal reference point positions from the transverse gap information according to the longitudinal gap information comprises: Obtaining a lateral vector through the lateral gap information, wherein the lateral vector includes the coordinate value of each position point of the table in the lateral direction; Suppressing position points in the lateral vector whose coordinate values of adjacent position points are less than a preset distance, so as to retain position points with larger coordinate values among the adjacent position points; A preset reference number of position points are screened out from the lateral vectors that have undergone the suppression process as longitudinal reference point positions.
4. The universal table recognition method according to claim 2, wherein the step of determining a preset reference number of longitudinal reference point positions from the transverse gap information comprises: A preset reference number of longitudinal reference point positions are equidistantly determined from the transverse gap information.
5. The universal table recognition method according to any one of claims 1 to 4, wherein the step of recognizing the table structure of the table according to the horizontal sub-feature graph and the vertical sub-feature graph comprises: Selecting a preset number of sampling points from each column of the longitudinal sub-feature graph as first sampling points, and selecting a preset number of sampling points from each row of the transverse sub-feature graph as second sampling points; Predicting the coordinate value of each of the first sampling points using a first transformer network, and predicting the coordinate value of each of the second sampling points using a second transformer network; Aggregate the coordinate values of all the first sampling points corresponding to each column to obtain a vertical dividing line, and Aggregating the coordinate values of all the second sampling points to obtain a horizontal dividing line; The table structure of the table is identified according to the horizontal dividing line and the vertical dividing line.
6. The universal table recognition method according to claim 5, wherein the step of recognizing the table structure of the table according to the horizontal dividing line and the vertical dividing line comprises: Merging the horizontal dividing line and the vertical dividing line to obtain an initial cell area of the table; Scaling the coordinates of the initial cell area of the table so that the scaled initial cell area has the same size as the original feature map of the table; According to the coordinate values of the scaled initial cell area, the original feature map is segmented to obtain a plurality of segmented feature map blocks; Fusing the text features of the table with the corresponding segmented feature blocks to obtain fused features; Each of the fused features is input into a graph neural network to obtain a table structure of the table.
7. The universal table recognition method according to any one of claims 1 to 4, wherein the step of obtaining the horizontal gap information and the vertical gap information of the table comprises: obtaining a table image of the table; Extracting image information of the table image through a pre-trained object detection network to obtain an original feature map; The original feature map is input into the transverse feature extraction module and the longitudinal feature extraction module respectively to obtain the transverse gap information and the longitudinal gap information of the table.
8. A universal table recognition device, the device comprising: An acquisition module, used to acquire horizontal gap information and vertical gap information of a table; a determination module, configured to determine a longitudinal sampling position according to the transverse gap information, and to determine a transverse sampling position according to the longitudinal gap information; An extraction module, configured to extract the entire column information of the horizontal gap information according to the vertical sampling position to obtain a vertical sub-feature map, and to extract the entire row information of the vertical gap information according to the horizontal sampling position to obtain a horizontal sub-feature map; An identification module is used to identify the table structure of the table according to the horizontal sub-feature graph and the vertical sub-feature graph.
9. A computer device comprising a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer-readable instructions: Get the horizontal gap information and vertical gap information of the table; Determine a longitudinal sampling position of the transverse gap information according to the longitudinal gap information, and determine a transverse sampling position of the longitudinal gap information according to the transverse gap information; Extracting the entire column information of the horizontal gap information according to the vertical sampling position to obtain a vertical sub-feature map, and extracting the entire row information of the vertical gap information according to the horizontal sampling position to obtain a horizontal sub-feature map; A table structure of the table is identified according to the horizontal sub-feature graph and the vertical sub-feature graph.
10. The computer device according to claim 9, wherein the processor implements the following steps when executing the computer-readable instructions: Determining a preset reference number of longitudinal reference point positions from the transverse gap information according to the longitudinal gap information; The preset reference number of longitudinal reference point positions are used as the longitudinal sampling positions.
11. The computer device according to claim 10, wherein the processor implements the following steps when executing the computer-readable instructions: The lateral vector is obtained by the lateral gap information, wherein, The horizontal vector includes the coordinate value of each position point of the table in the horizontal direction; Suppressing position points in the lateral vector whose coordinate values of adjacent position points are less than a preset distance, so as to retain position points with larger coordinate values among the adjacent position points; A preset reference number of position points are screened out from the lateral vectors that have undergone the suppression process as longitudinal reference point positions.
12. The computer device according to claim 10, wherein the processor executes the computer-readable instructions to specifically implement the following steps: A preset reference number of longitudinal reference point positions are equidistantly determined from the transverse gap information.
13. The computer device according to any one of claims 9 to 12, wherein the processor implements the following steps when executing the computer-readable instructions: Selecting a preset number of sampling points from each column of the longitudinal sub-feature graph as first sampling points, and selecting a preset number of sampling points from each row of the transverse sub-feature graph as second sampling points; Predicting the coordinate value of each of the first sampling points using a first transformer network, and predicting the coordinate value of each of the second sampling points using a second transformer network; Aggregating the coordinate values of all the first sampling points corresponding to each column to obtain a longitudinal dividing line, and aggregating the coordinate values of all the second sampling points corresponding to each row to obtain a transverse dividing line; The table structure of the table is identified according to the horizontal dividing line and the vertical dividing line.
14. The computer device according to claim 13, wherein the processor implements the following steps when executing the computer-readable instructions: Merging the horizontal dividing line and the vertical dividing line to obtain an initial cell area of the table; Scaling the coordinates of the initial cell area of the table so that the scaled initial cell area has the same size as the original feature map of the table; According to the coordinate values of the scaled initial cell area, the original feature map is segmented to obtain a plurality of segmented feature map blocks; Fusing the text features of the table with the corresponding segmented feature blocks to obtain fused features; Each of the fused features is input into a graph neural network to obtain a table structure of the table.
15. A computer-readable storage medium storing computer-readable instructions, wherein: When the computer readable instructions are executed by one or more processors, the one or more processors perform the following steps: Get the horizontal gap information and vertical gap information of the table; Determine a longitudinal sampling position of the transverse gap information according to the longitudinal gap information, and determine a transverse sampling position of the longitudinal gap information according to the transverse gap information; Extracting the entire column information of the horizontal gap information according to the vertical sampling position to obtain a vertical sub-feature map, and extracting the entire row information of the vertical gap information according to the horizontal sampling position to obtain a horizontal sub-feature map; A table structure of the table is identified according to the horizontal sub-feature graph and the vertical sub-feature graph.
16. The readable storage medium according to claim 15, wherein when the computer-readable instructions are executed by one or more processors, the one or more processors specifically perform the following steps: Determining a preset reference number of longitudinal reference point positions from the transverse gap information according to the longitudinal gap information; The preset reference number of longitudinal reference point positions are used as the longitudinal sampling positions.
17. The readable storage medium according to claim 16, wherein when the computer-readable instructions are executed by one or more processors, the one or more processors specifically perform the following steps: The lateral vector is obtained by the lateral gap information, wherein, The horizontal vector includes the coordinate value of each position point of the table in the horizontal direction; Suppressing position points in the lateral vector whose coordinate values of adjacent position points are less than a preset distance, so as to retain position points with larger coordinate values among the adjacent position points; A preset reference number of position points are screened out from the lateral vectors that have undergone the suppression process as longitudinal reference point positions.
18. The readable storage medium according to claim 16, wherein when the computer readable instructions are executed by one or more processors, the one or more processors specifically perform the following steps: A preset reference number of longitudinal reference point positions are equidistantly determined from the transverse gap information.
19. The readable storage medium according to any one of claims 15 to 18, wherein when the computer-readable instructions are executed by one or more processors, the one or more processors specifically perform the following steps: Selecting a preset number of sampling points from each column of the longitudinal sub-feature graph as first sampling points, and selecting a preset number of sampling points from each row of the transverse sub-feature graph as second sampling points; Predicting the coordinate value of each of the first sampling points using a first transformer network, and predicting the coordinate value of each of the second sampling points using a second transformer network; Aggregating the coordinate values of all the first sampling points corresponding to each column to obtain a longitudinal dividing line, and aggregating the coordinate values of all the second sampling points corresponding to each row to obtain a transverse dividing line; The table structure of the table is identified according to the horizontal dividing line and the vertical dividing line.
20. The readable storage medium according to claim 19, wherein when the computer-readable instructions are executed by one or more processors, the one or more processors specifically perform the following steps: Merging the horizontal dividing line and the vertical dividing line to obtain an initial cell area of the table; Scaling the coordinates of the initial cell area of the table so that the scaled initial cell area has the same size as the original feature map of the table; According to the coordinate values of the scaled initial cell area, the original feature map is segmented to obtain a plurality of segmented feature map blocks; Fusing the text features of the table with the corresponding segmented feature blocks to obtain fused features; Each of the fused features is input into a graph neural network to obtain a table structure of the table.
Citation Information
Patent Citations
Table structure identification method and device, electronic equipment and storage medium
CN112528863A
Table identification method and device
CN113269153A
Table structure identification method and device, storage medium and electronic equipment
CN113297975A
End-to-end table detection and structure identification method and system
CN113435240A
Table extraction method, apparatus and device, and storage medium
CN114357958A
Cited By
Wireless table detection method and system
CN119274197A
Deformation table cell instance segmentation method and system
CN120544214A
Text recognition method and system and storage medium
CN122392084A
