Method and device for training universal certificate base model, storage medium and electronic equipment

By combining the supervised comparison learning framework, a general document base model was trained, which solved the problems of uneven distribution of document data and uneven categories, and improved the accuracy and training efficiency of electronic identity authentication.

CN118886475AActive Publication Date: 2024-11-01ANT BLOCKCHAIN TECHNOLOGY (SHANGHAI) CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202410844141.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-26
Publication Date
2024-11-01
Estimated Expiration
2044-06-26

AI Technical Summary

Technical Problem

The existing technology faces the problems of uneven distribution of global certificate data and serious uneven categories in electronic identity authentication. Traditional self-supervised algorithms fail to effectively utilize document category information, resulting in low model training efficiency and accuracy.

Method used

Using a method combining a supervised contrast learning framework, through self-supervised and supervised learning branches, the general document base model is trained using document image samples and enhanced samples, and combined with the scene characteristics of the document, the combination of data and classified information is achieved, and the training is carried out to achieve applicable Model of electronic identity authentication.

Benefits of technology

It improves the accuracy and training efficiency of the model and can be effectively used for classification, quality compliance and anti-counterfeiting tasks in electronic identity authentication.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118886475A_ABST
    Figure CN118886475A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a method and device for training a universal certificate base model, a storage medium and electronic equipment. The method comprises the following steps: obtaining a plurality of certificate categories and a plurality of certificate image samples corresponding to each certificate category; obtaining certificate image enhancement samples corresponding to the plurality of certificate image samples; according to the certificate category, the certificate image sample and the certificate image enhancement sample, based on a preset backbone network, training is carried out by combining a supervised comparative learning framework, a trained general certificate base model is obtained, the supervised comparative learning framework comprises a self-supervised learning branch, a supervised learning branch and a classification branch, and the self-supervised learning branch comprises a self-supervised learning branch and a supervised learning branch; the self-supervised learning branch comprises a self-supervised contrast loss function, the supervised learning branch comprises a supervised contrast loss function, and the classification branch comprises a cross entropy loss function.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to computer technology, and in particular to a method, device, storage medium and electronic equipment for training a universal certificate base model. Background Art

[0002] With the development of mobile terminal technology and the popularization of application use, more and more business scenarios require electronic identity authentication (Electronic Know Your Customer, ekyc). For example, various applications (such as finance) need to verify various user certificates for identity authentication. However, the data distribution of ekyc global certificates is uneven. There are tens of thousands of core certificates, while other certificates have only a few or even no certificates. Traditional self-supervised algorithms treat each certificate as a category, and self-supervised pre-training does not utilize the category information of thousands of certificates worldwide. Direct CNN (Convolutional Neural Networks) classification faces the problem of serious category imbalance. Summary of the invention

[0003] The purpose of the embodiments of this specification is to provide a method, device, storage medium and electronic device for training a universal certificate base model.

[0004] The embodiment of this specification provides a method for training a universal certificate base model, which trains a backbone network in combination with a certificate-based supervised comparative learning framework to obtain a trained universal certificate base model, and combines the scene characteristics of the certificate (similar contents of the same type of certificates and corresponding to the same certificate category) to implement a supervised + self-supervised model training method based on certificates, which not only utilizes a large amount of certificate data, but also utilizes the classification information of the certificate data, combines the data and the classification information, and trains a universal certificate base model, which can be used in downstream tasks such as classification, quality compliance, and anti-counterfeiting in electronic identity authentication, thereby improving the accuracy and training efficiency of the model. The method includes:

[0005] Obtain multiple document categories and multiple document image samples corresponding to each document category;

[0006] Obtaining enhanced document image samples corresponding to the multiple document image samples;

[0007] According to the document category, document image samples, and document image enhancement samples, based on a preset backbone network, a trained universal document base model is obtained by training in combination with a supervised contrast learning framework, wherein the supervised contrast learning framework includes a self-supervised learning branch, a supervised learning branch, and a classification branch, the self-supervised learning branch includes a self-supervised contrast loss function, the supervised learning branch includes a supervised contrast loss function, and the classification branch includes a cross-entropy loss function.

[0008] Furthermore, the self-supervised learning branch is connected to the first backbone network and the second backbone network, the input of the self-supervised contrast loss function includes the output of the first backbone network and the output of the second backbone network, the input of the first backbone network is an ID image sample, and the input of the second backbone network is an ID image enhancement sample corresponding to the one ID image sample; the supervised learning branch is connected to the third backbone network and the fourth backbone network, the input of the supervised contrast loss function includes the output of the third backbone network and the output of the fourth backbone network, the input of the third backbone network is the one ID image sample, and the input of the fourth backbone network is other ID image samples belonging to the ID category corresponding to the one ID image sample.

[0009] Furthermore, the input of the fourth backbone network is the ID image enhancement sample corresponding to the one ID image sample or other ID image samples belonging to the ID category corresponding to the one ID image sample.

[0010] Furthermore, the input of the classification branch includes the output of the first backbone network, the output of the third backbone network, and the document category corresponding to the document image sample.

[0011] Furthermore, the self-supervised learning branch also includes two first projection networks, the input of each first projection network is the output of the first backbone network or the output of the second backbone network, and each first projection network is used to map the representation vector output by the backbone network connected thereto into a vector for loss calculation, and the supervised learning branch also includes two second projection networks, the input of each second projection network is the output of the third backbone network or the output of the fourth backbone network, and each second projection network is used to map the representation vector output by the backbone network connected thereto into a vector for loss calculation.

[0012] Furthermore, the input of the classification branch includes: the output of the first projection network corresponding to the first backbone network, the output of the second projection network corresponding to the third backbone network, and the document category corresponding to the one document image sample.

[0013] Further, the trained universal certificate base model includes a trained backbone network and a single linear layer network connected to the trained backbone network;

[0014] Wherein, the method further comprises:

[0015] After the training is completed, the first projection network or the second projection network connected to the trained backbone network is replaced with a single linear layer network.

[0016] Furthermore, the step of obtaining a plurality of enhanced document image samples corresponding to the plurality of document image samples includes:

[0017] For each of the multiple certificate image samples, at least one data enhancement method is used to perform image enhancement processing on the certificate image sample to obtain a corresponding certificate image enhancement sample.

[0018] Furthermore, for each of the multiple certificate image samples, at least one data enhancement method is used to perform image enhancement processing on the certificate image sample to obtain a corresponding certificate image enhancement sample, including:

