Certificate identification method and system and computer equipment
Through the certificate recognition method based on residual neural network, we deal with the problems of low recognition accuracy and high resource consumption in document recognition. Using triple-tuple data and loss function optimization model, efficient document type recognition is achieved, suitable for online appointments Online deployment of the automotive industry.
Patent Information
- Application Number
- CN202411307873.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-19
- Publication Date
- 2025-01-03
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The prior art has problems of low recognition accuracy and high resource consumption in document recognition, especially when processing complex document images, especially the training and inference process of deep networks requires high computing resources and data quality has the performance of the model. Important influence.
Using the certificate recognition method based on the residual neural network structure, the original picture set is processed into triple data, the maximum distance between positive and negative samples is calculated as the first loss function, and the cross entropy loss function is used to perform the image classification model. Iterative updates to obtain a target image classification model with stable weight parameters, which is used to identify the certificate type.
It improves the robustness and accuracy of the certificate identification model, reduces the consumption of computing resources, improves the efficiency of document identification and classification, and is suitable for online deployment in the online car-hailing industry.
Smart Images

Figure CN119251562A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a document recognition method and system, and computer equipment. Background Art
[0002] In the online car-hailing industry, the review of various qualification certificates is a very important part. These certificates can be mainly divided into certificates related to people (person certificates) and certificates related to vehicles (vehicle certificates). Currently, the methods for processing certificate recognition in the industry can be roughly divided into two categories:
[0003] The first category is the traditional image recognition method, which detects edge features in the document image through edge detection algorithms, such as Canny, Sobel and other algorithms. Then a predefined template is used to match the image to detect the location and content of the document. Finally, optical character recognition technology (OCR:Optical Character Recognition) is used to extract text information from the image, such as Tesseract. The disadvantages of this type of traditional method are poor robustness and poor adaptability to conditions such as lighting, rotation, scale changes and complex backgrounds. It is also very limited in extracting features from images and cannot effectively process complex document images, especially when the document is damaged or noisy.
[0004] The second category is deep learning-based methods, such as ResNet and Inception network structures based on convolutional neural networks (CNNs), YOLO, Faster R-CNN, and SSD networks for detecting key information areas (such as photos and text areas) in documents, and LSTM and Transformer architectures for processing and recognizing serialized text information. This type of neural network-based method can process relatively complex document images with high accuracy and good robustness to changes in illumination, rotation, and scale. It can also automatically learn effective features from data in feature extraction without too much manual design of feature extractors. However, the training and inference processes require high computing resources, especially for deep networks. In addition, a large amount of labeled data is required for training, and the data quality has a significant impact on model performance. The internal working mechanism of the model is difficult to explain, and debugging and optimization are challenging. Summary of the invention
[0005] To this end, the present invention provides a document recognition method and system, and a computer device, aiming to solve the technical problems of low recognition accuracy or high resource consumption in the prior art for document recognition.
[0006] To achieve the above objectives, the present invention adopts the following technical solutions:
[0007] According to a first aspect of the present invention, the present invention provides a document recognition method, the method comprising:
[0008] Collect multiple original pictures, add a label type to each of the original pictures, and obtain a sample picture set; the label type includes a person certificate type, a vehicle certificate type, and / or an irrelevant type;
[0009] Processing the sample picture set into multiple groups of triplet data; the triplet data includes anchor point data, positive sample data and negative sample data;
[0010] Calculating the maximum distance between positive and negative samples in the triple data as a first loss function; and classifying the triple data using a picture classification model based on a residual neural network structure to calculate a corresponding second loss function;
[0011] Calculate the total loss function of the triple data based on the first loss function and the second loss function;
[0012] The image classification model is iteratively updated using the total loss function to obtain a target image classification model with stable weight parameters, and the target image classification model is used to identify the type of certificate.
[0013] Optionally, before processing the sample picture set into a plurality of groups of triplet data, the method further includes:
[0014] Performing data enhancement on the images in the sample image set to obtain a diversified sample image set;
[0015] The data enhancement includes at least one of three-dimensional rotation, left-right flipping, brightness adjustment and contrast adjustment.
[0016] Optionally, processing the sample picture set into a plurality of groups of triplet data includes:
[0017] Randomly select a picture from the sample picture set as a reference image;
[0018] Screening a first target picture set having the same label type as the reference image, and randomly selecting a picture from the first target picture set as a positive sample image;
[0019] Screening a second target image set having a label type different from that of the reference image, and randomly selecting an image from the second target image set as a negative sample image;
[0020] A triplet image is formed using the reference image, the positive sample image and the negative sample image.
[0021] Optionally, the method further comprises:
[0022] Feature encoding is performed on the triplet image to obtain anchor point data corresponding to the reference image, positive sample data corresponding to the positive sample image, and negative sample data corresponding to the negative sample image.
[0023] Optionally, calculating the maximum distance between positive and negative samples in the triplet data as a first loss function includes:
[0024] Respectively calculating a first distance between the anchor point data and the positive sample data and a second distance between the anchor point data and the negative sample data; the distance is a Euclidean distance or a cosine distance;
[0025] The maximum distance between positive and negative samples is calculated using the first distance and the second distance. The formula is as follows:
[0026] LOSS1=L(A,P,N)=max(0,d(A,P)-d(A,N)+b)
[0027] Among them, LOSS1 is the first loss function; A represents anchor point data; P represents positive sample data; N represents negative sample data; d(A,P) is the first distance; d(A,N) is the second distance; b is the boundary hyperparameter, which is used to control the minimum distance difference between positive and negative samples.
[0028] Optionally, the classifying the triplet data using the image classification model based on the residual neural network structure and calculating the corresponding second loss function includes:
[0029] Inputting the triplet data into the picture classification model for training, and obtaining a classification result output by the picture classification model;
[0030] The classification error is determined using the classification result and the label type corresponding to the triple data, and the cross entropy loss of the image classification model is calculated based on the classification error. The formula is as follows:
[0031]
[0032] Among them, LOSS2 is the second loss function; C is the number of categories; y i is the tag type; The probability that the image classification model predicts the image to be of the i-th category.
[0033] Optionally, calculating the total loss function of the triple data based on the first loss function and the second loss function includes:
[0034] The total loss function of the triple data is the sum of the first loss function and the second loss function, and the formula is as follows:
[0035] LOSS=LOSS1+LOSS2
[0036] Among them, LOSS is the total loss function; LOSS1 is the first loss function; LOSS2 is the second loss function.
[0037] Optionally, the iterative updating of the image classification model by using the total loss function to obtain a target image classification model with stable weight parameters includes:
[0038] Optimizing the weight parameters of the image classification model using a gradient descent method so that the total loss function reaches a preset threshold;
[0039] A test data set is obtained, and the image classification model whose total loss function reaches a preset threshold is tested and verified to obtain an image classification model that meets the accuracy requirements as the target image classification model.
[0040] According to a second aspect of the present invention, the present invention provides a document recognition system, the system comprising:
[0041] A data acquisition module, used to collect a plurality of original images, add a label type to each of the original images, and obtain a sample image set; the label type includes a person certificate type, a vehicle certificate type, and / or an irrelevant type;
[0042] A data processing module, used for processing the sample picture set into multiple groups of triple data; the triple data includes anchor point data, positive sample data and negative sample data;
[0043] A function calculation module, used to calculate the maximum distance between positive and negative samples in the triple data as a first loss function; and to perform residual network classification on the triple data using an image classification model to calculate a corresponding second loss function; and to calculate a total loss function of the triple data based on the first loss function and the second loss function;
[0044] The model prediction module is used to iteratively update the image classification model using the total loss function to obtain a target image classification model with stable weight parameters, and use the target image classification model to identify the type of certificate.
[0045] According to the third aspect of the present invention, the present invention provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the document recognition method as described in any one of the first aspect of the present invention is implemented.
[0046] The present invention adopts the above technical solution and has at least the following beneficial effects:
[0047] Through the scheme of the present invention, multiple original images are collected, and label types are added to each of the original images to obtain a sample image set; the sample image set is processed into multiple groups of triple data; the maximum distance between positive and negative samples in the triple data is calculated as the first loss function; and the triple data is classified using an image classification model based on a residual neural network structure to calculate the corresponding second loss function; the total loss function of the triple data is calculated based on the first loss function and the second loss function; the image classification model is iteratively updated using the total loss function to obtain a target image classification model with stable weight parameters, and the target image classification model is used to identify the type of certificate. Thus, by combining the advantages of traditional methods and deep learning methods, the robustness and accuracy of the image classification model are improved, so that the personal certificates of drivers in the online car-hailing industry and the review of vehicle certificates meet the requirements of online deployment, and the efficiency of certificate recognition and classification is greatly improved.
[0048] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0050] Figure 1 A schematic diagram showing a flow chart of a document recognition method provided by an embodiment of the present invention;
[0051] Figure 2 A schematic diagram of a process flow of triplet data processing provided by an embodiment of the present invention is shown;
[0052] Figure 3 A schematic diagram showing the structure of a certificate recognition system provided by an embodiment of the present invention is shown;
[0053] Figure 4 A schematic diagram showing the structure of a certificate recognition system provided by another embodiment of the present invention is shown;
[0054] Figure 5 A schematic diagram of the physical structure of a computer device provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0055] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0056] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "include..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0057] The embodiment of the present invention provides a document recognition method, such as Figure 1 As shown, at least the following steps S101 to S104 may be included:
[0058] Step S101, collect multiple original pictures, add a label type to each original picture, and obtain a sample picture set.
[0059] The original image in the embodiment of the present invention may be a vehicle certificate image, a person certificate image or other irrelevant images with varying degrees of clarity. The label type may be annotated by a fine-tuned large model or may be manually annotated. The label type may include a person certificate type, a vehicle certificate type and / or an irrelevant type.
[0060] Step S102: Process the sample picture set into multiple groups of triplet data.
[0061] It should be noted that, before processing the sample picture set, the embodiment of the present invention may perform data enhancement on the pictures in the sample picture set to obtain a diversified sample picture set. The data enhancement processing may include operations such as three-dimensional rotation, left-right flipping, brightness adjustment, and contrast adjustment.
[0062] Triplet data refers to the form of (A, P, N) consisting of anchor data A (correct dataset sample), positive sample data P and negative sample data N. In contrastive learning, triplet data refers to a data sample consisting of three pictures, usually including the following three parts:
[0063] Anchor (A): reference image, usually the original image or query image;
[0064] Positive (P): images that are similar to the reference image, usually belonging to the same category or having the same features;
[0065] Negative (N): An image that is different from the reference image, usually belonging to a different class or having different characteristics.
[0066] In an embodiment of the present invention, since each picture in the sample picture set has a corresponding label type, the label type can be used to generate triple data. The specific process of processing the sample picture set into multiple groups of triple data can be as follows: randomly selecting a picture in the sample picture set as an Anchor reference image; screening a first target picture set with the same label type as the reference image, and randomly selecting a picture in the first target picture set as a Positive sample image; screening a second target picture set with a different label type from the reference image, and randomly selecting a picture in the second target picture set as a Negative sample image; and using the reference image, the positive sample image and the negative sample image to form a triple image. It can be understood that the Positive sample image is semantically similar to the Anchor reference image; the Negative negative sample image is semantically different from the Anchor reference image.
[0067] It should be noted that in practical applications, we need to consider the balance and dynamic generation of triples. That is, we need to ensure that the ratio of positive sample images to negative sample images in the generated triples is reasonable. Also, for large datasets, we can dynamically generate triplets in each training batch instead of generating all triplets at once.
[0068] After generating the triplet image, we can Figure 2 The data processing flow shown in the figure performs subsequent processing on the triple image. By performing feature encoding (such as one-hot encoding) on the triple image, the anchor point data corresponding to the reference image, the positive sample data corresponding to the positive sample image, and the negative sample data corresponding to the negative sample image are obtained, that is, the triple data that can be used for subsequent calculations is obtained.
[0069] Step S103, calculate the maximum distance between positive and negative samples in the triple data as the first loss function; and classify the triple data using an image classification model based on a residual neural network structure to calculate the corresponding second loss function; calculate the total loss function of the triple data based on the first loss function and the second loss function.
[0070] It is understandable that in the process of generating triplet data, since the anchor data is randomly selected, the corresponding positive sample data and negative sample data are also randomly selected from the sample set, which causes a certain error in distinguishing positive and negative samples, namely the triplet error. In practical applications, the smaller the triplet error, the more accurate the semantic positioning of the classification. Reflected in the positive and negative sample data, the farther the distance between the positive sample data and the negative sample data, the more accurate it is. In order to calculate the distance between the positive and negative sample data, the embodiment of the present invention first calculates the first distance d(A, P) between the anchor data and the positive sample data and the second distance d(A, N) between the anchor data and the negative sample data, and then calculates the maximum distance between the positive and negative samples based on the first distance and the second distance. The distance calculated in the embodiment of the present invention can be a Euclidean distance or a cosine distance. The calculation formula of the first loss function is as follows:
[0071] LOSS1=L(A,P,N)=max(0,d(A,P)-d(A,N)+b)
[0072] Among them, LOSS1 is the first loss function; A represents anchor point data; P represents positive sample data; N represents negative sample data; d(A,P) is the first distance; d(A,N) is the second distance; b is the boundary hyperparameter, which is used to control the minimum distance difference between positive and negative samples.
[0073] In the classification task, the embodiment of the present invention also constructs an image classification model based on the residual neural network structure to classify triple data. The image classification model can be a neural network model based on ResNet50 or Wide ResNet50. The residual neural network structure introduces "residual connections" (skip connections or shortcut connections) to solve the problems of gradient vanishing and gradient exploding in deep neural networks. Practice has proved that this approach greatly improves the effect of classification tasks. The core component of ResNet or its variant Wide ResNet50 is the residual block. A typical residual block can be expressed as:
[0074] y=F(x,{W i})+x
[0075] Where x is the model input; F(x,{W i}) is the input transformation function (e.g., two layers of convolution operations and activation function ReLU); y represents the residual connection that directly skips the transformation and is added to the transformed output.
[0076] It is understandable that in the process of training the image classification model, there will be classification errors. The embodiment of the present invention reflects the error situation through the size of the second loss function. Generally, in classification tasks, the loss function commonly used by ResNet or WideResNet is the cross-entropy loss (Cross-Entropy Loss), which is used to measure the difference between the predicted category distribution and the true category distribution. By minimizing the cross-entropy loss, the prediction of the image classification model will gradually approach the true category label. The cross-entropy loss can be expressed as:
[0077]
[0078] Among them, LOSS2 is the second loss function; C is the number of categories; y i is the tag type; The probability of the image classification model predicting the i-th category.
[0079] Furthermore, the total loss function of the triple data is the sum of the first loss function and the second loss function, and the formula is as follows:
[0080] LOSS=LOSS1+LOSS2
[0081] Among them, LOSS is the total loss function; LOSS1 is the first loss function; LOSS2 is the second loss function.
[0082] Step S104, using the total loss function to iteratively update the image classification model to obtain a target image classification model with stable weight parameters, and using the target image classification model to identify the type of certificate.
[0083] Specifically, the gradient descent method can be used to optimize the weight parameters of the image classification model so that the total loss function reaches a preset threshold. A test data set is obtained to test and verify the image classification model whose total loss function reaches the preset threshold, and a picture classification model that meets the accuracy requirements is obtained as the target picture classification model.
[0084] In other words, the weights of the trained image classification model, such as ResNet50 or Wide ResNet50, can be updated through gradient descent. By observing the numerical value of the total loss function, when the value reaches a certain accuracy, the image classification model is considered to have reached a stable state, which is often referred to as loss balance. After the image classification model is trained and stabilized, it is tested and verified on a batch of new data sets. By calculating the accuracy of the classification categories predicted by the model and the originally labeled classification categories, the effect of the image classification model is evaluated. Finally, a target image classification model that meets the accuracy requirements can be obtained for identifying the type of certificate.
[0085] The embodiment of the present invention provides a document recognition method, which introduces a fine-tuned large model to automatically annotate the collected raw data of the online car-hailing industry to obtain a large number of samples, combines the deep learning framework and integrates the contrastive learning method, obtains triple data samples under the premise of reasonably designing positive and negative sample sampling, and designs an algorithm so that the trained model can fully learn and compare to better correctly distinguish the originally unclear pictures, thereby improving the recognition accuracy of picture classification. The present invention has at least the following advantages:
[0086] ① Through fine-tuning the industry large model to assist in the labeling task, the large amount of collected data is fully utilized, and a large number of high-quality triple samples are obtained, which provides a data basis for model training, thereby solving the problem of insufficient samples in image recognition problems, and at the same time ensuring the quality and quantity of the verification set;
[0087] ② Using classification based on residual neural network structure under large samples, by learning the information of positive and negative samples for comparative identification, it can effectively distinguish positive and negative samples and improve the recognition of certificate images;
[0088] ③ When producing triplet data, the contrast loss function effectively trains an embedding model for similarity calculation by shortening the distance between similar samples and increasing the distance between dissimilar samples during the training process. It has been widely verified in many computer vision and natural language processing tasks; it provides a large amount of high-quality data, making the contrast function more stable during the gradient update process.
[0089] ④ It can operate large sample data, has high automatic recognition accuracy, strong generalization ability, high robustness for different business scenarios, and strong adaptability to scenarios.
[0090] Further, as Figure 1 The specific implementation of the present invention provides a document recognition system, such as Figure 3 As shown, the system may include: a data acquisition module 310 , a data processing module 320 , a function calculation module 330 and a model prediction module 340 .
[0091] The data acquisition module 310 can be used to collect multiple original pictures, add a label type to each original picture, and obtain a sample picture set; the label type includes a person certificate type, a vehicle certificate type, and / or an irrelevant type;
[0092] The data processing module 320 may be used to process the sample picture set into multiple sets of triplet data; the triplet data includes anchor point data, positive sample data and negative sample data;
[0093] The function calculation module 330 can be used to calculate the maximum distance between positive and negative samples in the triple data as a first loss function; and use the image classification model to perform residual network classification on the triple data to calculate the corresponding second loss function; calculate the total loss function of the triple data based on the first loss function and the second loss function;
[0094] The model prediction module 340 can be used to iteratively update the image classification model using the total loss function to obtain a target image classification model with stable weight parameters, and use the target image classification model to identify the document type.
[0095] Alternatively, if Figure 4 As shown, another embodiment of the present invention provides a certificate recognition system, which also includes: a data enhancement module 350.
[0096] The data enhancement module 350 may be used to perform data enhancement on the images in the sample image set before processing the sample image set into multiple groups of triple data to obtain a diversified sample image set;
[0097] The data enhancement includes at least one of three-dimensional rotation, left-right flipping, brightness adjustment and contrast adjustment.
[0098] Optionally, the data processing module 320 may also be used to randomly select a picture from the sample picture set as a reference image;
[0099] Filter a first target image set with the same label type as the reference image, and randomly select a picture in the first target image set as a positive sample image;
[0100] Filter a second target image set with a label type different from that of the reference image, and randomly select an image in the second target image set as a negative sample image;
[0101] A triplet image is formed using a reference image, a positive sample image and a negative sample image;
[0102] Feature encoding is performed on the triplet image to obtain anchor point data corresponding to the reference image, positive sample data corresponding to the positive sample image, and negative sample data corresponding to the negative sample image.
[0103] Optionally, the function calculation module 330 may also be used to respectively calculate a first distance between the anchor point data and the positive sample data and a second distance between the anchor point data and the negative sample data; the distance is a Euclidean distance or a cosine distance;
[0104] The maximum distance between positive and negative samples is calculated using the first distance and the second distance. The formula is as follows:
[0105] LOSS1=L(A,P,N)=max(0,d(A,P)-d(A,N)+b)
[0106] Among them, LOSS1 is the first loss function; A represents anchor point data; P represents positive sample data; N represents negative sample data; d(A,P) is the first distance; d(A,N) is the second distance; b is the boundary hyperparameter, which is used to control the minimum distance difference between positive and negative samples.
[0107] Optionally, the function calculation module 330 may also be used to input the triplet data into the image classification model for training, and obtain the classification result output by the image classification model;
[0108] The classification error is determined by using the classification result and the label type corresponding to the triple data. The cross entropy loss of the image classification model is calculated based on the classification error. The formula is as follows:
[0109]
[0110] Among them, LOSS2 is the second loss function; C is the number of categories; y i is the tag type; The probability of the image classification model predicting the i-th category.
[0111] Optionally, the function calculation module 330 may also be used to use the sum of the first loss function and the second loss function as the total loss function of the triple data, which is expressed as follows:
[0112] LOSS=LOSS1+LOSS2
[0113] Among them, LOSS is the total loss function; LOSS1 is the first loss function; LOSS2 is the second loss function.
[0114] Optionally, the model prediction module 340 may also be used to optimize the weight parameters of the image classification model using a gradient descent method so that the total loss function reaches a preset threshold;
[0115] A test data set is obtained, and the image classification model whose total loss function reaches a preset threshold is tested and verified to obtain an image classification model that meets the accuracy requirements as the target image classification model.
[0116] It should be noted that for other corresponding descriptions of the functional modules involved in the document recognition system provided in the embodiment of the present invention, reference can be made to Figure 1 The corresponding description of the method shown will not be repeated here.
[0117] Based on the above Figure 1 The method shown, accordingly, an embodiment of the present invention also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the document recognition method of any of the above embodiments are implemented.
[0118] Based on the above Figure 1 The method shown and Figure 4 The embodiment of the device shown in the figure, the embodiment of the present invention also provides a physical structure diagram of a computer device, such as Figure 5 As shown, the computer device may include a communication bus, a processor, a memory and a communication interface, and may also include an input / output interface and a display device, wherein each functional unit may communicate with each other through the bus. The memory stores a computer program, and the processor is used to execute the program stored in the memory and execute the steps of the document recognition method in the above embodiment.
[0119] Those skilled in the art can clearly understand that the specific working processes of the systems, devices, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and for the sake of brevity, they are not further described here.
[0120] In addition, the functional units in various embodiments of the present invention may be physically independent of each other, or two or more functional units may be integrated together, or all functional units may be integrated into one processing unit. The above integrated functional units may be implemented in the form of hardware, or in the form of software or firmware.
[0121] Those skilled in the art can understand that if the integrated functional unit is implemented in the form of software and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention can essentially or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, which includes a number of instructions to enable a computing device (such as a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present invention when running the instructions. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk and other media that can store program codes.
[0122] Alternatively, all or part of the steps of implementing the aforementioned method embodiments may be accomplished by hardware associated with program instructions (such as a computing device such as a personal computer, a server, or a network device), and the program instructions may be stored in a computer-readable storage medium. When the program instructions are executed by a processor of a computing device, the computing device executes all or part of the steps of the methods described in the embodiments of the present invention.
[0123] 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 aforementioned embodiments, those skilled in the art should understand that within the spirit and principles of the present invention, the technical solutions described in the aforementioned embodiments can still be modified, or some or all of the technical features therein can be replaced by equivalents. However, these modifications or replacements do not deviate from the protection scope of the present invention.
Claims
1. A document recognition method, characterized in that: The method comprises: Collect multiple original pictures, add a label type to each of the original pictures, and obtain a sample picture set; the label type includes a person certificate type, a vehicle certificate type, and / or an irrelevant type; Processing the sample picture set into multiple groups of triplet data; the triplet data includes anchor point data, positive sample data and negative sample data; Calculating the maximum distance between positive and negative samples in the triple data as a first loss function; and classifying the triple data using a picture classification model based on a residual neural network structure to calculate a corresponding second loss function; Calculate the total loss function of the triple data based on the first loss function and the second loss function; The image classification model is iteratively updated using the total loss function to obtain a target image classification model with stable weight parameters, and the target image classification model is used to identify the type of certificate.
2. The method according to claim 1, characterized in that Before processing the sample picture set into a plurality of groups of triplet data, the method further includes: Performing data enhancement on the images in the sample image set to obtain a diversified sample image set; The data enhancement includes at least one of three-dimensional rotation, left-right flipping, brightness adjustment and contrast adjustment.
3. The method according to claim 1, characterized in that: Processing the sample picture set into multiple groups of triplet data includes: Randomly select a picture from the sample picture set as a reference image; Screening a first target picture set having the same label type as the reference image, and randomly selecting a picture from the first target picture set as a positive sample image; Screening a second target image set having a label type different from that of the reference image, and randomly selecting an image from the second target image set as a negative sample image; A triplet image is formed using the reference image, the positive sample image and the negative sample image.
4. The method according to claim 3, characterized in that The method further comprises: Feature encoding is performed on the triplet image to obtain anchor point data corresponding to the reference image, positive sample data corresponding to the positive sample image, and negative sample data corresponding to the negative sample image.
5. The method according to claim 1, characterized in that The calculating the maximum distance between positive and negative samples in the triple data as a first loss function includes: Respectively calculating a first distance between the anchor point data and the positive sample data and a second distance between the anchor point data and the negative sample data; the distance is a Euclidean distance or a cosine distance; The maximum distance between positive and negative samples is calculated using the first distance and the second distance. The formula is as follows: LOSS1=L(A,P,N)=max(0,d(A,P)-d(A,N)+b) Among them, LOSS1 is the first loss function; A represents anchor point data; P represents positive sample data; N represents negative sample data; d(A,P) is the first distance; d(A,N) is the second distance; b is the boundary hyperparameter, which is used to control the minimum distance difference between positive and negative samples.
6. The method according to claim 1, characterized in that The method of classifying the triplet data using the image classification model based on the residual neural network structure and calculating the corresponding second loss function includes: Inputting the triplet data into the picture classification model for training, and obtaining a classification result output by the picture classification model; The classification error is determined using the classification result and the label type corresponding to the triple data, and the cross entropy loss of the image classification model is calculated based on the classification error. The formula is as follows: Among them, LOSS2 is the second loss function; C is the number of categories; y i is the tag type; The probability that the image classification model predicts the image to be of the i-th category.
7. The method according to claim 1, characterized in that The calculating the total loss function of the triple data based on the first loss function and the second loss function includes: The total loss function of the triple data is the sum of the first loss function and the second loss function, and the formula is as follows: LOSS=LOSS1+LOSS2 Among them, LOSS is the total loss function; LOSS1 is the first loss function; LOSS2 is the second loss function.
8. The method according to claim 1, characterized in that The iterative updating of the image classification model by using the total loss function to obtain a target image classification model with stable weight parameters includes: Optimizing the weight parameters of the image classification model using a gradient descent method so that the total loss function reaches a preset threshold; A test data set is obtained, and the image classification model whose total loss function reaches a preset threshold is tested and verified to obtain an image classification model that meets the accuracy requirements as the target image classification model.
9. A document recognition system, characterized in that: The system comprises: A data acquisition module, used to collect a plurality of original images, add a label type to each of the original images, and obtain a sample image set; the label type includes a person certificate type, a vehicle certificate type, and / or an irrelevant type; A data processing module, used for processing the sample picture set into multiple groups of triple data; the triple data includes anchor point data, positive sample data and negative sample data; A function calculation module, used to calculate the maximum distance between positive and negative samples in the triple data as a first loss function; and to perform residual network classification on the triple data using an image classification model to calculate a corresponding second loss function; and to calculate a total loss function of the triple data based on the first loss function and the second loss function; The model prediction module is used to iteratively update the image classification model using the total loss function to obtain a target image classification model with stable weight parameters, and use the target image classification model to identify the type of certificate.
10. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the document recognition method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Fine-grained classification method and device of target object and electronic equipment
CN109784366A
Remote sensing aircraft target classification method and device based on double-triple pseudo-twin architecture
CN113435383A
