Document image processing method, large model training method, device, equipment, medium and product
By performing visual encoding, feature migration and decoding of document images, adapted electronic documents are generated, which solves the problem of incomplete document image processing in the existing technology and achieves automated processing and efficient document content restoration.
Patent Information
- Application Number
- CN202410889838.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-03
- Publication Date
- 2024-10-11
AI Technical Summary
Existing technology makes it difficult to directly convert document images into electronic documents. In particular, it is difficult to completely obtain the layout information and image information, resulting in the need for subsequent manual processing to restore the document content.
Through visual encoding, feature migration and decoding of document images, electronic documents adapted to the document images are generated, including layout and content, to achieve end-to-end document image processing.
It improves the automated processing capabilities of document images, reduces manual processing costs, can completely restore document content and avoid post-processing steps, and enhances the accuracy and efficiency of processing.
Smart Images

Figure CN118762374A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence technology, in particular to computer vision, deep learning, large models and other technical fields, and can be applied to scenarios such as OCR. Specifically, it relates to a document image processing method, a large model training method, a device, an electronic device, a storage medium and a program product. Background Art
[0002] Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level and software-level technologies. Artificial intelligence technology has broad application prospects and can be applied to various fields of artificial intelligence. For example, text processing, image processing, semantic understanding, machine translation, human-computer interaction, etc. Using large models to handle tasks in different fields requires comprehensive consideration of factors such as timeliness and cost. Summary of the invention
[0003] The present disclosure provides a document image processing method, a large model training method, a device, an electronic device, a storage medium and a program product.
[0004] According to one aspect of the present disclosure, a document image processing method is provided, comprising: visually encoding a document image to obtain document features; performing feature migration on the document features to obtain migration features; and decoding the migration features to obtain an electronic document that matches the document image, wherein the electronic document includes an identifier for indicating a page layout and document content.
[0005] According to another aspect of the present disclosure, a method for training a large model is provided, comprising: visually encoding a sample document image to obtain sample document features; performing feature migration on the sample document features to obtain sample migration features; decoding the sample migration features to obtain a sample electronic document that matches the sample document image, wherein the sample electronic document includes a sample identifier for indicating a page layout and sample document content; and training the large model using the sample electronic document and a sample label that matches the sample document image.
[0006] According to another aspect of the present disclosure, a document image processing device is provided, comprising: an image encoding module for visually encoding a document image to obtain document features; a feature migration module for migrating document features to obtain migration features; and a feature decoding module for decoding the migration features to obtain an electronic document that matches the document image, wherein the electronic document includes an identifier for indicating a page layout and document content.
[0007] According to another aspect of the present disclosure, a training device for a large model is provided, comprising: a sample image encoding module, used to perform visual encoding on a sample document image to obtain sample document features; a sample feature migration module, used to perform feature migration on the sample document features to obtain sample migration features; a sample feature decoding module, used to decode the sample migration features to obtain a sample electronic document that matches the sample document image, wherein the sample electronic document includes a sample identifier for indicating a page layout and sample document content; and a large model training module, used to train a large model using sample electronic documents and sample labels that match the sample document images.
[0008] According to another aspect of the present disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the above method.
[0009] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable a computer to execute the above method.
[0010] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, and the computer program implements the above method when executed by a processor.
[0011] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0013] Figure 1 An exemplary system architecture to which the document image processing method and apparatus according to an embodiment of the present disclosure can be applied is schematically shown;
[0014] Figure 2 A flowchart of a document image processing method according to an embodiment of the present disclosure is schematically shown;
[0015] Figure 3 A schematic diagram of an electronic document according to an embodiment of the present disclosure is schematically shown;
[0016] Figure 4 The schematic diagram of the structure of the large model according to the embodiment of the present disclosure is shown;
[0017] Figure 5A flowchart of a large model training method according to an embodiment of the present disclosure is schematically shown;
[0018] Figure 6 The following schematically shows a flow chart of generating sample labels according to an embodiment of the present disclosure;
[0019] Figure 7 A schematic diagram of a process flow of a large model training method according to another embodiment of the present disclosure is schematically shown;
[0020] Figure 8 A block diagram schematically shows a document image processing device according to an embodiment of the present disclosure;
[0021] Fig. 9 A block diagram schematically shows a large model training device according to an embodiment of the present disclosure; and
[0022] Fig.10 A block diagram of an electronic device suitable for implementing a document image processing method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0023] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0024] As for document images, it is difficult to directly perform electronic editing due to image format limitations, making it difficult to transcribe, edit and archive important documents.
[0025] In some instances, text recognition can be performed on document images using OCR (Optical Character Recognition) technology to obtain electronic documents. However, using traditional OCR recognition technology, it is difficult to ensure that the layout information, table information, and image information in the document image are fully obtained, and manual processing is required to obtain an electronic document that restores the document image content.
[0026] Therefore, in order to improve the automated processing capability of document images and reduce the manual processing cost, the present disclosure provides a document image processing method, which will be described below.
[0027] Figure 1 An exemplary system architecture to which the document image processing method and apparatus according to an embodiment of the present disclosure can be applied is schematically shown.
[0028] It should be noted that Figure 1 The examples shown are only examples of system architectures to which the embodiments of the present disclosure can be applied, in order to help those skilled in the art understand the technical content of the present disclosure, but do not mean that the embodiments of the present disclosure cannot be used in other devices, systems, environments or scenarios. For example, in another embodiment, the exemplary system architecture to which the document image processing method and apparatus can be applied may include a terminal device, but the terminal device may implement the document image processing method and apparatus provided by the embodiments of the present disclosure without interacting with the server.
[0029] like Figure 1 As shown, the system architecture 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired and / or wireless communication links, etc.
[0030] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as knowledge reading applications, web browser applications, search applications, instant messaging tools, email clients and / or social platform software, etc. (only as examples).
[0031] The terminal devices 101 , 102 , and 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0032] The server 105 may be a server that provides various services, such as a background management server (only an example) that provides support for the content browsed by the user using the terminal devices 101, 102, and 103. The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.
[0033] It should be noted that the document image processing method provided in the embodiment of the present disclosure can generally be executed by the terminal device 101, 102, or 103. Accordingly, the document image processing apparatus provided in the embodiment of the present disclosure can also be set in the terminal device 101, 102, or 103.
[0034] Alternatively, the document image processing method provided in the embodiment of the present disclosure may also be generally executed by the server 105. Accordingly, the document image processing apparatus provided in the embodiment of the present disclosure may generally be arranged in the server 105. The document image processing method provided in the embodiment of the present disclosure may also be executed by a server or a server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105. Accordingly, the document image processing apparatus provided in the embodiment of the present disclosure may also be arranged in a server or a server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105.
[0035] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.
[0036] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision, disclosure and application of user personal information involved comply with the provisions of relevant laws and regulations, take necessary confidentiality measures, and do not violate public order and good morals.
[0037] In the technical solution of the present disclosure, the user's authorization or consent is obtained before obtaining or collecting the user's personal information.
[0038] It can be understood that the above describes the system architecture of the present disclosure, and the document image processing method of the present disclosure will be described below.
[0039] Figure 2 The flowchart of the document image processing method according to the embodiment of the present disclosure is schematically shown.
[0040] like Figure 2 As shown, the method includes operations S210 to S230.
[0041] In operation S210, visual encoding is performed on the document image to obtain document features.
[0042] In operation S220, feature migration is performed on the document features to obtain migration features.
[0043] In operation S230, the migration feature is decoded to obtain an electronic document matching the document image.
[0044] In one example, the document image may include a document image of a Chinese journal, an English journal, a book, a magazine, a newspaper, etc. The electronic document adapted to the document image may include an identifier for indicating a layout and document content. The identifier for the layout may include an identifier for indicating a layout structure of a document object in the document image and a logical relationship between multiple document objects. The document content may include editable text content.
[0045] The layout of the electronic document may be the same as the document layout in the document image, but is not limited thereto, and may also be a layout optimized based on the document layout of the document image. The document content of the electronic document is the same as the document content in the document image.
[0046] In one example, visually encoding a document image may include extracting features in the document image, such as image features, deep semantic features, etc., to obtain document features.
[0047] In one example, migrating the document features may include performing feature mapping or feature conversion on the document features to obtain migrated features.
[0048] In one example, decoding the migration feature may include predicting the migration feature character by character (token) to obtain the electronic document.
[0049] In one example, the migration features are decoded to obtain identifiers and document content indicating the page layout, which can completely restore the document content in the document image from multiple aspects such as the content and the structural layout of the document objects. No post-processing is required, and end-to-end document image processing is achieved, thereby improving the level of automated processing.
[0050] According to the relevant examples of the present disclosure, the document image can be visually encoded to obtain document features, and the document features can be decoded to obtain an electronic document.
[0051] Compared with the method of directly decoding document features, the document image processing method provided by the example of the present disclosure can well transfer document features to transfer features expressed by language features and knowledge by transferring document features based on image characteristics and knowledge, thereby improving the decoding processing capability of transfer features.
[0052] It can be understood that the document image processing method is described above, and the method of obtaining document features will be further described below.
[0053] According to the embodiments of the present disclosure, Figure 2The operation S210 shown, visually encoding the document image to obtain the document features, may include: performing image data conversion on the document image to obtain image conversion features for encoding. Encoding the image conversion features to obtain the document features.
[0054] In one example, performing image data conversion on a document image may include converting the image into a vector. A convolutional neural network may be used to perform convolution processing on the document image to complete the image data conversion. However, this is not limited to this. The document image may also be converted into image data in other ways, as long as the data conversion method is capable of carrying the document layout structure information and document content information of the document image.
[0055] In one example, encoding image conversion features to obtain document features may include: encoding image conversion features using an encoding method including an attention mechanism to obtain document features. The encoding method including the attention mechanism may include encoding image conversion features using an Encoder in a Transformer. However, it is not limited to this. It may also include encoding image conversion features using an improved encoder. The improved encoder may include improvements in the number of attention heads, improvements in the number of attention mechanism layers and feedforward neural network (FFN) layers, etc.
[0056] According to an embodiment of the present disclosure, before encoding a document image, image data conversion is performed on the document image to improve encoding efficiency and the richness of features extracted from the document image, thereby improving the restoration effect of the electronic document.
[0057] According to an embodiment of the present disclosure, performing image data conversion on a document image to obtain image conversion features for encoding includes: performing image segmentation on the document image to obtain an image block sequence. Performing data conversion on the image block sequence to obtain image conversion features for encoding.
[0058] In one example, the document image may be segmented according to a predetermined pixel granularity, for example, the document image may be segmented according to an N*N resolution to obtain a sequence of image blocks arranged in position order.
[0059] In one example, performing data conversion on the image block sequence may include: performing linear mapping on the image block sequence to obtain an image mapping vector.
[0060] The image conversion feature can be obtained based on the image mapping vector. For example, the image mapping vector is used as the image conversion feature. However, it is not limited to this. The image conversion feature can also be obtained based on the image mapping vector and the position information used to identify the image block sequence.
[0061] According to the embodiments of the present disclosure, by converting the image data of the document image in the above manner, the document image can be segmented to refine the analysis granularity of the document image and improve the information content of the extracted image conversion features. In addition, the image conversion features in the form of vectors are used to express the document with the image as the carrier, which improves the processing capability of the subsequent decoding and improves the integrity and accuracy of the final electronic document.
[0062] According to an embodiment of the present disclosure, when executing Figure 2 Before the operation S210 shown, the document image processing method may further include: pre-processing the document image.
[0063] In one example, preprocessing may include: noise reduction, deformation correction, image shadow removal, image enhancement, etc.
[0064] In the disclosed embodiment, by preprocessing the document image, the content of invalid features and noise features is reduced, thereby improving the effect and efficiency of visual encoding of the preprocessed document image.
[0065] It can be understood that the above describes the determination of document features, and the processing of document features will be further described below.
[0066] According to the embodiments of the present disclosure, Figure 2 The operation S220 shown, performing feature migration on the document features to obtain migration features, may include: performing feature downsampling on the document features to obtain migration features.
[0067] In one example, downsampling the document features may include: aggregating or filtering the document features to obtain migration features, thereby obtaining migration features whose vector dimensions are smaller than those of the document features.
[0068] According to the embodiments of the present disclosure, by downsampling the document features, the vector dimension of the document features can be changed, so that the output features obtained through visual encoding are aligned with the input feature dimensions to be decoded, thereby improving the connectivity and coupling between visual encoding and decoding. In addition, while avoiding the use of traditional OCR technology, the end-to-end document image processing recovery capability and efficiency are improved.
[0069] According to the embodiments of the present disclosure, Figure 2 The operation S230 shown, decoding the migration feature to obtain an electronic document adapted to the document image, may include: when the document object in the document image includes a plurality of column text segments, decoding the migration feature to obtain an electronic document conforming to the reading order.
[0070] In one example, the plurality of column text segments may include a plurality of column text segments, such as a plurality of double-column or triple-column text segments.
[0071] In one example, the electronic document may include an integrated text segment, which is a text segment in which the paragraph formats of multiple column text segments are adjusted, for example, multiple column text segments are integrated into a text segment of one paragraph that conforms to the reading order.
[0072] Figure 3 A schematic diagram of an electronic document according to an embodiment of the present disclosure is schematically shown.
[0073] like Figure 3 As shown, the document image P310 includes a double-column text segment 310. After the document image P310 is processed, an electronic document P320 including an integrated text segment 320 in a reading order is obtained.
[0074] By utilizing the document image processing method provided by the embodiment of the present disclosure, an electronic document conforming to the reading order can be obtained, thereby improving the generalization of end-to-end processing and expanding the scope of application.
[0075] Exemplarily, decoding the migration feature to obtain the electronic document in accordance with the reading order may include: decoding the migration feature and the text prompt instruction to obtain the electronic document in accordance with the reading order.
[0076] In one example, the format and type of the text prompt are not limited, as long as they are used to indicate the expected characteristics of the electronic document. For example, under the guidance of the text prompt, the migration features can be decoded to obtain an electronic document that conforms to the reading order.
[0077] According to the embodiments of the present disclosure, text prompt instructions are used as guidance so that the final electronic document meets expectations, improving the end-to-end restoration capability of document images while improving the richness and diversity of electronic documents.
[0078] According to an embodiment of the present disclosure, an electronic document may include a formatted document, for example, a plain text document that is easy to read and write. However, it is not limited thereto, and may also be other types of data exchange marked documents. As long as it is an electronic document including an identifier for indicating a layout and document content.
[0079] According to an embodiment of the present disclosure, when executing Figure 2 After the operation S230 shown, the document image processing method may further include an operation of: performing format conversion on the format-marked document to obtain an electronic document in a target format.
[0080] According to the embodiments of the present disclosure, the format conversion of the formatted document can be performed, for example, the format conversion of the web page format, to obtain an electronic document with the web page as the target format. However, it is not limited to this. It can also include an editable electronic document that matches the document layout in the document image.
[0081] Exemplarily, an electronic document matching the local content of the document image may be obtained according to the expected result represented by the text prompt instruction, for example, an electronic document matching at least one content such as a table, an image, a formula, or a text.
[0082] According to the embodiments of the present disclosure, by utilizing the document image processing method, the format of the electronic document can be converted, thereby improving the universality and diversity of the electronic document.
[0083] It can be understood that the above text has provided a detailed description of the document image processing method, and the following text will further describe a large model for executing the document image processing method.
[0084] Figure 4 The structural diagram of a large model according to an embodiment of the present disclosure is schematically shown.
[0085] like Figure 4 As shown, the large model for executing the document image processing method may include a visual encoder M410, a feature transfer module M420 and a decoder M430.
[0086] like Figure 4 As shown, the document image 410 can be input into the visual encoder M410 to obtain document features. The document features can be input into the feature migration module M420 to obtain migration features. The migration features can also be input into the decoder M430 to obtain the electronic document 420.
[0087] like Figure 4 As shown, the prompt instruction 430 (prompt) and the document image 410 can also be used as input data and input into the large model, so that the large model can output the expected electronic document 420 based on the prompt instruction. Exemplarily, the migration feature and the prompt instruction 430 can be input into the decoder M430 to obtain the electronic document 420. However, it is not limited to this. The document image and the prompt instruction can also be input into the visual encoder to obtain the document feature. As long as it can facilitate the large model to determine the output result that meets the user's expectations.
[0088] In one example, the visual encoder may include a vision transformer (ViT), but is not limited thereto and may also include a pre-trained model in the visual field such as a cross-scale window attention transformer (Swin-transformer).
[0089] In one example, the decoder may include a decoder in a large language model (LLM) of a Transformer network architecture.
[0090] Exemplarily, the decoder may include 24 layers of Transformer decoding layers and prediction head branches. Each decoding layer may include 16 attention heads. After being processed by the 24 decoding layers, a feature coding vector with a dimension of 2048 is output, and the feature coding vector and the text sequence output at the historical moment that has been output are processed by the prediction head branch to output the predicted text at the current moment until an electronic document is obtained.
[0091] In one example, the feature transfer module may include a multilayer perceptron (MLP), but is not limited thereto, and may also include a pooling layer, as long as it is a network model that can perform a downsampling function.
[0092] In the relevant examples of the present disclosure, the multi-task model for performing the document image parsing task may include a text line detection and recognition model, a table detection and recognition model, a layout detection and classification model, a formula detection and recognition model, etc. The multiple models are trained separately from each other, and the models are coupled to each other. In addition to the need to perform different complex model optimizations, a model in the multi-task model needs to perform additional data processing when it is input into the downstream model, and there are many post-processing steps.
[0093] Compared with the method of performing document image parsing tasks using a multi-task model, the document image processing method provided by the embodiment of the present disclosure can avoid the problem of error accumulation in subsequent models caused by errors in one model. In addition, it also reduces the maintenance cost of model optimization and avoids the problem of multiple models being incompatible with each other due to partial model optimization. In addition, the flexibility and adaptability of the end-to-end model are improved.
[0094] It can be understood that the above describes the network structure of the large model, and the following will describe the training method of the large model.
[0095] It is worth noting that Figure 5 The sample document images, sample document features, sample migration features, and sample electronic documents shown are respectively Figure 2 The document images, document features, migration features, interpretations of electronic documents, and processing methods shown are the same or similar only to reflect the different embodiments. Similarly, if the nouns involved in the training method of the large model and the nouns involved in the document image processing method differ only in the “sample”, the interpretations and processing methods can be the same or similar. No further details will be given here.
[0096] Figure 5 A flowchart of a large model training method according to an embodiment of the present disclosure is schematically shown.
[0097] like Figure 5 As shown, the method includes operations S510 to S540.
[0098] In operation S510, visual encoding is performed on the sample document image to obtain sample document features.
[0099] In operation S520, feature migration is performed on sample document features to obtain sample migration features.
[0100] In operation S530, the sample migration feature is decoded to obtain a sample electronic document that matches the sample document image.
[0101] In operation S540, a large model is trained using sample electronic documents and sample labels matched with sample document images.
[0102] In one example, visually encoding the sample document image may include extracting features in the sample document image, such as image features, deep semantic features, etc., to obtain sample document features.
[0103] In one example, performing feature migration on sample document features may include performing feature mapping or feature conversion on the sample document features to obtain sample migration features.
[0104] In one example, decoding the sample migration feature may include predicting the sample migration feature character by character (token) to obtain a sample electronic document.
[0105] In one example, the sample label may include an identification label for indicating the layout of the sample document image and a document content label. The sample label may be used as real data. The sample electronic document may be used as processing data. The sample electronic document used as processing data may be compared with the sample label used as real data, and the parameters of the large model may be adjusted until the sample electronic document output by the large model approaches the sample label, thereby completing the training of the large model.
[0106] According to an embodiment of the present disclosure, the sample labels used to train the large model include identification labels and document content labels for indicating the layout of the sample document image. The sample electronic documents used to train the large model include sample identification labels and sample document content for indicating the layout of the sample document image. Thus, by training the large model with sample labels and sample electronic documents, the large model can learn the knowledge and ability to perform document image processing tasks end-to-end, thereby improving the automation processing level of the large model.
[0107] According to the embodiments of the present disclosure, Figure 5 The operation S510 shown, visually encoding the sample document image to obtain the sample document feature, may include: performing image data conversion on the sample document image to obtain the sample image conversion feature for encoding. Encoding the sample image conversion feature to obtain the sample document feature.
[0108] In one example, performing image data conversion on the sample document image may include converting the image data into vector data. The sample document image may be convoluted using a convolutional neural network to complete the image data conversion. However, this is not limited to this. The image data conversion may also be performed in other ways, as long as the data conversion method is capable of carrying the document layout structure information and document content information of the sample document image.
[0109] In one example, encoding the sample image conversion features to obtain the sample document features may include: encoding the sample image conversion features using an encoding method including an attention mechanism to obtain the sample document features. The encoding method including the attention mechanism may include encoding the sample image conversion features using an Encoder in a Transformer. However, it is not limited to this. It may also refer to encoding the sample image conversion features using an improved encoder. The improved encoder may include improvements in the number of attention heads, improvements in the number of attention mechanism layers and FFN layers, etc.
[0110] According to an embodiment of the present disclosure, performing image data conversion on a sample document image to obtain sample image conversion features for encoding may include: performing image segmentation on the sample document image to obtain a sample image block sequence. Performing data conversion on the sample image block sequence to obtain sample image conversion features for encoding.
[0111] In an example, performing data conversion on the sample image block sequence may include: performing linear mapping on the sample image block sequence to obtain a sample mapping vector.
[0112] According to an embodiment of the present disclosure, when executing Figure 5 Before the operation S510 shown, the training method of the large model may further include: preprocessing the sample document image.
[0113] In one example, preprocessing may include: noise reduction, deformation correction, image shadow removal, image enhancement, etc.
[0114] According to the embodiments of the present disclosure, Figure 5 The operation S520 shown, performing feature migration on the sample document features to obtain sample migration features, may include: performing feature sampling on the sample document features to obtain sample migration features.
[0115] In one example, feature downsampling of the sample document features may include: aggregating or feature filtering the sample document features to obtain sample migration features. The resulting sample migration features have a vector dimension smaller than that of the sample document features.
[0116] According to an embodiment of the present disclosure, for the operation S530 as shown in Figure 5 decoding the sample migration features to obtain a sample electronic document adapted to the sample document image may include: when the sample document objects in the sample document image include multiple sample column text segments, decoding the sample migration features to obtain a sample electronic document that conforms to the reading order.
[0117] In one example, the sample electronic document includes sample integrated text segments, and the sample integrated text segments are text segments with the paragraph formats of multiple sample column text segments adjusted.
[0118] It can be understood that the generation of the sample electronic document has been described above, and the determination of the sample label will be described below.
[0119] According to an embodiment of the present disclosure, before performing the operation S510 as shown in Figure 5 the training method of the large model may further include: determining the sample label of the sample document image.
[0120] In one example, the identification labels in the sample label for indicating the layout of the sample document image may include document title identification labels, paragraph title identification labels, paragraph identification labels, table title identification labels, table structure identification labels, picture identification labels, figure title identification labels, header identification labels, footnote identification labels, footer identification labels, page number identification labels, etc.
[0121] In one example, the document content label may include text line content labels. For example, text.
[0122] The specific sample label organization format may be as follows:
[0123] <Document Title><Text Line>< / Document Title>
[0124] <Paragraph Title><Text Line>< / Paragraph Title>
[0125] <Text Paragraph><Text Line>< / Text Paragraph>
[0126] <Text Paragraph><Text Line>< / Text Paragraph>
[0127]
[0128] <bbox>< / bbox>
[0129]
[0130]
[0131]
[0132] <Image>
[0133] <bbox>< / bbox>
[0134] <Figure title>< / Figure title>
[0135] < / Image>
[0136] <Header>Text line< / Header>
[0137] <Footnote>Text line< / Footnote>
[0138] <Footer>Text line< / Footer>
[0139] <Page number>Text line< / Page number>
[0140] Exemplarily, determining the sample label of the sample document image may include: performing layout analysis on the sample document image to obtain a sample layout analysis result; performing content analysis on the sample document image to obtain a sample object analysis result; and obtaining a sample label based on the sample layout analysis result and the sample object analysis result.
[0141] In one example, the sample layout analysis result may include sample information for indicating the layout of the sample document image. For example, the sample layout analysis result includes sample information on the layout of tables, table titles, figures, figure titles, document titles, paragraph titles, text paragraphs, tables of contents, headers, footers, footnotes, page numbers, columns, etc. in the sample document image.
[0142] In one example, the sample layout analysis result may be identified, such as identifying the position coordinates of the detection frame, the detection frame category, and the layout label, to obtain an identification label for the layout. However, it is not limited thereto. The sample layout analysis result may also be corrected based on the sample object analysis result to obtain an identification label for the layout.
[0143] In one example, the sample object analysis result may include object recognition results of sample document objects such as text paragraphs, tables, formulas, etc. However, it is not limited thereto. The sample object analysis result may also include object detection results of the object category, position, etc. of sample document objects such as text paragraphs, tables, formulas, etc.
[0144] In one example, a content label may be obtained based on the object recognition result in the sample object analysis result. However, it is not limited thereto. The object detection result may also be used to optimize the sample layout analysis result to obtain an identification label for the layout.
[0145] In one example, a sample label may be obtained based on an identification label and a content label of a layout.
[0146] According to an embodiment of the present disclosure, a sample label is obtained based on the sample layout analysis results and the sample object analysis results, so that the sample label includes an identification label for indicating the layout of the sample document image and a content label, thereby improving the information richness of the sample label. The sample label is applied to the scenario of training a large model, thereby improving the training efficiency of the large model and the end-to-end document image processing capability of the trained large model.
[0147] According to an embodiment of the present disclosure, performing content analysis on a sample document image to obtain a sample object analysis result may include: performing object detection on the sample document object according to a detection method that matches the object type of the sample document object in the sample document image to obtain an object detection result. Performing character recognition on the sample document object according to a recognition method that matches the object type to obtain an object recognition result. Obtaining a sample object analysis result based on the object detection result and the object recognition result.
[0148] Exemplarily, the sample document object may include at least one of text, table, formula, and diagram.
[0149] Exemplarily, for sample document objects of different object types, the same detection method and recognition method may be used to process the sample document objects respectively to obtain object detection results and object recognition results.
[0150] In one example, the sample document object may be processed according to a detection method and an identification method that match the object type of the sample document object to obtain an object detection result and an object identification result.
[0151] According to the embodiments of the present disclosure, the sample document objects are processed respectively according to the detection mode and recognition mode that match the object type of the sample document object, so that the sample document objects can be processed in a targeted manner to improve the accuracy of the object detection results and the object recognition results. In this way, the object detection results and the object recognition results can be applied to the training scene of the large model to improve the training efficiency and training accuracy of the large model.
[0152] Take the sample document object as text content as an example. The text line detection method can be used to perform object detection on the sample document object to obtain an object detection result. The text line detection method can include a regression-based method or a segmentation-based method. The object detection result can include a text line detection box. The text line detection box can be a rectangular box, and the information contained includes: the detection box position coordinates and the detection box category.
[0153] In one example, the regression-based method for text line detection does not require post-processing steps, which improves processing efficiency. The segmentation-based method for text line detection can first obtain the segmented foreground area of the text line, and then use the contour detection method to obtain the final text line detection box. Compared with the regression-based method, the segmentation-based method can support text line detection of any shape, improve the scope of application and expand universality.
[0154] Take the sample document object as text content as an example. The text line recognition method can be used to perform character recognition on the sample document object to obtain an object recognition result. The text line recognition method can include a text line recognition method based on a CRNN (Convolutional Recurrent Neural Network, a convolutional recurrent neural network) + CTC (Connectionist temporal classification, a classification algorithm) network. The network can solve the problem of long text recognition difficulty.
[0155] Take the sample document object including a table as an example. The table detection method can be used to perform object detection on the sample document object to obtain an object detection result. The table detection method can include an autoregressive scheme based on sequence generation or a regression-based scheme. The object detection result can include a table detection box. The table detection box can be a rectangular box, and the information contained includes: the detection box position coordinates and the detection box category.
[0156] In one example, the autoregressive scheme based on sequence generation can directly obtain the HTML (HyperText Markup Language) structure of the complete table, which improves the detection speed for longer tables. The regression-based scheme can detect the physical coordinates of each cell in the table and the logical relationship between each cell.
[0157] In one example, the text in the table can be recognized using a text line recognition method to obtain an object recognition result, which will not be described in detail here.
[0158] Take the sample document object including a formula as an example. The table detection + recognition method can be used to perform object detection and recognition on the sample document object to obtain an object detection result and an object recognition result. The table detection method can include a formula processing model for detecting a formula and identifying the corresponding formula content.
[0159] In one example, the formula processing model may include a visual encoding network + LSTM (Long Short-Term Memory) + attention mechanism.
[0160] By utilizing the formula processing model provided by the embodiments of the present disclosure, the processing efficiency of the dual processing of detecting and identifying formulas in sample documents can be improved.
[0161] It can be understood that the above describes the determination of sample object analysis results, and the following describes the determination of sample layout analysis results.
[0162] According to an embodiment of the present disclosure, performing layout analysis on a sample document image to obtain a sample layout analysis result may include: performing physical layout analysis on the sample document image to obtain a physical layout analysis result for indicating the layout. Based on the physical layout analysis result, determining multiple sample text segments from the sample document image. Performing logical layout analysis on the multiple sample text segments to obtain a logical layout analysis result for indicating a reading order. Based on the physical layout analysis result and the logical layout analysis result, obtaining a sample layout analysis result.
[0163] In one example, a layout analysis model may be used to perform physical layout analysis on a sample document image to obtain a physical layout analysis result.
[0164] Exemplarily, the physical layout analysis model may include a convolutional neural network (CNN) and a transformer network connected in sequence. The convolutional neural network is used to extract local features. The encoding layer in the transformer network is used to extract global features. However, it is not limited to this, and may also include a convolutional neural network, an encoding layer of a transformer network, a decoding layer of a transformer network, and a feature prediction layer connected in sequence. Among them, the convolutional neural network is used to extract local features of the sample document image and provide them to the encoding layer; the encoding layer is used to extract global features of the sample document image and provide them to the decoding layer; the decoding layer decodes the features provided by the encoding layer to obtain decoded features; the feature prediction layer predicts the decoded features to obtain a detection frame and a layout category corresponding to the detection frame.
[0165] In one example, multiple sample text segments can be determined from a sample document image based on the physical layout analysis result. A logical layout analysis model can be used to perform logical layout analysis on the multiple sample text segments to obtain a logical layout analysis result. The logical layout analysis result characterizes the logical relationship or reading order between the multiple sample text segments.
[0166] Exemplarily, the physical layout analysis may include object types of sample document objects, such as headers, footers, tables, pictures, text paragraphs, etc., and geometric coordinates of sample document objects. The logical layout analysis results include the reading order and subordinate relationships between multiple sample document objects in different areas at the logical level.
[0167] Exemplarily, the logical layout analysis model may include a large language model. The large language model is used to predict the text reading order in combination with multiple modal information such as geometric coordinates, visual features, and text semantics of sample document objects, which has a significant effect improvement.
[0168] According to the embodiments of the present disclosure, the physical layout analysis results and the logical layout analysis results are combined to obtain sample layout analysis results, so that the sample layout analysis results not only include layout information on the layout, but also include layout information at the logical level. Sample labels are obtained using the information-rich and comprehensive sample layout analysis results, so that the obtained sample labels can reflect a variety of layout information, thereby improving the functionality and end-to-end document image processing capabilities of the large model trained using the sample labels.
[0169] Figure 6 The flowchart of generating sample labels according to an embodiment of the present disclosure is schematically shown.
[0170] like Figure 6 As shown, a physical layout analysis is performed on the sample document image P610 to obtain a physical layout analysis result 610.
[0171] like Figure 6 As shown, based on the physical layout analysis result 610, multiple sample text segments are determined from the sample document image P610. Logical layout analysis is performed on the multiple sample text segments to obtain a logical layout analysis result 620.
[0172] like Figure 6 As shown, content analysis is performed on the sample document image P610 to obtain text line analysis results 620 , table analysis results 630 , image analysis results 640 , and formula analysis results 650 .
[0173] like Figure 6 As shown, based on the physical layout analysis result 610 , the logical layout analysis result 620 , the text line analysis result 630 , the table analysis result 640 , the image analysis result 650 , and the formula analysis result 660 , a sample label N 610 is obtained.
[0174] According to an embodiment of the present disclosure, obtaining a sample label based on a sample layout analysis result and a sample object detection result may include: obtaining a target sample layout analysis result based on an object detection result and a sample layout analysis result. Obtaining a sample label based on a target sample layout analysis result and a document object recognition result.
[0175] In one example, obtaining a target sample layout analysis result based on the object detection results and the sample layout analysis results may include: using the object detection results and the sample layout analysis results in an optimized manner that matches the object type of the sample document object, to correct the detection frame position coordinates and detection frame category of the sample document object to obtain the target sample layout analysis result.
[0176] For example, the text detection box of the object detection result and the text paragraph box of the sample layout analysis result can be intersected and matched to obtain the subordinate relationship between the text line and the text paragraph, as well as the detection box position coordinates of the target detection box of the sample document object and the object type of the sample document object.
[0177] For another example, for a text line with formulas, the content of each formula text can be represented, and a formula text identifier can be added to each formula to identify the formula content.
[0178] In one example, the target sample layout analysis results such as detection box position coordinates, detection box category and object type of the sample document object can be mapped and then combined with the document object recognition results such as the text of the sample document object to obtain a sample label.
[0179] For example, the physical layout analysis result includes that the object type of the sample document object is a table, and the detection frame position coordinates of the table include fixed-point coordinates (A, B, C, D). The object detection result characterizes that the detection frame position coordinates of the sample document object include fixed-point coordinates (A, B, C, D), and the detection frame category is a table. A mapping relationship can be established based on the physical layout analysis result and the object detection result. Combined with the document object recognition result, such as the text in the table row, a sample label about the table is obtained.
[0180] For sample document images with tables, the coordinates of the detection box of the complete table and the structure information of the table can be recorded. The HTML structure information of the table can be completed by marking the physical coordinates and logical coordinates of each cell. For physical coordinates, the detection box of each cell is marked; for logical coordinates, the starting and ending row and column information between each cell needs to be marked.
[0181] Exemplarily, the subordinate relationships in the results of the logical layout analysis can be used to determine the subordinate relationships between the figure title and the figure, and between the table title and the table, and then the corresponding figures, tables and corresponding titles are combined and marked to obtain sample labels.
[0182] According to the embodiments of the present disclosure, the target sample layout analysis result is obtained by using the object detection result and the sample layout analysis result, so that a mapping relationship can be established between the object detection result and the sample layout analysis result, thereby improving the matching degree and combination accuracy of the target sample layout analysis result and the document object recognition result. In addition, the object detection result and the sample layout analysis result can be used to verify the results, thereby improving the accuracy of the target sample layout analysis result.
[0183] It can be understood that the above describes the method of determining sample labels, and the following describes how to train a large model using sample labels.
[0184] According to an embodiment of the present disclosure, the large model may include a visual encoder, a feature sampling module, and a decoder.
[0185] According to an embodiment of the present disclosure, training a large model using sample electronic documents and sample labels that match sample document images may include: training the large model in steps.
[0186] In one example, step-by-step training of the large model may include: pre-training the large model using sample electronic documents and sample labels to obtain a pre-trained large model; and training the pre-trained large model using fine-tuning sample document images and fine-tuning sample labels matching the fine-tuning sample document images.
[0187] In one example, the noise intensity of the fine-tuning sample label is lower than the noise intensity of the sample label. The noise intensity can be reflected by precision or accuracy.
[0188] For example, the fine-tuned sample labels are obtained by manual labeling, while the sample labels are obtained by processing sample document images with a pre-trained model. The accuracy of the fine-tuned sample labels is higher than that of the sample labels.
[0189] In one example, in order to reduce labor costs, the number of fine-tuning sample labels will be smaller than the number of sample labels, and a large number of sample labels and sample electronic documents are used to pre-train the large model, thereby reducing the difficulty of training the large model and improving the knowledge content learned by the large model. Furthermore, by using a small number of fine-tuning sample labels and fine-tuning sample document images to train the pre-trained large model, the document image processing capability of the trained large model can be improved while reducing the training cost and training efficiency of the large model by fine-tuning the pre-trained large model.
[0190] Figure 7 The figure schematically shows a flow chart of a method for training a large model according to another embodiment of the present disclosure.
[0191] like Figure 7 As shown, a sample document image 710 may be input into a large model to obtain a sample electronic document 720 .
[0192] like Figure 7 As shown, in the process of pre-training the large model, based on the sample electronic document 720 and the sample label 730 matching the sample document image 720, the parameters of the decoder can be fixed and the parameters of the visual encoder and the feature sampling module can be adjusted to obtain the pre-trained large model.
[0193] like Figure 7 As shown, the fine-tuning sample document image 740 can be input into the pre-trained large model to obtain a fine-tuning sample electronic document image 750.
[0194] like Figure 7 As shown, in the fine-tuning stage, the pre-trained large model can be trained using the fine-tuning sample electronic document image 750 and the fine-tuning sample label 760 matching the fine-tuning sample electronic document image 750 to obtain the trained large model.
[0195] According to the embodiments of the present disclosure, during the pre-training process, the parameters of the fixed decoder can be used to adjust the parameters of the visual encoder and the feature sampling module, thereby enhancing the visual effect of the visual model composed of the visual encoder and the feature sampler. During the fine-tuning process, the parameters of the visual encoder, feature sampler and decoder in the pre-trained large model can be adjusted to optimize the correlation and collaboration between the three modules, thereby improving the document parsing effect of the large model.
[0196] According to an embodiment of the present disclosure, a document image processing method is provided, comprising: inputting a document image to be processed into a large model trained using the large model training method provided by the above embodiment, to obtain an electronic document adapted to the document image to be processed.
[0197] By using the large model-based document image processing method provided by the embodiment of the present disclosure, an end-to-end document image parsing system is obtained, which reduces the number of models and the cumbersome steps of model training compared to the traditional document recognition system. By adopting an end-to-end processing solution, redundant post-processing operations can be eliminated and output results that meet the requirements can be directly obtained.
[0198] The document image processing method provided in the embodiment of the present disclosure can be used to complete various tasks such as layout detection and recognition, text line detection and recognition, table detection and recognition, formula detection and recognition, etc., thereby reducing manual post-processing and avoiding coupling problems between models, and can play a role in different downstream tasks.
[0199] Figure 8 A block diagram of a document image processing apparatus according to an embodiment of the present disclosure is schematically shown.
[0200] like Figure 8As shown, the document image processing device 800 of this embodiment includes an image encoding module 810 , a feature migration module 820 and a feature decoding module 830 .
[0201] The image encoding module 810 is used to perform visual encoding on the document image to obtain document features.
[0202] The feature migration module 820 is used to migrate document features to obtain migration features.
[0203] The feature decoding module 830 is used to decode the migration feature to obtain an electronic document adapted to the document image, wherein the electronic document includes an identifier for indicating the page layout and the document content.
[0204] According to an embodiment of the present disclosure, the image encoding module 810 includes an image conversion submodule and a feature encoding submodule.
[0205] The image conversion submodule is used to perform image data conversion on the document image to obtain image conversion features for encoding.
[0206] The feature encoding submodule is used to encode the image conversion features to obtain document features.
[0207] According to an embodiment of the present disclosure, the image conversion submodule includes an image segmentation unit and a sequence conversion unit.
[0208] The image segmentation unit is used to segment the document image to obtain an image block sequence.
[0209] The sequence conversion unit is used to perform data conversion on the image block sequence to obtain image conversion features for encoding.
[0210] According to an embodiment of the present disclosure, the feature migration module includes a feature downsampling submodule.
[0211] The feature downsampling submodule is used to downsample document features to obtain migration features.
[0212] According to an embodiment of the present disclosure, the feature decoding module includes a feature decoding submodule.
[0213] The feature decoding submodule is used to decode the migration features when the document object in the document image includes multiple column text segments to obtain an electronic document that conforms to the reading order, wherein the electronic document includes an integrated text segment, which is a text segment with the paragraph format of multiple column text segments adjusted.
[0214] According to an embodiment of the present disclosure, the electronic document includes a format-marked document; and the document image processing apparatus 800 further includes a format conversion module.
[0215] The format conversion module is used to convert the format of the format-marked document to obtain an electronic document in a target format.
[0216] Fig. 9 A block diagram of a large model training device according to an embodiment of the present disclosure is schematically shown.
[0217] like Fig. 9 As shown, the large model training device 900 of this embodiment includes a sample image encoding module 910, a sample feature migration module 920, a sample feature decoding module 930 and a large model training module 940.
[0218] The sample image encoding module 910 is used to perform visual encoding on the sample document image to obtain sample document features.
[0219] The sample feature migration module 920 is used to migrate sample document features to obtain sample migration features.
[0220] The sample feature decoding module 930 is used to decode the sample migration feature to obtain a sample electronic document that matches the sample document image.
[0221] The large model training module 940 is used to train the large model using sample electronic documents and sample labels that match the sample document images.
[0222] According to an embodiment of the present disclosure, the sample image encoding module 910 includes a sample image conversion submodule and a sample feature encoding submodule.
[0223] The sample image conversion submodule is used to perform image data conversion on the sample document image to obtain sample image conversion features for encoding.
[0224] The sample feature encoding submodule is used to encode the sample image conversion features to obtain the sample document features.
[0225] According to an embodiment of the present disclosure, the sample image conversion submodule includes a sample image segmentation unit and a sample sequence conversion unit.
[0226] The sample image segmentation unit is used to segment the sample document image to obtain a sample image block sequence.
[0227] The sample sequence conversion unit is used to perform data conversion on the sample image block sequence to obtain sample image conversion features for encoding.
[0228] According to an embodiment of the present disclosure, the sample feature migration module 920 includes a sample feature sampling submodule.
[0229] The sample feature sampling submodule is used to perform feature sampling on sample document features to obtain sample migration features.
[0230] According to an embodiment of the present disclosure, the sample feature decoding module 930 includes a sample feature decoding submodule.
[0231] The sample feature decoding submodule is used to decode the sample migration feature when the sample document object in the sample document image includes multiple sample column text segments, so as to obtain a sample electronic document that conforms to the reading order, wherein the sample electronic document includes a sample integrated text segment, and the sample integrated text segment is a text segment in which the paragraph format of multiple sample column text segments is adjusted.
[0232] According to an embodiment of the present disclosure, the large model training device 900 further includes a layout analysis module, a content analysis module and a label determination module.
[0233] The layout analysis module is used to perform layout analysis on sample document images to obtain sample layout analysis results.
[0234] The content analysis module is used to perform content analysis on the sample document image to obtain the sample object analysis result.
[0235] The label determination module is used to obtain the sample label based on the sample layout analysis results and the sample object analysis results.
[0236] According to an embodiment of the present disclosure, the content analysis module includes an object detection submodule, a character recognition submodule and an object analysis result determination submodule.
[0237] The object detection submodule is used to perform object detection on the sample document object in accordance with a detection method that matches the object type of the sample document object in the sample document image to obtain an object detection result.
[0238] The character recognition submodule is used to perform character recognition on the sample document object according to a recognition method that matches the object type to obtain an object recognition result.
[0239] The object analysis result determination submodule is used to obtain the sample object analysis result based on the object detection result and the object recognition result.
[0240] According to an embodiment of the present disclosure, the layout analysis module includes: a physical layout analysis submodule, a text segment determination submodule, a logical layout analysis submodule and a layout analysis result determination submodule.
[0241] The physical layout analysis submodule is used to perform physical layout analysis on the sample document image to obtain a physical layout analysis result for indicating the layout.
[0242] The text segment determination submodule is used to determine multiple sample text segments from the sample document image based on the physical layout analysis result.
[0243] The logical layout analysis submodule is used to perform logical layout analysis on multiple sample text segments to obtain logical layout analysis results for indicating the reading order.
[0244] The layout analysis result determination submodule is used to obtain the sample layout analysis result based on the physical layout analysis result and the logical layout analysis result.
[0245] According to an embodiment of the present disclosure, the label determination module includes: a target result determination submodule and a label determination submodule.
[0246] The target result determination submodule is used to obtain the target sample layout analysis result based on the object detection result and the sample layout analysis result.
[0247] The label determination submodule is used to obtain the sample label based on the target sample layout analysis results and document object recognition results.
[0248] According to an embodiment of the present disclosure, the large model includes a visual encoder, a feature sampling module and a decoder; the large model training module 940 includes a parameter fixing submodule and a large model training submodule.
[0249] The parameter fixing submodule is used to fix the parameters of the decoder and adjust the respective parameters of the visual encoder and the feature sampling module based on the sample electronic document and the sample label matching the sample document image to obtain a pre-trained large model.
[0250] The large model training submodule is used to train the pre-trained large model using the fine-tuning sample document images and the fine-tuning sample labels matching the fine-tuning sample document images, wherein the noise intensity of the fine-tuning sample labels is lower than the noise intensity of the sample labels.
[0251] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0252] According to an embodiment of the present disclosure, an electronic device includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method as described above.
[0253] According to an embodiment of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause a computer to execute the method as described above.
[0254] According to an embodiment of the present disclosure, a computer program product includes a computer program, and when the computer program is executed by a processor, the computer program implements the method as described above.
[0255] Fig.10 A schematic block diagram of an example electronic device 1000 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0256] like Fig.10 As shown, the device 1000 includes a computing unit 1001, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 1002 or a computer program loaded from a storage unit 1008 into a random access memory (RAM) 1003. In the RAM 1003, various programs and data required for the operation of the device 1000 can also be stored. The computing unit 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.
[0257] A number of components in the device 1000 are connected to an input / output (I / O) interface 1005, including: an input unit 1006, such as a keyboard, a mouse, etc.; an output unit 1007, such as various types of displays, speakers, etc.; a storage unit 1008, such as a disk, an optical disk, etc.; and a communication unit 1009, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 1009 allows the device 1000 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0258] The computing unit 1001 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 1001 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 1001 performs the various methods and processes described above, such as a document image processing method. For example, in some embodiments, the document image processing method may be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 1008. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 1000 via the ROM 1002 and / or the communication unit 1009. When the computer program is loaded into the RAM 1003 and executed by the computing unit 1001, one or more steps of the document image processing method described above may be performed. Alternatively, in other embodiments, the computing unit 1001 may be configured to execute the document image processing method in any other appropriate manner (eg, by means of firmware).
[0259] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0260] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0261] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, 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 of the foregoing.
[0262] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0263] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0264] A computer system may include a client and a server. The client and the server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises through computer programs running on respective computers and having a client-server relationship to each other. The server may be a cloud server, a server in a distributed system, or a server combined with a blockchain.
[0265] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0266] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A document image processing method, comprising: Visually encode the document image to obtain document features; Performing feature migration on the document features to obtain migration features; as well as The migration feature is decoded to obtain an electronic document adapted to the document image, wherein the electronic document includes an identifier for indicating a page layout and document content.
2. The method according to claim 1, wherein: The visual encoding of the document image to obtain document features includes: Performing image data conversion on the document image to obtain image conversion features for encoding; and The image conversion feature is encoded to obtain the document feature.
3. The method according to claim 2, wherein: The step of converting the document image into image data to obtain image conversion features for encoding includes: Performing image segmentation on the document image to obtain an image block sequence; and Data conversion is performed on the image block sequence to obtain the image conversion feature for encoding.
4. The method according to any one of claims 1 to 3, wherein: The step of performing feature migration on the document features to obtain migration features includes: The document features are downsampled to obtain the migration features.
5. The method according to any one of claims 1 to 4, wherein: The step of decoding the migration feature to obtain an electronic document adapted to the document image includes: In the case where the document object in the document image includes a plurality of columnar text segments, the migration feature is decoded to obtain the electronic document conforming to the reading order, wherein the electronic document includes an integrated text segment, and the integrated text segment is a text segment in which the paragraph format of the plurality of columnar text segments is adjusted.
6. The method according to claim 5, wherein: The electronic document includes a formatted markup document; The method further comprises: The format-marked document is format-converted to obtain an electronic document in a target format.
7. A large model training method, comprising: Visually encode the sample document image to obtain the sample document features; Performing feature migration on the sample document features to obtain sample migration features; Decoding the sample migration feature to obtain a sample electronic document that matches the sample document image, wherein the sample electronic document includes a sample identifier for indicating a layout and sample document content; and The large model is trained using the sample electronic documents and sample labels that match the sample document images.
8. The method according to claim 7, wherein: The visual encoding of the sample document image to obtain the sample document features includes: Performing image data conversion on the sample document image to obtain sample image conversion features for encoding; and The sample image conversion features are encoded to obtain the sample document features.
9. The method according to claim 8, wherein: The performing image data conversion on the sample document image to obtain sample image conversion features for encoding includes: Performing image segmentation on the sample document image to obtain a sample image block sequence; and Data conversion is performed on the sample image block sequence to obtain the sample image conversion features used for encoding.
10. The method according to any one of claims 7 to 9, wherein: The step of performing feature migration on the sample document features to obtain sample migration features includes: Feature sampling is performed on the sample document features to obtain the sample migration features.
11. The method according to any one of claims 7 to 10, wherein: The decoding of the sample migration feature to obtain a sample electronic document adapted to the sample document image includes: In the case where the sample document object in the sample document image includes a plurality of sample column text segments, the sample migration feature is decoded to obtain the sample electronic document conforming to the reading order, wherein the sample electronic document includes a sample integrated text segment, and the sample integrated text segment is a text segment in which the paragraph format of the plurality of sample column text segments is adjusted.
12. The method according to any one of claims 7 to 11, further comprising: Performing layout analysis on the sample document image to obtain a sample layout analysis result; Performing content analysis on the sample document image to obtain a sample object analysis result; as well as The sample label is obtained based on the sample layout analysis result and the sample object analysis result.
13. The method according to claim 12, wherein: The performing content analysis on the sample document image to obtain a sample object analysis result includes: Performing object detection on the sample document object in accordance with a detection method that matches the object type of the sample document object in the sample document image to obtain an object detection result; Performing character recognition on the sample document object according to a recognition method that matches the object type to obtain an object recognition result; and The sample object analysis result is obtained based on the object detection result and the object recognition result.
14. The method according to claim 12 or 13, wherein: The performing layout analysis on the sample document image to obtain a sample layout analysis result includes: Performing physical layout analysis on the sample document image to obtain a physical layout analysis result for indicating a layout; Based on the physical layout analysis result, determining a plurality of sample text segments from the sample document image; Performing logical layout analysis on the plurality of sample text segments to obtain a logical layout analysis result for indicating a reading order; and The sample layout analysis result is obtained based on the physical layout analysis result and the logical layout analysis result.
15. The method according to any one of claims 12 to 14, wherein: The obtaining of the sample label based on the sample layout analysis result and the sample object detection result includes: Based on the object detection result and the sample layout analysis result, obtaining a target sample layout analysis result; and The sample label is obtained based on the target sample layout analysis result and the document object recognition result.
16. The method according to claim 7, wherein: The large model includes a visual encoder, a feature sampling module and a decoder; The step of training the large model by using the sample electronic document and the sample label matched with the sample document image comprises: Based on the sample electronic document and the sample label matching the sample document image, fixing the parameters of the decoder and adjusting the parameters of the visual encoder and the feature sampling module, respectively, to obtain a pre-trained large model; and The pre-trained large model is trained using a fine-tuning sample document image and a fine-tuning sample label that matches the fine-tuning sample document image, wherein the noise intensity of the fine-tuning sample label is lower than the noise intensity of the sample label.
17. A document image processing device, comprising: An image encoding module is used to visually encode the document image to obtain document features; A feature migration module, used to migrate the document features to obtain migration features; and The feature decoding module is used to decode the migration feature to obtain an electronic document adapted to the document image, wherein the electronic document includes a mark indicating a layout and document content.
18. The device according to claim 17, wherein: The image encoding module comprises: An image conversion submodule, used to perform image data conversion on the document image to obtain image conversion features for encoding; and The feature encoding submodule is used to encode the image conversion features to obtain the document features.
19. The device according to claim 18, wherein: The image conversion submodule comprises: An image segmentation unit, configured to segment the document image to obtain an image block sequence; and A sequence conversion unit is used to perform data conversion on the image block sequence to obtain the image conversion feature for encoding.
20. The device according to any one of claims 17 to 19, wherein The feature migration module comprises: The feature downsampling submodule is used to perform feature downsampling on the document features to obtain the migration features.
21. The device according to any one of claims 17 to 20, wherein: The feature decoding module comprises: The feature decoding submodule is used to decode the migration feature when the document object in the document image includes multiple column text segments to obtain the electronic document in a reading order, wherein the electronic document includes an integrated text segment, and the integrated text segment is a text segment in which the paragraph format of the multiple column text segments is adjusted.
22. The device according to claim 21, wherein The electronic document includes a formatted markup document; The device also includes: The format conversion module is used to convert the format of the format-marked document to obtain an electronic document in a target format.
23. A large model training device, comprising: A sample image encoding module is used to perform visual encoding on the sample document image to obtain sample document features; A sample feature migration module, used to migrate the sample document features to obtain sample migration features; A sample feature decoding module, used for decoding the sample migration feature to obtain a sample electronic document adapted to the sample document image, wherein the sample electronic document includes a sample identifier for indicating a layout and sample document content; as well as The large model training module is used to train the large model using the sample electronic document and the sample labels matching the sample document images.
24. The device according to claim 23, wherein: The sample image encoding module comprises: a sample image conversion submodule, configured to perform image data conversion on the sample document image to obtain sample image conversion features for encoding; and The sample feature encoding submodule is used to encode the sample image conversion features to obtain the sample document features.
25. The device according to claim 24, wherein: The sample image conversion submodule comprises: a sample image segmentation unit, configured to segment the sample document image to obtain a sample image block sequence; and The sample sequence conversion unit is used to perform data conversion on the sample image block sequence to obtain the sample image conversion features used for encoding.
26. The device according to any one of claims 23 to 25, wherein: The sample feature migration module includes: The sample feature sampling submodule is used to perform feature sampling on the sample document features to obtain the sample migration features.
27. The device according to any one of claims 23 to 26, wherein: The sample feature decoding module comprises: The sample feature decoding submodule is used to decode the sample migration feature when the sample document object in the sample document image includes multiple sample column text segments, so as to obtain the sample electronic document in a reading order, wherein the sample electronic document includes a sample integrated text segment, and the sample integrated text segment is a text segment in which the paragraph format of the multiple sample column text segments is adjusted.
28. The apparatus according to any one of claims 23 to 27, further comprising: A layout analysis module, used to perform layout analysis on the sample document image to obtain a sample layout analysis result; A content analysis module, used to perform content analysis on the sample document image to obtain a sample object analysis result; as well as The label determination module is used to obtain the sample label based on the sample layout analysis result and the sample object analysis result.
29. The device according to claim 28, wherein The content analysis module comprises: An object detection submodule, configured to perform object detection on the sample document object in accordance with a detection method that matches the object type of the sample document object in the sample document image, and obtain an object detection result; a character recognition submodule, configured to perform character recognition on the sample document object according to a recognition method matching the object type to obtain an object recognition result; and The object analysis result determination submodule is used to obtain the sample object analysis result based on the object detection result and the object recognition result.
30. The device according to claim 28 or 29, wherein: The layout analysis module comprises: A physical layout analysis submodule, used to perform physical layout analysis on the sample document image to obtain a physical layout analysis result for indicating a layout; A text segment determination submodule, configured to determine a plurality of sample text segments from the sample document image based on the physical layout analysis result; a logical layout analysis submodule, configured to perform a logical layout analysis on the plurality of sample text segments to obtain a logical layout analysis result for indicating a reading order; and The layout analysis result determination submodule is used to obtain the sample layout analysis result based on the physical layout analysis result and the logical layout analysis result.
31. The device according to any one of claims 28 to 30, wherein: The label determination module includes: a target result determination submodule, configured to obtain a target sample layout analysis result based on the object detection result and the sample layout analysis result; and The label determination submodule is used to obtain the sample label based on the target sample layout analysis result and the document object recognition result.
32. The device according to claim 23, wherein: The large model includes a visual encoder, a feature sampling module and a decoder; The large model training module includes: A parameter fixing submodule, used to fix the parameters of the decoder and adjust the parameters of the visual encoder and the feature sampling module based on the sample electronic document and the sample label matching the sample document image, so as to obtain a pre-trained large model; and The large model training submodule is used to train the pre-trained large model using a fine-tuning sample document image and a fine-tuning sample label matching the fine-tuning sample document image, wherein the noise intensity of the fine-tuning sample label is lower than the noise intensity of the sample label.
33. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 16.
34. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-16.
35. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 16.
Citation Information
Cited By
Image processing method and device, electronic equipment and storage medium
CN119418351A
Building programmed modeling method and system based on unmanned aerial vehicle image
CN120635338A