[0019] For each of the multiple certificate image samples, randomly crop the certificate image sample to obtain a cropped certificate image sample, and adjust the resolution of the cropped certificate image sample so that the adjusted resolution is the same as the resolution of the certificate image sample;

[0020] For each document image sample after adjusting the resolution, at least one data enhancement method is used to perform image enhancement processing on the document image sample after adjusting the resolution to obtain a corresponding document image enhanced sample.

[0021] The present specification also provides a method for document type identification, the method comprising:

[0022] Inputting a first document image into the trained universal document base model to obtain a first representation vector output by the universal document base model, wherein the universal document base model is trained based on the method for training a universal document base model described in an embodiment of this specification;

[0023] A search is performed in a feature library for the first characterization vector. If a feature vector matching the first characterization vector exists in the feature library, the document category corresponding to the feature vector is used as the first document category corresponding to the first document image, wherein the feature library includes multiple document categories and feature vectors corresponding to each document category.

[0024] Furthermore, the method further comprises:

[0025] If there is no feature vector matching the first representation vector in the feature library, obtaining a second document category corresponding to the first document image;

[0026] The second certificate category is added to the feature library, and the first characterization vector is added to the feature library as a feature vector corresponding to the second certificate category.

[0027] This specification also provides a method for training a downstream task model, the method comprising:

[0028] Using the model parameters corresponding to the trained universal certificate base model as the training initialization parameters of the downstream task model, wherein the universal certificate base model is trained based on the method for training a universal certificate base model described in the embodiment of this specification;

[0029] The downstream task model is trained according to the training initialization parameters to obtain a trained downstream task model.

[0030] The embodiment of this specification also provides a device for training a universal certificate base model, including:

[0031] The certificate image sample acquisition module is used to obtain multiple certificate categories and multiple certificate image samples corresponding to each certificate category;

[0032] A certificate image enhancement sample acquisition module, used to obtain a plurality of certificate image enhancement samples corresponding to the plurality of certificate image samples;

[0033] The universal document base model training module is used to obtain a trained universal document base model based on the document category, document image samples, and document image enhancement samples, by training in combination with a supervised contrast learning framework based on a preset backbone network, wherein the supervised contrast learning framework includes a self-supervised learning branch, a supervised learning branch, and a classification branch, the self-supervised learning branch includes a self-supervised contrast loss function, the supervised learning branch includes a supervised contrast loss function, and the classification branch includes a cross-entropy loss function.

[0034] The embodiment of this specification also provides a document type identification device, including:

[0035] An input module, used for inputting a first document image into the trained universal document base model to obtain a first representation vector output by the universal document base model, wherein the universal document base model is trained based on the method for training a universal document base model described in an embodiment of this specification;

[0036] A retrieval module is used to search for the first characterization vector in a feature library. If a feature vector matching the first characterization vector exists in the feature library, the document category corresponding to the feature vector is used as the first document category corresponding to the first document image, wherein the feature library includes multiple document categories and feature vectors corresponding to each document category.

[0037] The embodiment of this specification also provides a device for training a downstream task model, including:

[0038] A parameter initialization module, used to use the model parameters corresponding to the trained universal certificate base model as training initialization parameters of the downstream task model, wherein the universal certificate base model is trained based on the method for training a universal certificate base model described in the embodiment of this specification;

[0039] The downstream task model training module is used to train the downstream task model according to the training initialization parameters to obtain a trained downstream task model.

[0040] The embodiments of the present specification also provide a computer program product, wherein the computer program product stores at least one instruction, and the at least one instruction is suitable for being loaded by a processor and executing the above method steps.

[0041] The embodiments of the present specification also provide a storage medium, wherein the storage medium stores a computer program, and the computer program is suitable for being loaded by a processor and executing the steps of the above method.

[0042] An embodiment of the present specification also provides an electronic device, comprising: a processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the steps of the above method.

[0043] In the embodiments of the present specification, the backbone network is trained in combination with a supervised comparative learning framework based on certificates to obtain a trained universal certificate base model. Combined with the scenario characteristics of the certificates (similar contents of the same certificates and corresponding to the same certificate categories), a supervised + self-supervised model training method based on certificates is implemented. It not only utilizes a large amount of certificate data, but also utilizes the classification information of the certificate data. The data and classification information are combined to train a universal certificate base model, which can be used in downstream tasks such as classification, quality compliance, and anti-counterfeiting in electronic identity authentication, thereby improving the accuracy of the model and the training efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] Figure 1 A flowchart of a method for training a universal certificate base model provided in an embodiment of this specification;

[0045] Figure 2A schematic diagram of a supervised contrastive learning framework provided as an example in an embodiment of this specification;

[0046] Figure 3 A flowchart of a method for identifying a certificate type provided in an embodiment of this specification;

[0047] Figure 4 A flowchart of a method for training a downstream task model provided in an embodiment of this specification;

[0048] Figure 5 A schematic diagram of the structure of a device for training a universal certificate base model provided in an embodiment of this specification;

[0049] Figure 6 A schematic diagram of the structure of a device for identifying the type of certificate provided in an embodiment of this specification;

[0050] Figure 7 A schematic diagram of the structure of a device for training a downstream task model provided in an embodiment of this specification;

[0051] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of this specification. DETAILED DESCRIPTION

[0052] In order to make the purpose, technical solutions and advantages of this specification more clear, the technical solutions of this specification will be clearly and completely described below in combination with the specific embodiments of this specification and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of them. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this specification.

[0053] See also Figure 1 , is a flow chart of a method for training a universal certificate base model provided in an embodiment of this specification. In an embodiment of this specification, the method for training a universal certificate base model is applied to a device for training a universal certificate base model (hereinafter referred to as a "first training device") or an electronic device equipped with the first training device. Figure 1 The process shown in FIG. 1 is described in detail, and the method for training the universal certificate base model may specifically include the following steps:

[0054] S102, obtaining a plurality of certificate categories and a plurality of certificate image samples corresponding to each certificate category.

[0055] In some embodiments, various certificates in the world are classified according to certificate categories to obtain multiple certificate categories and multiple certificate image samples corresponding to each certificate category. In some embodiments, each certificate image sample is labeled with its corresponding certificate category, so that a training data set is formed based on multiple certificate categories and multiple certificate image samples corresponding to each certificate category. In some embodiments, certificate categories include but are not limited to identity cards, passports, etc. of various countries. It should be noted that the above certificate categories are only examples and not limitations. Those skilled in the art should understand that any certificate category can be included in the protection scope of this specification, and this specification does not limit this.

