Document recognition method, device, equipment and storage medium based on deep learning
Through the detection model and document semantic segmentation model based on the YOLO algorithm, the document frame is extracted and semantically segmented, which solves the problems of long time consumption and poor robustness of traditional document recognition methods, and achieves more efficient and accurate document recognition.
Patent Information
- Application Number
- CN202011581192.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-28
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2040-12-28
AI Technical Summary
Traditional document recognition methods are time-consuming and have poor robustness to blurry images, resulting in low recognition accuracy.
A detection model based on the YOLO algorithm is used for document frame detection, and a pre-trained document semantic segmentation model is used for semantic segmentation, key field frames are extracted, and document information is obtained through text recognition.
It improves the accuracy and efficiency of document recognition and enhances the robustness to blurry pictures.
Smart Images

Figure CN112699775B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a document recognition method, device, electronic device and computer-readable storage medium based on deep learning. Background Art
[0002] With the development of science and technology, various certificates, such as identity cards, are used in wider and wider fields, and the identification of certificates is receiving more and more attention.
[0003] The traditional method for document recognition is to preprocess the image, then use scale-invariant feature transformation to extract the key fields on the document, and finally perform recognition. However, this method is time-consuming and less robust to slightly blurred images. Most document images are not high-definition, resulting in low accuracy of the recognition results. Summary of the invention
[0004] The present invention provides a document recognition method, device and computer-readable storage medium based on deep learning, the main purpose of which is to solve the problem of low accuracy in document recognition.
[0005] To achieve the above object, the present invention provides a document recognition method based on deep learning, comprising:
[0006] Use the detection model based on the YOLO algorithm to detect the image to be identified and obtain the document frame diagram;
[0007] Intercepting the certificate frame diagram to obtain a certificate image;
[0008] Based on the dilated convolution, a pre-trained document semantic segmentation model is used to perform semantic segmentation on the document image to obtain multiple key field boxes;
[0009] The document image is subjected to text recognition according to the key field frame to obtain the document information.
[0010] Optionally, the detecting model based on the YOLO algorithm is used to detect the image to be identified to obtain the document block diagram, including:
[0011] Resizing the image to be recognized to obtain an input image;
[0012] Inputting the input image into the feature extraction network of the detection model to perform feature extraction, and obtaining a feature map output by the feature extraction network;
[0013] The feature map is further input into the segmentation network of the detection model to perform image segmentation, thereby obtaining a plurality of grids output by the segmentation network;
[0014] The multiple grids pass through the fully connected layer of the detection model to perform target detection on the image in each grid to obtain a document frame diagram.
[0015] Optionally, performing target detection on the image in each grid through the fully connected layer of the detection model to obtain a document block diagram includes:
[0016] The image in each grid is identified through the fully connected layer of the detection model and multiple candidate bounding boxes are predicted, and the confidence of each candidate bounding box is calculated;
[0017] The candidate bounding box corresponding to the highest confidence value is used as the target detection box, and a box is selected and marked at the same position in the image to be identified according to the size and position of the target detection box to obtain a document frame diagram.
[0018] Optionally, the document image is semantically segmented using a pre-trained document semantic segmentation model to obtain multiple key field boxes, including:
[0019] Inputting the document image into the hole convolution layer of the document semantic segmentation model for feature extraction to obtain multiple feature maps of different scales;
[0020] Inputting the multiple feature maps of different scales into the spatial pyramid layer of the document semantic segmentation model for fusion to obtain a fine feature map;
[0021] Input the fine feature map into the decoding layer of the document semantic segmentation model for convolution and upsampling to obtain a segmentation result map;
[0022] The segmentation result graph is corrected to obtain a plurality of key field frames.
[0023] Optionally, the segmentation result map is corrected to obtain a plurality of key field frames, including:
[0024] Obtaining the vertex coordinates of all field boxes in the segmentation result graph;
[0025] Using a preset perspective transformation matrix to map and transform the vertex coordinates to obtain new vertex coordinates;
[0026] A box is selected and marked at the same position in the document image according to the new vertex coordinates to obtain multiple key field boxes.
[0027] Optionally, performing text recognition on the certificate image according to the key field box and collecting the detected text and the corresponding category to obtain certificate information includes:
[0028] Using the key field frame as a text detection frame of the document image;
[0029] Performing text recognition on the text detection frame of the certificate image to obtain a plurality of detection texts corresponding to the key field frame;
[0030] The multiple detection texts are classified and identified to obtain certificate information.
[0031] Optionally, before using the pre-trained document semantic segmentation model to perform semantic segmentation on the document image, the method further includes:
[0032] Collect multiple document images, and annotate the document images with category labels and positions according to preset labels to obtain a training data set;
[0033] Perform semantic segmentation on the training data set using a document semantic segmentation model to obtain a training result set;
[0034] Calculating the loss value of the training result set using a preset loss function;
[0035] According to the loss value, the back propagation algorithm is used to update the parameters of the document semantic segmentation model, and the step of using the document semantic segmentation model to perform semantic segmentation on the training data set to obtain a training result set is returned until the loss value no longer decreases, thereby obtaining a trained document semantic segmentation model.
[0036] In order to solve the above problems, the present invention also provides a document recognition device based on deep learning, the device comprising:
[0037] A detection module is used to detect the image to be identified using a detection model based on the YOLO algorithm to obtain a document block diagram;
[0038] An interception module, used for intercepting the certificate frame diagram to obtain a certificate image;
[0039] A semantic segmentation module, used to perform semantic segmentation on the document image based on a dilated convolution using a pre-trained document semantic segmentation model to obtain a plurality of key field boxes;
[0040] The recognition module is used to perform text recognition on the certificate image according to the key field frame to obtain certificate information.
[0041] In order to solve the above problem, the present invention further provides an electronic device, the electronic device comprising:
[0042] a memory storing at least one instruction; and
[0043] A processor executes instructions stored in the memory to implement the above-mentioned deep learning-based document recognition method.
[0044] In order to solve the above problems, the present invention also provides a computer-readable storage medium, in which at least one instruction is stored. The at least one instruction is executed by a processor in an electronic device to implement the above-mentioned deep learning-based document recognition method.
[0045] The embodiment of the present invention uses a detection model based on the YOLO algorithm to detect the image to be identified. The YOLO algorithm is a single-stage detection algorithm, which has the advantage of fast speed and can improve the efficiency of detection. The document image is semantically segmented using a pre-trained document semantic segmentation model to determine the regional location of the document information. The document semantic segmentation model is constructed based on a deep learning algorithm and trained based on a training data set. It has stronger robustness and can further improve the accuracy of identification and improve work efficiency. Therefore, the document recognition method, device, electronic device and computer-readable storage medium based on deep learning proposed in the present invention can solve the problem of low document recognition accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 A schematic diagram of a process flow of a document recognition method based on deep learning provided by an embodiment of the present invention;
[0047] Figure 2 A functional module diagram of a document recognition device based on deep learning provided by an embodiment of the present invention;
[0048] Figure 3 A schematic diagram of the structure of an electronic device for implementing the deep learning-based document recognition method provided in one embodiment of the present invention.
[0049] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0050] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0051] The embodiment of the present application provides a document recognition method based on deep learning. The execution subject of the document recognition method based on deep learning includes but is not limited to at least one of the electronic devices such as a server and a terminal that can be configured to execute the method provided by the embodiment of the present application. In other words, the document recognition method based on deep learning can be executed by software or hardware installed on a terminal device or a server device, and the software can be a blockchain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, etc.
[0052] Reference Figure 1FIG. 1 is a flow chart of a method for document recognition based on deep learning provided by an embodiment of the present invention. In this embodiment, the method for document recognition based on deep learning includes:
[0053] S1. Use the detection model based on the YOLO algorithm to detect the image to be identified and obtain the document frame diagram.
[0054] The image to be identified in the embodiment of the present invention is an image containing a certificate, such as an ID card, a passport, etc. The image to be identified can be obtained from a database. In order to further ensure the privacy and security of the image to be identified, the image to be identified can also be obtained from a node of a blockchain.
[0055] The detection model based on the YOLO algorithm is a target detection model based on a deep neural network, which can realize the document detection task according to preset labels, that is, identify the document and determine its exact position in the image.
[0056] In detail, the detection model based on the YOLO algorithm is used to detect the image to be identified to obtain the document block diagram, including:
[0057] Resizing the image to be recognized to obtain an input image;
[0058] Inputting the input image into the feature extraction network of the detection model to perform feature extraction, and obtaining a feature map output by the feature extraction network;
[0059] The feature map is further input into the segmentation network of the detection model to perform image segmentation, thereby obtaining a plurality of grids output by the segmentation network;
[0060] The multiple grids pass through the fully connected layer of the detection model to perform target detection on the image in each grid to obtain a document frame diagram.
[0061] The feature extraction is to sample the image through a convolution operation to remove the details in the image, so that the features of the input image are more obvious.
[0062] In the embodiment of the present invention, the feature map is further input into the segmentation network of the detection model to perform image segmentation, which is to divide the image into multiple image blocks of the same size, and the grid is an image block.
[0063] Furthermore, the plurality of grids are passed through the fully connected layer of the detection model to perform target detection on the image in each grid to obtain a document block diagram, including:
[0064] The image in each grid is identified through the fully connected layer of the detection model and multiple candidate bounding boxes are predicted, and the confidence of each candidate bounding box is calculated;
[0065] The candidate bounding box corresponding to the highest confidence value is used as the target detection box, and a box is selected and marked at the same position in the image to be identified according to the size and position of the target detection box to obtain a document frame diagram.
[0066] The confidence level includes the probability that the candidate bounding box contains the target (such as an ID card) and the accuracy of the candidate bounding box. The probability that the candidate bounding box contains the target is denoted as P r , when the candidate bounding box is the background (i.e. does not contain the target), then P r = 0, and when the candidate bounding box contains the target, P r = 1. The accuracy of the candidate bounding box can be characterized by the intersection over union of the predicted box and the actual box, denoted as The predicted box is the candidate bounding box output by the detection model, and the actual box is the real bounding box of the target object. The candidate bounding box can be represented by (x, y, w, h), where (x, y) is the center coordinate of the candidate bounding box, and w and h are the width and height of the candidate bounding box. Therefore, the formula can be used The confidence level is calculated.
[0067] The marking of the target detection frame at the same position in the image to be identified according to the size and position of the target detection frame means marking a frame of the same size at the same position in the image to be identified according to the position and size of the target detection frame, so that the position of the target in the image to be identified, i.e., the document, is marked.
[0068] For example, the size of the image to be identified is adjusted to an input image of 416*416, and the feature extraction network of the detection model extracts features from the input image to obtain a feature map of a certain size, such as 13*13. Then the segmentation network of the detection model divides the feature image into 13*13 grids, and the fully connected layer of the detection model performs target detection on the image in each grid to check whether the grid contains a target with the same preset label. If so, the target position is predicted through the candidate bounding box, and the final detection result is obtained by calculating the confidence.
[0069] The detection model described in the embodiment of the present invention is based on the YOLO algorithm, and the YOLO algorithm is a single-stage detection algorithm, which has the advantage of high speed and can improve the efficiency of detection.
[0070] S2. intercepting the certificate frame diagram to obtain a certificate image.
[0071] In the embodiment of the present invention, the document image is an image that contains more target detection frames than the image to be identified, for example, an image that contains a green frame that frames the position and size of the ID card in a photo containing an ID card. The document image is an image of only the ID card, such as an image of only the ID card within the green frame and without the rest of the background.
[0072] In detail, the certificate image contains a target detection frame. In an embodiment of the present invention, the target detection frame is a boundary frame corresponding to the certificate. The certificate image is cropped to size according to the position of the target detection frame, the complete certificate is captured, the image within the target detection frame is retained, and the rest of the certificate image is removed to obtain the certificate image.
[0073] S3. Perform semantic segmentation on the document image using a pre-trained document semantic segmentation model based on dilated convolution to obtain multiple key field boxes.
[0074] The document semantic segmentation model described in the embodiment of the present invention is a segmentation model based on a deep neural network and can be used for image segmentation.
[0075] In detail, the document image is semantically segmented using a pre-trained document semantic segmentation model to obtain multiple key field boxes, including:
[0076] Inputting the document image into the hole convolution layer of the document semantic segmentation model for feature extraction to obtain multiple feature maps of different scales;
[0077] Inputting the multiple feature maps of different scales into the spatial pyramid layer of the document semantic segmentation model for fusion to obtain a fine feature map;
[0078] Input the fine feature map into the decoding layer of the document semantic segmentation model for convolution and upsampling to obtain a segmentation result map, wherein the segmentation result map includes a plurality of field boxes;
[0079] The segmentation result graph is corrected to obtain a plurality of key field frames.
[0080] Optionally, the hole convolution layer of the document semantic segmentation model in the embodiment of the present invention can control the receptive field without changing the size of the feature map, which is conducive to extracting multi-scale information.
[0081] Optionally, the spatial pyramid layer of the document semantic segmentation model can further extract multi-scale information, mainly through dilated convolutions of different rates. Furthermore, the spatial pyramid layer includes: (1) a 1×1 convolution layer and three 3×3 dilated convolutions; (2) a global average pooling layer to obtain image features, which are then sent to a 1×1 convolution layer and bilinearly interpolated to the original size; (3) the features of four different scales obtained from (1) and (2) are concatenated together, and then sent to a 1×1 convolution layer for fusion to obtain a new feature map with a size of 256 channels.
[0082] Optionally, the decoding layer of the document semantic segmentation model upsamples the result of the spatial pyramid layer by 4 times, then connects it with the low-level features when the feature sampling is performed in the hole convolution layer, performs a 3x3 convolution, and finally upsamples it by 4 times to obtain the final result.
[0083] Furthermore, the segmentation result map is corrected to obtain a plurality of key field frames, including:
[0084] Obtaining the vertex coordinates of all field boxes in the segmentation result graph;
[0085] Using a preset perspective transformation matrix to map and transform the vertex coordinates to obtain new vertex coordinates;
[0086] A box is selected and marked at the same position in the document image according to the new vertex coordinates to obtain multiple key field boxes.
[0087] The perspective transformation matrix is a transformation matrix obtained by using vertex coordinates of the original image and the transformed image in the training image; and the mapping transformation is calculated using a general transformation formula.
[0088] The field box in the segmentation result image may have errors such as offset and tilt. The embodiment of the present invention corrects it through perspective transformation. The field box is corrected by obtaining the coordinates of the four vertices of the field box and performing perspective transformation. The perspective transformation is a projection mapping of the image, which can correct the tilted image into a positive projection.
[0089] Optionally, before using the pre-trained document semantic segmentation model to perform semantic segmentation on the document image, the method further includes:
[0090] Collect multiple document images, and annotate the document images with category labels and positions according to preset labels to obtain a training data set;
[0091] Perform semantic segmentation on the training data set using a document semantic segmentation model to obtain a training result set;
[0092] Calculating the loss value of the training result set using a preset loss function;
[0093] According to the loss value, the back propagation algorithm is used to update the parameters of the document semantic segmentation model, and the step of using the document semantic segmentation model to perform semantic segmentation on the training data set to obtain a training result set is returned until the loss value no longer decreases, thereby obtaining a trained document semantic segmentation model.
[0094] The loss function in the embodiment of the present invention includes:
[0095]
[0096] Among them, Loss is the loss value, y t is the real field box, is the predicted field box output by the document semantic segmentation model, and N is the total number of training data sets.
[0097] S4. Perform text recognition on the certificate image according to the key field box to obtain certificate information.
[0098] In detail, the text recognition of the certificate image is performed according to the key field frame to obtain the certificate information, including:
[0099] Using the key field frame as a text detection frame of the document image;
[0100] Performing text recognition on the text detection frame of the certificate image to obtain a plurality of detection texts corresponding to the key field frame;
[0101] The multiple detection texts are subjected to category identification, and the detection texts are combined with corresponding categories to obtain certificate information.
[0102] Furthermore, the performing category recognition on the multiple detected texts includes:
[0103] Obtain a key field box corresponding to the detected text;
[0104] The outline size of the key field frame is calculated, and the category of the detected text corresponding to the key field frame is obtained by searching in a preset category information table according to the outline size.
[0105] The category information table includes a plurality of certificate information categories and corresponding outline size ranges.
[0106] For example, in an embodiment of the present invention, OCR technology is used to perform text recognition on the image portion within multiple key field boxes in the certificate image to obtain text content, and the certificate information category corresponding to the text content is identified based on the outline size of the key field box. The certificate information category includes name, gender, nationality and ID number. The recognized text content is combined with the corresponding certificate information category to obtain the certificate information in the certificate image.
[0107] The embodiment of the present invention recognizes documents based on a deep learning algorithm, uses object detection for document interception, and uses semantic segmentation for key field extraction. Compared with traditional solutions, it has stronger robustness and higher accuracy.
[0108] The embodiment of the present invention uses a detection model based on the YOLO algorithm to detect the image to be identified. The YOLO algorithm is a single-stage detection algorithm, which has the advantage of fast speed and can improve the efficiency of detection. The document image is semantically segmented using a pre-trained document semantic segmentation model to determine the regional location of the document information. The document semantic segmentation model is constructed based on a deep learning algorithm and trained based on a training data set. It has stronger robustness and can further improve the accuracy of identification and improve work efficiency. Therefore, the document recognition method, device, electronic device and computer-readable storage medium based on deep learning proposed in the present invention can solve the problem of low document recognition accuracy.
[0109] like Figure 2 , is a functional module diagram of a deep learning-based document recognition device provided in one embodiment of the present invention.
[0110] The deep learning-based document recognition device 100 of the present invention can be installed in an electronic device. According to the functions to be implemented, the deep learning-based document recognition device 100 can include a detection module 101, an interception module 102, a semantic segmentation module 103 and a recognition module 104. The module of the present invention can also be referred to as a unit, which refers to a series of computer program segments that can be executed by an electronic device processor and can complete fixed functions, which are stored in the memory of the electronic device.
[0111] In this embodiment, the functions of each module / unit are as follows:
[0112] The detection module 101 is used to detect the image to be identified using a detection model based on the YOLO algorithm to obtain a document frame diagram.
[0113] The image to be identified in the embodiment of the present invention is an image containing a certificate, such as an ID card, a passport, etc. The image to be identified can be obtained from a database. In order to further ensure the privacy and security of the image to be identified, the image to be identified can also be obtained from a node of a blockchain.
[0114] The detection model based on the YOLO algorithm is a target detection model based on a deep neural network, which can realize the document detection task according to preset labels, that is, identify the document and determine its exact position in the image.
[0115] In detail, the detection module 101 is specifically used for:
[0116] Resizing the image to be recognized to obtain an input image;
[0117] Inputting the input image into the feature extraction network of the detection model to perform feature extraction, and obtaining a feature map output by the feature extraction network;
[0118] The feature map is further input into the segmentation network of the detection model to perform image segmentation, thereby obtaining a plurality of grids output by the segmentation network;
[0119] The multiple grids pass through the fully connected layer of the detection model to perform target detection on the image in each grid to obtain a document frame diagram.
[0120] The feature extraction is to sample the image through a convolution operation to remove the details in the image, so that the features of the input image are more obvious.
[0121] In the embodiment of the present invention, the feature map is further input into the segmentation network of the detection model to perform image segmentation, which is to divide the image into multiple image blocks of the same size, and the grid is an image block.
[0122] Furthermore, the plurality of grids are passed through the fully connected layer of the detection model to perform target detection on the image in each grid to obtain a document block diagram, including:
[0123] The image in each grid is identified through the fully connected layer of the detection model and multiple candidate bounding boxes are predicted, and the confidence of each candidate bounding box is calculated;
[0124] The candidate bounding box corresponding to the highest confidence value is used as the target detection box, and a box is selected and marked at the same position in the image to be identified according to the size and position of the target detection box to obtain a document frame diagram.
[0125] The confidence level includes the probability that the candidate bounding box contains the target (such as an ID card) and the accuracy of the candidate bounding box. The probability that the candidate bounding box contains the target is denoted as P r , when the candidate bounding box is the background (i.e. does not contain the target), then P r = 0, and when the candidate bounding box contains the target, P r= 1. The accuracy of the candidate bounding box can be characterized by the intersection over union of the predicted box and the actual box, denoted as The predicted box is the candidate bounding box output by the detection model, and the actual box is the real bounding box of the target object. The candidate bounding box can be represented by (x, y, w, h), where (x, y) is the center coordinate of the candidate bounding box, and w and h are the width and height of the candidate bounding box. Therefore, the formula can be used The confidence level is calculated.
[0126] The marking of the target detection frame at the same position in the image to be identified according to the size and position of the target detection frame means marking a frame of the same size at the same position in the image to be identified according to the position and size of the target detection frame, so that the position of the target in the image to be identified, i.e., the document, is marked.
[0127] For example, the size of the image to be identified is adjusted to an input image of 416*416, and the feature extraction network of the detection model extracts features from the input image to obtain a feature map of a certain size, such as 13*13. Then the segmentation network of the detection model divides the feature image into 13*13 grids, and the fully connected layer of the detection model performs target detection on the image in each grid to check whether the grid contains a target with the same preset label. If so, the target position is predicted through the candidate bounding box, and the final detection result is obtained by calculating the confidence.
[0128] The detection model described in the embodiment of the present invention is based on the YOLO algorithm, and the YOLO algorithm is a single-stage detection algorithm, which has the advantage of high speed and can improve the efficiency of detection.
[0129] The interception module 102 is used to intercept the certificate frame diagram to obtain a certificate image.
[0130] In the embodiment of the present invention, the document image is an image that contains more target detection frames than the image to be identified, for example, an image that contains a green frame that frames the position and size of the ID card in a photo containing an ID card. The document image is an image of only the ID card, such as an image of only the ID card within the green frame and without the rest of the background.
[0131] In detail, the certificate image contains a target detection frame. In an embodiment of the present invention, the target detection frame is a boundary frame corresponding to the certificate. The certificate image is cropped to size according to the position of the target detection frame, the complete certificate is captured, the image within the target detection frame is retained, and the rest of the certificate image is removed to obtain the certificate image.
[0132] The semantic segmentation module 103 is used to perform semantic segmentation on the document image based on the hole convolution using a pre-trained document semantic segmentation model to obtain multiple key field boxes.
[0133] The document semantic segmentation model described in the embodiment of the present invention is a segmentation model based on a deep neural network and can be used for image segmentation.
[0134] In detail, the semantic segmentation module 103 is specifically used for:
[0135] Inputting the document image into the hole convolution layer of the document semantic segmentation model for feature extraction to obtain multiple feature maps of different scales;
[0136] Inputting the multiple feature maps of different scales into the spatial pyramid layer of the document semantic segmentation model for fusion to obtain a fine feature map;
[0137] Input the fine feature map into the decoding layer of the document semantic segmentation model for convolution and upsampling to obtain a segmentation result map, wherein the segmentation result map includes a plurality of field boxes;
[0138] The segmentation result graph is corrected to obtain a plurality of key field frames.
[0139] Optionally, the hole convolution layer of the document semantic segmentation model in the embodiment of the present invention can control the receptive field without changing the size of the feature map, which is conducive to extracting multi-scale information.
[0140] Optionally, the spatial pyramid layer of the document semantic segmentation model can further extract multi-scale information, mainly through dilated convolutions of different rates. Furthermore, the spatial pyramid layer includes: (1) a 1×1 convolution layer and three 3×3 dilated convolutions; (2) a global average pooling layer to obtain image features, which are then sent to a 1×1 convolution layer and bilinearly interpolated to the original size; (3) the features of four different scales obtained from (1) and (2) are concatenated together, and then sent to a 1×1 convolution layer for fusion to obtain a new feature map with a size of 256 channels.
[0141] Optionally, the decoding layer of the document semantic segmentation model upsamples the result of the spatial pyramid layer by 4 times, then connects it with the low-level features when the feature sampling is performed in the hole convolution layer, performs a 3x3 convolution, and finally upsamples it by 4 times to obtain the final result.
[0142] Furthermore, the segmentation result map is corrected to obtain a plurality of key field frames, including:
[0143] Obtaining the vertex coordinates of all field boxes in the segmentation result graph;
[0144] Using a preset perspective transformation matrix to map and transform the vertex coordinates to obtain new vertex coordinates;
[0145] A box is selected and marked at the same position in the document image according to the new vertex coordinates to obtain multiple key field boxes.
[0146] The perspective transformation matrix is a transformation matrix obtained by using vertex coordinates of the original image and the transformed image in the training image; and the mapping transformation is calculated using a general transformation formula.
[0147] The field box in the segmentation result image may have errors such as offset and tilt. The embodiment of the present invention corrects it through perspective transformation. The field box is corrected by obtaining the coordinates of the four vertices of the field box and performing perspective transformation. The perspective transformation is a projection mapping of the image, which can correct the tilted image into a positive projection.
[0148] Optionally, before using the pre-trained document semantic segmentation model to perform semantic segmentation on the document image, the method further includes:
[0149] Collect multiple document images, and annotate the document images with category labels and positions according to preset labels to obtain a training data set;
[0150] Perform semantic segmentation on the training data set using a document semantic segmentation model to obtain a training result set;
[0151] Calculating the loss value of the training result set using a preset loss function;
[0152] According to the loss value, the back propagation algorithm is used to update the parameters of the document semantic segmentation model, and the step of using the document semantic segmentation model to perform semantic segmentation on the training data set to obtain a training result set is returned until the loss value no longer decreases, thereby obtaining a trained document semantic segmentation model.
[0153] The loss function in the embodiment of the present invention includes:
[0154]
[0155] Among them, Loss is the loss value, y t is the real field box, is the predicted field box output by the document semantic segmentation model, and N is the total number of training data sets.
[0156] The recognition module 104 performs text recognition on the certificate image according to the key field frame to obtain certificate information.
[0157] In detail, the identification module 104 is specifically used for:
[0158] Using the key field frame as a text detection frame of the document image;
[0159] Performing text recognition on the text detection frame of the certificate image to obtain a plurality of detection texts corresponding to the key field frame;
[0160] The multiple detection texts are subjected to category identification, and the detection texts are combined with corresponding categories to obtain certificate information.
[0161] Furthermore, the performing category recognition on the multiple detected texts includes:
[0162] Obtain a key field box corresponding to the detected text;
[0163] The outline size of the key field frame is calculated, and the category of the detected text corresponding to the key field frame is obtained by searching in a preset category information table according to the outline size.
[0164] The category information table includes a plurality of certificate information categories and corresponding outline size ranges.
[0165] For example, in an embodiment of the present invention, OCR technology is used to perform text recognition on the image portion within multiple key field boxes in the certificate image to obtain text content, and the certificate information category corresponding to the text content is identified based on the outline size of the key field box. The certificate information category includes name, gender, nationality and ID number. The recognized text content is combined with the corresponding certificate information category to obtain the certificate information in the certificate image.
[0166] The embodiment of the present invention recognizes documents based on a deep learning algorithm, uses object detection for document interception, and uses semantic segmentation for key field extraction. Compared with traditional solutions, it has stronger robustness and higher accuracy.
[0167] like Figure 3 , is a schematic diagram of the structure of an electronic device for implementing a document recognition method based on deep learning provided by an embodiment of the present invention.
[0168] The electronic device 1 may include a processor 10, a memory 11 and a bus, and may also include a computer program stored in the memory 11 and executable on the processor 10, such as a deep learning-based document recognition program 12.
[0169] Among them, the memory 11 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, mobile hard disk, multimedia card, card-type memory (for example: SD or DX memory, etc.), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 11 can be an internal storage unit of the electronic device 1, such as a mobile hard disk of the electronic device 1. In other embodiments, the memory 11 can also be an external storage device of the electronic device 1, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 1. Further, the memory 11 can also include both an internal storage unit of the electronic device 1 and an external storage device. The memory 11 can not only be used to store application software and various types of data installed in the electronic device 1, such as the code of the document recognition program 12 based on deep learning, but also can be used to temporarily store data that has been output or is to be output.
[0170] The processor 10 may be composed of an integrated circuit in some embodiments, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips. The processor 10 is the control core (Control Unit) of the electronic device, and uses various interfaces and lines to connect various components of the entire electronic device, and executes or executes programs or modules (such as deep learning-based document recognition programs, etc.) stored in the memory 11, and calls data stored in the memory 11 to execute various functions of the electronic device 1 and process data.
[0171] The bus may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is configured to realize connection and communication between the memory 11 and at least one processor 10, etc.
[0172] Figure 3 Only an electronic device with components is shown, and those skilled in the art will understand that Figure 3The structure shown does not constitute a limitation on the electronic device 1, and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0173] For example, although not shown, the electronic device 1 may also include a power source (such as a battery) for supplying power to each component. Preferably, the power source may be logically connected to the at least one processor 10 through a power management device, so that the power management device can realize functions such as charging management, discharging management, and power consumption management. The power source may also include any components such as one or more DC or AC power sources, recharging devices, power failure detection circuits, power converters or inverters, power status indicators, etc. The electronic device 1 may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.
[0174] Furthermore, the electronic device 1 may also include a network interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the electronic device 1 and other electronic devices.
[0175] Optionally, the electronic device 1 may further include a user interface, which may be a display, an input unit (such as a keyboard), or a standard wired interface or a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode) touch device. The display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device 1 and to display a visual user interface.
[0176] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.
[0177] The deep learning-based document recognition program 12 stored in the memory 11 of the electronic device 1 is a combination of multiple instructions. When running in the processor 10, it can achieve:
[0178] Use the detection model based on the YOLO algorithm to detect the image to be identified and obtain the document frame diagram;
[0179] Intercepting the certificate frame diagram to obtain a certificate image;
[0180] Based on the dilated convolution, a pre-trained document semantic segmentation model is used to perform semantic segmentation on the document image to obtain multiple key field boxes;
[0181] The document image is subjected to text recognition according to the key field frame to obtain the document information.
[0182] Specifically, the specific implementation method of the processor 10 for the above instructions can refer to Figures 1 to 3 The description of the relevant steps in the corresponding embodiments will not be repeated here.
[0183] Furthermore, if the module / unit integrated in the electronic device 1 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. The computer-readable storage medium can be volatile or non-volatile. For example, the computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, and a read-only memory (ROM).
[0184] The present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor of an electronic device, the computer program can implement:
[0185] Use the detection model based on the YOLO algorithm to detect the image to be identified and obtain the document frame diagram;
[0186] Intercepting the certificate frame diagram to obtain a certificate image;
[0187] Based on the dilated convolution, a pre-trained document semantic segmentation model is used to perform semantic segmentation on the document image to obtain multiple key field boxes;
[0188] The document image is subjected to text recognition according to the key field frame to obtain the document information.
[0189] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0190] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0191] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional modules.
[0192] It is obvious to those skilled in the art that the present invention is not limited to the details of the above exemplary embodiments, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0193] Therefore, no matter from which point of view, the embodiments should be regarded as illustrative and non-restrictive, and the scope of the present invention is limited by the appended claims rather than the above description, so it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any attached figure mark in the claims should not be regarded as limiting the claims involved.
[0194] The blockchain referred to in the present invention is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the blockchain underlying platform, platform product service layer, and application service layer.
[0195] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the system claim can also be implemented by one unit or device through software or hardware. The second and other words are used to indicate names, but not to indicate any particular order.
[0196] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.
Claims
1. A document recognition method based on deep learning, characterized in that: The method comprises: Use the detection model based on the YOLO algorithm to detect the image to be identified and obtain the document frame diagram; Intercepting the certificate frame diagram to obtain a certificate image; Based on the dilated convolution, a pre-trained document semantic segmentation model is used to perform semantic segmentation on the document image to obtain a segmentation result image, and the segmentation result image is corrected to obtain multiple key field boxes; the outline size of the key field box is calculated to obtain the category of the detection text corresponding to the key field box, and text recognition is performed on the document image according to the category of the detection text to obtain document information.
2. The document recognition method based on deep learning as claimed in claim 1, characterized in that: The detection model based on the YOLO algorithm is used to detect the image to be identified, and a document block diagram is obtained, including: Resizing the image to be recognized to obtain an input image; Inputting the input image into the feature extraction network of the detection model to perform feature extraction, and obtaining a feature map output by the feature extraction network; The feature map is further input into the segmentation network of the detection model to perform image segmentation, thereby obtaining a plurality of grids output by the segmentation network; The multiple grids pass through the fully connected layer of the detection model to perform target detection on the image in each grid to obtain a document frame diagram.
3. The document recognition method based on deep learning as claimed in claim 2, characterized in that: The target detection is performed on the image in each grid through the fully connected layer of the detection model to obtain a document block diagram, including: The image in each grid is identified through the fully connected layer of the detection model and multiple candidate bounding boxes are predicted, and the confidence of each candidate bounding box is calculated; The candidate bounding box corresponding to the highest confidence value is used as the target detection box, and a box is selected and marked at the same position in the image to be identified according to the size and position of the target detection box to obtain a document frame diagram.
4. The document recognition method based on deep learning as claimed in claim 1, characterized in that: The document image is semantically segmented using a pre-trained document semantic segmentation model based on the dilated convolution to obtain a segmentation result image, including: Inputting the document image into the hole convolution layer of the document semantic segmentation model for feature extraction to obtain multiple feature maps of different scales; Inputting the multiple feature maps of different scales into the spatial pyramid layer of the document semantic segmentation model for fusion to obtain a fine feature map; The fine feature map is input into the decoding layer of the document semantic segmentation model for convolution and upsampling to obtain a segmentation result map.
5. The document recognition method based on deep learning as claimed in claim 1, characterized in that: The segmentation result map is corrected to obtain a plurality of key field frames, including: Obtaining the vertex coordinates of all field boxes in the segmentation result graph; Using a preset perspective transformation matrix to map and transform the vertex coordinates to obtain new vertex coordinates; A box is selected and marked at the same position in the document image according to the new vertex coordinates to obtain multiple key field boxes.
6. The document recognition method based on deep learning as claimed in claim 1, characterized in that: The step of performing text recognition on the certificate image according to the category of the detected text to obtain certificate information includes: Using the key field frame as a text detection frame of the document image; Performing text recognition on the text detection frame of the certificate image to obtain a plurality of detection texts corresponding to the key field frame; The multiple detection texts are subjected to category identification, and the detection texts are combined with corresponding categories to obtain certificate information.
7. The document recognition method based on deep learning according to any one of claims 1 to 6, characterized in that: Before using the pre-trained document semantic segmentation model to perform semantic segmentation on the document image, the method further includes: Collect multiple document images, and annotate the document images with category labels and positions according to preset labels to obtain a training data set; Perform semantic segmentation on the training data set using a document semantic segmentation model to obtain a training result set; Calculating the loss value of the training result set using a preset loss function; According to the loss value, the back propagation algorithm is used to update the parameters of the document semantic segmentation model, and the step of using the document semantic segmentation model to perform semantic segmentation on the training data set to obtain a training result set is returned until the loss value no longer decreases, thereby obtaining a trained document semantic segmentation model.
8. A document recognition device based on deep learning, characterized in that: The device comprises: A detection module is used to detect the image to be identified using a detection model based on the YOLO algorithm to obtain a document block diagram; An interception module, used for intercepting the certificate frame diagram to obtain a certificate image; A semantic segmentation module, used for performing semantic segmentation on the document image based on a pre-trained document semantic segmentation model using a dilated convolution to obtain a segmentation result image, and correcting the segmentation result image to obtain a plurality of key field frames; The recognition module is used to calculate the outline size of the key field box, obtain the category of the detection text corresponding to the key field box, perform text recognition on the certificate image according to the category of the detection text, and obtain the certificate information.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, 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 so that the at least one processor can execute the deep learning-based document recognition method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the deep learning-based document recognition method as described in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Card identification method and device, terminal and storage medium
CN110472602A
Identity card information identification method and device
CN111353497A
Certificate image correction method, device and equipment, and storage medium
CN111860489A
