A document correction system for distorted test papers
By applying a document correction system based on Transformer in the field of test paper image processing, the problem of distorting test paper image processing in the prior art is solved, and more efficient correction and text recognition effects are achieved.
Patent Information
- Application Number
- CN202411396493.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-09
- Publication Date
- 2025-03-11
- Estimated Expiration
- 2044-10-09
AI Technical Summary
The prior art is difficult to effectively deal with distorted test paper images, which affects the accuracy and readability of text recognition tasks.
A document correction system based on Transformer is adopted, including a segmentation module of test paper images and a correction module based on multi-head attention mechanism. The segmentation module is built using UNet, extracting image features through convolutional layers, residual connections and transposed convolutional layers to generate mask diagrams. Then, the divided information is input into the Transformer structure to generate an optical flow diagram for correction.
It significantly improves the correction effect of distorted test paper images, enhances the accuracy of text recognition and readability of test paper documents, and shows superior performance on the test paper document image dataset compared with other methods.
Smart Images

Figure CN118898846B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of image processing, and in particular to a document correction system applied to distorted test papers. Background Art
[0002] Examination papers have long been used to test teaching outcomes. Examination papers help teachers understand students’ learning status at each stage and in each course. If the examination paper content can be identified and analyzed, and the answers of each student to each question can be recorded, teachers can make targeted and reasonable plans for the key points and difficulties of different subjects, so that teaching and review guidance can be truly targeted [1].
[0003] With the development of information science and technology, people are increasingly inclined to use computers as tools for automated information processing, which not only saves manpower and time, but also effectively reduces human errors. Physical data informatization is an important application field of computer information automation processing. In the early days, due to technical limitations, many materials were recorded in paper form, which had high storage costs, limited storage time, and high costs for sorting and retrieval.
[0004] The field of education is a major branch of physical data informatization. Examinations are an effective means of teaching evaluation during the teaching process. The informatization of examination papers not only helps to store examination papers electronically, but also allows for quick and effective statistical analysis of examination paper contents. Currently, OCR (Optical Character Recognition) technology has a relatively good effect on printed text recognition, but there is still a lot of room for research and application in handwritten digit recognition and mathematical formula recognition [2].
[0005] Photographic or scanned document images often exhibit various forms of degradation, including geometric distortion, shadows, penetration, stains, etc. These degradations pose significant challenges to existing document analysis and recognition systems, and also seriously damage the visual appeal and readability of test documents. Document image restoration, which addresses the goals of flattening documents, shadow removal, clean appearance restoration, deblurring, or text segmentation, has both academic and practical significance [3]. However, existing methods do not handle distorted test papers, that is, images with two pages or one full page cannot be handled well.
[0006] The literature involved is as follows:
[0007] [1] Liang Jing. Design and implementation of test paper analysis system based on classical measurement theory[D]. Inner Mongolia University, 2014.
[0008] [2] Xie Yuanhui. Research on test paper recognition based on digital image processing[D]. Xidian University, 2021. DOI:10.27389 / d.cnki.gxadu.2020.001662.
[0009] [3] Zhang J, Peng D, Liu C, et al. DocRes: A Generalist ModelTowardUnifying Document Image Restoration Tasks[J]. arxiv preprint arxiv:2405.04408,2024.. Summary of the invention
[0010] In order to solve the problems, defects and deficiencies of the prior art, a correction model for test paper document image restoration is proposed based on Transformer. The purpose of the present invention is to provide a document correction system for distorted test paper images, which can process distorted test paper images and better correct distorted test paper images, so as to perform text recognition tasks more accurately.
[0011] The specific technical solutions are as follows:
[0012] A document correction system for distorted test papers,
[0013] It includes a test paper image segmentation module and a test paper image correction module based on a multi-head attention mechanism;
[0014] The test paper image segmentation module uses a segmentation model built based on UNet to segment the left and right edge information of the test paper document, extracts and fuses image features through convolutional layers, residual connections, and transposed convolutional layers to obtain an image segmentation map, and then performs post-processing to obtain an actual mask map; the segmented information is then input into a test paper image correction module based on a multi-head attention mechanism to correct the segmented image;
[0015] The test paper image correction module based on the multi-head attention mechanism adopts a Transformer structure, including an Encoder-Decoder structure, and uses a multi-head attention structure network to generate an optical flow map of the image. A series of Encoder encoder blocks are used for step-by-step downsampling and Decoder decoder blocks are used for step-by-step upsampling to obtain a corrected test paper document image.
[0016] Furthermore, the dataset is constructed as follows:
[0017] Collect the original test paper documents, perform data preprocessing and put them into the sample library;
[0018] Collect the original test paper document data and obtain the real information of the test paper document by scanning;
[0019] The distorted test paper image is obtained by shooting, and the test paper document image dataset is constructed corresponding to the real information.
[0020] Furthermore, the preprocessing of the data set includes: performing data preprocessing on the collected distorted test paper images, three-dimensional coordinate maps of the distorted test papers, and optical flow maps, including data cleaning and data cropping, and then putting the preprocessed data into a sample library.
[0021] Furthermore, the process of training the segmentation model and the document correction model includes:
[0022] Build and train the segmentation model; extract any distorted test paper images from the sample library and obtain the edge information of the test paper images;
[0023] Based on the left edge information and the right edge information obtained by the segmentation model, a document correction model based on a multi-head attention mechanism is constructed and trained;
[0024] In order to obtain the final test paper image correction model, it includes a test paper image segmentation module and a test paper image correction module based on a multi-head attention mechanism.
[0025] Furthermore, a segmentation model is constructed and trained; any distorted test paper image is extracted from the sample library, and the edge information of the test paper image is obtained, which specifically includes:
[0026] Data import, model input includes images , 3D coordinate graph and optical flow graph , for images To cut: First, the three-dimensional coordinate map Generate mask map : By extracting the three-dimensional coordinate map The three channel data of this color image mark the non-zero RGB pixels as white and the rest as black to determine the mask map The most edge point , according to the four edge points of the image Cut to get , then , , The size is uniformly scaled to 256*256, and the format is converted to Numpy, respectively. , , ;
[0027] Get data, segment the image edges through the deep learning model of the UNet architecture, and input the image , combined with convolutional layers, residual connections and transposed convolutional layers to extract and fuse image features, first through a 5-layer convolutional structure, the network gradually obtains features on 1 / 4, 1 / 8, 1 / 16, and 1 / 32 of the image, which are recorded as ; These features are enhanced by residual blocks and laterally connected with the features retained in the downsampling stage during the upsampling process to obtain a feature representation with an increased number of channels ;
[0028] After multiple layers of convolution and residual connection, the features The spatial resolution of the feature map is gradually restored by upsampling and transposed convolution; after feature fusion, , and then through multiple residual block processing and Sigmoid activation function binary boundary output, the key entity three-dimensional coordinate map is obtained ;
[0029] During the training phase, the model output With the real three-dimensional coordinate diagram The difference between them is calculated through the loss function Perform calculations to adjust network parameters;
[0030] (1)
[0031] (2).
[0032] Furthermore, based on the left edge information and the right edge information obtained by the segmentation model, a document correction model based on a multi-head attention mechanism is constructed and trained:
[0033] Based on the three-dimensional coordinate diagram of the key entity The model input includes , , ;
[0034] Get data, through the Encoder structure, the model from the input image Get the feature representation from , and then processed by the ReLU activation function to introduce nonlinearity;
[0035] Represent the features Through a series of Encoder blocks, the image is gradually downsampled and the number of channels is increased to obtain features at 1 / 4, 1 / 8, 1 / 16, and 1 / 32 of the image, which are recorded as , and then further downsampled through the convolutional layer;
[0036] After the encoder stage, the features Through the Decoder decoder block, we can get , while reducing the number of channels and performing feature fusion to obtain features , the decoder stage also uses upsampling layers to restore features spatial resolution;
[0037] In the final stage of the decoder, the update model is used to estimate the optical flow of pixels in the image and obtain the optical flow features ; Finally, the model transforms the optical flow features Upsample to the same resolution as the original image to generate the final optical flow map ;
[0038] During the training phase, the model output With real optical flow The difference between them is calculated through the loss function Perform calculations to adjust network parameters for optimal performance;
[0039] (3).
[0040] Furthermore, for the distorted test paper image to be processed , input the image information into the final model after training, and first obtain the three-dimensional coordinate map of the test paper after segmentation On this basis, the predicted image Optical flow graph , and finally and Perform grid sampling to obtain the corrected test paper image .
[0041] Furthermore, it also includes a key text display module for displaying the corrected image in the image of the test paper document. The key entities are highlighted according to their text.
[0042] Furthermore, it also includes an OCR recognition module, which is used to perform OCR recognition on the corrected test paper document image to obtain recognized test paper data.
[0043] Based on the above design, in the actual use and implementation process, the control system includes a test paper correction mobile APP system, which shares an API interface with the client system, and the control system also includes a digital management terminal, which includes a correction management system, and the correction management system includes a user correction module. The system can correct the distorted test paper image input by each user during use, return the corrected test paper image, and recognize the text on the test paper for the user to use.
[0044] And, a document correction method applied to distorted test papers, a segmentation model built based on UNet to achieve the segmentation of the left and right edge information of the test paper document, extracting and fusing image features through convolutional layers, residual connections and transposed convolutional layers to obtain an image segmentation map, and then post-processing to obtain the actual mask map; the segmented information is then input into the Transformer structure to correct the segmented image, including an Encoder-Decoder structure, and a multi-head attention structure network is used to generate an optical flow map of the image, and a series of Encoder encoder blocks are used for step-by-step downsampling and Decoder decoder blocks are used for step-by-step upsampling to obtain the corrected test paper document image.
[0045] Considering the robustness and interpretability of the model, the present invention adopts the UNet segmentation model to realize the segmentation of the left edge information and the right edge information of the test paper document. The segmentation model adopts UNet, and extracts and fuses image features through convolutional layers, residual connections and transposed convolutional layers to obtain image segmentation maps, and then post-processes to obtain actual mask maps. Different from the traditional test paper document image information extraction method, the present invention separates the left edge information and the right edge information of the test paper and then integrates them, instead of directly obtaining the segmented graphics. At the same time, the present invention adopts the Transformer architecture to correct the segmented graphics, including the Encoder-Decoder structure, and the features are gradually downsampled by a series of Encoder encoder blocks and gradually upsampled by Decoder decoder blocks to obtain the corrected test paper document image. Experimental results show that the scheme provided by the present invention has superior performance compared with other methods on the constructed test paper document image dataset. In addition, the ablation study results highlight the excellent model performance of the method of the present invention and emphasize the broad application prospects of Transformer in the field of test paper document image processing. The effectiveness of the Transformer correction model proposed in this invention on complex test documents has been verified through experiments.
[0046] After adopting the above scheme, the present invention and its preferred scheme have the following beneficial effects:
[0047] (1) Use the segmentation module to obtain the left and right edge information of the test paper document, and then integrate them to obtain the mask image. This method effectively segments the test paper document image.
[0048] (2) A correction model for test paper document images is implemented, which can correct the segmented test paper document images. At the same time, in order to improve the correction accuracy of the multi-head branch model, the cross-head spatial collaborative attention mechanism is introduced to extract complex test paper document image information through the design of the test paper image correction module based on the multi-head attention mechanism of the present invention. This mechanism uses different head branches to process different entity types of the document, and uses the spatial attention mechanism to coordinate information communication between different branches, thereby improving the correction performance of the model.
[0049] (3) The performance of the proposed method was evaluated by conducting experiments on a real test paper document dataset and comparing it with other methods. The experimental results show that the proposed method achieves the best performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] The present invention is further described in detail below with reference to the accompanying drawings and specific embodiments:
[0051] Figure 1 It is a flow chart of the main model design process of the system of the present invention;
[0052] Figure 2 It is a schematic diagram of the correction model in the present invention;
[0053] Figure 3 It is a schematic diagram of the result after the test paper document image is segmented in the present invention;
[0054] Figure 4 It is a display diagram of the prediction results of the correction model provided by the present invention on the test paper document image dataset;
[0055] Figure 5 This is a graph showing the OCR recognition results. DETAILED DESCRIPTION
[0056] In order to make the features and advantages of this patent more obvious and easy to understand, the following embodiments are specifically described in detail with the accompanying drawings as follows:
[0057] The use of test paper document images is of great significance in today's education industry. If the information on a paper test paper can be quickly and accurately identified, it will provide more help to teachers and students. However, the correction of test paper document images with unclear edges has always been a severe challenge. Traditional document image correction can only correct one page of document images, while general test paper document images include a whole page, that is, two pages on the left and right, which poses a challenge to the document correction field.
[0058] In order to solve this problem, the present invention introduces a test paper document image correction system based on Transformer. Through a series of Encoder encoder blocks, step-by-step downsampling and Decoder decoder blocks, step-by-step upsampling are performed to obtain a corrected test paper document image. The accuracy and efficiency of key information extraction are significantly improved. Specifically, first, the present invention constructs a segmentation model based on UNet to achieve the segmentation of left edge information and right edge information of the test paper document, extracts and fuses image features through convolutional layers, residual connections and transposed convolutional layers to obtain image segmentation maps, and then post-processes to obtain actual mask maps. The segmented information is then input into the Transformer structure, and a multi-head attention structure network is used to generate an optical flow map of the image, thereby obtaining the corrected result. This method not only alleviates the error propagation caused by traditional detection and recognition methods, but also effectively reduces the interference of redundant environmental information in the model. By evaluating the model on a test paper document image data set, significant performance has been achieved in terms of accuracy. The technical scheme and beneficial effects of the present invention will be described in detail below in conjunction with the accompanying drawings.
[0059] The embodiment of the present invention provides a document correction system for distorted test paper images. The design and construction process of the system can be regarded as the following steps:
[0060] Step A, Analyze requirements and design models: Pre-design a document correction system for distorted test paper images, including a test paper image segmentation module and a test paper image correction module based on a multi-head attention mechanism;
[0061] Step B, collect the original test paper documents, perform data preprocessing operations and then put them into the sample library;
[0062] Step B1, collecting original test paper document data, and obtaining real information of the test paper document using a flatbed scanner;
[0063] Step B2, use a mobile phone to take a picture of the test paper document as a distorted test paper image, corresponding to its real information, and construct a test paper document image dataset;
[0064] Step B3, performing data preprocessing on the collected distorted test paper images, the three-dimensional coordinate graphs of the distorted test papers, and the optical flow graphs, including data cleaning and data clipping, and then putting the preprocessed data into a sample library;
[0065] Step C, training the segmentation model and document correction model;
[0066] Step C1, constructing and training a segmentation model; extracting any distorted test paper image from the sample library, and obtaining edge information of the test paper image;
[0067] Step C2, constructing a document correction model based on a multi-head attention mechanism, and based on the left edge information and right edge information obtained by the aforementioned segmentation model;
[0068] Step C3, training the constructed model to obtain the final test paper image correction model;
[0069] Step D, connecting to the database, designing the client, and ensuring the steady transmission of data; for the distorted test paper image to be processed, inputting the image information of the test paper document into the final model to obtain the corrected document image;
[0070] Step E: Perform a text recognition task on the above results and return the corrected text recognition results.
[0071] like Figure 1 As shown, the construction process of the model corresponding to the most important core part provided in this embodiment includes the following steps:
[0072] S101, collect the original test paper document data set, perform data preprocessing operations and put it into the sample library;
[0073] S102, constructing and training a segmentation model; extracting any distorted test paper image from the sample library, obtaining edge information of the test paper image; manually annotating key entity test paper content to be detected in the test paper image;
[0074] S103, constructing a document correction model based on a multi-head attention mechanism, and training the constructed model based on the left edge information and the right edge information obtained by the aforementioned segmentation model to obtain a final test paper correction model;
[0075] S104, connecting to the database and designing the client; for the distorted test paper image to be processed, inputting the image information of the test paper document into the final model to obtain the corrected document image;
[0076] S105, performing a text recognition task on the above results, and returning a corrected text recognition result;
[0077] S106, highlighting the key entity text of the corrected test paper image, which can help the test paper checker to quickly locate the data for verification and improve work efficiency.
[0078] like Figure 2 As shown, it is a schematic diagram of the test paper document image correction model based on the multi-head attention mechanism in the present invention, which describes the detailed process of processing the document image to output the correction result, specifically including the following steps:
[0079] Step 1.1: Data import, the input of the model includes images , 3D coordinate graph and optical flow graph , for images To cut: First, the three-dimensional coordinate map generate ,Sure The most edge point , according to the four most edge points Cut to get , then , , Scale them uniformly to 256*256, convert them into Numpy format, and get , , .
[0080] The three-dimensional coordinate maps mentioned above refer to "3D coordinate maps". Those skilled in the art can refer to the third part of the paper "DewarpNet: Single-Image Document Unwarping With Stacked 3D and 2DRegression Networks, 2019ICCV" to obtain them. An .exr file will be obtained, which can be visualized as a picture. The three-dimensional map is mainly used to determine the generation of the mask.
[0081] Among them, the mask map The method of generating is: from The data of the red, green, and blue channels are extracted from the corresponding multidimensional arrays, and the non-zero RGB pixel positions in the original image are marked as white.
[0082] Step 1.2: Get data and segment the image edges using the UNet deep learning model. The input is image , combining convolutional layers, residual connections and transposed convolutional layers to extract and fuse image features. First, through the 5-layer convolutional structure, the network gradually obtains the features on 1 / 4, 1 / 8, 1 / 16, and 1 / 32 of the image, which are recorded as ; These features are enhanced by residual blocks and laterally connected with the features retained in the downsampling stage during the upsampling process to obtain a feature representation with an increased number of channels .
[0083] Step 1.3: After multiple layers of convolution and residual connection, the features The spatial resolution of the feature map is gradually restored by upsampling and transposed convolution; after feature fusion, , and then through a series of residual block processing and Sigmoid activation function binary boundary output, the key entity three-dimensional coordinate map is obtained .
[0084] In step 1, during the training phase, the output of the model is With the real three-dimensional coordinate diagram The difference between them is calculated through the loss function Perform calculations to adjust network parameters.
[0085] (1)
[0086] (2)
[0087] Step 2.1: Get the three-dimensional coordinate diagram of the key entity described in step 1.3 , data import, model input includes , , .
[0088] Step 2.2: Get data, through the Encoder structure, the model from the input image Get the feature representation from These feature representations are processed by the ReLU activation function to introduce non-linearity.
[0089] Step 2.3: The features are gradually downsampled through a series of Encoder blocks while increasing the number of channels to obtain features at 1 / 4, 1 / 8, 1 / 16, and 1 / 32 of the image, denoted as , and further downsampled through convolutional layers.
[0090] Step 2.4: After the encoder stage, the features Through the Decoder decoder block, we can get , while reducing the number of channels and performing feature fusion to obtain features , the decoder stage also uses upsampling layers to restore features spatial resolution.
[0091] Step 2.5: In the final stage of the decoder, the update module is used to estimate the optical flow of pixels in the image and obtain the optical flow features Finally, the model transforms the optical flow features Upsample to the same resolution as the original image to generate the final optical flow map .
[0092] In step 2, during the training phase, the output of the model With real optical flow The difference between them is calculated through the loss function Perform calculations to adjust network parameters for optimal performance.
[0093] (3)
[0094] The present invention realizes correction of distorted images, which actually involves learning the pixel offset of the distorted image, that is, the optical flow map, through a model, and then obtaining the corrected image by grid_sampling the original image and the optical flow map.
[0095] As a preferred embodiment of the present invention, a real test paper document image is used. There are 65 test papers from different subjects. The test paper layout is fixed, and one side is composed of two left and right pages. Each test paper has at least two sides. The subjects of the test paper include Chinese, mathematics, English, biology, geography, chemistry, history, and physics. The entire data set is divided into 70% training set, 10% validation set, and 20% test set. For all experiments, training and testing are performed under the same hardware environment. The Adam optimizer is used for training, with an initial learning rate of 0.001 and a batch size of 16. Data standardization and data enhancement techniques are used in the training process. Data enhancement includes random rotation, random cropping, and random horizontal flipping. The flipped images are flipped back to normal pages. The randomly cropped images are 256*256 size images. Two common evaluation indicators are used: Multi-Scale Structural Similarity (MS-SSIM) and Local Distortion (LD). In OCR quality evaluation, Edit Distance (ED) and Character Error Rate (CER) are used to measure the performance of the model.
[0096] Figure 3 The figure shows the prediction results of the segmentation model provided by the present invention on the test paper document image dataset. Figure 3 It can be seen that the model can segment the edges of the test paper document, including the left edge information and the right edge information. Figure 4 Two examples of using the solution of the present invention to correct the input and output of the system and finally call OCR recognition are shown. In addition, the model also uses OCR technology to recognize the text of the output results and highlight the fonts, such as Figure 5 It is worth noting that the model shows remarkable results in identifying texts and segmenting their edges.
[0097] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0098] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0099] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0100] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0101] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0102] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
[0103] This patent is not limited to the above-mentioned optimal implementation mode. Anyone can derive other various forms of a document correction system for distorted test papers under the inspiration of this patent. All equal changes and modifications made according to the scope of the patent application of the present invention should be covered by this patent.
Claims
1. A document correction system for distorted examination papers, characterized in that: The document correction system includes a test paper image segmentation module and a test paper image correction module based on a multi-head attention mechanism; The test paper image segmentation module implements the segmentation of the left edge information and the right edge information of the test paper document based on the deep learning model of the UNet architecture, extracts and fuses image features through convolutional layers, residual connections and transposed convolutional layers to obtain a three-dimensional coordinate diagram of key entities; and then inputs the segmented information into the test paper image correction module based on the multi-head attention mechanism to correct the segmented graphics; The test paper image correction module based on the multi-head attention mechanism adopts a Transformer structure, including an encoder-decoder structure, and uses a multi-head attention structure network to generate an optical flow map of the image, and performs step-by-step downsampling through a series of encoder blocks and step-by-step upsampling through decoder blocks to generate a final optical flow map; The process of training the segmentation module and the test paper image correction module includes: Construct and train a segmentation module; extract any distorted test paper image from the sample library, and obtain the left edge information and the right edge information of the test paper image; obtaining the left edge information and the right edge information of the test paper image specifically includes: Data import, input includes images , 3D coordinate graph and optical flow graph ; For images To cut: First, the three-dimensional coordinate map Generate mask map , by extracting the 3D coordinate map The three channel data of this color image mark the non-zero RGB pixels as white to determine the mask map The most edge point , according to the four edge points of the image Cut to get ;Will , , Scaling and format conversion are performed respectively to obtain , , ; Get data and segment the image edges using the UNet deep learning model. The input is , combining convolutional layers, residual connections, and transposed convolutional layers to extract and fuse image features; through a series of residual block processing and the binary boundary output of the Sigmoid activation function, the three-dimensional coordinate map of the key entity is obtained. ; Based on the left edge information and the right edge information obtained by the segmentation module, a test paper image correction module based on a multi-head attention mechanism is constructed and trained; specifically, the following steps are included: Data import, input includes images , 3D coordinate diagram of key entities , ; Get data, through the encoder structure, from the input image Get the feature representation from , and then processed by the ReLU activation function to introduce nonlinearity; Represent the features The image is gradually downsampled through a series of encoder blocks, while the number of channels is increased to obtain features at 1 / 4, 1 / 8, 1 / 16, and 1 / 32 of the image, respectively. , further downsampled through convolutional layers; After the encoder stage, the features By progressive upsampling through the decoder block, we get , while reducing the number of channels and performing feature fusion to obtain features , the decoder stage also uses upsampling layers to restore features spatial resolution; in the final stage of the decoder, the update module is used to estimate the optical flow of pixels in the image and obtain the optical flow features ; Finally, the optical flow features Upsample to the same resolution as the original image to generate the final optical flow map ; Obtain the test paper image segmentation module of the document correction system and the test paper image correction module based on the multi-head attention mechanism; For the distorted test paper images to be processed , input the image information into the document correction system, and first obtain the three-dimensional coordinate map of the key entities of the test paper after segmentation On this basis, the distorted test paper image to be processed is predicted Optical flow graph , and finally and Perform grid sampling to obtain the corrected test paper image .
2. A document correction system for distorted test papers according to claim 1, characterized in that: The dataset is constructed as follows: Collect the original test paper documents, perform data preprocessing and put them into the sample library; Collect the original test paper document data and obtain the real information of the test paper document by scanning; The distorted test paper image is obtained by shooting, and the test paper document image dataset is constructed corresponding to the real information.
3. A document correction system for distorted test papers according to claim 2, characterized in that: The preprocessing of the data set includes: data preprocessing of the collected distorted test paper images, three-dimensional coordinate maps of the distorted test papers and optical flow maps, including data cleaning and data cropping, and then putting the preprocessed data into the sample library.
4. A document correction system for distorted test papers according to claim 1, characterized in that: The , , Scaling and format conversion are performed respectively to obtain , , The specific process includes: Will , , The size is uniformly scaled to 256*256, and the format is converted to Numpy, respectively. , , ; The process of extracting and fusing image features by combining convolutional layers, residual connections and transposed convolutional layers specifically includes: first, through a 5-layer convolutional structure, the network gradually obtains features on 1 / 4, 1 / 8, 1 / 16, and 1 / 32 of the image, which are respectively recorded as ; These features are enhanced by residual blocks and laterally connected with the features retained in the downsampling stage during the upsampling process to obtain a feature representation with an increased number of channels ; After multiple layers of convolution and residual connection, the feature The spatial resolution of the feature map is gradually restored by upsampling and transposed convolution; after feature fusion, ; The construction and training of the segmentation module also includes: in the training stage, the segmentation module outputs With 3D coordinates The difference between them is calculated through the loss function Perform calculations to adjust network parameters; (1) (2)。 5. A document correction system for distorted test papers according to claim 1, characterized in that: The process of constructing and training the test paper image correction module based on the multi-head attention mechanism also includes: During the training phase, the test paper image correction module based on the multi-head attention mechanism outputs and The difference between them is calculated through the loss function Perform calculations to adjust network parameters for optimal performance; (3)。 6. A document correction system for distorted test papers according to claim 1, characterized in that: It also includes a key text display module for displaying the corrected image in the image of the test paper document. The key entities are highlighted according to their text.
7. A document correction system for distorted test papers according to claim 1, characterized in that: It also includes an OCR recognition module, which is used to perform OCR recognition on the corrected test paper document image to obtain recognized test paper data.
8. A document correction method for distorted test papers, characterized in that: The test paper image segmentation module is used to implement the segmentation of the left edge information and the right edge information of the test paper document based on the deep learning model of the UNet architecture, and the image features are extracted and fused through the convolution layer, the residual connection and the transposed convolution layer to obtain the three-dimensional coordinate map of the key entity; the segmented information is then input into the test paper image correction module based on the multi-head attention mechanism to correct the segmented graphics; the segmented information is then input into the test paper image correction module using the Transformer structure to correct the segmented graphics, the Transformer structure includes an encoder-decoder structure, and a multi-head attention structure network is used to generate an optical flow map of the image, and a series of encoder blocks are used to perform step-by-step downsampling and decoder blocks are used to perform step-by-step upsampling to generate the final optical flow map; The process of training the segmentation module and the test paper image correction module includes: Construct and train a segmentation module; extract any distorted test paper image from the sample library, and obtain the left edge information and the right edge information of the test paper image; obtaining the left edge information and the right edge information of the test paper image specifically includes: Data import, input includes images , 3D coordinate graph and optical flow graph ; For images To cut: First, the three-dimensional coordinate map Generate mask map , by extracting the 3D coordinate map The three channel data of this color image mark the non-zero RGB pixels as white to determine the mask map The most edge point , according to the four edge points of the image Cut to get ;Will , , Scaling and format conversion are performed respectively to obtain , , ; Get data and segment the image edges using the UNet deep learning model. The input is , combining convolutional layers, residual connections, and transposed convolutional layers to extract and fuse image features; through a series of residual block processing and the binary boundary output of the Sigmoid activation function, the three-dimensional coordinate map of the key entity is obtained. ; Based on the left edge information and the right edge information obtained by the segmentation module, a test paper image correction module based on a multi-head attention mechanism is constructed and trained; specifically, the following steps are included: Data import, input includes images , 3D coordinate diagram of key entities , ; Get data, through the encoder structure, the model from the input image Get the feature representation from , and then processed by the ReLU activation function to introduce nonlinearity; Represent the features The image is gradually downsampled through a series of encoder blocks, while the number of channels is increased to obtain features at 1 / 4, 1 / 8, 1 / 16, and 1 / 32 of the image, respectively. , further downsampled through convolutional layers; After the encoder stage, the features By progressive upsampling through the decoder block, we get , while reducing the number of channels and performing feature fusion to obtain features , the decoder stage also uses upsampling layers to restore features spatial resolution; in the final stage of the decoder, the update module is used to estimate the optical flow of pixels in the image and obtain the optical flow features ; Finally, the model transforms the optical flow features Upsample to the same resolution as the original image to generate the final optical flow map ; Obtain the test paper image segmentation module of the document correction system and the test paper image correction module based on the multi-head attention mechanism; For the distorted test paper images to be processed , input the image information into the document correction system, and first obtain the three-dimensional coordinate map of the key entities of the test paper after segmentation On this basis, the distorted test paper image to be processed is predicted Optical flow graph , and finally and Perform grid sampling to obtain the corrected test paper image .
Citation Information
Patent Citations
Document image correction method and device applied to distorted document
CN118711191A