[0056] S104: Obtain enhanced document image samples corresponding to the multiple document image samples.

[0057] In some embodiments, for a certain document image sample, a preset data enhancement method is used to perform image data enhancement processing on the document image sample to obtain one or more document image enhancement samples corresponding to the document image sample, wherein each document image enhancement sample represents a different perspective of the corresponding document image sample and contains some information subsets in the document image sample. The data enhancement method includes but is not limited to data enhancement based on geometric transformation (such as flipping, rotating, cropping, translating, and adding noise, etc.), data enhancement based on color space transformation (such as adjusting brightness, contrast, saturation, channel separation, and grayscale conversion, etc.), and other data enhancement methods (such as random occlusion, automatic enhancement, random enhancement, sample generation adversarial network, local perturbation, image denoising, Sim enhancement (random color distortion and Gaussian blur are performed in sequence, and additional sparse image distortion operations may be performed at the end of the sequence)). It should be noted that the above data enhancement methods are only examples and not limitations. Those skilled in the art should understand that any data enhancement method can be included in the protection scope of this specification, and this specification does not limit this.

[0058] S106, according to the document category, document image samples, and document image enhancement samples, based on a preset backbone network, a trained universal document base model is obtained by training in combination with a supervised contrast learning framework, wherein the supervised contrast learning framework includes a self-supervised learning branch, a supervised learning branch, and a classification branch, the self-supervised learning branch includes a self-supervised contrast loss function, the supervised learning branch includes a supervised contrast loss function, and the classification branch includes a cross entropy loss function.

[0059] In some embodiments, multiple certificate categories, multiple certificate image samples corresponding to each certificate category, and one or more certificate image enhancement samples corresponding to each certificate image sample are used as training data. In some embodiments, a preset backbone network (backbone) is trained on the training data by combining a supervised contrastive learning framework to obtain a trained universal certificate base model, wherein the backbone network (also referred to as a basic network or backbone network) includes but is not limited to network structures such as resnet50 and vit base. The backbone network is used to extract features of input training data (certificate image samples or certificate image enhancement samples). It should be noted that the network structure of the above backbone network is only an example, not a limitation. Those skilled in the art should understand that any backbone network can be included in the protection scope of this specification, and this specification does not limit this.

[0060] In some embodiments, the input of the backbone network is a document image sample or a document image enhancement sample. In the process of training the universal document base model, the backbone network is trained by combining it with a supervised contrastive learning framework, that is, the backbone network is connected to the supervised contrastive learning framework, and the feature vector output by the backbone network is used as the input of the supervised contrastive learning framework. In some embodiments, the input of the supervised contrastive learning framework includes, in addition to the feature vector output by the backbone network, the document category corresponding to the document image sample input to the backbone network or the document category corresponding to the document image enhancement sample. In some embodiments, the supervised contrastive learning framework includes a self-supervised learning branch, a supervised learning branch and a classification branch. The self-supervised learning branch includes a self-supervised contrast loss function, the supervised learning branch includes a supervised contrast loss function, and the classification branch includes a cross-entropy loss function and a softmax (normalized exponent) function. The self-supervised contrast loss function is used to adjust the parameters of the backbone network by calculating the self-supervised contrast loss according to the two feature vectors output by the backbone network. The supervised contrast loss function is used to adjust the parameters of the backbone network by calculating the supervised contrast loss according to the two feature vectors output by the backbone network. The softmax function is used to obtain corresponding predicted classification information based on the feature vector output by the backbone network. The predicted classification information includes at least one predicted classification and / or a probability value corresponding to each predicted classification. The cross-entropy loss function is used to adjust the parameters of the backbone network by calculating the loss according to the predicted classification information output by the softmax function and the document category corresponding to the document image sample.

[0061] In some embodiments, the types of classification branches include, but are not limited to, linear classifiers (e.g., basic linear classifiers, least squares linear classifiers, perceptrons, logistic regression classifiers, etc.), nonlinear classifiers (e.g., SVM (support vector machine), decision tree, naive Bayes, KNN (K-nearest neighbor algorithm)), and other classifiers. It should be noted that the above classifiers are only examples and not limitations. Those skilled in the art should understand that any classifier can be included in the scope of protection of this specification, and this specification does not limit this.

[0062] In some embodiments, the self-supervised learning branch can adopt the self-supervised method of DINOv2 (a computer vision self-supervised model released by Meta), which is a combination of DINO (maximization of local information between visual Transformers) and iBOT (minimization of similarity between features) losses, and introduces the centering method of SwAV (sample centering). In addition, a regularization term is added to expand the features so that the features are more evenly distributed in the feature space.

[0063] In some embodiments, the self-supervised learning branch includes, but is not limited to, various branches using different types of self-supervised learning algorithms, such as a generative self-supervised learning branch, a discriminative self-supervised learning branch, a contrast-generative / adversarial self-supervised learning branch, etc. If the self-supervised learning branch is a generative self-supervised learning branch, then the self-supervised contrast loss function it includes is a generative contrast loss function, if the self-supervised learning branch is a discriminative self-supervised learning branch, then the self-supervised contrast loss function it includes is a discriminative contrast loss function, if the self-supervised learning branch is a contrast-generative / adversarial self-supervised learning branch, then the self-supervised contrast loss function it includes includes both a generative contrast loss function and a discriminative contrast loss function. It should be noted that the above-mentioned self-supervised learning branches are only examples and not limitations. Those skilled in the art should understand that self-supervised learning branches using any self-supervised learning algorithm can be included in the protection scope of this specification, and this specification does not limit this.

[0064] In some embodiments, the supervised learning branch includes but is not limited to a branch using any type of supervised learning algorithm (e.g., a classification algorithm (e.g., logistic regression, random forest, convolutional neural network CNN, multi-layer perceptron MLP, etc.), a regression algorithm (e.g., linear regression, polynomial regression, ridge regression, Lasso regression, etc.)), which is not specifically limited in this example embodiment. In some embodiments, the supervised contrast loss function includes but is not limited to a 0-1 loss function, a Hinge loss function, an exponential loss function, a square loss function, a log loss function, etc., which is not specifically limited in this example embodiment.

[0065] In some embodiments, after the training is completed, the trained backbone network is used as a universal certificate base model, so that the universal certificate base model not only learns the characterization ability of the certificate image, but also learns the category information corresponding to the certificate image. In some embodiments, the feature vector output by the backbone network can be used as the characterization vector output of the universal certificate base model, and a feature library is extracted for each certificate, and then features are extracted for the new certificate, and the category of the feature library is retrieved. In some embodiments, the model parameters of the universal certificate base model can also be used as training initialization parameters for downstream tasks (for example, classification, quality compliance, anti-counterfeiting, OCR (Optical Character Recognition) and other tasks), which can improve the training efficiency of the downstream task model and improve the accuracy of downstream tasks.

