Image generation method and device, computer readable storage medium and electronic device
Automatically generating table images and annotated images for model training through electronic devices solves the problems of high manual annotation costs and unsatisfactory accuracy in the existing technology, and achieves efficient and accurate sample generation.
Patent Information
- Application Number
- CN202110961145.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-20
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2041-08-20
AI Technical Summary
In image processing technology, the existing technology requires a large amount of manual collection and labeling of table image samples, resulting in high costs and unsatisfactory labeling accuracy.
Obtain basic table data in web page format through electronic devices, determine the table style and annotation style, generate web page tables and combine the annotation styles to obtain annotation results, and then generate table images and annotation images for model training, and use computers to automatically complete sample generation. Save labor costs and improve labeling accuracy.
It realizes the automatic generation of table images and annotation images for model training, saving the cost of manual collection and annotation, and improving the accuracy and efficiency of annotation.
Smart Images

Figure CN113643408B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of image processing, and in particular to an image generating method, an image generating device, a computer-readable storage medium, and an electronic device. Background Art
[0002] In the scenario of converting a table image into a table, computer vision technology can be used to recognize the captured image and generate the corresponding table. Specifically, a machine learning model can be trained to segment the cell lines of the input table image to obtain the border line of each cell.
[0003] During the model training process, it is necessary to take pictures of table images and manually mark the corresponding border lines to obtain sample images, which consumes a lot of manpower and is costly. Summary of the invention
[0004] The present disclosure provides an image generation method, an image generation device, a computer-readable storage medium and an electronic device, thereby overcoming, at least to a certain extent, the problem that obtaining samples in model training requires a lot of manpower and is costly.
[0005] According to a first aspect of the present disclosure, there is provided an image generation method, comprising: obtaining basic data of a table in a web page format; determining a table style and a marking style corresponding to the table style; obtaining a web page table according to the basic table data and the table style, and obtaining a marking result of the web page table in combination with the marking style; generating a table image using the web page table, and generating a marking image corresponding to the table image using the marking result of the web page table.
[0006] According to a second aspect of the present disclosure, there is provided an image generating device, comprising: a data acquiring module, for acquiring basic data of a table in a web page format; a style determining module, for determining a table style and a marking style corresponding to the table style; a web page result generating module, for obtaining a web page-side table according to the basic data of the table and the table style, and obtaining a marking result of the web page-side table in combination with the marking style; an image generating module, for generating a table image using the web page-side table, and generating a marking image corresponding to the table image using the marking result of the web page-side table.
[0007] According to a third aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the above-mentioned image generating method is implemented.
[0008] According to a fourth aspect of the present disclosure, an electronic device is provided, comprising a processor; and a memory for storing one or more programs, wherein when the one or more programs are executed by the processor, the processor implements the above-mentioned image generation method.
[0009] In the technical solutions provided in some embodiments of the present disclosure, basic data of a table in a web page format is obtained, a table style and a corresponding annotation style are determined, a web page table is obtained based on the basic data of the table and the table style, and the annotation result of the web page table is obtained in combination with the annotation style, a table image is generated using the web page table, and an annotation image corresponding to the table image is generated using the annotation result of the web page table. On the one hand, the scheme of the present disclosure generates table images and corresponding annotation images for model training by a computer, which can save the cost of manual collection and manual annotation, and the efficiency of sample generation is high; on the other hand, given that manual annotation may have the problem of unsatisfactory accuracy, the present disclosure uses a computer to complete the annotation, which can improve the accuracy of the annotation.
[0010] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present disclosure, and together with the specification, are used to explain the principles of the present disclosure. Obviously, the drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0012] Figure 1 A schematic diagram showing an exemplary scenario of the image generation scheme of the present disclosure;
[0013] Figure 2 A schematic diagram of the structure of an electronic device suitable for implementing an embodiment of the present disclosure is shown;
[0014] Figure 3 A flowchart of an image generating method according to an exemplary embodiment of the present disclosure is schematically shown;
[0015] Figure 4 A schematic diagram showing the contents of the table data in the disclosed solution;
[0016] Figure 5 A schematic diagram of a web page table according to an embodiment of the present disclosure is shown;
[0017] Figure 6 Shown with Figure 5 Schematic diagram of the corresponding annotation results on the web page;
[0018] Figure 7 A schematic diagram showing a table image of an embodiment of the present disclosure;
[0019] Figure 8 Shown with Figure 7Schematic diagram of the corresponding annotated image with visible horizontal lines;
[0020] Fig. 9 Shown with Figure 7 Schematic diagram of the corresponding annotated image with visible vertical lines;
[0021] Fig.10 Shown with Figure 7 Schematic diagram of the corresponding annotated image with invisible horizontal lines;
[0022] Fig.11 Shown with Figure 7 Schematic diagram of the corresponding annotated image of the invisible vertical line;
[0023] Fig.12 A flowchart schematically shows the entire process of the image generation solution of an embodiment of the present disclosure;
[0024] Fig.13 A block diagram schematically shows an image generating device according to an exemplary embodiment of the present disclosure;
[0025] Fig.14 A block diagram of an image generating device according to another exemplary embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0026] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as being limited to the examples set forth herein; on the contrary, these embodiments are provided so that the present disclosure will be more comprehensive and complete, and the concepts of the example embodiments are fully conveyed to those skilled in the art. The described features, structures, or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present disclosure.
[0027] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0028] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the steps. For example, some steps can be decomposed, and some steps can be combined or partially combined, so the actual execution order may change according to the actual situation. In addition, all the terms "first", "second", "third", "fourth", "fifth", "sixth", etc. below are only for the purpose of distinction and should not be used as limitations of the present disclosure.
[0029] In the process of converting a table image into a table, a model method is usually used to achieve this. Before applying the model, the model needs to be trained. Some technologies require manual collection of training samples and manual annotation, which is costly. The disclosed solution provides a new image sample generation method, in which an electronic device automatically generates a table image as a sample and a corresponding annotated image, so as to solve the problem of high cost caused by manual annotation of sample images to a certain extent.
[0030] Figure 1 A schematic diagram showing an exemplary scenario of the image generation scheme of the present disclosure.
[0031] First, the electronic device executes a sample image generation process to generate a sample image, wherein the sample image described in the present disclosure includes a table image and an annotated image corresponding to the table image. Next, the generated sample image can be applied to a model training process to obtain a trained model. Subsequently, when a table image to be identified needs to be identified as a table, the table image can be input into the trained model so that the model outputs a corresponding table.
[0032] The image generation scheme disclosed in the present invention mainly focuses on the above-mentioned process of generating sample images.
[0033] Specifically, first, the electronic device can obtain the basic data of the table in the web page format, and determine the table style and the annotation style corresponding to the table style. Next, the electronic device can obtain the web page table according to the basic data of the table and the table style, and obtain the annotation result of the web page table in combination with the annotation style. Subsequently, the electronic device can generate a table image using the web page table, and generate an annotation image corresponding to the table image using the annotation result of the web page table.
[0034] It can be understood that the table image and the corresponding annotated image generated by the image generation solution of the present disclosure are sample images required for training the model.
[0035] The image generation method disclosed in the present invention can be implemented by an electronic device, and accordingly, the image generation device can be configured in the electronic device. The electronic device can include but is not limited to a smart phone, a tablet computer, a personal computer, a server, etc.
[0036] Figure 2 A schematic diagram of the structure of a computer system suitable for implementing the electronic device according to the exemplary embodiment of the present disclosure is shown.
[0037] It should be noted that Figure 2 The computer system 200 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0038] like Figure 2 As shown, the computer system 200 includes a central processing unit (CPU) 201, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 202 or a program loaded from a storage part 208 into a random access memory (RAM) 203. Various programs and data required for system operation are also stored in the RAM 203. The CPU 201, the ROM 202, and the RAM 203 are connected to each other via a bus 204. An input / output (I / O) interface 205 is also connected to the bus 204.
[0039] The following components are connected to the I / O interface 205: an input section 206 including a keyboard, a mouse, etc.; an output section 207 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 208 including a hard disk, etc.; and a communication section 209 including a network interface card such as a LAN card, a modem, etc. The communication section 209 performs communication processing via a network such as the Internet. A drive 210 is also connected to the I / O interface 205 as needed. A removable medium 211, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 210 as needed, so that a computer program read therefrom is installed into the storage section 208 as needed.
[0040] In particular, according to an embodiment of the present disclosure, the process described below with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication part 209, and / or installed from a removable medium 211. When the computer program is executed by the central processing unit (CPU) 201, various functions defined in the system of the present disclosure are executed.
[0041] The present disclosure also provides a computer-readable storage medium, which may be included in the electronic device described in the above embodiments; or may exist independently without being assembled into the electronic device.
[0042] The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.
[0043] Computer-readable storage media can send, propagate or transmit programs for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable storage medium can be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0044] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by an electronic device, the electronic device implements the method described in the following embodiments.
[0045] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0046] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, and the units described may also be arranged in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.
[0047] Figure 3The flowchart of the image generation method according to the exemplary embodiment of the present disclosure is schematically shown. Figure 3 , the image generation method may include the following steps:
[0048] S32. Obtain basic data of the table in web page format.
[0049] In the exemplary embodiment of the present disclosure, referring to Figure 4 The basic data of the table includes but is not limited to the number of rows and columns, cell content, cell merge information and invisible line information, etc. Among them, the cell merge information includes information about which cells need to be merged, and the invisible line information includes information about which cell borders are invisible lines. Invisible lines usually include invisible horizontal lines and invisible vertical lines.
[0050] In one embodiment, the basic data of the table may be information randomly generated by an electronic device, wherein the cell content may be obtained by randomly extracting text from, for example, news, novels, etc. In another embodiment, the basic data of the table may be data input by a user. The present disclosure does not limit this.
[0051] It should be noted that the table basic data conforms to the web page (html) format, for example, the electronic device directly generates the table basic data in html format.
[0052] According to other embodiments of the present disclosure, first, the electronic device can obtain original table data written in a programming language. The data items and data contents contained in the original table data are consistent with the above-mentioned basic table data. In addition, the present disclosure does not limit the programming language used by the user, for example, Python can be used for writing.
[0053] Next, the original table data can be extracted line by line in the form of a string that meets the web page format to obtain the basic table data in the web page format. Wherein, meeting the web page format can refer to being in accordance with the specifications of HTML and CSS (cascading stylesheets).
[0054] For example, a cell can be represented as:
[0055] <div style="opacity:1;"> Cell Contents
[0056] Among them, rowspan indicates the merging of rows, and colspan indicates the merging of columns.
[0057] In the case where the cell contains invisible lines, you can give it in the td class, for example:
[0058] <div style="opacity:1;"> Cell Content 1
[0059] In the exemplary solution of the present disclosure, if the border is in the vertical direction and is part of the left side of the entire table outer border, it can be represented by "hl_cl"; if the border is in the vertical direction and is part of the right side of the entire table outer border, it can be represented by "hl_cr"; other cases can be represented by "hl_cm". In addition, for horizontal invisible lines (i.e., invisible horizontal lines), there are similar representation methods.
[0060] S34. Determine the table style and the annotation style corresponding to the table style.
[0061] In the exemplary embodiment of the present disclosure, the style refers to the CSS style. The table style and the annotation style can be determined according to the model and scenario to be applied later, and the present disclosure does not limit this. For example, the table style can include but is not limited to the layout of the web page, the form of the line and the line width (i.e., the thickness of the line), etc. The annotation style can include color information, specifically including line color, cell background color, cell content color, etc.
[0062] According to an embodiment of the present disclosure, the user may perform style configuration according to the table basic data acquired in step S32 to obtain a table style and a corresponding annotation style.
[0063] According to another embodiment of the present disclosure, a style library can be pre-built, and the style library includes multiple style groups, each of which includes a table style and a corresponding annotation style. Each style group can be reused, that is, one style group can be applied to multiple table basic data.
[0064] In the case where a style library is pre-built, the electronic device can determine the table style and the corresponding annotation style from the style library. For example, a style group can be randomly selected from the style library. Alternatively, the style group can be specified by the user.
[0065] S36. Obtain the web page table based on the basic data and table style of the table, and obtain the annotation result of the web page table in combination with the annotation style.
[0066] After determining the basic data and style of the table, the electronic device can obtain the web page table, for example, Figure 5 The web page form shown.
[0067] When a web page table is obtained, the annotation style can be combined to obtain the annotation result of the web page table. Figure 6 The labeling results are shown.
[0068] For example, Figure 6The illustrated annotation styles may include configuring visible horizontal lines in red, visible vertical lines in blue, invisible horizontal lines in yellow, and invisible vertical lines in green. In addition, the background of the annotation result is configured in black, and each cell content is configured in black.
[0069] S38. Generate a table image using the table on the web page, and generate a labeled image corresponding to the table image using the labeling result of the table on the web page.
[0070] For table images:
[0071] The electronic device can generate a table image using a webpage table. Specifically, a node-html-to-image conversion operation can be performed on the webpage table to generate a first intermediate image, and the table image can be obtained based on the first intermediate image.
[0072] In some embodiments of the present disclosure, the first intermediate image can be directly used as a table image and applied to the model training process.
[0073] In some other embodiments of the present disclosure, since the first intermediate image obtained by conversion may contain a table area and a non-table area, the table area can be cropped from the first intermediate image, and a table image can be obtained based on the table area. That is, the cropped table area is directly used as a table image and applied to the model training process.
[0074] For the process of determining the table area and the sub-table area, the corresponding marking results may be used. For example, the table area and the non-table area may be divided by determining the four outermost vertices of the non-black pixels in the marking results.
[0075] In addition, in order to improve the robustness of the subsequent model, the cropped table area can be further processed. For example, the area around the table area can be randomly filled (padding), such as randomly filling a white area. Subsequently, the filled image is used as a table image and applied to the model training process.
[0076] Figure 7 A schematic diagram of a table image according to an embodiment of the present disclosure is shown.
[0077] For annotated images:
[0078] The electronic device can perform a conversion operation from a web page to an image on the annotation result of the table on the web page, generate a second intermediate image, and obtain an annotated image corresponding to the table image based on the second intermediate image.
[0079] In some embodiments of the present disclosure, the second intermediate image can be directly used as a labeled image and applied to the model training process.
[0080] In some other embodiments of the present disclosure, considering that the converted second intermediate image may include annotated areas and non-annotated areas, the annotated area can be cropped from the second intermediate image to obtain a third intermediate image, and the annotated image can be obtained based on the third intermediate image.
[0081] According to one embodiment, the third intermediate image is the marked area. According to another embodiment, the third intermediate image may be an image after random filling. Specifically, after the marked area is cropped out from the second intermediate image, the area around the marked area may be randomly filled, and the filled image is determined as the third intermediate image.
[0082] The third intermediate image can be directly used as a labeled image and applied to the model training process.
[0083] In addition, when the third intermediate image includes invisible lines (including invisible horizontal lines and / or invisible vertical lines), the electronic device can also adjust the line width of the invisible lines, and use the adjusted image as a labeled image for the model training process. Invisible lines with smaller line widths usually have poor learning capabilities, and increasing the line width of the invisible lines is beneficial to the subsequent model learning process.
[0084] Specifically, first, the electronic device may determine the content of the cells adjacent to the invisible line in the table image; then, the electronic device may determine the target line width based on the content of the cells, wherein the target line width refers to the minimum width of the area without content between the contents of the adjacent cells. Figure 5 For example, there is an invisible vertical line between the first column and the second column, and the target line width is the distance (width) between "necessary things" and "Lun mirror this"; for another example, there is an invisible vertical line between the fourth column and the fifth column, and the target line width is the distance between "defeat them both" and "BAK". Subsequently, the width of the invisible line can be adjusted to the corresponding target line width to obtain a third intermediate image after line width adjustment, so as to obtain a labeled image.
[0085] The third intermediate image after line width adjustment can be used as a labeled image and applied to the model training process.
[0086] According to some further embodiments of the present disclosure, for the third intermediate image after cropping or cropping and filling, the types of lines in the third intermediate image include at least one of visible horizontal lines and invisible horizontal lines, and the types of lines in the third intermediate image also include at least one of visible vertical lines and invisible vertical lines. It is easy to understand that the horizontal lines and vertical lines described in the present disclosure are both border lines of table cells. In addition, the horizontal lines can be defined as distributed along a first direction, and the vertical lines can be defined as distributed along a second direction, and the first direction is perpendicular to the second direction.
[0087] First, at least two fourth intermediate images are obtained based on the third intermediate image, the fourth intermediate image only contains lines of the same line type, and the fourth intermediate image is a binary image. In other words, images of a single line type can be segmented one by one according to the line types contained in the third intermediate image, and the corresponding binary images can be obtained. Since the third intermediate image contains at least rows and columns, it also includes at least horizontal lines and vertical lines. As for the specific number of fourth intermediate images, it depends on the number of line types contained in the third intermediate image. For example, if the line types of the third intermediate image include visible horizontal lines, visible vertical lines, invisible horizontal lines, and invisible vertical lines, four fourth intermediate images can be obtained.
[0088] Next, the electronic device may obtain a labeled image based on the fourth intermediate image. For example, the obtained fourth intermediate image may be directly used as a labeled image and applied to the model training process.
[0089] In addition, considering that there are breakpoints between the lines in the fourth intermediate image, the electronic device may first complete the breakpoints, and then use the image with the completed breakpoints as the annotated image.
[0090] Specifically, when the line type of the line in the fourth intermediate image is a visible horizontal line or an invisible horizontal line, if the distance between two horizontal lines in the fourth intermediate image in the first direction is less than the first preset distance, the two horizontal lines are complemented to obtain the fifth intermediate image. If the two horizontal lines are recorded as the first horizontal line and the second horizontal line, the complementation in the present disclosure means extending the first horizontal line to the second horizontal line along the extension direction of the first horizontal line, or extending the second horizontal line to the first horizontal line along the extension direction of the second horizontal line.
[0091] On the one hand, if the distance between the two horizontal lines in the first direction is greater than the first preset distance, no complement is performed between the two lines. On the other hand, in some scenarios, the first preset distance may be consistent with the line width of the vertical line between the two horizontal lines, or may be preconfigured as a fixed value.
[0092] Similarly, when the line type of the line in the fourth intermediate image is a visible vertical line or an invisible vertical line, if the distance between the two vertical lines in the fourth intermediate image in the second direction is less than the second preset distance, the two vertical lines are complemented to obtain a sixth intermediate image. If the two vertical lines are recorded as a first vertical line and a second vertical line, the complementation described in the present disclosure means extending the first vertical line to the second vertical line along the extension direction of the first vertical line, or extending the second vertical line to the first vertical line along the extension direction of the second vertical line.
[0093] On the one hand, if the distance between the two vertical lines in the second direction is greater than the second preset distance, no complement is performed between the two. On the other hand, in some scenarios, the second preset distance may be consistent with the line width of the horizontal line between the two vertical lines, or may be preconfigured as a fixed value. In addition, the first preset distance and the second preset distance may be the same or different.
[0094] When determining whether the lines are completed, a single line can also be analyzed. If the current line is a visible horizontal line, search along the first direction, and if another horizontal line (a general term for visible horizontal lines and invisible horizontal lines) appears within the first preset distance, the area between the two is completed as a visible horizontal line; if the current line is an invisible horizontal line, search along the first direction, and if another horizontal line appears within the first preset distance, the area between the two is completed as an invisible horizontal line; if the current line is a visible vertical line, search along the second direction, and if another vertical line (a general term for visible vertical lines and invisible vertical lines) appears within the second preset distance, the area between the two is completed as a visible vertical line; if the current line is an invisible vertical line, search along the second direction, and if another vertical line appears within the second preset distance, the area between the two is completed as an invisible vertical line.
[0095] When the fifth intermediate image and the sixth intermediate image are determined, a labeled image corresponding to the horizontal line can be obtained based on the fifth intermediate image, and a labeled image corresponding to the vertical line can be obtained based on the sixth intermediate image.
[0096] In one embodiment, the fifth intermediate image can be used as a labeled image corresponding to the horizontal line and applied to the model training process, and the sixth intermediate image can be used as a labeled image corresponding to the vertical line and applied to the model training process.
[0097] In another embodiment, when the line type of the line in the fourth intermediate image is an invisible horizontal line, the line width of the invisible horizontal line can be adjusted for the obtained fifth intermediate image, and the image with adjusted line width is used as an annotated image corresponding to the horizontal line and applied to the model training process.
[0098] Specifically, the content of the cell adjacent to the invisible horizontal line in the table image can be determined, the target line width can be determined based on the cell content, and the line width of the invisible horizontal line can be adjusted to the target line width to obtain a marked image corresponding to the horizontal line.
[0099] Similarly, when the line type of the line in the fourth intermediate image is an invisible vertical line, for the obtained sixth intermediate image, the line width of the invisible vertical line can be adjusted, and the image with adjusted line width can be used as an annotated image corresponding to the vertical line and applied to the model training process.
[0100] Specifically, the content of the cell adjacent to the invisible vertical line in the table image can be determined, the target line width can be determined based on the cell content, and the line width of the invisible vertical line can be adjusted to the target line width to obtain a labeled image corresponding to the vertical line.
[0101] It should be noted that no matter what types of lines are included in the third intermediate image, in some embodiments of the present disclosure, four annotated images will be obtained.
[0102] against Figure 7 For example, Figure 8 The corresponding annotated image of visible horizontal lines (only two) is shown. Fig. 9 The corresponding annotated image with visible vertical lines is shown (no visible vertical lines), Fig.10 The corresponding annotated images of invisible horizontal lines are shown (the line widths are not exactly the same). Fig.11 The corresponding annotated images of invisible vertical lines are shown (the line widths are not exactly the same).
[0103] In addition, the line widths of the invisible lines may be configured as fixed values, which depends on subsequent models and scenarios, and the present disclosure does not impose any restrictions on this.
[0104] The following will refer to Fig.12 The image generation process of the present disclosure is described.
[0105] In step S1202, the original table data may be written based on Python.
[0106] In step S1204, for the written result, each line is output as a character string that satisfies the HTML format.
[0107] In step S1206, a table style and a corresponding annotation style may be obtained.
[0108] In step S1208, based on the output results of step S1204 and step S1206, a web page table and annotation results corresponding to the web page table can be obtained.
[0109] In step S1210, the result of the web page may be exported as an image.
[0110] In step S1212, post-processing operations may be performed, such as a combination of one or more of the above-mentioned cropping, filling, line breakpoint completion, and invisible line width adjustment, to generate a table image and a corresponding annotation image for use in subsequent model training processes.
[0111] To sum up, on the one hand, the scheme disclosed in the present invention generates table images and corresponding annotated images for model training by computer, which can save the cost of manual collection and manual annotation, and the efficiency of sample generation is high; on the other hand, given that manual annotation may have the problem of unsatisfactory accuracy, the present invention uses a computer to complete the annotation, which can improve the accuracy of the annotation.
[0112] It should be noted that although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0113] Furthermore, this example implementation also provides an image generating device.
[0114] Fig.13 FIG. 1 schematically shows a block diagram of an image generating device according to an exemplary embodiment of the present disclosure. Fig.13 According to an exemplary embodiment of the present disclosure, the image generating device 13 may include a data acquiring module 131 , a style determining module 133 , a web page result generating module 135 , and an image generating module 137 .
[0115] Specifically, the data acquisition module 131 can be used to acquire basic data of a table in a web page format; the style determination module 133 can be used to determine the table style and the annotation style corresponding to the table style; the web page result generation module 135 can be used to obtain a web page table based on the basic table data and the table style, and obtain the annotation result of the web page table in combination with the annotation style; the image generation module 137 can be used to generate a table image using the web page table, and generate an annotation image corresponding to the table image using the annotation result of the web page table.
[0116] According to an exemplary embodiment of the present disclosure, the data acquisition module 131 may be configured to execute: acquiring original table data written in a programming language; extracting the original table data line by line in the form of a string satisfying the web page format to obtain basic table data in the web page format.
[0117] According to an exemplary embodiment of the present disclosure, referring to Fig.14 Compared with the image generating device 13 , the image generating device 14 may further include a sample library building module 141 .
[0118] Specifically, the sample library construction module 141 can be configured to execute: pre-constructing a style library, the style library containing multiple style groups, each style group including a table style and a corresponding annotation style; wherein, determining the table style and the annotation style corresponding to the table style includes: determining the table style and the annotation style corresponding to the table style from the style library.
[0119] According to an exemplary embodiment of the present disclosure, the image generation module 137 may be configured to execute: performing a conversion operation from a web page to an image on a web page table to generate a first intermediate image; and obtaining a table image based on the first intermediate image.
[0120] According to an exemplary embodiment of the present disclosure, the first intermediate image includes a table area and a non-table area. In this case, the image generation module 137 may be configured to perform: cutting out the table area from the first intermediate image; and obtaining a table image based on the table area.
[0121] According to an exemplary embodiment of the present disclosure, the image generation module 137 may also be configured to perform: randomly filling the area surrounding the table area, and determining the filled image as a table image.
[0122] According to an exemplary embodiment of the present disclosure, the image generation module 137 can be configured to perform: performing a conversion operation from a web page to an image on the annotation result of the table on the web page side to generate a second intermediate image; and obtaining an annotated image corresponding to the table image based on the second intermediate image.
[0123] According to an exemplary embodiment of the present disclosure, the second intermediate image includes an annotated area and a non-annotated area. In this case, the image generation module 137 can be configured to perform: cropping the annotated area from the second intermediate image to obtain a third intermediate image; and obtaining an annotated image based on the third intermediate image.
[0124] According to an exemplary embodiment of the present disclosure, the process of the image generation module 137 obtaining the third intermediate image can be configured to execute: cropping a marked area from the second intermediate image; randomly filling the area around the marked area, and determining the filled image as the third intermediate image.
[0125] According to an exemplary embodiment of the present disclosure, the third intermediate image includes invisible lines, and the invisible lines include invisible horizontal lines and / or invisible vertical lines. In this case, the image generation module 137 can be configured to perform: determining the content of the cell adjacent to the invisible line in the table image; determining the target line width based on the content of the cell; adjusting the line width of the invisible line to the target line width to obtain the annotated image.
[0126] According to an exemplary embodiment of the present disclosure, the line type of the lines in the third intermediate image includes at least one of a visible horizontal line and an invisible horizontal line, and the line type of the lines in the third intermediate image also includes at least one of a visible vertical line and an invisible vertical line, the horizontal lines are distributed along a first direction, and the vertical lines are distributed along a second direction perpendicular to the first direction. In this case, the image generation module 137 can be configured to perform: obtaining at least two fourth intermediate images based on the third intermediate image, the fourth intermediate image only contains lines of the same line type, and the fourth intermediate image is a binary image; and obtaining a labeled image based on the fourth intermediate image.
[0127] According to an exemplary embodiment of the present disclosure, the image generation module 137 may be configured to execute: in a case where the line type of the lines in the fourth intermediate image is a visible horizontal line or an invisible horizontal line, if the distance between two horizontal lines in the fourth intermediate image in the first direction is less than a first preset distance, then the two horizontal lines are filled to obtain a fifth intermediate image; in a case where the line type of the lines in the fourth intermediate image is a visible vertical line or an invisible vertical line, if the distance between two vertical lines in the fourth intermediate image in the second direction is less than a second preset distance, then the two vertical lines are filled to obtain a sixth intermediate image; obtaining an annotated image corresponding to the horizontal line based on the fifth intermediate image, and obtaining an annotated image corresponding to the vertical line based on the sixth intermediate image.
[0128] According to an exemplary embodiment of the present disclosure, when the line type of the line in the fourth intermediate image is an invisible horizontal line, the image generation module 137 can be configured to execute: determining the content of the cell adjacent to the invisible horizontal line in the table image; determining the target line width based on the content of the cell; adjusting the line width of the invisible horizontal line to the target line width to obtain a labeled image corresponding to the horizontal line.
[0129] According to an exemplary embodiment of the present disclosure, when the line type of the line in the fourth intermediate image is an invisible vertical line, the image generation module 137 can be configured to execute: determining the content of the cell adjacent to the invisible vertical line in the table image; determining the target line width based on the content of the cell; adjusting the line width of the invisible vertical line to the target line width to obtain a labeled image corresponding to the vertical line.
[0130] Since the functional modules of the image generating device in the embodiment of the present disclosure are the same as those in the above-mentioned method embodiment, they will not be described in detail here.
[0131] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0132] In addition, the above-mentioned figures are only schematic illustrations of the processes included in the method according to the exemplary embodiments of the present disclosure, and are not intended to be limiting. It is easy to understand that the processes shown in the above-mentioned figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.
[0133] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0134] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing what is disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure. The specification and embodiments are to be considered merely as exemplary, and the true scope and spirit of the present disclosure are indicated by the claims.
[0135] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. An image generation method, characterized in that: include: Get basic data of the table in web page format; Determine a table style and a marking style corresponding to the table style; According to the basic data of the table and the table style, a web page table is obtained, and in combination with the annotation style, an annotation result of the web page table is obtained; Generate a table image using the webpage table, and generate a marked image corresponding to the table image using the marked result of the webpage table; Wherein, using the webpage table to generate a table image includes: performing a conversion operation from a webpage to an image on the webpage table to generate a first intermediate image; obtaining the table image based on the first intermediate image; and / or Using the annotation results of the table on the web page to generate an annotated image corresponding to the table image includes: performing a conversion operation from a web page to an image on the annotation results of the table on the web page to generate a second intermediate image; and obtaining an annotated image corresponding to the table image based on the second intermediate image.
2. The image generation method according to claim 1, characterized in that: Obtaining basic data in a web page format includes: Get the original table data written in the programming language; The original table data is extracted line by line in the form of a character string satisfying the web page format, so as to obtain the basic data of the table in the web page format.
3. The image generation method according to claim 1, characterized in that: The image generation method further comprises: Pre-building a style library, wherein the style library includes a plurality of style groups, each of which includes a table style and a corresponding annotation style; The step of determining a table style and a marking style corresponding to the table style includes: determining the table style and the marking style corresponding to the table style from the style library.
4. The image generation method according to claim 1, characterized in that: In the case where the table image is obtained based on the first intermediate image, the first intermediate image includes a table area and a non-table area; wherein obtaining the table image based on the first intermediate image includes: cropping the table area from the first intermediate image; The table image is obtained based on the table area.
5. The image generation method according to claim 4, characterized in that: Obtaining the table image based on the table area includes: The area around the table is randomly filled, and the filled image is determined as the table image.
6. The image generation method according to claim 1, characterized in that: In the case where the annotated image corresponding to the table image is obtained based on the second intermediate image, the second intermediate image includes an annotated area and a non-annotated area; wherein obtaining the annotated image corresponding to the table image based on the second intermediate image includes: cropping the marked area from the second intermediate image to obtain a third intermediate image; The annotated image is obtained based on the third intermediate image.
7. The image generation method according to claim 6, characterized in that: Cropping the marked area from the second intermediate image to obtain a third intermediate image includes: cropping the marked area from the second intermediate image; The area surrounding the marked region is randomly filled, and the filled image is determined as the third intermediate image.
8. The image generation method according to claim 6, characterized in that: The third intermediate image includes invisible lines, and the invisible lines include invisible horizontal lines and / or invisible vertical lines. The step of obtaining the annotated image based on the third intermediate image includes: determining the contents of cells in the table image that are immediately adjacent to the invisible line; determining a target line width based on the content of the cell; The line width of the invisible line is adjusted to the target line width to obtain the annotated image.
9. The image generation method according to claim 6 or 7, characterized in that: The line types of the lines in the third intermediate image include at least one of a visible horizontal line and an invisible horizontal line, and the line types of the lines in the third intermediate image also include at least one of a visible vertical line and an invisible vertical line, the horizontal lines are distributed along a first direction, and the vertical lines are distributed along a second direction perpendicular to the first direction; wherein obtaining the annotated image based on the third intermediate image includes: obtaining at least two fourth intermediate images based on the third intermediate image, wherein the fourth intermediate images only contain lines of the same line type and are binary images; The annotated image is obtained based on the fourth intermediate image.
10. The image generation method according to claim 9, characterized in that: Obtaining the annotated image based on the fourth intermediate image includes: When the line type of the line in the fourth intermediate image is a visible horizontal line or an invisible horizontal line, if the distance between two horizontal lines in the fourth intermediate image in the first direction is less than a first preset distance, the two horizontal lines are filled to obtain a fifth intermediate image; When the line type of the line in the fourth intermediate image is a visible vertical line or an invisible vertical line, if the distance between two vertical lines in the fourth intermediate image in the second direction is less than a second preset distance, the two vertical lines are filled to obtain a sixth intermediate image; The annotated image corresponding to the horizontal line is obtained based on the fifth intermediate image, and the annotated image corresponding to the vertical line is obtained based on the sixth intermediate image.
11. The image generation method according to claim 10, characterized in that: When the line type of the line in the fourth intermediate image is an invisible horizontal line, obtaining the annotated image corresponding to the horizontal line based on the fifth intermediate image includes: Determining the content of the cell in the table image that is immediately adjacent to the invisible horizontal line; determining a target line width based on the content of the cell; The line width of the invisible horizontal line is adjusted to the target line width to obtain the annotated image corresponding to the horizontal line.
12. The image generation method according to claim 10, characterized in that: When the line type of the line in the fourth intermediate image is an invisible vertical line, obtaining the annotated image corresponding to the vertical line based on the sixth intermediate image includes: Determining the content of the cell in the table image that is immediately adjacent to the invisible vertical line; determining a target line width based on the content of the cell; The line width of the invisible vertical line is adjusted to the target line width to obtain the annotated image corresponding to the vertical line.
13. An image generating device, characterized in that: include: A data acquisition module is used to obtain basic data of a table in a web page format; A style determination module, used to determine a table style and a marking style corresponding to the table style; A web page result generation module, used to obtain a web page table according to the basic data of the table and the table style, and obtain a marking result of the web page table in combination with the marking style; An image generation module, used to generate a table image using the table on the web page, and to generate an annotated image corresponding to the table image using the annotation result of the table on the web page; The image generation module is configured to perform: performing a conversion operation from a web page to an image on the web page table to generate a first intermediate image; and obtaining the table image based on the first intermediate image; and / or A conversion operation from a web page to an image is performed on the annotation result of the table on the web page to generate a second intermediate image; and an annotated image corresponding to the table image is obtained based on the second intermediate image.
14. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the image generating method according to any one of claims 1 to 12 is implemented.
15. An electronic device, characterized in that: include: processor; A memory for storing one or more programs, which, when executed by the processor, enables the processor to implement the image generating method according to any one of claims 1 to 12.
