Table identification method and related equipment thereof
By comprehensively processing the position information of cells and text, the problem of table recognition failure caused by inaccurate cell position information in the prior art is solved, and the accuracy and user experience of table recognition are improved.
Patent Information
- Application Number
- CN202310746659.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-21
- Publication Date
- 2024-12-24
AI Technical Summary
When the position information of multiple cells is inaccurate, the existing table recognition method cannot correctly complete the matching between cells and text, resulting in table recognition failure and reducing user experience.
By obtaining the target image, the target model is used to extract the position information of cells and separators, combined with the text recognition results, the position information of cells and text is comprehensively processed to match, ensuring the accuracy of the match.
Improve the accuracy and user experience of table recognition, and can rely on the separator information to correct the cell position information when it is inaccurate, ensuring correct matching and table extraction.
Smart Images

Figure CN119181104A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of artificial intelligence (AI) technology, and in particular to a table recognition method and related equipment. Background Art
[0002] Table recognition is an important part of image processing, and its purpose is to convert a table in image form into a table in text form. When a user has a table recognition requirement, the image containing the table to be recognized can be processed through the neural network model in AI technology to extract the required table from the image, thereby meeting the user's table recognition requirement.
[0003] In the related art, a target image containing a table to be recognized can be input into a neural network model. Then, the neural network model can first perform preliminary processing on the target image to obtain the characteristics of the target image. Then, the neural network model can further process the characteristics of the target image to output multiple cells of the table and the location information of the multiple cells. Then, the target image can be recognized to obtain multiple texts of the table and the location information of the multiple texts. Finally, based on the location information of the cells and the location information of the texts, multiple cells and multiple texts can be matched to obtain the desired table.
[0004] In the above table recognition process, only the position information of multiple cells output by the model is considered, and the factors considered are relatively simple. Once the position information of multiple cells is not accurate enough, the matching between multiple cells and multiple texts cannot be correctly completed, and the correct table cannot be obtained. Summary of the invention
[0005] The embodiment of the present application provides a table recognition method and related equipment, which can correctly complete the matching between multiple cells and multiple texts, thereby obtaining a correct table and improving the user experience.
[0006] A first aspect of an embodiment of the present application provides a table recognition method, the method comprising:
[0007] When table recognition is required, a target image may be first obtained, the target image includes a table to be recognized, and the table to be recognized is composed of a plurality of cells and a plurality of texts. In the plurality of cells, each cell is filled with at least one text from the plurality of texts.
[0008] After obtaining the target image, the target image can be input into the target model so as to perform a series of processing on the target image through the target model, thereby obtaining a plurality of cells of the table, first position information of the plurality of cells, and second position information of the plurality of separators between the plurality of cells. The first position information of the plurality of cells can be understood as the coordinates of the decoding frames of the plurality of cells in the image coordinate system, and the second position information of the plurality of separators can also be understood as the coordinates of the pixels occupied by the plurality of separators in the target image in the image coordinate system, and the image coordinate system is constructed based on the target image.
[0009] After obtaining the target image, text recognition can be directly performed on the target image to obtain multiple texts in the table to be recognized and the third position information of the multiple texts. The third position information of the multiple texts can be understood as the coordinates of the text boxes of the multiple texts in the image coordinate system.
[0010] After obtaining the second position information of the multiple separators, a series of processing can be performed on the second position information of the multiple separators to obtain the fourth position information of the multiple cells. The fourth position information of the multiple cells can be understood as the coordinates of the segmentation boxes of the multiple cells in the image coordinate system.
[0011] After obtaining the first position information of the multiple cells, the third position information of the multiple texts, and the fourth position information of the multiple cells, these information can be processed comprehensively to complete the matching between the multiple cells and the multiple texts, thereby merging the multiple cells and the multiple texts into the required table. At this point, the table recognition is completed.
[0012] It can be seen from the above method that when table recognition is required, a target image containing the table to be recognized can be obtained first. After obtaining the target image, the target image can be input into the target model to process the target image through the target model, thereby obtaining multiple cells of the table, first position information of multiple cells, and second position information of multiple separators between multiple cells. After obtaining the target image, text recognition can also be performed on the target image to obtain multiple texts of the table and third position information of multiple texts. Then, the second position information of multiple separators can be used to determine the fourth position information of multiple cells. Finally, the first position information of multiple cells, the third position information of multiple texts, and the fourth position information of multiple cells can be comprehensively considered to complete the matching between multiple cells and multiple texts, thereby obtaining the required table. In the above process, the target model includes the first position information of multiple cells and the third position information of multiple separators between the multiple cells, and the third position information of the multiple separators is used to calculate the fourth position information of the multiple cells. Therefore, when performing table recognition, not only the first position information of the multiple cells output by the model is considered, but also the calculated fourth position information of the multiple cells is considered. The factors considered are relatively comprehensive. Even if the first position information of the multiple cells is not accurate enough, the fourth position information of the multiple cells is accurate enough (because it takes into account the influence of the separators between the cells). In this way, the matching between the multiple cells and the multiple texts can be correctly completed, thereby obtaining the correct table and improving the user experience.
[0013] In a possible implementation, processing a target image through a target model to obtain multiple cells of a table includes: extracting features of the target image through a target model to obtain visual features of the target image; encoding and first decoding the visual features of the target image through a target model to obtain multiple cells of the table. In the aforementioned implementation, after obtaining the target image, the target model may perform multi-level feature extraction on the target image, thereby sequentially obtaining initial visual features of the target image, intermediate visual features of the target image, and final visual features of the target image. After obtaining the initial visual features of the target image, the intermediate visual features of the target image, and the final visual features of the target image, the target model may encode the final visual features of the target image to obtain encoded features of the target image. After obtaining the encoded features of the target image, the target model may perform a first decoding on the encoded features of the target image to obtain an HTML sequence, the HTML sequence containing multiple cells presented in HTML form, that is, the HTML sequence contains descriptions of multiple cells of the table.
[0014] In one possible implementation, processing the target image through the target model to obtain the first position information of the multiple cells includes: encoding the visual features of the target image through the target model and performing a second decoding to obtain the first position information of the multiple cells. In the aforementioned implementation, the target model may also perform a second decoding on the encoded features of the target image (the second decoding is a different decoding operation from the first decoding), thereby accurately obtaining the first position information of the multiple cells, that is, the coordinates of the decoding frames of the multiple cells in the image coordinate system.
[0015] In a possible implementation, processing the target image through the target model to obtain the second position information of multiple separators between multiple cells includes: performing feature fusion on the visual features of the target image through the target model to obtain the fusion features of the target image; classifying the fusion features of the target image through the target model to obtain the second position information of multiple separators between multiple cells. In the aforementioned implementation, after obtaining the intermediate visual features of part of the target image and the final visual features of the target image, the target model can fuse the intermediate visual features of part of the target image and the final visual features of the target image to obtain the fusion features of the target image. After obtaining the fusion features of the target image, the target model can classify the fusion features of the target image at the pixel level to divide all pixels of the target image into two parts, the first part of pixels is the pixels occupied by multiple cells, and the second part of pixels is the pixels occupied by multiple separators between multiple cells, so the coordinates of the pixels occupied by multiple separators in the image coordinate system can be obtained, which is used as the second position information of multiple separators. It can be seen that the target model provided in the embodiment of the present application is a multi-task framework that can predict the positions of multiple cells in a table and the positions of multiple separators in a table.
[0016] In a possible implementation, based on the second position information, determining the fourth position information of the plurality of cells includes: based on the difference between the size of the target image and the size of the fusion feature of the target image, enlarging the second position information to obtain the enlarged second position information of the plurality of separators, the size of the target image being larger than the size of the fusion feature of the target image; and calculating the enlarged second position information to obtain the fourth position information of the plurality of cells. In the aforementioned implementation, after obtaining the second position information of the plurality of separators, since the size of the fusion feature of the target image is smaller than the size of the target image in the process of the target model acquiring the fusion feature of the target image, the second position information of the plurality of separators obtained based on the fusion feature of the target image is also the position information reduced to a certain extent. In order to restore the position information of the plurality of separators that conforms to the actual size, the second position information of the plurality of separators can be enlarged based on the difference between the size of the target image and the size of the fusion feature of the target image, thereby obtaining the enlarged second position information of the plurality of separators, which is conducive to improving the accuracy of the position information of the separators, thereby more correctly completing the matching between the plurality of cells and the plurality of separators.
[0017] In one possible implementation, multiple cells and multiple texts are matched based on the first position information, the third position information, and the fourth position information to obtain a table, including: obtaining a first correspondence between multiple cells and the first position information, and a second correspondence between multiple texts and the third position information; performing a first match between the fourth position information and the third position information to obtain a third correspondence between the fourth position information and the third position information; performing a second match between the fourth position information and the first position information to obtain a fourth correspondence between the fourth position information and the first position information; and filling multiple texts into multiple cells according to the first correspondence, the second correspondence, the third correspondence, and the fourth correspondence to obtain a table. In the above implementation, since the first correspondence between multiple cells and the first position information of multiple cells can be understood as the correspondence between multiple cells and multiple decoding boxes, the second correspondence between multiple texts and the third position information of multiple texts can be understood as the correspondence between multiple texts and multiple text boxes, the third correspondence between the fourth position information of multiple cells and the third position information of multiple texts can be understood as the correspondence between multiple text boxes and multiple segmentation boxes, and the fourth correspondence between the fourth position information of multiple cells and the first position information between multiple cells can be understood as the correspondence between multiple decoding boxes and multiple segmentation boxes, the following relationship chain can be used: multiple texts → multiple text boxes → multiple segmentation boxes → multiple decoding boxes → multiple cells to combine these four groups of correspondences, thereby finally obtaining the correspondence between multiple cells and multiple texts. Then, according to the correspondence, multiple texts can be accurately filled into multiple cells, thereby accurately obtaining the required table.
[0018] In a possible implementation, the first matching is a center matching, and the second matching is a Hungarian matching.
[0019] The second aspect of an embodiment of the present application provides a model training method, which includes: acquiring a first image, the first image containing a first table to be identified; processing the first image through the model to be trained to obtain multiple first cells of the first table, fifth position information of the multiple first cells, and sixth position information of multiple first separators between the multiple first cells; based on the fifth position information and the sixth position information, training the model to be trained to obtain a target model.
[0020] The target model obtained by training the above method can be used for table recognition. Specifically, when table recognition is required, a target image containing the table to be recognized can be obtained first. After obtaining the target image, the target image can be input into the target model to process the target image through the target model, thereby obtaining multiple cells of the table, first position information of multiple cells, and second position information of multiple separators between multiple cells. After obtaining the target image, text recognition can also be performed on the target image to obtain multiple texts of the table and third position information of multiple texts. Then, the second position information of multiple separators can be used to determine the fourth position information of multiple cells. Finally, the first position information of multiple cells, the third position information of multiple texts, and the fourth position information of multiple cells can be comprehensively considered to complete the matching between multiple cells and multiple texts, thereby obtaining the required table. In the above process, the target model includes the first position information of multiple cells and the third position information of multiple separators between the multiple cells, and the third position information of the multiple separators is used to calculate the fourth position information of the multiple cells. Therefore, when performing table recognition, not only the first position information of the multiple cells output by the model is considered, but also the calculated fourth position information of the multiple cells is considered. The factors considered are relatively comprehensive. Even if the first position information of the multiple cells is not accurate enough, the fourth position information of the multiple cells is accurate enough (because it takes into account the influence of the separators between the cells). In this way, the matching between the multiple cells and the multiple texts can be correctly completed, thereby obtaining the correct table and improving the user experience.
[0021] In one possible implementation, the method also includes: acquiring a second image, the second image containing a second table to be identified; processing the second image through a backbone network to be trained and a segmentation network to be trained to obtain seventh position information of multiple second separators between multiple second cells of the second table; training the backbone network to be trained based on the seventh position information to obtain a pre-trained backbone network; and constructing a model to be trained based on the pre-trained backbone network and the segmentation network to be trained.
[0022] In one possible implementation, the method also includes: acquiring a second image and a third image, the second image containing a second table to be identified, and the third image containing a third table to be identified; processing the second image and the third image through a backbone network to be trained to obtain visual features of the second image and visual features of the third image; training the backbone network to be trained based on the visual features of the second image and the visual features of the third image to obtain a pre-trained backbone network; and constructing a model to be trained based on the pre-trained backbone network.
[0023] In a possible implementation manner, the second image and the third image are derived from the same image, and the second table and the third table are derived from the same table.
[0024] In one possible implementation, processing the first image through the model to be trained to obtain multiple first cells of the first table includes: extracting features of the first image through the model to be trained to obtain visual features of the first image; encoding and first decoding the visual features of the first image through the model to be trained to obtain multiple first cells of the first table.
[0025] In one possible implementation, processing the first image through the model to be trained to obtain the fifth position information of multiple first cells includes: encoding the visual features of the first image through the model to be trained and performing a second decoding to obtain the fifth position information of multiple first cells.
[0026] In one possible implementation, the first image is processed by the model to be trained to obtain the sixth position information of multiple first separators between multiple first cells, including: performing feature fusion on the visual features of the first image by the model to be trained to obtain the fusion features of the first image; and classifying the fusion features of the first image by the model to be trained to obtain the sixth position information of multiple first separators between multiple first cells.
[0027] A third aspect of an embodiment of the present application provides a table recognition device, characterized in that the device includes: an acquisition module, used to acquire a target image, the target image contains a table to be recognized; a processing module, used to process the target image through a target model to obtain multiple cells of the table, first position information of the multiple cells, and second position information of multiple separators between the multiple cells; a recognition module, used to perform text recognition on the target image to obtain multiple texts of the table and third position information of the multiple texts; a determination module, used to determine fourth position information of the multiple cells based on the second position information; and a matching module, used to match the multiple cells and the multiple texts based on the first position information, the third position information, and the fourth position information to obtain a table.
[0028] It can be seen from the above device that when table recognition is required, a target image containing the table to be recognized can be obtained first. After obtaining the target image, the target image can be input into the target model to process the target image through the target model, thereby obtaining multiple cells of the table, first position information of multiple cells, and second position information of multiple separators between multiple cells. After obtaining the target image, text recognition can also be performed on the target image to obtain multiple texts of the table and third position information of multiple texts. Then, the second position information of multiple separators can be used to determine the fourth position information of multiple cells. Finally, the first position information of multiple cells, the third position information of multiple texts, and the fourth position information of multiple cells can be comprehensively considered to complete the matching between multiple cells and multiple texts, thereby obtaining the required table. In the above process, the target model includes the first position information of multiple cells and the third position information of multiple separators between the multiple cells, and the third position information of the multiple separators is used to calculate the fourth position information of the multiple cells. Therefore, when performing table recognition, not only the first position information of the multiple cells output by the model is considered, but also the calculated fourth position information of the multiple cells is considered. The factors considered are relatively comprehensive. Even if the first position information of the multiple cells is not accurate enough, the fourth position information of the multiple cells is accurate enough (because it takes into account the influence of the separators between the cells). In this way, the matching between the multiple cells and the multiple texts can be correctly completed, thereby obtaining the correct table and improving the user experience.
[0029] In one possible implementation, the processing module is used to: extract features of a target image through a target model to obtain visual features of the target image; encode and first decode the visual features of the target image through the target model to obtain multiple cells of a table.
[0030] In a possible implementation, the processing module is used to encode and second decode the visual features of the target image through a target model to obtain first position information of multiple cells.
[0031] In one possible implementation, the processing module is used to: perform feature fusion on the visual features of the target image through the target model to obtain fused features of the target image; and classify the fused features of the target image through the target model to obtain second position information of multiple separators between multiple cells.
[0032] In one possible implementation, a determination module is used to: amplify the second position information based on the difference between the size of a target image and the size of a fusion feature of the target image to obtain the amplified second position information of multiple separators, wherein the size of the target image is larger than the size of the fusion feature of the target image; and calculate the amplified second position information to obtain the fourth position information of multiple cells.
[0033] In one possible implementation, the matching module is used to: obtain a first correspondence between multiple cells and first position information, and a second correspondence between multiple texts and third position information; perform a first match between the fourth position information and the third position information to obtain a third correspondence between the fourth position information and the third position information; perform a second match between the fourth position information and the first position information to obtain a fourth correspondence between the fourth position information and the first position information; and fill multiple texts into multiple cells according to the first correspondence, the second correspondence, the third correspondence, and the fourth correspondence to obtain a table.
[0034] In a possible implementation, the first matching is a center matching, and the second matching is a Hungarian matching.
[0035] The fourth aspect of an embodiment of the present application provides a model training device, which includes: an acquisition module for acquiring a first image, the first image containing a first table to be identified; a processing module for processing the first image through a model to be trained to obtain multiple first cells of the first table, fifth position information of the multiple first cells, and sixth position information of multiple first separators between the multiple first cells; a training module for training the model to be trained based on the fifth position information and the sixth position information to obtain a target model.
[0036] The target model obtained by training the above-mentioned device can be used for table recognition. Specifically, when table recognition is required, a target image containing the table to be recognized can be obtained first. After obtaining the target image, the target image can be input into the target model to process the target image through the target model, thereby obtaining multiple cells of the table, first position information of multiple cells, and second position information of multiple separators between multiple cells. After obtaining the target image, text recognition can also be performed on the target image to obtain multiple texts of the table and third position information of multiple texts. Then, the second position information of multiple separators can be used to determine the fourth position information of multiple cells. Finally, the first position information of multiple cells, the third position information of multiple texts, and the fourth position information of multiple cells can be comprehensively considered to complete the matching between multiple cells and multiple texts, thereby obtaining the required table. In the above process, the target model includes the first position information of multiple cells and the third position information of multiple separators between the multiple cells, and the third position information of the multiple separators is used to calculate the fourth position information of the multiple cells. Therefore, when performing table recognition, not only the first position information of the multiple cells output by the model is considered, but also the calculated fourth position information of the multiple cells is considered. The factors considered are relatively comprehensive. Even if the first position information of the multiple cells is not accurate enough, the fourth position information of the multiple cells is accurate enough (because it takes into account the influence of the separators between the cells). In this way, the matching between the multiple cells and the multiple texts can be correctly completed, thereby obtaining the correct table and improving the user experience.
[0037] In one possible implementation, the device also includes: a construction module, which is used to: obtain a second image, the second image contains a second table to be identified; process the second image through a backbone network to be trained and a segmentation network to be trained to obtain seventh position information of multiple second separators between multiple second cells of the second table; train the backbone network to be trained based on the seventh position information to obtain a pre-trained backbone network; and construct a model to be trained based on the pre-trained backbone network and the segmentation network to be trained.
[0038] In one possible implementation, the device also includes: a construction module, used to: obtain a second image and a third image, the second image contains a second table to be identified, and the third image contains a third table to be identified; process the second image and the third image through a backbone network to be trained to obtain visual features of the second image and visual features of the third image; train the backbone network to be trained based on the visual features of the second image and the visual features of the third image to obtain a pre-trained backbone network; and construct a model to be trained based on the pre-trained backbone network.
[0039] In a possible implementation manner, the second image and the third image are derived from the same image, and the second table and the third table are derived from the same table.
[0040] In one possible implementation, the processing module is used to: extract features of the first image through the model to be trained to obtain visual features of the first image; encode and decode the visual features of the first image through the model to be trained to obtain multiple first cells of the first table.
[0041] In one possible implementation, the processing module is used to: encode and second decode the visual features of the first image using a model to be trained to obtain fifth position information of the plurality of first cells.
[0042] In one possible implementation, the processing module is used to: perform feature fusion on the visual features of the first image through the model to be trained to obtain fused features of the first image; classify the fused features of the first image through the model to be trained to obtain sixth position information of multiple first separators between multiple first cells.
[0043] A fifth aspect of an embodiment of the present application provides a table recognition device, which includes a memory and a processor; the memory stores code, and the processor is configured to execute the code. When the code is executed, the table recognition device executes the method described in the first aspect or any possible implementation method of the first aspect.
[0044] A sixth aspect of an embodiment of the present application provides a model training device, which includes a memory and a processor; the memory stores code, and the processor is configured to execute the code. When the code is executed, the model training device executes the method described in the second aspect or any possible implementation method of the second aspect.
[0045] A seventh aspect of an embodiment of the present application provides a circuit system, which includes a processing circuit, and the processing circuit is configured to execute a method as described in the first aspect, any possible implementation of the first aspect, the second aspect, or any possible implementation of the second aspect.
[0046] An eighth aspect of an embodiment of the present application provides a chip system, which includes a processor for calling a computer program or computer instructions stored in a memory so that the processor executes a method as described in the first aspect, any possible implementation of the first aspect, the second aspect, or any possible implementation of the second aspect.
[0047] In a possible implementation manner, the processor is coupled to the memory through an interface.
[0048] In a possible implementation, the chip system also includes a memory, in which a computer program or computer instructions are stored.
[0049] A ninth aspect of an embodiment of the present application provides a computer storage medium storing a computer program, which, when executed by a computer, enables the computer to implement the method described in the first aspect, any possible implementation of the first aspect, the second aspect, or any possible implementation of the second aspect.
[0050] The tenth aspect of the embodiments of the present application provides a computer program product, which stores instructions, which, when executed by a computer, enable the computer to implement the method described in the first aspect, any possible implementation of the first aspect, the second aspect, or any possible implementation of the second aspect.
[0051] In an embodiment of the present application, when table recognition is required, a target image containing a table to be recognized may be first obtained. After obtaining the target image, the target image may be input into a target model so that the target image may be processed by the target model to obtain a plurality of cells of the table, first position information of the plurality of cells, and second position information of the plurality of separators between the plurality of cells, respectively. After obtaining the target image, text recognition may also be performed on the target image to obtain a plurality of texts of the table and third position information of the plurality of texts. Then, the second position information of the plurality of separators may be used to determine the fourth position information of the plurality of cells. Finally, the first position information of the plurality of cells, the third position information of the plurality of texts, and the fourth position information of the plurality of cells may be comprehensively considered to complete the matching between the plurality of cells and the plurality of texts, thereby obtaining the required table. In the above process, the target model includes the first position information of multiple cells and the third position information of multiple separators between the multiple cells, and the third position information of the multiple separators is used to calculate the fourth position information of the multiple cells. Therefore, when performing table recognition, not only the first position information of the multiple cells output by the model is considered, but also the calculated fourth position information of the multiple cells is considered. The factors considered are relatively comprehensive. Even if the first position information of the multiple cells is not accurate enough, the fourth position information of the multiple cells is accurate enough (because it takes into account the influence of the separators between the cells). In this way, the matching between the multiple cells and the multiple texts can be correctly completed, thereby obtaining the correct table and improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 A structural diagram of the main framework of artificial intelligence;
[0053] Figure 2aA structural diagram of a table recognition system provided in an embodiment of the present application;
[0054] Figure 2b Another structural diagram of the table recognition system provided in an embodiment of the present application;
[0055] Figure 2c A schematic diagram of a device related to table identification provided in an embodiment of the present application;
[0056] Figure 3 A schematic diagram of the system 100 architecture provided in an embodiment of the present application;
[0057] Figure 4 A schematic diagram of the structure of the target model provided in the embodiment of the present application;
[0058] Figure 5 A flowchart of a table recognition method provided in an embodiment of the present application;
[0059] Figure 6 A schematic diagram of the structure of the target model provided in the embodiment of the present application;
[0060] Figure 7 A schematic diagram of a decoding frame provided in an embodiment of the present application;
[0061] Figure 8 A schematic diagram of a segmentation frame provided in an embodiment of the present application;
[0062] Fig. 9 A schematic diagram of a flow chart of a model training method provided in an embodiment of the present application;
[0063] Fig.10 A schematic diagram of a framework for segmentation pre-training provided in an embodiment of the present application;
[0064] Fig.11 A schematic diagram of separator enhancement provided in an embodiment of the present application;
[0065] Fig.12 A schematic diagram of a framework for self-supervised pre-training provided in an embodiment of the present application;
[0066] Fig.13 A schematic diagram of the structure of a table recognition device provided in an embodiment of the present application;
[0067] Fig.14 A schematic diagram of the structure of a model training device provided in an embodiment of the present application;
[0068] Fig.15 A schematic diagram of the structure of an execution device provided in an embodiment of the present application;
[0069] Fig.16 A schematic diagram of the structure of the training device provided in the embodiment of the present application;
[0070] Fig.17 A schematic diagram of the structure of the chip provided in an embodiment of the present application. DETAILED DESCRIPTION
[0071] The embodiment of the present application provides a table recognition method and related equipment, which can correctly complete the matching between multiple cells and multiple texts, thereby obtaining a correct table and improving the user experience.
[0072] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, which is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0073] Table recognition is an important part of image processing, and its purpose is to convert a table in image form into a table in text form. When a user has a table recognition requirement, the neural network model in AI technology can be used to process the image containing the table to be recognized to extract the required table from the image, thereby meeting the user's table recognition requirement. For example, a company has accumulated a large number of images containing contracts, delivery orders, receipts and other forms. With the help of a neural network model, contracts, delivery orders, receipts and other forms can be efficiently extracted from these images.
[0074] In the related art, a target image containing a table to be recognized can be input into a neural network model. Then, the neural network model can first perform preliminary processing on the target image to obtain the characteristics of the target image. Then, the neural network model can further process the characteristics of the target image to output multiple cells of the table and the location information of the multiple cells. Then, text recognition (optical character recognition, OCR) can be performed on the target image to obtain multiple texts of the table and the location information of the multiple texts. Finally, based on the relationship between the location information of the cells and the location information of the texts, multiple cells and multiple texts can be matched to obtain the desired table.
[0075] In the above table recognition process, only the position information of multiple cells output by the model is considered, and the factors considered are relatively simple. Once the position information of multiple cells is not accurate enough, the matching between multiple cells and multiple texts cannot be correctly completed (for example, the position of some cells is incorrect, causing these cells to drift, and the text that should be filled in these cells is filled in other cells), and the correct table cannot be obtained, which reduces the user experience.
[0076] In order to solve the above problems, the embodiment of the present application provides a table recognition method, which can be implemented in combination with artificial intelligence (AI) technology. AI technology is a technical discipline that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence. AI technology obtains the best results by sensing the environment, acquiring knowledge and using knowledge. In other words, artificial intelligence technology is a branch of computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Using artificial intelligence for data processing is a common application of artificial intelligence.
[0077] First, the overall workflow of the artificial intelligence system is described. Figure 1 , Figure 1 It is a structural diagram of the main framework of artificial intelligence. The following is an explanation of the above artificial intelligence theme framework from two dimensions: "intelligent information chain" (horizontal axis) and "IT value chain" (vertical axis). Among them, the "intelligent information chain" reflects a series of processes from data acquisition to processing. For example, it can be a general process of intelligent information perception, intelligent information representation and formation, intelligent reasoning, intelligent decision-making, intelligent execution and output. In this process, the data has undergone a condensation process of "data-information-knowledge-wisdom". The "IT value chain" reflects the value that artificial intelligence brings to the information technology industry from the underlying infrastructure of human intelligence, information (providing and processing technology implementation) to the industrial ecology process of the system.
[0078] (1) Infrastructure
[0079] The infrastructure provides computing power support for the AI system, enables communication with the outside world, and supports it through the basic platform. It communicates with the outside world through sensors; computing power is provided by smart chips (CPU, NPU, GPU, ASIC, FPGA and other hardware acceleration chips); the basic platform includes distributed computing frameworks and networks and other related platform guarantees and support, which can include cloud storage and computing, interconnected networks, etc. For example, sensors communicate with the outside world to obtain data, and these data are provided to the smart chips in the distributed computing system provided by the basic platform for calculation.
[0080] (2) Data
[0081] The data on the upper layer of the infrastructure is used to represent the data sources in the field of artificial intelligence. The data involves graphics, images, voice, text, and IoT data of traditional devices, including business data of existing systems and perception data such as force, displacement, liquid level, temperature, and humidity.
[0082] (3) Data processing
[0083] Data processing usually includes data training, machine learning, deep learning, search, reasoning, decision-making and other methods.
[0084] Among them, machine learning and deep learning can symbolize and formalize data for intelligent information modeling, extraction, preprocessing, and training.
[0085] Reasoning refers to the process of simulating human intelligent reasoning in computers or intelligent systems, using formalized information to perform machine thinking and solve problems based on reasoning control strategies. Typical functions are search and matching.
[0086] Decision-making refers to the process of making decisions after intelligent information is reasoned, usually providing functions such as classification, sorting, and prediction.
[0087] (4) General ability
[0088] After the data has undergone the data processing mentioned above, some general capabilities can be further formed based on the results of the data processing, such as an algorithm or a general system, for example, translation, text analysis, computer vision processing, speech recognition, image recognition, etc.
[0089] (5) Smart products and industry applications
[0090] Smart products and industry applications refer to the products and applications of artificial intelligence systems in various fields. They are the encapsulation of the overall artificial intelligence solution, which productizes intelligent information decision-making and realizes practical applications. Its application areas mainly include: smart terminals, smart transportation, smart medical care, autonomous driving, smart cities, etc.
[0091] Next, several application scenarios of this application are introduced.
[0092] Figure 2a A structural diagram of a table recognition system provided in an embodiment of the present application, the table recognition system includes a user device and a data processing device. The user device includes an intelligent terminal such as a mobile phone, a personal computer or an information processing center. The user device is the initiator of the table recognition, and as the initiator of the table recognition request, the request is usually initiated by the user through the user device.
[0093] The above-mentioned data processing device can be a device or server with data processing function such as a cloud server, a network server, an application server and a management server. The data processing device receives the table recognition request from the intelligent terminal through the interactive interface, and then performs table recognition processing in the form of machine learning, deep learning, search, reasoning, decision-making, etc. through the memory for storing data and the processor link for data processing. The memory in the data processing device can be a general term, including local storage and databases for storing historical data. The database can be on the data processing device or on other network servers.
[0094] exist Figure 2a In the table recognition system shown, the user device can receive the user's instructions. For example, the user can trigger / select an image containing a table to be recognized on the user device, and then initiate a request to the data processing device, so that the data processing device performs table recognition processing on the image on the user device, thereby obtaining a table recognition result for the image, that is, the table to be extracted. Exemplarily, the user can input to the user device or select an image containing a table to be recognized on the user device, and then the user device initiates a table recognition request for the application to the data processing device, so that the data processing device performs table recognition processing on the image, thereby obtaining a table recognition result for the image, that is, the table extracted from the image.
[0095] exist Figure 2a In the embodiment of the present application, the data processing device can execute the table recognition method.
[0096] Figure 2b Another structural diagram of the table recognition system provided in the embodiment of the present application is shown in FIG. Figure 2b In the embodiment, the user device directly serves as a data processing device. After determining an application triggered / selected by the user, the user device can directly perform table recognition processing on the application. The specific process is similar to Figure 2a Similarly, please refer to the above description and will not repeat them here.
[0097] exist Figure 2b In the table recognition system shown, the user device can receive user instructions. For example, the user can input into the user device or select an image containing a table to be recognized on the user device. The user device can then perform table recognition processing on the image to obtain a table recognition result for the image, i.e., a table extracted from the image.
[0098] exist Figure 2b In the embodiment of the present application, the user equipment itself can execute the table recognition method.
[0099] Figure 2cA schematic diagram of the related equipment for table identification provided in an embodiment of the present application.
[0100] Above Figure 2a and Figure 2b The user equipment in the example may specifically be Figure 2c The local device 301 or the local device 302 in Figure 2a The data processing device in the embodiment may be Figure 2c The execution device 210 in the embodiment, wherein the data storage system 250 can store the data to be processed by the execution device 210, and the data storage system 250 can be integrated on the execution device 210, or can be set on the cloud or other network servers.
[0101] Figure 2a and Figure 2b The processor in the system can perform data training / machine learning / deep learning through a neural network model or other models (for example, a model based on a support vector machine), and use the model finally trained or learned from the data to perform table recognition processing on the image, thereby obtaining corresponding processing results.
[0102] Figure 3 A schematic diagram of the system 100 architecture provided in an embodiment of the present application, Figure 3 In the embodiment, the execution device 110 is configured with an input / output (I / O) interface 112 for data interaction with an external device. The user can input data to the I / O interface 112 through the client device 140. The input data may include: various tasks to be scheduled, callable resources and other parameters in the embodiment of the application.
[0103] When the execution device 110 preprocesses the input data, or when the computing module 111 of the execution device 110 performs calculation and other related processing (such as implementing the function of the neural network in the present application), the execution device 110 can call the data, code, etc. in the data storage system 150 for the corresponding processing, and can also store the data, instructions, etc. obtained by the corresponding processing in the data storage system 150.
[0104] Finally, the I / O interface 112 returns the processing result to the client device 140 so as to provide it to the user.
[0105] It is worth noting that the training device 120 can generate corresponding target models / rules based on different training data for different goals or tasks, and the corresponding target models / rules can be used to achieve the above goals or complete the above tasks, thereby providing the user with the desired results. The training data can be stored in the database 130 and come from the training samples collected by the data collection device 160.
[0106] exist Figure 3 In the case shown in the figure, the user can manually give input data, and the manual giving can be operated through the interface provided by the I / O interface 112. In another case, the client device 140 can automatically send input data to the I / O interface 112. If the client device 140 is required to automatically send input data and needs to obtain the user's authorization, the user can set the corresponding authority in the client device 140. The user can view the results output by the execution device 110 on the client device 140, and the specific presentation form can be a specific method such as display, sound, action, etc. The client device 140 can also be used as a data acquisition terminal to collect the input data of the input I / O interface 112 and the output results of the output I / O interface 112 as shown in the figure as new sample data, and store them in the database 130. Of course, it is also possible not to collect through the client device 140, but the I / O interface 112 directly stores the input data of the input I / O interface 112 and the output results of the output I / O interface 112 as new sample data in the database 130.
[0107] It is worth noting that Figure 3 This is only a schematic diagram of a system architecture provided by an embodiment of the present application. The positional relationship between the devices, components, modules, etc. shown in the figure does not constitute any limitation. For example, in Figure 3 In the embodiment, the data storage system 150 is an external memory relative to the execution device 110. In other cases, the data storage system 150 may also be placed in the execution device 110. Figure 3 As shown, a neural network can be obtained by training according to the training device 120.
[0108] The present application also provides a chip including a neural network processor NPU. The chip can be arranged in Figure 3 The execution device 110 shown in FIG. 1 is used to complete the calculation work of the calculation module 111. The chip can also be set in Figure 3 The training device 120 shown is used to complete the training work of the training device 120 and output the target model / rule.
[0109] Neural network processor NPU, NPU is mounted on the main central processing unit (CPU) (host CPU) as a coprocessor, and the main CPU assigns tasks. The core part of NPU is the operation circuit, and the controller controls the operation circuit to extract data from the memory (weight memory or input memory) and perform operations.
[0110] In some implementations, the arithmetic circuit includes multiple processing units (process engines, PEs) inside. In some implementations, the arithmetic circuit is a two-dimensional systolic array. The arithmetic circuit can also be a one-dimensional systolic array or other electronic circuits capable of performing mathematical operations such as multiplication and addition. In some implementations, the arithmetic circuit is a general-purpose matrix processor.
[0111] For example, suppose there is an input matrix A, a weight matrix B, and an output matrix C. The operation circuit takes the corresponding data of matrix B from the weight memory and caches it on each PE in the operation circuit. The operation circuit takes the matrix A data from the input memory and performs matrix operations with matrix B. The partial results or final results of the matrix are stored in the accumulator.
[0112] The vector computing unit can further process the output of the operation circuit, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc. For example, the vector computing unit can be used for network calculations of non-convolutional / non-FC layers in neural networks, such as pooling, batch normalization, local response normalization, etc.
[0113] In some implementations, the vector computation unit can store the processed output vector to a unified buffer. For example, the vector computation unit can apply a nonlinear function to the output of the computation circuit, such as a vector of accumulated values, to generate an activation value. In some implementations, the vector computation unit generates a normalized value, a merged value, or both. In some implementations, the processed output vector can be used as an activation input to the computation circuit, such as for use in a subsequent layer in a neural network.
[0114] The unified memory is used to store input data and output data.
[0115] The weight data is directly transferred from the external memory to the input memory and / or the unified memory through the direct memory access controller (DMAC), the weight data in the external memory is stored in the weight memory, and the data in the unified memory is stored in the external memory.
[0116] The bus interface unit (BIU) is used to implement interaction between the main CPU, DMAC and instruction fetch memory through the bus.
[0117] An instruction fetch buffer connected to the controller, used to store instructions used by the controller;
[0118] The controller is used to call the instructions cached in the memory to control the working process of the computing accelerator.
[0119] Generally, the unified memory, input memory, weight memory and instruction fetch memory are all on-chip memories, and the external memory is a memory outside the NPU, which can be a double data rate synchronous dynamic random access memory (DDRSDRAM), a high bandwidth memory (HBM) or other readable and writable memory.
[0120] Since the embodiments of the present application involve the application of a large number of neural networks, in order to facilitate understanding, the relevant terms and related concepts such as neural networks involved in the embodiments of the present application are first introduced below.
[0121] (1) Neural Network
[0122] A neural network may be composed of neural units, and a neural unit may refer to an operation unit with xs and intercept 1 as input, and the output of the operation unit may be:
[0123]
[0124] Where s=1, 2, ...n, n is a natural number greater than 1, Ws is the weight of xs, and b is the bias of the neural unit. f is the activation function of the neural unit, which is used to introduce nonlinear characteristics into the neural network to convert the input signal in the neural unit into the output signal. The output signal of the activation function can be used as the input of the next convolution layer. The activation function can be a sigmoid function. A neural network is a network formed by connecting many of the above-mentioned single neural units together, that is, the output of one neural unit can be the input of another neural unit. The input of each neural unit can be connected to the local receptive field of the previous layer to extract the characteristics of the local receptive field. The local receptive field can be an area composed of several neural units.
[0125] The work of each layer in the neural network can be described by the mathematical expression y=a(Wx+b): From a physical level, the work of each layer in the neural network can be understood as completing the transformation from the input space to the output space (i.e., the row space to the column space of the matrix) through five operations on the input space (the set of input vectors). These five operations include: 1. Dimension increase / reduction; 2. Zoom in / out; 3. Rotation; 4. Translation; 5. "Bending". Among them, operations 1, 2, and 3 are completed by Wx, operation 4 is completed by +b, and operation 5 is implemented by a(). The word "space" is used here because the classified object is not a single thing, but a class of things, and space refers to the collection of all individuals of this class of things. Among them, W is a weight vector, and each value in the vector represents the weight value of a neuron in the neural network of this layer. The vector W determines the spatial transformation from the input space to the output space described above, that is, the weight W of each layer controls how to transform the space. The purpose of training a neural network is to finally obtain the weight matrix of all layers of the trained neural network (the weight matrix formed by many layers of vectors W). Therefore, the training process of a neural network is essentially about learning how to control spatial transformations, or more specifically, learning the weight matrix.
[0126] Because we want the output of the neural network to be as close as possible to the value we really want to predict, we compare the current network's predicted value with the target value we really want, and then update the weight vector of each layer of the neural network based on the difference between the two (of course, there is usually an initialization process before the first update, that is, pre-configuring parameters for each layer in the neural network). For example, if the network's predicted value is high, adjust the weight vector to make it predict a lower value, and keep adjusting until the neural network can predict the target value we really want. Therefore, it is necessary to predefine "how to compare the difference between the predicted value and the target value", which is the loss function or objective function, which are important equations used to measure the difference between the predicted value and the target value. Among them, taking the loss function as an example, the higher the output value (loss) of the loss function, the greater the difference, so the training of the neural network becomes a process of minimizing this loss as much as possible.
[0127] (2) Back propagation algorithm
[0128] Neural networks can use the error back propagation (BP) algorithm to correct the size of the parameters in the initial neural network model during the training process, so that the reconstruction error loss of the neural network model becomes smaller and smaller. Specifically, the forward transmission of the input signal to the output will generate error loss, and the parameters in the initial neural network model are updated by back propagating the error loss information, so that the error loss converges. The back propagation algorithm is a back propagation movement dominated by error loss, which aims to obtain the optimal parameters of the neural network model, such as the weight matrix.
[0129] The method provided in the present application is described below from the training side of the neural network and the application side of the neural network.
[0130] The model training method provided in the embodiment of the present application involves the processing of data sequences, and can be specifically applied to methods such as data training, machine learning, and deep learning, to perform symbolized and formalized intelligent information modeling, extraction, preprocessing, and training on the training data (for example, the first image, the second image, and the third image, etc. in the model training method provided in the embodiment of the present application), and finally obtain a trained neural network (such as the target model in the model training method provided in the embodiment of the present application); and the table recognition method provided in the embodiment of the present application can use the above-mentioned trained neural network to input input data (for example, the target image in the table recognition method provided in the embodiment of the present application, etc.) into the trained neural network to obtain output data (such as the table in the table recognition method provided in the embodiment of the present application, etc.). It should be noted that the model training method and the table recognition method provided in the embodiment of the present application are inventions based on the same concept, and can also be understood as two parts in a system, or two stages of an overall process: such as the model training stage and the model application stage.
[0131] The table recognition method provided in the embodiment of the present application can be implemented through the target model. Figure 4 A schematic diagram of the structure of the target model provided in the embodiment of the present application, such as Figure 4 As shown, the target model includes: a backbone network, an encoder, a first decoder, a second decoder, a fusion network and a segmentation network (segmentation head) and other modules, all of which are trained modules. Among them, the input end of the backbone network is the input end of the entire target model, the output end of the backbone network is respectively connected to the input end of the encoder and the input end of the fusion network, the output end of the encoder is respectively connected to the input end of the first decoder and the input end of the second decoder, the output end of the fusion network is connected to the input end of the segmentation network, the output end of the first decoder, the output end of the second decoder and the output end of the segmentation network serve as the output end of the entire target model. In order to understand the workflow of realizing table recognition based on the target model, the following is combined with Figure 5This workflow is further introduced. Figure 5 A flow chart of a table recognition method provided in an embodiment of the present application is shown as follows: Figure 5 As shown, the method includes:
[0132] 501. Obtain a target image, where the target image includes a table to be recognized.
[0133] In this embodiment, when table recognition is required, a target image may be obtained first, and the target image includes a table to be recognized, that is, the table to be recognized is presented in the form of an image. It can be understood that in the target image, the table to be recognized presented by the target image is composed of multiple cells and multiple texts, and each cell is filled with at least one text.
[0134] It is worth noting that for any cell in the table to be recognized, if the cell is filled with a line of text, the line of text can be regarded as a text, and if the cell is filled with multiple lines of text, the multiple lines of text can be regarded as multiple texts (multiple lines of text correspond to multiple texts one by one). The line of text involved here can be any of the following: a phrase, a sentence, a word, etc.
[0135] 502. Process the target image through the target model to obtain a plurality of cells of the table, first position information of the plurality of cells, and second position information of a plurality of separators between the plurality of cells.
[0136] After obtaining the target image, the target image can be input into the target model, so as to perform a series of processing on the target image through the target model, thereby obtaining a plurality of cells of the table to be identified, first position information of the plurality of cells (in the image coordinate system), and second position information of the plurality of separators between the plurality of cells (in the image coordinate system). The image coordinate system is constructed based on the target image, for example, the lower left vertex of the target image is used as the origin of the image coordinate system, etc., which is not limited here.
[0137] It is worth noting that, among the multiple cells, there is a separator between any two adjacent cells, and then, there are multiple separators between the multiple cells. Among the multiple separators, any separator can be any of the following: a solid line, a dotted line, a color block, a blank area, and the like.
[0138] Specifically, the target model may obtain multiple cells of the table, first position information of multiple cells, and second position information of multiple separators in the following manner:
[0139] (1) After obtaining the target image, the backbone network of the target model can perform feature extraction on the target image, thereby obtaining the visual features of the target image, and sending the visual features of the target image to the encoder and the fusion network. It should be noted that since the backbone network usually includes multiple feature extraction layers connected in series, the visual features of the target image include the initial visual features of the target image, the intermediate visual features of the target image, and the final visual features of the target image. In the backbone network, the first feature extraction layer can perform feature extraction on the target image (for example, convolution, full connection, downsampling, etc.), thereby obtaining the output of the first feature extraction layer (that is, the initial visual features of the target image), the second feature extraction layer can perform feature extraction on the output of the first feature extraction layer, thereby obtaining the output of the second feature extraction layer (that is, the intermediate visual features of the target image), the third feature extraction layer can perform feature extraction on the output of the second feature extraction layer, thereby obtaining the output of the third feature extraction layer (that is, the intermediate visual features of the target image), ..., the last feature extraction layer can perform feature extraction on the output of the second-to-last feature extraction layer, so that the output of the last feature extraction layer is the final visual features of the target image. Then, the backbone network can send the final visual features of the target image to the encoder, and send the intermediate visual features of part of the target image and the final visual features of the target image to the fusion network.
[0140] For example, Figure 6 As shown ( Figure 6 A structural diagram of a target model provided in an embodiment of the present application), the target model includes a backbone network, an encoder, a hypertext markup language (HTML) decoder, a position decoder, a fusion network, and a segmentation network. Assume that the backbone network includes several feature extraction layers. After receiving a target image containing a table, the several feature extraction layers of the backbone network extract features of the target image in turn. The output of the first feature extraction layer is the initial visual feature of the target image, the output of the second feature extraction layer is the intermediate visual feature of the target image, ..., and the output of the last feature extraction layer is the final visual feature of the target image. Then, the backbone network can send the output of the last feature extraction layer to the encoder, and send the outputs of the last three feature extraction layers to the fusion network.
[0141] (2) After obtaining the visual features of the target image, the encoder may first encode the visual features of the target image to obtain the encoded features of the target image, and send the encoded features of the target image to the first decoder and the second decoder respectively. It should be noted that after obtaining the final visual features of the target image, the encoder may encode the final visual features of the target image to obtain the encoded features of the target image.
[0142] Still like the above example, after obtaining the final visual features of the target image, the encoder can encode the final visual features of the target image to obtain the encoded features of the target image, and send the encoded features of the target image to the HTML decoder and the position decoder respectively.
[0143] (3) After obtaining the coding features of the target image, the first decoder can perform a first decoding on the coding features of the target image, thereby obtaining multiple cells of the table. It should be noted that at this time, the multiple cells of the table are presented in a programming language form (for example, HTML form, etc.).
[0144] Still like the above example, after obtaining the encoding features of the target image, the HTML decoder can decode the encoding features of the target image to obtain an HTML sequence, which can also be understood as multiple cells of a table presented in HTML form (the sequence contains descriptions of multiple cells). Figure 6 As shown in , in the HTML sequence, "..." is the first entire row in the table (the entire row contains two sub-rows and four sub-columns), "" is a cell in the first entire row that occupies two sub-rows, "" is a cell in the first entire row that occupies two sub-columns, and so on.
[0145] (4) After obtaining the coding features of the target image, the second decoder can perform a second decoding on the coding features of the target image (the first decoding and the second decoding are different decoding operations), thereby obtaining the first position information of multiple cells. It should be noted that the first position information of multiple cells can be understood as the coordinates of the decoding boxes (decbox) of the multiple cells in the image coordinate system. For any cell, the decoding box of the cell can be constructed by the second decoder based on the pixels occupied by the boundary of the cell (in the target image), so the coordinates of the decoding box of the cell can be approximately understood as the coordinates of the pixels occupied by the boundary of the cell. Due to the performance limitations of the second decoder itself, the difference between the two parts of the coordinates is still relatively large, that is, the decoding box of the cell cannot accurately overlap with the boundary of the cell, and there is a gap between the two.
[0146] Still like the above example, after obtaining the encoding features of the target image, the position decoder can decode the encoding features of the target image to obtain the coordinates of the decbox of multiple cells in the image coordinate system. The origin of the image coordinate system coincides with the lower left vertex of the target image. Figure 7 It can be known that Figure 7A schematic diagram of a decoding frame provided in an embodiment of the present application), after the position decoder parses the coordinates of the decbox of each cell, for any cell, the coordinates of the decbox of the cell are different from the coordinates of the boundary of the cell (the pixels occupied), that is, there is a large gap between the position of the decbox of the cell and the position of the cell (the boundary).
[0147] (5) After obtaining the visual features of the target image, the fusion network can perform feature fusion on the visual features of the target image to obtain the fused features of the target image. It should be noted that after obtaining the intermediate visual features of part of the target image and the final visual features of the target image, the fusion network can fuse (for example, add, multiply, concatenate, etc.) the intermediate visual features of part of the target image and the final visual features of the target image to obtain the fused features of the target image. Then, the fusion network can send the fused features of the target image to the segmentation network.
[0148] Still as in the above example, after obtaining the outputs of the last three feature extraction layers, that is, after obtaining the intermediate visual features of the two parts of the target image and the final visual features of the target image, the fusion network can fuse the intermediate visual features of the two parts of the target image and the final visual features of the target image to obtain the fused features of the target image, and send the fused features of the target image to the segmentation network.
[0149] (6) After obtaining the fusion features of the target image, the segmentation network can perform pixel-level classification on the fusion features of the target image (including the fusion features of all pixels in the target image) to divide all pixels of the target image into two parts. The first part of pixels is pixels occupied by multiple cells, and the second part of pixels is pixels occupied by multiple separators between multiple cells. Therefore, the coordinates of the pixels occupied by multiple separators (in the target image) in the image coordinate system can be obtained, that is, the second position information of the multiple separators.
[0150] Still as in the above example, after obtaining the fused features of the target image, the segmentation network can classify the fused features of the target image at the pixel level to obtain a separator mask. The separator mask contains the coordinates of multiple separators (occupied pixels) between multiple cells, that is, the positions of multiple separators.
[0151] 503. Perform text recognition on the target image to obtain multiple texts in the table and third position information of the multiple texts.
[0152] After obtaining the target image, text recognition can be directly performed on the target image to obtain multiple texts in the table to be recognized and the third position information of the multiple texts (in the image coordinate system). It should be noted that the third position information of the multiple texts can be understood as the coordinates of the text boxes of the multiple texts in the image coordinate system.
[0153] Still like the above example, after obtaining the target image, OCR can be performed on the target image to extract the coordinates of multiple texts in the table and the text boxes of multiple texts in the image coordinate system.
[0154] It should be understood that there is no particular order in which step 502 and step 503 are executed. Step 502 can be executed before or after step 503. Step 502 and step 503 can also be executed simultaneously.
[0155] 504. Determine fourth position information of the plurality of cells based on the second position information.
[0156] After obtaining the second position information of the plurality of separators, a series of processing may be performed on the second position information of the plurality of separators, thereby obtaining the fourth position information of the plurality of cells (in the image coordinate system).
[0157] Specifically, the fourth position information of multiple cells may be obtained in the following manner:
[0158] (1) After obtaining the second position information of multiple separators, since the backbone network will perform downsampling and other operations in the process of extracting the visual features of the target image, the size of the extracted visual features of the target image will be smaller than the size of the original target image. Correspondingly, the size of the fused features of the target image obtained based on the fusion of the visual features of the target image is also smaller than the size of the target image. Then, the second position information of the multiple separators obtained based on the fusion features of the target image is also the position information reduced to a certain extent. In order to restore the position information of the multiple separators that conform to the actual size, the second position information of the multiple separators can be enlarged based on the difference between the size of the target image and the size of the fusion features of the target image, so as to obtain the enlarged second position information of the multiple separators. It can be understood that the enlarged second position information of the multiple separators matches the position information of the target image (in the image coordinate system).
[0159] (2) After obtaining the enlarged second position information of the multiple separators, a connected domain search and calculation based on the circumscribed rectangular frame can be performed based on the enlarged second position information of the multiple separators, so as to obtain the fourth position information of the multiple cells. It should be noted that the fourth position information of the multiple cells can be understood as the coordinates of the segmentation boxes (segbox) of the multiple cells in the image coordinate system. For any cell, the segmentation box of the cell can be constructed based on the pixels occupied by several (for example, 4) separators around the cell, so the coordinates of the segmentation box of the cell can be basically equivalent to the coordinates of the pixels occupied by several separators around the cell, and the difference between the two parts of the coordinates is relatively small, that is, the segmentation box of the cell can basically overlap with the boundary of the cell, and there is basically no gap between the two.
[0160] As in the above example, after obtaining the coordinates of multiple separators, the coordinates of multiple separators can be searched for connected domains and calculated based on the external rectangular box, so as to obtain the coordinates of the segbox of multiple cells in the image coordinate system (in this process, cells with an area smaller than a preset threshold can also be eliminated). Figure 8 It can be known that Figure 8 A schematic diagram of a segmentation frame provided in an embodiment of the present application) is shown. After parsing the coordinates of the segbox of each cell, for any cell, the coordinates of the segbox of the cell and the coordinates of the boundary of the cell (the pixels occupied) are almost the same, that is, there is almost no difference between the position of the segbox of the cell and the position of the cell (the boundary).
[0161] 505. Based on the first position information, the third position information, and the fourth position information, multiple cells and multiple texts are matched to obtain a table.
[0162] After obtaining the first position information of the multiple cells, the third position information of the multiple texts, and the fourth position information of the multiple cells, the first position information of the multiple cells, the third position information of the multiple texts, and the fourth position information of the multiple cells can be comprehensively processed to complete the matching between the multiple cells and the multiple texts, thereby merging the multiple cells and the multiple texts into the required table. At this point, the table recognition is completed.
[0163] Specifically, you can obtain the required forms in the following ways:
[0164] (1) Since the outputs of the first decoder and the second decoder are parallel, that is, each time the first decoder outputs a cell, the second decoder will simultaneously output the first position information of the cell, that is, the first correspondence between multiple cells and the first position information of multiple cells can be directly obtained, and the first correspondence can also be understood as the correspondence between multiple cells and multiple decoding frames. Similarly, when performing text recognition, each time a text is obtained, the third position information of the text is also obtained at the same time, so the second correspondence between multiple texts and the third position information can be directly obtained, and the second correspondence can also be understood as the correspondence between multiple texts and multiple text frames.
[0165] As in the above example, when the HTML decoder outputs each cell presented in HTML format, the position encoder will also output the coordinates of the decbox of the cell accordingly. Then, the coordinates of the multiple cells output by the HTML decoder and the multiple decboxes of the multiple cells output by the position encoder are corresponding, which is equivalent to obtaining the corresponding relationship between the multiple cells and the multiple decboxes.
[0166] Similarly, when performing OCR, each time a text is obtained, the coordinates of the text box of the text are also obtained accordingly. Then, the coordinates of the multiple texts and the multiple text boxes of the multiple texts obtained in the end are corresponding, which is equivalent to obtaining the corresponding relationship between the multiple texts and the multiple text boxes.
[0167] (2) Furthermore, a first match (for example, center matching, etc.) can be performed on the fourth position information of multiple cells and the third position information of multiple texts to obtain a third correspondence between the fourth position information of multiple cells and the third position information of multiple texts. The third correspondence can also be understood as a correspondence between multiple text boxes and multiple segmentation boxes.
[0168] Still like the above example, the coordinates of multiple segboxes and the coordinates of multiple text boxes can be centrally matched to obtain the corresponding relationship between the multiple segboxes and the multiple text boxes.
[0169] (3) Furthermore, a second match (for example, Hungarian matching, etc.) can be performed on the fourth position information of the multiple cells and the first position information of the multiple cells to obtain a fourth correspondence between the fourth position information of the multiple cells and the first position information of the multiple cells. The fourth correspondence can also be understood as a correspondence between multiple decoding frames and multiple segmentation frames.
[0170] Still like the above example, Hungarian matching can be performed on the coordinates of multiple segboxes and the coordinates of multiple decboxes to obtain the corresponding relationship between multiple segboxes and multiple decboxes.
[0171] (4) Since the first correspondence, the second correspondence, the third correspondence and the fourth correspondence are all known, and since the first correspondence is the correspondence between multiple cells and multiple decoding boxes, the second correspondence is the correspondence between multiple texts and multiple text boxes, the third correspondence is the correspondence between multiple text boxes and multiple segmentation boxes, and the fourth correspondence is the correspondence between multiple decoding boxes and multiple segmentation boxes, these four groups of correspondences can be combined to finally obtain the correspondence between multiple cells and multiple texts (multiple texts → multiple text boxes → multiple segmentation boxes → multiple decoding boxes → multiple cells). According to the correspondence, multiple texts can be accurately filled into multiple cells, thereby obtaining the required table. It should be noted that the table obtained at this time is a table presented in HTML format, and the table can be converted into a table presented in Excel format, so the table presented in Excel format is directly provided to the user for viewing and use.
[0172] Still as in the above example, after successfully matching multiple segboxes with multiple text boxes, and matching multiple segboxes with multiple decboxes, it is equivalent to matching multiple text boxes with multiple decboxes, and then it is equivalent to matching multiple texts with multiple cells (because multiple cells have been matched with multiple decboxes, and multiple segboxes have been matched with multiple text boxes), so multiple texts can be filled into multiple cells accordingly, so as to obtain a table presented in HTML format, and convert it into a table presented in Excel format.
[0173] In addition, the table recognition method provided in the embodiment of the present application can be compared with the table recognition method provided in the related art. The comparison results are shown in Table 1:
[0174] Table 1
[0175] method Related Technology 1 Related Technology 2 Related Technology 3 Related Technology 4 Embodiments of the present application Indicator 1 96.75 97.23 97.10 97.20 97.47
[0176] Based on Table 1, it can be seen that the table recognition method provided in the embodiment of the present application has better performance.
[0177] In an embodiment of the present application, when table recognition is required, a target image containing a table to be recognized may be first obtained. After obtaining the target image, the target image may be input into a target model so that the target image may be processed by the target model to obtain a plurality of cells of the table, first position information of the plurality of cells, and second position information of the plurality of separators between the plurality of cells, respectively. After obtaining the target image, text recognition may also be performed on the target image to obtain a plurality of texts of the table and third position information of the plurality of texts. Then, the second position information of the plurality of separators may be used to determine the fourth position information of the plurality of cells. Finally, the first position information of the plurality of cells, the third position information of the plurality of texts, and the fourth position information of the plurality of cells may be comprehensively considered to complete the matching between the plurality of cells and the plurality of texts, thereby obtaining the required table. In the above process, the target model includes the first position information of multiple cells and the third position information of multiple separators between the multiple cells, and the third position information of the multiple separators is used to calculate the fourth position information of the multiple cells. Therefore, when performing table recognition, not only the first position information of the multiple cells output by the model is considered, but also the calculated fourth position information of the multiple cells is considered. The factors considered are relatively comprehensive. Even if the first position information of the multiple cells is not accurate enough, the fourth position information of the multiple cells is accurate enough (because it takes into account the influence of the separators between the cells). In this way, the matching between the multiple cells and the multiple texts can be correctly completed, thereby obtaining the correct table and improving the user experience.
[0178] The above is a detailed description of the table recognition method provided in the embodiment of the present application. The following will introduce the model training method provided in the embodiment of the present application. Fig. 9 A flow chart of the model training method provided in the embodiment of the present application is as follows: Fig. 9 As shown, the method includes:
[0179] 901. Acquire a first image, where the first image includes a first table to be identified.
[0180] In this embodiment, when the model to be trained needs to be trained, a batch of training data may be first obtained, the batch of training data includes a first image, and the first image includes a first table to be recognized. It should be noted that, for the first image, the real HTML sequence corresponding to the first table (including the real description of the first cells of the first table), the real position information of the first cells of the first table, and the real position information of the first separators between the first cells are known.
[0181] 902. Process the first image by using the model to be trained to obtain multiple first cells of the first table, fifth position information of the multiple first cells, and sixth position information of multiple first separators between the multiple first cells.
[0182] After obtaining the first image, the first image can be input into the model to be trained so as to process the first image through the model to be trained to obtain the (predicted) HTML sequence corresponding to the first table (including predicted descriptions of multiple first cells, which sequence can also be understood as multiple first cells predicted by the model), the fifth position information of the multiple first cells (can also be called the predicted position information of the multiple first cells), and the sixth position information of the multiple first separators between the multiple first cells (can also be called the predicted position information of the multiple first separators).
[0183] In one possible implementation, processing the first image through the model to be trained to obtain multiple first cells of the first table includes: extracting features of the first image through the model to be trained to obtain visual features of the first image; encoding and first decoding the visual features of the first image through the model to be trained to obtain multiple first cells of the first table.
[0184] In one possible implementation, processing the first image through the model to be trained to obtain the fifth position information of multiple first cells includes: encoding the visual features of the first image through the model to be trained and performing a second decoding to obtain the fifth position information of multiple first cells.
[0185] In one possible implementation, the first image is processed by the model to be trained to obtain the sixth position information of multiple first separators between multiple first cells, including: performing feature fusion on the visual features of the first image by the model to be trained to obtain the fusion features of the first image; and classifying the fusion features of the first image by the model to be trained to obtain the sixth position information of multiple first separators between multiple first cells.
[0186] For the introduction of step 902, please refer to the above Figure 5 The relevant description of step 502 in the illustrated embodiment will not be repeated here.
[0187] 903. Based on the fifth position information and the sixth position information, train the model to be trained to obtain a target model.
[0188] After obtaining the HTML sequence corresponding to the first table, the fifth position information of the multiple first cells, and the sixth position information of the multiple first separators, since the real HTML sequence corresponding to the first table, the real position information of the multiple first cells, and the real position information of the multiple first separators are known, the HTML sequence corresponding to the first table, the fifth position information of the multiple first cells, the sixth position information of the multiple first separators, the real HTML sequence corresponding to the first table, the real position information of the multiple first cells, and the real position information of the multiple first separators can be calculated using a preset first loss function to obtain a first loss, and the first loss is used to indicate the difference between the HTML sequence corresponding to the first table and the real HTML sequence corresponding to the first table, the difference between the fifth position information of the multiple first cells and the real position information of the multiple first cells, and the difference between the sixth position information of the multiple first separators and the real position information of the multiple first separators.
[0189] After obtaining the first loss, the parameters of the model to be trained can be updated based on the first loss, thereby obtaining the model to be trained after the updated parameters, and the next batch of training data is used to continue training the model to be trained after the updated parameters until the model training conditions are met (for example, the first loss converges, etc.), thereby obtaining Figure 5 Target model in the illustrated embodiment.
[0190] Furthermore, before executing step 901 to step 903, a model to be trained may be constructed first. The model to be trained may be constructed in a variety of ways (segmentation pre-training method and self-supervised pre-training method):
[0191] (1) When it is necessary to obtain a model to be trained, a batch of training data may be first obtained, the batch of training data including a second image, the second image including a second table to be recognized. It should be noted that, for the second image, the actual position information of the plurality of second separators between the plurality of second cells of the second table is known.
[0192] After obtaining the second image, the second image can be input into the backbone network to be trained and the segmentation network to be trained, so as to process the second image through the backbone network to be trained and the segmentation network to be trained, thereby obtaining the seventh position information of multiple second separators between multiple second cells of the second table (also called predicted position information of multiple second separators).
[0193] After obtaining the seventh position information of multiple second separators, since the real position information of the multiple second separators is known, the seventh position information of the multiple second separators and the real position information of the multiple second separators can be calculated through a preset second loss function to obtain the second loss, and the second loss is used to indicate the difference between the seventh position information of the multiple second separators and the real position information of the multiple second separators.
[0194] After obtaining the second loss, the parameters of the backbone network to be trained can be updated based on the second loss to obtain the backbone network with updated parameters, and the backbone network with updated parameters can be continuously trained using the next batch of training data until the model training conditions are met (for example, the second loss converges, etc.), thereby obtaining the pre-trained backbone network.
[0195] After obtaining the pre-trained backbone network, the model to be trained can be constructed using the pre-trained backbone network, the encoder to be trained, the first decoder to be trained, the second decoder to be trained, the fusion network to be trained, and the segmentation network to be trained.
[0196] For example, Fig.10 As shown ( Fig.10 A framework schematic diagram of segmentation pre-training provided in an embodiment of the present application) can use the table image to input into the backbone network to be trained and the segmentation head (segmentation network) to be trained to obtain the predicted delimiter mask, and then use the real delimiter mask and the predicted delimiter mask to train the backbone network to be trained, thereby obtaining the pre-trained backbone network.
[0197] Then, the model to be trained can be constructed based on the pre-trained backbone network, the encoder to be trained, the HTML decoder to be trained, the position decoder to be trained, the fusion network to be trained, and the segmentation head to be trained.
[0198] (2) When it is necessary to obtain a model to be trained, a batch of training data may be obtained first. The batch of training data may include a second image and a third image. The second image includes a second table to be identified, and the third image includes a third table to be identified. It should be noted that the second image and the third image may be derived from the same image. That is, the table contained in the image may be delimited by separator enhancement (conversion of the form of separators) to obtain the second image and the third image. Then, the second table contained in the second image and the third table contained in the third image are derived from the table contained in the image. That is, the text content contained in the second table is the same as the text content contained in the third table, but the separator contained in the second table and the separator contained in the third table are of different forms (of course, the second image and the second image may also be derived from two different images, so the second table and the third table are two completely different tables).
[0199] After obtaining the second image and the third image, the second image and the third image can be input into the backbone network to be trained, and the second image and the third image can be processed by the backbone network to be trained to obtain the visual features of the second image and the visual features of the third image.
[0200] The visual features of the second image and the visual features of the third image are obtained. The visual features of the second image and the visual features of the third image can be calculated by a preset third loss function to obtain a third loss, and the third loss is used to indicate the difference between the visual features of the second image and the visual features of the third image.
[0201] After obtaining the third loss, the parameters of the backbone network to be trained can be updated based on the third loss to obtain the backbone network with updated parameters, and the backbone network with updated parameters can be continuously trained using the next batch of training data until the model training conditions are met (for example, the third loss converges, etc.), thereby obtaining the pre-trained backbone network.
[0202] After obtaining the pre-trained backbone network, the model to be trained can be constructed using the pre-trained backbone network, the encoder to be trained, the first decoder to be trained, the second decoder to be trained, the fusion network to be trained, and the segmentation network to be trained.
[0203] For example, Fig.11 As shown ( Fig.11 A schematic diagram of separator enhancement provided in an embodiment of the present application) is shown. After obtaining the original image (the original image contains a framed table), all frame lines of the table in the original image can be removed to obtain an image of a frameless table, and then separator enhancement is performed on the image to obtain an image of a table with few frame lines, an image of a table with full frame lines, and an image of a color block table.
[0204] like Fig.12 As shown ( Fig.12 A framework diagram of self-supervised pre-training provided in an embodiment of the present application) can use the image of the full-frame table and the image of the color block table to input into the backbone network to be trained and the projection head to obtain the feature representation of the two images, and then use the feature representation of the two images to train the backbone network to be trained, thereby obtaining the pre-trained backbone network.
[0205] Then, the model to be trained can be constructed based on the pre-trained backbone network, the encoder to be trained, the HTML decoder to be trained, the position decoder to be trained, the fusion network to be trained, and the segmentation head to be trained.
[0206] In addition, the target model trained in the embodiment of the present application (through segmentation pre-training and self-supervised pre-training) can be compared with the model trained by the related technology. The comparison results are shown in Table 2 and Table 3:
[0207] Table 2
[0208]
[0209] Table 3
[0210]
[0211] Based on Tables 2 and 3, it can be seen that no matter which method is used to train the target model, the performance of the target model is better than the model trained by related technologies, and the self-supervised pre-training method is better than the segmentation pre-training method.
[0212] In addition, the backbone models trained in the embodiments of the present application (through segmentation pre-training and self-supervised pre-training) can also be compared, and the comparison results are shown in Table 4 and Table 5:
[0213] Table 4
[0214] set up Baseline Segmentation Pre-training Self-supervised pre-training Dataset 1 93.7254 96.0480 96.4825 Dataset 2 95.6014 96.7568 97.7145 Dataset 3 67.7351 71.5732 74.8981
[0215] Table 5
[0216] set up Baseline Segmentation Pre-training Self-supervised pre-training Dataset 1 94.5336 94.7593 95.3500 Dataset 2 98.4151 98.5635 98.8969 Dataset 3 73.6368 74.6732 74.9954
[0217] Based on Tables 2 and 3, it can be seen that the backbone network obtained by self-supervised pre-training is better than the backbone network obtained by segmentation pre-training.
[0218] The target model obtained by training in the embodiment of the present application can be used for table recognition. Specifically, when table recognition is required, a target image containing a table to be recognized can be obtained first. After obtaining the target image, the target image can be input into the target model to process the target image through the target model, thereby obtaining multiple cells of the table, the first position information of multiple cells, and the second position information of multiple separators between the multiple cells. After obtaining the target image, text recognition can also be performed on the target image, thereby obtaining multiple texts of the table and the third position information of multiple texts. Then, the second position information of multiple separators can be used to determine the fourth position information of multiple cells. Finally, the first position information of multiple cells, the third position information of multiple texts, and the fourth position information of multiple cells can be comprehensively considered to complete the matching between multiple cells and multiple texts, thereby obtaining the required table. In the above process, the target model includes the first position information of multiple cells and the third position information of multiple separators between the multiple cells, and the third position information of the multiple separators is used to calculate the fourth position information of the multiple cells. Therefore, when performing table recognition, not only the first position information of the multiple cells output by the model is considered, but also the calculated fourth position information of the multiple cells is considered. The factors considered are relatively comprehensive. Even if the first position information of the multiple cells is not accurate enough, the fourth position information of the multiple cells is accurate enough (because it takes into account the influence of the separators between the cells). In this way, the matching between the multiple cells and the multiple texts can be correctly completed, thereby obtaining the correct table and improving the user experience.
[0219] The above is a detailed description of the table recognition method and the model training method provided in the embodiments of the present application. The following will introduce the table recognition device and the model training device provided in the embodiments of the present application. Fig.13 A schematic diagram of a structure of a table recognition device provided in an embodiment of the present application, such as Fig.13 As shown, the device comprises:
[0220] An acquisition module 1301 is used to acquire a target image, where the target image includes a table to be recognized;
[0221] A processing module 1302 is used to process the target image through the target model to obtain a plurality of cells of the table, first position information of the plurality of cells, and second position information of a plurality of separators between the plurality of cells;
[0222] The recognition module 1303 is used to perform text recognition on the target image to obtain multiple texts in the table and third position information of the multiple texts;
[0223] A determination module 1304 is used to determine fourth position information of the plurality of cells based on the second position information;
[0224] The matching module 1305 is used to match multiple cells and multiple texts based on the first position information, the third position information and the fourth position information to obtain a table.
[0225] In an embodiment of the present application, when table recognition is required, a target image containing a table to be recognized may be first obtained. After obtaining the target image, the target image may be input into a target model so that the target image may be processed by the target model to obtain a plurality of cells of the table, first position information of the plurality of cells, and second position information of the plurality of separators between the plurality of cells, respectively. After obtaining the target image, text recognition may also be performed on the target image to obtain a plurality of texts of the table and third position information of the plurality of texts. Then, the second position information of the plurality of separators may be used to determine the fourth position information of the plurality of cells. Finally, the first position information of the plurality of cells, the third position information of the plurality of texts, and the fourth position information of the plurality of cells may be comprehensively considered to complete the matching between the plurality of cells and the plurality of texts, thereby obtaining the required table. In the above process, the target model includes the first position information of multiple cells and the third position information of multiple separators between the multiple cells, and the third position information of the multiple separators is used to calculate the fourth position information of the multiple cells. Therefore, when performing table recognition, not only the first position information of the multiple cells output by the model is considered, but also the calculated fourth position information of the multiple cells is considered. The factors considered are relatively comprehensive. Even if the first position information of the multiple cells is not accurate enough, the fourth position information of the multiple cells is accurate enough (because it takes into account the influence of the separators between the cells). In this way, the matching between the multiple cells and the multiple texts can be correctly completed, thereby obtaining the correct table and improving the user experience.
[0226] In one possible implementation, the processing module 1302 is used to: extract features of a target image through a target model to obtain visual features of the target image; encode and first decode the visual features of the target image through the target model to obtain multiple cells of a table.
[0227] In a possible implementation, the processing module 1302 is used to encode and second decode the visual features of the target image through the target model to obtain first position information of multiple cells.
[0228] In one possible implementation, the processing module 1302 is used to: perform feature fusion on the visual features of the target image through the target model to obtain fused features of the target image; and classify the fused features of the target image through the target model to obtain second position information of multiple separators between multiple cells.
[0229] In one possible implementation, the determination module 1304 is used to: amplify the second position information based on the difference between the size of the target image and the size of the fusion feature of the target image to obtain the amplified second position information of multiple separators, the size of the target image being larger than the size of the fusion feature of the target image; and calculate the amplified second position information to obtain the fourth position information of multiple cells.
[0230] In one possible implementation, the matching module 1305 is used to: obtain a first correspondence between multiple cells and first position information, and a second correspondence between multiple texts and third position information; perform a first match between the fourth position information and the third position information to obtain a third correspondence between the fourth position information and the third position information; perform a second match between the fourth position information and the first position information to obtain a fourth correspondence between the fourth position information and the first position information; and fill multiple texts into multiple cells according to the first correspondence, the second correspondence, the third correspondence and the fourth correspondence to obtain a table.
[0231] In a possible implementation, the first matching is a center matching, and the second matching is a Hungarian matching.
[0232] Fig.14 A structural diagram of a model training device provided in an embodiment of the present application, such as Fig.14 As shown, the device comprises:
[0233] An acquisition module 1401 is used to acquire a first image, where the first image includes a first table to be identified;
[0234] A processing module 1402 is used to process the first image by using the model to be trained to obtain a plurality of first cells of the first table, fifth position information of the plurality of first cells, and sixth position information of a plurality of first separators between the plurality of first cells;
[0235] The training module 1403 is used to train the model to be trained based on the fifth position information and the sixth position information to obtain a target model.
[0236] The target model obtained by training in the embodiment of the present application can be used for table recognition. Specifically, when table recognition is required, a target image containing a table to be recognized can be obtained first. After obtaining the target image, the target image can be input into the target model to process the target image through the target model, thereby obtaining multiple cells of the table, the first position information of multiple cells, and the second position information of multiple separators between the multiple cells. After obtaining the target image, text recognition can also be performed on the target image, thereby obtaining multiple texts of the table and the third position information of multiple texts. Then, the second position information of multiple separators can be used to determine the fourth position information of multiple cells. Finally, the first position information of multiple cells, the third position information of multiple texts, and the fourth position information of multiple cells can be comprehensively considered to complete the matching between multiple cells and multiple texts, thereby obtaining the required table. In the above process, the target model includes the first position information of multiple cells and the third position information of multiple separators between the multiple cells, and the third position information of the multiple separators is used to calculate the fourth position information of the multiple cells. Therefore, when performing table recognition, not only the first position information of the multiple cells output by the model is considered, but also the calculated fourth position information of the multiple cells is considered. The factors considered are relatively comprehensive. Even if the first position information of the multiple cells is not accurate enough, the fourth position information of the multiple cells is accurate enough (because it takes into account the influence of the separators between the cells). In this way, the matching between the multiple cells and the multiple texts can be correctly completed, thereby obtaining the correct table and improving the user experience.
[0237] In one possible implementation, the device also includes: a construction module, which is used to: obtain a second image, the second image contains a second table to be identified; process the second image through a backbone network to be trained and a segmentation network to be trained to obtain seventh position information of multiple second separators between multiple second cells of the second table; train the backbone network to be trained based on the seventh position information to obtain a pre-trained backbone network; and construct a model to be trained based on the pre-trained backbone network and the segmentation network to be trained.
[0238] In one possible implementation, the device also includes: a construction module, used to: obtain a second image and a third image, the second image contains a second table to be identified, and the third image contains a third table to be identified; process the second image and the third image through a backbone network to be trained to obtain visual features of the second image and visual features of the third image; train the backbone network to be trained based on the visual features of the second image and the visual features of the third image to obtain a pre-trained backbone network; and construct a model to be trained based on the pre-trained backbone network.
[0239] In a possible implementation manner, the second image and the third image are derived from the same image, and the second table and the third table are derived from the same table.
[0240] In one possible implementation, the processing module 1402 is used to: extract features of the first image through the model to be trained to obtain visual features of the first image; encode and decode the visual features of the first image through the model to be trained to obtain multiple first cells of the first table.
[0241] In one possible implementation, the processing module 1402 is used to: encode and second decode the visual features of the first image using the model to be trained to obtain fifth position information of the plurality of first cells.
[0242] In one possible implementation, the processing module 1402 is used to: perform feature fusion on the visual features of the first image through the model to be trained to obtain fused features of the first image; classify the fused features of the first image through the model to be trained to obtain sixth position information of multiple first separators between multiple first cells.
[0243] It should be noted that the information interaction, execution process, etc. between the modules / units of the above-mentioned device are based on the same concept as the method embodiment of the present application, and the technical effects they bring are the same as those of the method embodiment of the present application. For specific contents, please refer to the description in the method embodiment shown above in the embodiment of the present application, and will not be repeated here.
[0244] The embodiment of the present application also relates to an execution device, Fig.15 A schematic diagram of the structure of the execution device provided in the embodiment of the present application. Fig.15 As shown, the execution device 1500 can be specifically a mobile phone, a tablet, a laptop, a smart wearable device, a server, etc., which is not limited here. Fig.13 The table recognition device described in the corresponding embodiment is used to implement Figure 5 Specifically, the execution device 1500 includes: a receiver 1501, a transmitter 1502, a processor 1503 and a memory 1504 (wherein the number of the processor 1503 in the execution device 1500 can be one or more, Fig.15 In the example of FIG. 1501 , the processor 1503 may include an application processor 15031 and a communication processor 15032. In some embodiments of the present application, the receiver 1501, the transmitter 1502, the processor 1503 and the memory 1504 may be connected via a bus or other means.
[0245] The memory 1504 may include a read-only memory and a random access memory, and provides instructions and data to the processor 1503. A portion of the memory 1504 may also include a non-volatile random access memory (NVRAM). The memory 1504 stores processor and operation instructions, executable modules or data structures, or subsets thereof, or extended sets thereof, wherein the operation instructions may include various operation instructions for implementing various operations.
[0246] The processor 1503 controls the operation of the execution device. In a specific application, the various components of the execution device are coupled together through a bus system, wherein the bus system includes not only a data bus but also a power bus, a control bus, and a status signal bus, etc. However, for the sake of clarity, various buses are referred to as bus systems in the figure.
[0247] The method disclosed in the above embodiment of the present application can be applied to the processor 1503, or implemented by the processor 1503. The processor 1503 can be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 1503. The above processor 1503 can be a general processor, a digital signal processor (digital signal processing, DSP), a microprocessor or a microcontroller, and can further include an application specific integrated circuit (application specific integrated circuit, ASIC), a field programmable gate array (field-programmable gate array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The processor 1503 can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to execute, or the hardware and software modules in the decoding processor can be combined and executed. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 1504, and the processor 1503 reads the information in the memory 1504 and completes the steps of the above method in combination with its hardware.
[0248] The receiver 1501 can be used to receive input digital or character information and generate signal input related to the relevant settings and function control of the execution device. The transmitter 1502 can be used to output digital or character information through the first interface; the transmitter 1502 can also be used to send instructions to the disk group through the first interface to modify the data in the disk group; the transmitter 1502 can also include a display device such as a display screen.
[0249] In one embodiment of the present application, the processor 1503 is configured to: Figure 5 Corresponding to the target model in the embodiment, the required table is identified from the target image.
[0250] The present application also relates to a training device. Fig.16 A schematic diagram of the structure of the training device provided in the embodiment of the present application. Fig.16 As shown, the training device 1600 is implemented by one or more servers. The training device 1600 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 1616 (for example, one or more processors) and memory 1632, one or more storage media 1630 (for example, one or more mass storage devices) storing application programs 1642 or data 1644. Among them, the memory 1632 and the storage medium 1630 can be short-term storage or permanent storage. The program stored in the storage medium 1630 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the training device. Furthermore, the central processing unit 1616 can be configured to communicate with the storage medium 1630 to execute a series of instruction operations in the storage medium 1630 on the training device 1600.
[0251] The training device 1600 may also include one or more power supplies 1626, one or more wired or wireless network interfaces 1650, one or more input and output interfaces 1658; or, one or more operating systems 1641, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
[0252] Specifically, the training device can perform Fig. 9 The model training method in the corresponding embodiment is used to obtain the target model.
[0253] An embodiment of the present application also relates to a computer storage medium, in which a program for signal processing is stored. When the program is run on a computer, the computer executes the steps executed by the aforementioned execution device, or the computer executes the steps executed by the aforementioned training device.
[0254] An embodiment of the present application also relates to a computer program product, which stores instructions, which, when executed by a computer, enable the computer to execute the steps executed by the aforementioned execution device, or enable the computer to execute the steps executed by the aforementioned training device.
[0255] The execution device, training device or terminal device provided in the embodiments of the present application may specifically be a chip, and the chip includes: a processing unit and a communication unit, wherein the processing unit may be, for example, a processor, and the communication unit may be, for example, an input / output interface, a pin or a circuit, etc. The processing unit may execute the computer execution instructions stored in the storage unit so that the chip in the execution device executes the data processing method described in the above embodiment, or so that the chip in the training device executes the data processing method described in the above embodiment. Optionally, the storage unit is a storage unit in the chip, such as a register, a cache, etc. The storage unit may also be a storage unit located outside the chip in the wireless access device, such as a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM), etc.
[0256] For details, please refer to Fig.17 , Fig.17 A schematic diagram of the structure of a chip provided in an embodiment of the present application, the chip can be expressed as a neural network processor NPU 1700, NPU 1700 is mounted on the host CPU (Host CPU) as a coprocessor, and the host CPU assigns tasks. The core part of the NPU is the operation circuit 1703, which is controlled by the controller 1704 to extract matrix data from the memory and perform multiplication operations.
[0257] In some implementations, the operation circuit 1703 includes multiple processing units (Process Engine, PE) inside. In some implementations, the operation circuit 1703 is a two-dimensional systolic array. The operation circuit 1703 can also be a one-dimensional systolic array or other electronic circuits capable of performing mathematical operations such as multiplication and addition. In some implementations, the operation circuit 1703 is a general-purpose matrix processor.
[0258] For example, assume there is an input matrix A, a weight matrix B, and an output matrix C. The operation circuit takes the corresponding data of matrix B from the weight memory 1702 and caches it on each PE in the operation circuit. The operation circuit takes the matrix A data from the input memory 1701 and performs matrix operation with matrix B, and the partial result or final result of the matrix is stored in the accumulator 1708.
[0259] The unified memory 1706 is used to store input data and output data. The weight data is directly transferred to the weight memory 1702 through the direct memory access controller (DMAC) 1705. The input data is also transferred to the unified memory 1706 through the DMAC.
[0260] BIU stands for Bus Interface Unit, i.e., bus interface unit 1713 , which is used for the interaction between AXI bus, DMAC and instruction fetch buffer (IFB) 1709 .
[0261] The bus interface unit 1713 (Bus Interface Unit, BIU for short) is used for the instruction fetch memory 1709 to obtain instructions from the external memory, and is also used for the storage unit access controller 1705 to obtain the original data of the input matrix A or the weight matrix B from the external memory.
[0262] DMAC is mainly used to transfer input data in the external memory DDR to the unified memory 1706 or to transfer weight data to the weight memory 1702 or to transfer input data to the input memory 1701.
[0263] The vector calculation unit 1707 includes multiple operation processing units, and further processes the output of the operation circuit 1703 when necessary, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc. It is mainly used for non-convolutional / fully connected layer network calculations in neural networks, such as Batch Normalization, pixel-level summation, upsampling of predicted label planes, etc.
[0264] In some implementations, the vector calculation unit 1707 can store the processed output vector to the unified memory 1706. For example, the vector calculation unit 1707 can apply a linear function; or a nonlinear function to the output of the operation circuit 1703, such as linear interpolation of the predicted label plane extracted by the convolution layer, and then, for example, a vector of accumulated values to generate an activation value. In some implementations, the vector calculation unit 1707 generates a normalized value, a pixel-level summed value, or both. In some implementations, the processed output vector can be used as an activation input to the operation circuit 1703, for example, for use in a subsequent layer in a neural network.
[0265] An instruction fetch buffer 1709 connected to the controller 1704 is used to store instructions used by the controller 1704;
[0266] Unified memory 1706, input memory 1701, weight memory 1702 and instruction fetch memory 1709 are all on-chip memories. External memories are private to the NPU hardware architecture.
[0267] The processor mentioned in any of the above places may be a general-purpose central processing unit, a microprocessor, an ASIC, or one or more integrated circuits for controlling the execution of the above program.
[0268] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.
[0269] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0270] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0271] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.
Claims
1. A table recognition method, characterized in that: The method comprises: Acquire a target image, wherein the target image includes a table to be recognized; Processing the target image through a target model to obtain a plurality of cells of the table, first position information of the plurality of cells, and second position information of a plurality of separators between the plurality of cells; Performing text recognition on the target image to obtain a plurality of texts in the table and third position information of the plurality of texts; Based on the second position information, determining fourth position information of the plurality of cells; Based on the first position information, the third position information and the fourth position information, the multiple cells and the multiple texts are matched to obtain the table.
2. The method according to claim 1, characterized in that: The target image is processed by the target model to obtain a plurality of cells of the table, including: Extracting features of the target image using a target model to obtain visual features of the target image; The visual features of the target image are encoded and first decoded by the target model to obtain a plurality of cells of the table.
3. The method according to claim 1 or 2, characterized in that: The processing of the target image by using the target model to obtain the first position information of the plurality of cells includes: The visual features of the target image are encoded and second decoded through the target model to obtain the first position information of the multiple cells.
4. The method according to any one of claims 1 to 3, characterized in that: The processing of the target image by using the target model to obtain the second position information of the plurality of separators between the plurality of cells comprises: Performing feature fusion on the visual features of the target image through the target model to obtain fusion features of the target image; The fusion features of the target image are classified by the target model to obtain second position information of the multiple separators between the multiple cells.
5. The method according to any one of claims 1 to 4, characterized in that: The determining, based on the second position information, fourth position information of the plurality of cells comprises: Based on the difference between the size of the target image and the size of the fusion feature of the target image, the second position information is enlarged to obtain the enlarged second position information of the plurality of separators, the size of the target image being larger than the size of the fusion feature of the target image; The amplified second position information is calculated to obtain fourth position information of the plurality of cells.
6. The method according to any one of claims 1 to 5, characterized in that: The matching of the plurality of cells and the plurality of texts based on the first position information, the third position information, and the fourth position information to obtain the table includes: Acquire a first correspondence relationship between the plurality of cells and the first position information, and a second correspondence relationship between the plurality of texts and the third position information; Performing a first match between the fourth location information and the third location information to obtain a third corresponding relationship between the fourth location information and the third location information; Performing a second matching on the fourth location information and the first location information to obtain a fourth corresponding relationship between the fourth location information and the first location information; According to the first corresponding relationship, the second corresponding relationship, the third corresponding relationship and the fourth corresponding relationship, the multiple texts are filled into the multiple cells to obtain the table.
7. The method according to claim 6, characterized in that The first matching is a center matching, and the second matching is a Hungarian matching.
8. A model training method, characterized in that: The method comprises: Acquire a first image, wherein the first image includes a first table to be identified; Processing the first image by using the model to be trained to obtain a plurality of first cells of the first table, fifth position information of the plurality of first cells, and sixth position information of a plurality of first separators between the plurality of first cells; Based on the fifth position information and the sixth position information, the model to be trained is trained to obtain a target model.
9. The method according to claim 8, characterized in that The method further comprises: acquiring a second image, wherein the second image includes a second table to be identified; Processing the second image by using the backbone network to be trained and the segmentation network to be trained to obtain seventh position information of a plurality of second separators between a plurality of second cells of the second table; Training the backbone network to be trained based on the seventh position information to obtain a pre-trained backbone network; Based on the pre-trained backbone network and the segmentation network to be trained, the model to be trained is constructed.
10. The method according to claim 8, characterized in that The method further comprises: Acquire a second image and a third image, wherein the second image includes a second table to be identified, and the third image includes a third table to be identified; Processing the second image and the third image by using a backbone network to be trained to obtain visual features of the second image and visual features of the third image; Training the backbone network to be trained based on the visual features of the second image and the visual features of the third image to obtain a pre-trained backbone network; Based on the pre-trained backbone network, the model to be trained is constructed.
11. The method according to claim 10, characterized in that The second image and the third image are derived from the same image, and the second table and the third table are derived from the same table.
12. The method according to any one of claims 8 to 11, characterized in that: The step of processing the first image by using the model to be trained to obtain a plurality of first cells of the first table includes: Extracting features of the first image using the model to be trained to obtain visual features of the first image; The visual features of the first image are encoded and first decoded by the model to be trained to obtain a plurality of first cells of the first table.
13. The method according to any one of claims 8 to 12, characterized in that: The step of processing the first image by using the model to be trained to obtain the fifth position information of the plurality of first cells includes: The visual features of the first image are encoded and second decoded by the model to be trained to obtain fifth position information of the multiple first cells.
14. The method according to any one of claims 8 to 13, characterized in that: The step of processing the first image by using the model to be trained to obtain sixth position information of the plurality of first separators between the plurality of first cells includes: Performing feature fusion on the visual features of the first image by using the model to be trained to obtain fused features of the first image; The fusion features of the first image are classified by the model to be trained to obtain sixth position information of the multiple first separators between the multiple first cells.
15. A table recognition device, characterized in that: The device comprises: An acquisition module, used for acquiring a target image, wherein the target image includes a table to be identified; A processing module, configured to process the target image through a target model to obtain a plurality of cells of the table, first position information of the plurality of cells, and second position information of a plurality of separators between the plurality of cells; A recognition module, used for performing text recognition on the target image to obtain a plurality of texts in the table and third position information of the plurality of texts; A determination module, configured to determine fourth position information of the plurality of cells based on the second position information; A matching module is used to match the multiple cells and the multiple texts based on the first position information, the third position information and the fourth position information to obtain the table.
16. A model training device, characterized in that: The device comprises: An acquisition module, configured to acquire a first image, wherein the first image includes a first table to be identified; a processing module, configured to process the first image by using a model to be trained to obtain a plurality of first cells of the first table, fifth position information of the plurality of first cells, and sixth position information of a plurality of first separators between the plurality of first cells; A training module is used to train the model to be trained based on the fifth position information and the sixth position information to obtain a target model.
17. A table recognition device, characterized in that: The device comprises a memory and a processor; the memory stores codes, and the processor is configured to execute the codes. When the codes are executed, the table recognition device executes the method according to any one of claims 1 to 14.
18. A computer storage medium, characterized in that: The computer storage medium stores one or more instructions, which, when executed by one or more computers, enable the one or more computers to implement the method of any one of claims 1 to 14.
19. A computer program product, characterized in that The computer program product stores instructions, which, when executed by a computer, enable the computer to implement the method according to any one of claims 1 to 14.
Citation Information
Cited By
Table recognition method and related device therefor
EP4715763A1
Table recognition method and related device therefor
WO2024260361A1