[0066] In some embodiments, the self-supervised learning branch is connected to the first backbone network and the second backbone network, the input of the self-supervised contrast loss function includes the output of the first backbone network and the output of the second backbone network, the input of the first backbone network is an ID image sample, and the input of the second backbone network is an ID image enhancement sample corresponding to the one ID image sample; the supervised learning branch is connected to the third backbone network and the fourth backbone network, the input of the supervised contrast loss function includes the output of the third backbone network and the output of the fourth backbone network, the input of the third backbone network is the one ID image sample, and the input of the fourth backbone network is other ID image samples belonging to the ID category corresponding to the one ID image sample. In some embodiments, a self-supervised learning branch is connected to a pair of backbone networks, and a self-supervised contrast loss function in the self-supervised learning branch calculates contrast loss based on a pair of feature vectors respectively output by the pair of backbone networks to adjust the parameters of the backbone networks. The pair of backbone networks include a first backbone network and a second backbone network. The first backbone network and the second backbone network have the same network structure and network parameters. Subsequently, in the training process of the universal certificate base model, the network parameters of the first backbone network and the network parameters of the second backbone network are synchronously adjusted according to the loss value calculated by the self-supervised contrast loss function, the supervised contrast loss function or the cross entropy loss function, so that the network parameters of the two remain consistent (i.e., shared parameters). In some embodiments, the input of the first backbone network is a document image sample. If the current input of the first backbone network is one of the multiple document image samples, the current input of the second backbone network is one of the one or more document image enhancement samples corresponding to the one document image sample. For example, if the current input of the first backbone network is the ID card image of country Y of user X, the current input of the second backbone network is the enhanced image corresponding to the ID card image of country Y of user X (for example, the enhanced image obtained by performing Gaussian blur processing on the ID card image of country Y of user X). In some embodiments, a supervised learning branch is connected to another pair of backbone networks, and a supervised contrast loss function in the supervised learning branch calculates the contrast loss based on a pair of feature vectors respectively output by the other pair of backbone networks to adjust the parameters of the backbone networks. The other pair of backbone networks includes a third backbone network and a fourth backbone network. The first backbone network, the second backbone network, the third backbone network, and the fourth backbone network correspond to the same network structure and network parameters. Subsequently, in the training process of the universal certificate base model, the network parameters of the first backbone network, the second backbone network, the third backbone network, and the fourth backbone network are synchronously adjusted according to the loss value calculated by the self-supervised contrast loss function, the supervised contrast loss function, or the cross entropy loss function, so that the network parameters of the four backbone networks remain consistent (i.e., shared parameters).In some embodiments, the current input of the third backbone network is the same as the current input of the first backbone network. If the current input of the first backbone network is one of the multiple document image samples, then the current input of the third backbone network is also the one document image sample, and the current input of the fourth backbone network is another document image sample belonging to the document category corresponding to the one document image sample. For example, if the current input of the first backbone network is the ID card image of user X in country Y, then the current input of the third backbone network is also the ID card image of user X in country Y, and the current input of the fourth backbone network is the ID card image of user Z in country Y.

[0067] In some embodiments, the input of the fourth backbone network is the enhanced ID image sample corresponding to the one ID image sample or other ID image samples belonging to the ID category corresponding to the one ID image sample. In some embodiments, if the current input of the first backbone network or the third backbone network is one of the multiple ID image samples, the current input of the fourth backbone network may be one of the one or more enhanced ID image samples corresponding to the ID image sample in addition to another ID image sample belonging to the ID category corresponding to the one ID image sample. For example, if the current input of the first backbone network is the ID card image of country Y of user X, the current input of the third backbone network is also the ID card image of country Y of user X, and the current input of the fourth backbone network is the ID card image of country Y of user Z or the enhanced image corresponding to the ID card image of country Y of user X (for example, the enhanced image obtained by Gaussian blurring the ID card image of country Y of user X). In some embodiments, the current input of the second backbone network and the fourth backbone network is the same, that is, the current input of the two is the same document image enhancement sample, or the current input of the second backbone network and the fourth backbone network can be different, that is, the current input of the two can be two different document image enhancement samples corresponding to one document image sample.

[0068] In some embodiments, the input of the classification branch includes the output of the first backbone network, the output of the third backbone network, and the document category corresponding to the document image sample. In some embodiments, the input of the classification branch includes the first feature vector output by the first backbone network, the second feature vector output by the third backbone network, and the document category corresponding to the document image sample input to the first backbone network corresponding to the first feature vector or the document category corresponding to the document image sample input to the third backbone network corresponding to the second feature vector. In some embodiments, the softmax function in the classification branch is used to obtain corresponding predicted classification information based on the first eigenvector and the second eigenvector, the predicted classification information includes at least one predicted classification and / or a probability value corresponding to each predicted classification, and the cross entropy loss function is used to adjust the parameters of the backbone network by calculating the loss based on the predicted classification information output by the softmax function and the document type input into the classification branch, wherein the first eigenvector and the second eigenvector can be first synthesized into a eigenvector, and then the synthesized eigenvector is input into the softmax function to obtain the corresponding predicted classification information, or the first eigenvector and the second eigenvector can be respectively input into the softmax function to obtain the corresponding first classification information and second classification information, and then the first classification information and the second classification information are synthesized into the corresponding predicted classification information.

[0069] In some embodiments, the self-supervised learning branch also includes two first projection networks, the input of each first projection network is the output of the first backbone network or the output of the second backbone network, and each first projection network is used to map the representation vector output by the backbone network connected thereto into a vector for loss calculation, and the supervised learning branch also includes two second projection networks, the input of each second projection network is the output of the third backbone network or the output of the fourth backbone network, and each second projection network is used to map the representation vector output by the backbone network connected thereto into a vector for loss calculation. In some embodiments, the self-supervised learning branch also includes a pair of first projection networks, each of which is composed of a multilayer perceptron including a hidden layer, one of the first projection networks in the pair of first projection networks is connected to the first backbone network, and the input of the first projection network is a feature vector (for example, 2048 dimensions) output by the first backbone network, and the other first projection network in the pair of first projection networks is connected to the second backbone network, and the input of the other first projection network is a feature vector (for example, 2048 dimensions) output by the second backbone network, each first projection network is used to map the representation vector output by the backbone network connected thereto into a projection vector (for example, 128 dimensions), that is, the output of each first projection network is a projection vector, and the self-supervised contrast loss function is used to perform loss calculation based on a pair of projection vectors output by a pair of first projection networks, respectively, wherein the two first projection networks correspond to the same network structure and network parameters. In some embodiments, the supervised learning branch further includes a pair of second projection networks, each of which is composed of a multilayer perceptron including a hidden layer, one of the second projection networks in the pair of second projection networks is connected to the third backbone network, the input of the second projection network is the feature vector (e.g., 2048 dimensions) output by the third backbone network, the other second projection network in the pair of second projection networks is connected to the fourth backbone network, the input of the other second projection network is the feature vector (e.g., 2048 dimensions) output by the fourth backbone network, each second projection network is used to map the representation vector output by the backbone network connected thereto into a projection vector (e.g., 128 dimensions), that is, the output of each second projection network is a projection vector, and the supervised contrast loss function is used to calculate the loss according to a pair of projection vectors output by the pair of second projection networks, wherein the two second projection networks correspond to the same network structure and network parameters. In some embodiments, the first projection network and the second projection network need to correspond to the same network structure and network parameters, or the two may correspond to different network structures and / or different network parameters.

[0070] In some embodiments, the input of the classification branch includes: the output of the first projection network corresponding to the first backbone network, the output of the second projection network corresponding to the third backbone network, and the document category corresponding to the document image sample. In some embodiments, the feature vector output by the first backbone network and the feature vector output by the third backbone network can be directly input into the classification branch, or the feature vector output by the first backbone network can also be first input into the first projection network connected thereto, and the first projection network then inputs the projection vector corresponding to the feature vector output by the first projection network into the classification branch, and the feature vector output by the third backbone network can also be first input into the second projection network connected thereto, and the second projection network then inputs the projection vector corresponding to the feature vector output by the second projection network into the classification branch.

[0071] In some embodiments, the trained universal certificate base model includes a trained backbone network and a single linear layer network connected to the trained backbone network; wherein the method further comprises: after the training is completed, replacing the first projection network or the second projection network connected to the trained backbone network with a single linear layer network. In some embodiments, after the training is completed, the trained backbone network and the first projection network or the second projection network connected to the backbone network are used as the universal certificate base model, and the backbone network can be any one of the first backbone network, the second backbone network, the third backbone network, and the fourth backbone network. In some embodiments, after the training is completed, the first projection network or the second projection network connected to the backbone network in the universal certificate base model needs to be replaced with a single linear layer network. In some embodiments, the input of the single linear layer is a 2048-dimensional feature vector, and the output is a 128-dimensional feature vector.

[0072] In some embodiments, obtaining multiple ID image enhanced samples corresponding to the multiple ID image samples includes: for each ID image sample among the multiple ID image samples, using at least one data enhancement method to perform image enhancement processing on the ID image sample to obtain a corresponding ID image enhanced sample. In some embodiments, for each of the multiple document image samples, at least one preset data enhancement method is used to perform image enhancement processing on the document image sample to obtain a document image enhancement sample corresponding to the document image sample, wherein one of the preset at least one data enhancement method may be selected to perform image enhancement processing on the document image sample, for example, one is randomly selected, or a data enhancement method that matches the attribute information (for example, size information, color information, layout information, etc.) is automatically selected from the preset at least one data enhancement method according to the attribute information of the document image sample, or image content recognition is performed on the document image sample, and a data enhancement method that matches the document content is automatically selected from the preset at least one data enhancement method according to the identified document content, or image enhancement processing may also be performed sequentially using the preset at least one data enhancement method for the document image sample, wherein the processing order corresponding to the at least one data enhancement method may be preset, or may be randomly determined, or may be determined according to the attribute information or document content of the document image sample.

[0073] In some embodiments, for each of the multiple ID image samples, at least one data enhancement method is used to perform image enhancement processing on the ID image sample to obtain a corresponding ID image enhancement sample, including: for each of the multiple ID image samples, randomly cropping the ID image sample to obtain a cropped ID image sample, adjusting the resolution of the cropped ID image sample so that the adjusted resolution is the same as the resolution of the ID image sample; for each ID image sample with adjusted resolution, at least one data enhancement method is used to perform image enhancement processing on the ID image sample with adjusted resolution to obtain a corresponding ID image enhancement sample. In some embodiments, it is necessary to first randomly crop the ID image sample to obtain a cropped ID image sample, then adjust the resolution of the cropped ID image sample to the original resolution of the ID image sample, and then use at least one preset data enhancement method to perform image enhancement processing on the ID image sample with adjusted resolution to obtain a corresponding ID image enhancement sample.

[0074] Figure 2 A schematic diagram of a supervised contrastive learning framework is provided as an example in an embodiment of this specification.

[0075] like Figure 2 As shown, the self-supervised learning branch is connected to a pair of backbone networks, and the self-supervised contrast loss function in the self-supervised learning branch calculates the contrast loss according to a pair of feature vectors respectively output by the pair of backbone networks to adjust the parameters of the backbone networks. The pair of backbone networks includes a first backbone network and a second backbone network. The current input X1 of the first backbone network is one of the multiple document image samples, and the current input X2 of the second backbone network is one of the one or more document image enhancement samples corresponding to the one document image sample. The supervised learning branch is connected to another pair of backbone networks, and the supervised contrast loss function in the supervised learning branch calculates the contrast loss according to a pair of feature vectors respectively output by the other pair of backbone networks to adjust the parameters of the backbone network. The other pair of backbone networks includes a third backbone network and a fourth backbone network, the input of the third backbone network is the same as the input of the first backbone network, that is, the current input X3 of the third backbone network is also the one ID image sample, the current input X4 of the fourth backbone network is the ID image enhancement sample corresponding to the one ID image sample or an other ID image belonging to the ID category corresponding to the one ID image sample, the classification branch is connected to the first backbone network and the third backbone network, and the current input X0 of the classification branch includes the first eigenvector output by the first backbone network, the second eigenvector output by the third backbone network, and the ID category corresponding to the ID image sample input to the first backbone network corresponding to the first eigenvector or the ID category corresponding to the ID image sample input to the third backbone network corresponding to the second eigenvector.

[0076] Figure 3 The following is a flow chart of a method for identifying the type of certificate provided in the embodiment of this specification. In the embodiment of this specification, the method for identifying the type of certificate is applied to a device for identifying the type of certificate or an electronic device equipped with the device for identifying the type of certificate. Figure 3 The process shown is described in detail, and the document type identification method may specifically include the following steps:

[0077] S302, inputting a first certificate image into the trained universal certificate base model to obtain a first representation vector output by the universal certificate base model, wherein the universal certificate base model is trained based on the method for training a universal certificate base model described in an embodiment of this specification.

[0078] In some embodiments, the training method of the universal certificate base model has been described in detail above and will not be repeated here. In some embodiments, in some embodiments, an ID card image is input into the trained universal certificate base model to obtain the first characterization vector output by the universal certificate base model. In some embodiments, if the universal certificate base model only includes a trained backbone network, the feature vector output by the backbone network can be used as the first characterization vector output by the universal certificate base model. If the universal certificate base model includes a trained backbone network and a single linear network connected to the backbone network (that is, the feature vector output by the backbone network will be input into a single linear layer network), the feature vector output by the single linear layer network can be used as the first characterization vector output by the universal certificate base model.

[0079] S304, searching a feature library for the first characterization vector, if a feature vector matching the first characterization vector exists in the feature library, taking the document category corresponding to the feature vector as the first document category corresponding to the first document image, wherein the feature library includes a plurality of document categories and feature vectors corresponding to each document category.

[0080] In some embodiments, based on the trained universal certificate base model, a feature vector corresponding to each certificate is obtained, and the certificate category corresponding to the certificate and the feature vector are stored in the feature library. In addition, the mapping relationship (corresponding relationship) between the certificate category and the feature vector is also stored in the feature library. In some embodiments, the first characterization vector output by the universal certificate base model is searched in the feature library. If there is a feature vector matching the first characterization vector in the feature library, the certificate category corresponding to the feature vector is used as the first certificate category corresponding to the first certificate image, wherein a feature vector matching the first characterization vector may mean that the two vectors are the same, or may also mean that the similarity between the two vectors is greater than or equal to a preset similarity threshold. In some embodiments, a feature vector corresponding to a certificate exists in the feature library, so that a global certificate template library can be constructed through the feature library.

[0081] In some embodiments, the method further includes: if there is no feature vector matching the first characterization vector in the feature library, obtaining a second document category corresponding to the first document image; adding the second document category to the feature library, and adding the first characterization vector to the feature library as a feature vector corresponding to the second document category. In some embodiments, if there is no feature vector matching the first characterization vector in the feature library, obtaining the second document category corresponding to the first document image. This exemplary embodiment does not specifically limit the method for obtaining the second document category corresponding to the first document image. For example, the second document category corresponding to the first document image input by the user can be obtained. For another example, the image content recognition can be performed on the first document image, and the second document category corresponding to the first document image can be determined according to the recognition result. In some embodiments, the second document category is added to the feature library, and the first characterization vector is added to the feature library as a feature vector corresponding to the second document category, that is, the second document category and the first characterization vector are added to the feature library, and a mapping relationship (corresponding relationship) between the second document category and the first characterization vector is added to the feature library. In some embodiments, there is no need to retrain the model for newly added certificates. Instead, the newly added certificate only needs to be input into the trained universal certificate base model, and the feature vector output by the universal certificate base model can be added to the feature library, so that a global certificate template library can be constructed through the feature library.

[0082] Figure 4 A flowchart of a method for training a downstream task model provided in an embodiment of this specification. In an embodiment of this specification, the method for training a downstream task model is applied to a device for training a downstream task model (hereinafter referred to as a "second training device") or an electronic device equipped with a second training device. Figure 4 The process shown is described in detail, and the method for training the downstream task model may specifically include the following steps:

[0083] S402, using the model parameters corresponding to the trained universal certificate base model as training initialization parameters of the downstream task model, wherein the universal certificate base model is trained based on the method for training a universal certificate base model described in the embodiments of this specification.

[0084] In some embodiments, the training method of the universal certificate base model has been described in detail above and will not be repeated here. In some embodiments, the model parameters (e.g., weights) corresponding to the trained universal certificate base model can be directly used as the training initialization parameters of the downstream task model, that is, the pre-training of the downstream task model is achieved by training the universal certificate base model, wherein the downstream tasks include but are not limited to classification, quality compliance, anti-counterfeiting, OCR, etc. in the certificate recognition task. It should be noted that the above downstream tasks are only examples and not limitations. Those skilled in the art should understand that any downstream tasks can be included in the protection scope of this specification, and this specification does not limit this.

[0085] S404, train the downstream task model according to the training initialization parameters to obtain a trained downstream task model. In some embodiments, training the downstream task model based on the training initialization parameters can improve the training efficiency of the downstream task model and improve the accuracy of the downstream tasks. This example embodiment does not specifically limit the training process of the downstream task model. In some embodiments, based on the trained downstream task model, the corresponding downstream task is executed.

[0086] Figure 5 A schematic diagram of a structure of a device for training a universal certificate base model provided in an embodiment of the present specification, the device for training a universal certificate base model (hereinafter referred to as "first training device 1") can be implemented as all or part of an electronic device through software, hardware or a combination of both. According to some embodiments, the first training device 1 includes a certificate image sample acquisition module 11, a certificate image enhancement sample acquisition module 12 and a universal certificate base model training module 13.

[0087] The certificate image sample acquisition module 11 is used to obtain multiple certificate categories and multiple certificate image samples corresponding to each certificate category;

[0088] The document image enhancement sample acquisition module 12 is used to obtain a plurality of document image enhancement samples corresponding to the plurality of document image samples;

[0089] The universal document base model training module 13 is used to obtain a trained universal document base model based on the document category, document image samples, and document image enhancement samples, by training in combination with a supervised contrast learning framework based on a preset backbone network, wherein the supervised contrast learning framework includes a self-supervised learning branch, a supervised learning branch, and a classification branch, the self-supervised learning branch includes a self-supervised contrast loss function, the supervised learning branch includes a supervised contrast loss function, and the classification branch includes a cross-entropy loss function.

[0090] In some embodiments, the self-supervised learning branch is connected to the first backbone network and the second backbone network, the input of the self-supervised contrast loss function includes the output of the first backbone network and the output of the second backbone network, the input of the first backbone network is an ID image sample, and the input of the second backbone network is an ID image enhancement sample corresponding to the one ID image sample; the supervised learning branch is connected to the third backbone network and the fourth backbone network, the input of the supervised contrast loss function includes the output of the third backbone network and the output of the fourth backbone network, the input of the third backbone network is the one ID image sample, and the input of the fourth backbone network is other ID image samples belonging to the ID category corresponding to the one ID image sample.

[0091] In some embodiments, the input of the fourth backbone network is an ID image enhancement sample corresponding to the one ID image sample or other ID image samples belonging to the ID category corresponding to the one ID image sample.

[0092] In some embodiments, the input of the classification branch includes the output of the first backbone network, the output of the third backbone network, and the document category corresponding to the one document image sample.

[0093] In some embodiments, the self-supervised learning branch also includes two first projection networks, the input of each first projection network is the output of the first backbone network or the output of the second backbone network, and each first projection network is used to map the representation vector output by the backbone network connected thereto into a vector for loss calculation, and the supervised learning branch also includes two second projection networks, the input of each second projection network is the output of the third backbone network or the output of the fourth backbone network, and each second projection network is used to map the representation vector output by the backbone network connected thereto into a vector for loss calculation.

[0094] In some embodiments, the input of the classification branch includes: the output of the first projection network corresponding to the first backbone network, the output of the second projection network corresponding to the third backbone network, and the document category corresponding to the one document image sample.

[0095] In some embodiments, the trained universal certificate base model includes a trained backbone network and a single linear layer network connected to the trained backbone network;

[0096] Wherein, the first training device 1 is also used for:

[0097] After the training is completed, the first projection network or the second projection network connected to the trained backbone network is replaced with a single linear layer network.

[0098] In some embodiments, obtaining a plurality of enhanced document image samples corresponding to the plurality of document image samples includes:

[0099] For each of the multiple certificate image samples, at least one data enhancement method is used to perform image enhancement processing on the certificate image sample to obtain a corresponding certificate image enhancement sample.

[0100] In some embodiments, for each of the multiple certificate image samples, performing image enhancement processing on the certificate image sample using at least one data enhancement method to obtain a corresponding certificate image enhancement sample includes:

[0101] For each of the multiple certificate image samples, randomly crop the certificate image sample to obtain a cropped certificate image sample, and adjust the resolution of the cropped certificate image sample so that the adjusted resolution is the same as the resolution of the certificate image sample;

[0102] For each document image sample after adjusting the resolution, at least one data enhancement method is used to perform image enhancement processing on the document image sample after adjusting the resolution to obtain a corresponding document image enhanced sample.

[0103] Figure 6 The present invention provides a schematic diagram of the structure of a document type recognition device provided in an embodiment of the present invention. The document type recognition device (hereinafter referred to as "document type recognition device 2") can be implemented as all or part of an electronic device through software, hardware or a combination of both. According to some embodiments, the document type recognition device 2 includes an input module 21 and a retrieval module 22.

[0104] An input module 21, used for inputting a first document image into the trained universal document base model to obtain a first representation vector output by the universal document base model, wherein the universal document base model is trained based on the method for training a universal document base model described in an embodiment of this specification;

[0105] The retrieval module 22 is used to search the feature library for the first characterization vector. If a feature vector matching the first characterization vector exists in the feature library, the document category corresponding to the feature vector is used as the first document category corresponding to the first document image, wherein the feature library includes multiple document categories and feature vectors corresponding to each document category.

[0106] In some embodiments, the document type identification device 2 is also used for:

[0107] If there is no feature vector matching the first representation vector in the feature library, obtaining a second document category corresponding to the first document image;

[0108] The second certificate category is added to the feature library, and the first characterization vector is added to the feature library as a feature vector corresponding to the second certificate category.

[0109] Figure 7 A schematic diagram of a structure of a device for training a downstream task model provided in an embodiment of the present specification, the device for training a downstream task model (hereinafter referred to as "second training device 3") can be implemented as all or part of an electronic device through software, hardware, or a combination of both. According to some embodiments, the second training device 3 includes a parameter initialization module 31 and a downstream task model training module 32.

[0110] A parameter initialization module 31, used to use the model parameters corresponding to the trained universal certificate base model as training initialization parameters of the downstream task model, wherein the universal certificate base model is trained based on the method for training a universal certificate base model described in the embodiment of this specification;

[0111] The downstream task model training module 32 is used to train the downstream task model according to the training initialization parameters to obtain a trained downstream task model.

[0112] The above device embodiments correspond to the method embodiments. For specific descriptions, please refer to the description of the method embodiments, which will not be repeated here. The device embodiments are obtained based on the corresponding method embodiments and have the same technical effects as the corresponding method embodiments. For specific descriptions, please refer to the corresponding method embodiments.

[0113] The embodiment of the present specification also provides a computer storage medium, which can store multiple instructions, and the instructions are suitable for being loaded by a processor to execute the method of the embodiment of the present specification.

[0114] The embodiments of the present specification also provide a computer program product, which stores at least one instruction, and the at least one instruction is loaded by the processor to execute the method of the embodiments of the present specification.

[0115] The embodiments of this specification also provide Figure 8 The structural diagram of the electronic device shown in FIG. Figure 8 At the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory, and may also include hardware required for other services. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to implement the above-mentioned voice activity detection method.

[0116] Of course, in addition to software implementation, this specification does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the executor of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0117] In the 1990s, improvements to a technology could be clearly distinguished as hardware improvements (for example, improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the method flow). However, with the development of technology, many improvements to the method flow today can be regarded as direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement in a method flow cannot be implemented using a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to ask a chip manufacturer to design and produce a dedicated integrated circuit chip. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages ​​and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.

[0118] The controller can be implemented in any appropriate manner, for example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in a purely computer-readable program code manner, the controller can be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be regarded as structures within the hardware component. Or even, the devices for implementing various functions can be regarded as both software modules for implementing the method and structures within the hardware component.

[0119] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0120] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.

[0121] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems, or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0122] This specification is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of this specification. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0123] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0124] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0125] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0126] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0127] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0128] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity 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, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0129] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0130] This specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.

[0131] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0132] The above description is only an embodiment of the present specification and is not intended to limit the present specification. For those skilled in the art, the present specification may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification shall be included in the scope of the claims of the present specification.

Claims

1. A method for training a universal certificate base model, comprising: Obtain multiple document categories and multiple document image samples corresponding to each document category; Obtaining enhanced document image samples corresponding to the multiple document image samples; According to the document category, document image samples, and document image enhancement samples, based on a preset backbone network, a trained universal document base model is obtained by training in combination with a supervised contrast learning framework, wherein the supervised contrast learning framework includes a self-supervised learning branch, a supervised learning branch, and a classification branch, the self-supervised learning branch includes a self-supervised contrast loss function, the supervised learning branch includes a supervised contrast loss function, and the classification branch includes a cross-entropy loss function.

2. According to the method of claim 1, the self-supervised learning branch is connected to the first backbone network and the second backbone network, the input of the self-supervised contrast loss function includes the output of the first backbone network and the output of the second backbone network, the input of the first backbone network is an ID image sample, and the input of the second backbone network is an ID image enhancement sample corresponding to the one ID image sample; the supervised learning branch is connected to the third backbone network and the fourth backbone network, the input of the supervised contrast loss function includes the output of the third backbone network and the output of the fourth backbone network, the input of the third backbone network is the one ID image sample, and the input of the fourth backbone network is other ID image samples belonging to the ID category corresponding to the one ID image sample.

3. According to the method of claim 2, the input of the fourth backbone network is the ID image enhancement sample corresponding to the one ID image sample or other ID image samples belonging to the ID category corresponding to the one ID image sample.

4. According to the method of claim 2 or 3, the input of the classification branch includes the output of the first backbone network, the output of the third backbone network and the document category corresponding to the document image sample.

5. According to the method of claim 4, the self-supervised learning branch also includes two first projection networks, the input of each first projection network is the output of the first backbone network or the output of the second backbone network, and each first projection network is used to map the representation vector output by the backbone network connected thereto into a vector for loss calculation, and the supervised learning branch also includes two second projection networks, the input of each second projection network is the output of the third backbone network or the output of the fourth backbone network, and each second projection network is used to map the representation vector output by the backbone network connected thereto into a vector for loss calculation.

6. The method according to claim 5, wherein the input of the classification branch comprises: The output of the first projection network corresponding to the first backbone network, the output of the second projection network corresponding to the third backbone network, and the document category corresponding to the one document image sample.

7. The method according to claim 5 or 6, wherein the trained universal certificate base model comprises a trained backbone network and a single linear layer network connected to the trained backbone network; in, The method further comprises: After the training is completed, the first projection network or the second projection network connected to the trained backbone network is replaced with a single linear layer network.

8. The method according to claim 1, wherein obtaining a plurality of enhanced document image samples corresponding to the plurality of document image samples comprises: For each of the multiple certificate image samples, at least one data enhancement method is used to perform image enhancement processing on the certificate image sample to obtain a corresponding certificate image enhancement sample.

9. The method according to claim 8, wherein for each of the plurality of certificate image samples, performing image enhancement processing on the certificate image sample using at least one data enhancement method to obtain a corresponding certificate image enhancement sample comprises: For each of the multiple certificate image samples, randomly crop the certificate image sample to obtain a cropped certificate image sample, and adjust the resolution of the cropped certificate image sample so that the adjusted resolution is the same as the resolution of the certificate image sample; For each document image sample after adjusting the resolution, at least one data enhancement method is used to perform image enhancement processing on the document image sample after adjusting the resolution to obtain a corresponding document image enhanced sample.

10. A method for identifying a certificate type, comprising: Inputting a first document image into the trained universal document base model to obtain a first representation vector output by the universal document base model, wherein the universal document base model is trained based on the method for training a universal document base model according to any one of claims 1 to 9; A search is performed in a feature library for the first characterization vector. If a feature vector matching the first characterization vector exists in the feature library, the document category corresponding to the feature vector is used as the first document category corresponding to the first document image, wherein the feature library includes multiple document categories and feature vectors corresponding to each document category.

11. The method according to claim 10, further comprising: If there is no feature vector matching the first representation vector in the feature library, obtaining a second document category corresponding to the first document image; The second certificate category is added to the feature library, and the first characterization vector is added to the feature library as a feature vector corresponding to the second certificate category.

12. A method for training a downstream task model, comprising: Using the model parameters corresponding to the trained universal certificate base model as training initialization parameters of the downstream task model, wherein the universal certificate base model is trained based on the method for training a universal certificate base model according to any one of claims 1 to 9; The downstream task model is trained according to the training initialization parameters of the downstream task model to obtain a trained downstream task model.

13. A device for training a universal document base model, comprising: The certificate image sample acquisition module is used to obtain multiple certificate categories and multiple certificate image samples corresponding to each certificate category; A certificate image enhancement sample acquisition module, used to obtain a plurality of certificate image enhancement samples corresponding to the plurality of certificate image samples; The universal document base model training module is used to obtain a trained universal document base model based on the document category, document image samples, and document image enhancement samples, by training in combination with a supervised contrast learning framework based on a preset backbone network, wherein the supervised contrast learning framework includes a self-supervised learning branch, a supervised learning branch, and a classification branch, the self-supervised learning branch includes a self-supervised contrast loss function, the supervised learning branch includes a supervised contrast loss function, and the classification branch includes a cross-entropy loss function.

14. A document type identification device, comprising: An input module, used for inputting a first certificate image into the trained universal certificate base model to obtain a first representation vector output by the universal certificate base model, wherein the universal certificate base model is trained based on the method for training a universal certificate base model according to any one of claims 1 to 9; A retrieval module is used to search for the first characterization vector in a feature library. If a feature vector matching the first characterization vector exists in the feature library, the document category corresponding to the feature vector is used as the first document category corresponding to the first document image, wherein the feature library includes multiple document categories and feature vectors corresponding to each document category.

15. A device for training a downstream task model, comprising: A parameter initialization module, used to use the model parameters corresponding to the trained universal certificate base model as training initialization parameters of the downstream task model, wherein the universal certificate base model is trained based on the method for training a universal certificate base model according to any one of claims 1 to 9; The downstream task model training module is used to train the downstream task model according to the training initialization parameters to obtain a trained downstream task model.

16. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 12 are implemented.

17. An electronic device, characterized in that: include: A processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the steps of the method as claimed in any one of claims 1 to 12.

18. A computer program product having at least one instruction stored thereon, characterized in that: When the at least one instruction is executed by the processor, the steps of the method described in any one of claims 1 to 12 are implemented.

Citation Information

Patent Citations

  • Method and device for training privacy information classification model and method and device for identifying privacy information

    CN114398681A

  • Intelligent skin lesion image classification device based on self-supervised learning

    CN115760707A

  • Small sample image classification method based on supervised and self-supervised combined comparative learning

    CN115810127A

  • Certificate identification model training method, certificate identification method and device

    CN117392478A

  • Image processing method and device based on supervised comparative learning

    CN117893842A