Color cast identification method and device, equipment and storage medium
By training a feature extraction model to process document images and portrait backgrounds, the problem of unsatisfactory color cast recognition of passport and document portraits in existing technologies is solved, achieving highly accurate color cast recognition and avoiding errors in automatic identity recognition systems.
Patent Information
- Application Number
- CN202411320525.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-21
- Publication Date
- 2025-01-10
AI Technical Summary
Existing color distortion recognition methods are not ideal for recognizing people in passports and other documents, leading to recognition errors in automatic identity recognition systems.
By training a feature extraction model, machine learning techniques are used to process ID card images and portrait backgrounds, extract image features, and determine the color cast recognition result based on feature similarity. The model improves recognition accuracy by expanding sample images and adjusting the color space.
It effectively identifies color casts in document images, avoids erroneous identification by automatic identity recognition systems, and improves the accuracy of color cast recognition during the passport printing process.
Smart Images

Figure CN119295774A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image recognition technology, and in particular to a color cast recognition method, device, equipment and storage medium. Background Art
[0002] Image color is an important feature of images and is crucial in the fields of smart security, medical imaging, and printing. However, due to factors such as light sources, acquisition, and imaging components, there will be a certain degree of difference in color between the image and the real image. This color cast difference not only affects the appearance, but may also have a serious negative impact on its use and value.
[0003] Especially in the passport printing process, due to the influence of ink nozzle blockage and other factors, various abnormal printing color casts may appear in the passport. The ID portrait in the passport is one of the most important personalized information in the passport. If the characteristics of the holder such as skin color do not match the passport printed portrait, it may cause the automatic identity recognition system to recognize the color cast. Therefore, the tolerance for color cast in the ID portrait in the passport is very low. However, the current color cast recognition method is not ideal for the color cast recognition of ID portraits. Summary of the invention
[0004] Based on this, it is necessary to provide a color cast recognition method, device, equipment and storage medium to address the above technical problems, so as to solve the technical problem that the color cast recognition effect of the relevant technology on the document portrait is not ideal.
[0005] In a first aspect, the present application provides a color cast identification method, comprising:
[0006] Obtaining a document image to be identified and a portrait base image corresponding to the document image;
[0007] The document image and the portrait base image are processed respectively by a trained feature extraction model to obtain a first image feature of the document image and a second image feature of the portrait base image;
[0008] The color cast recognition result of the document image is determined according to the feature similarity between the first image feature and the second image feature.
[0009] As a feasible embodiment of the present application, the trained feature extraction model is obtained by training through the following steps:
[0010] Acquire a sample portrait base map and a sample ID image corresponding to the sample portrait base map; the sample ID image includes a positive sample ID image and a negative sample ID image;
[0011] Inputting the sample portrait base image and the sample ID image into an initial feature extraction model to obtain a first prediction feature of the sample portrait base image, a second prediction feature of the positive sample ID image, and a third prediction feature of the negative sample ID image;
[0012] Determine a model loss value corresponding to the initial feature extraction model according to the first prediction feature, the second prediction feature, and the third prediction feature;
[0013] The initial feature extraction model is updated according to the model loss value until the model loss value obtained by inputting the sample portrait base map and the sample ID image into the updated feature extraction model meets the preset conditions, and the currently updated feature extraction model is determined as the trained feature extraction model.
[0014] As a feasible embodiment of the present application, the step of obtaining a sample portrait base map and a sample ID image corresponding to the sample portrait base map includes:
[0015] Obtain a sample portrait base image and a positive sample document image in a first color space corresponding to the sample portrait base image;
[0016] Converting the positive sample document image into a reference document image in a second color space;
[0017] The values of each color channel in the reference document image are adjusted to obtain a negative sample document image corresponding to the sample portrait base image.
[0018] As a feasible embodiment of the present application, the sample portrait base map includes a first portrait base map corresponding to a first portrait; the positive sample ID image includes a first positive sample ID image corresponding to the first portrait and a second positive sample ID image corresponding to the second portrait; the negative sample ID image includes a first negative sample ID image corresponding to the first portrait, a second negative sample ID image corresponding to the second portrait, and a third negative sample ID image corresponding to a third portrait;
[0019] The determining the model loss value corresponding to the initial feature extraction model according to the first prediction feature, the second prediction feature, and the third prediction feature includes:
[0020] Determining a first model loss value corresponding to the initial feature extraction model according to a feature difference between the predicted features of the first portrait base image and the predicted features of the first positive sample ID image, and a feature difference between the predicted features of the first portrait base image and the predicted features of the first negative sample ID image;
[0021] Determining a second model loss value corresponding to the initial feature extraction model according to feature differences between the predicted features of the first portrait base image and the predicted features of the second positive sample ID image, and feature differences between the predicted features of the first portrait base image and the predicted features of the second negative sample ID image;
[0022] Determining a third model loss value corresponding to the initial feature extraction model according to a feature difference between the predicted features of the first portrait base image and the predicted features of the second positive sample ID image, and a feature difference between the predicted features of the first portrait base image and the predicted features of the third negative sample ID image;
[0023] Determine a model loss value corresponding to the initial feature extraction model according to the first model loss value, the second model loss value and the third model loss value.
[0024] As a feasible embodiment of the present application, determining the model loss value corresponding to the initial feature extraction model according to the first model loss value, the second model loss value, and the third model loss value includes:
[0025] Determining a training round corresponding to the initial feature extraction model;
[0026] The first model loss value, the second model loss value, and the third model loss value are weighted according to the weight coefficient corresponding to the training round to obtain a model loss value corresponding to the initial feature extraction model.
[0027] As a feasible embodiment of the present application, determining the color cast recognition result of the document image according to the feature similarity between the first image feature and the second image feature includes:
[0028] Acquire historical document images with color cast;
[0029] Processing the historical document image by using the trained feature extraction model to obtain a third image feature of the historical document image;
[0030] The color cast recognition result of the document image is determined according to the feature similarity between the first image feature and the second image feature, and the feature similarity between the first image feature and the third image feature.
[0031] As a feasible embodiment of the present application, the document image and the portrait base map are processed respectively by the trained feature extraction model to obtain the first image feature of the document image and the second image feature of the portrait base map, including:
[0032] Performing image recognition on the document image and the portrait base image to obtain a first portrait region in the document image and a second portrait region in the portrait base image;
[0033] The first portrait region and the second portrait region are processed respectively by a trained feature extraction model to obtain first image features of the document image and second image features of the portrait base image.
[0034] In a second aspect, the present application provides a color cast identification device, comprising:
[0035] An acquisition module, used to acquire a document image to be identified and a portrait base image corresponding to the document image;
[0036] A processing module, used to process the document image and the portrait base image respectively through a trained feature extraction model to obtain a first image feature of the document image and a second image feature of the portrait base image;
[0037] A determination module is used to determine the color cast recognition result of the document image according to the feature similarity between the first image feature and the second image feature.
[0038] In a third aspect, the present application further provides a computer device, the computer device comprising:
[0039] one or more processors;
[0040] Memory; and
[0041] One or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the processor to implement the color cast identification method provided above.
[0042] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and the computer program is loaded by a processor to execute the color cast identification method provided above.
[0043] In a fifth aspect, an embodiment of the present application provides a computer program product or a computer program, wherein the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the color cast identification method provided above.
[0044] The color cast identification method provided in the embodiment of the present application obtains the document image to be identified and the portrait base map corresponding to the document image, processes the document image and the portrait base map respectively through the trained feature extraction model, obtains the first image feature of the document image and the second image feature of the portrait base map, and then determines the color cast identification result of the document image based on the first image feature and the second image. The feature extraction model trained by machine learning can effectively extract the color-related feature information in the document image and the portrait base map, so as to facilitate the subsequent determination of the color cast identification result of the document image by the similarity between these feature information, and can be effectively used for the color cast identification of the document portrait, so as to avoid the problem of recognition error caused by the color cast of the document portrait in the automatic identity recognition system. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0046] Figure 1 A schematic diagram of the steps of a color cast identification method provided in an embodiment of the present application;
[0047] Figure 2 A schematic diagram of a flow chart of steps for training a feature extraction model provided in an embodiment of the present application;
[0048] Figure 3 A schematic diagram of a process flow for obtaining a sample document image provided in an embodiment of the present application;
[0049] Figure 4a A schematic diagram of a model structure of a feature extraction model provided in an embodiment of the present application;
[0050] Figure 4b A schematic diagram of the effect of a training feature extraction model provided in an embodiment of the present application;
[0051] Figure 5 A schematic diagram of a process flow for determining a model loss value provided in an embodiment of the present application;
[0052] Figure 6a Another schematic diagram of a process flow for determining a color cast recognition result provided by an embodiment of the present application;
[0053] Figure 6b A schematic diagram of the effect of the complete process of a color cast identification method provided in an embodiment of the present application;
[0054] Figure 7 A schematic diagram of the structure of a color cast identification device provided in an embodiment of the present application;
[0055] Figure 8 A schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0056] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0057] In the description of this application, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this application, "plurality" means two or more, unless otherwise clearly and specifically defined.
[0058] In the description of the present application, the word "for example" is used to mean "used as an example, illustration or explanation". Any embodiment described as "for example" in the present application is not necessarily to be construed as being more preferred or advantageous than other embodiments. The following description is given to enable any technician in the field to implement and use the present invention. In the following description, details are listed for the purpose of explanation. It should be understood that a person of ordinary skill in the art can recognize that the present invention can be implemented without using these specific details. In other examples, well-known structures and processes will not be elaborated in detail to avoid obscuring the description of the present invention with unnecessary details. Therefore, the present invention is not intended to be limited to the embodiments shown, but is consistent with the widest scope consistent with the principles and features disclosed in the present application.
[0059] To facilitate understanding of the color cast identification method provided in the embodiment of the present application, the relevant application background of the color cast identification method is first described. Specifically, image color is an important characteristic of an image, which is crucial in the fields of intelligent security, medical imaging, and printing. However, in specific application scenarios, due to the influence of external factors such as light sources, acquisition, and imaging components, there is usually a certain degree of difference in color between the image and the real object. Especially in the field of portrait documents such as passports, during the passport printing process, due to the influence of ink nozzle blockage, etc., various abnormal printing color casts will usually appear in the portrait of the passport. The portrait of the passport is one of the most important personalized information in the passport. The characteristics of the holder such as skin color do not match the portrait printed in the passport, which often leads to recognition errors of the automatic identity recognition system. Therefore, compared with other images, the tolerance for color cast in the portrait of the passport is very low, so the requirements for color cast recognition are very high.
[0060] The current color cast recognition methods mainly process the two-dimensional histogram of the color channel and judge the color cast according to the maximum connected domain to realize the recognition of image color cast, or compare the information entropy of the color space histogram to determine whether the image has color cast. Although the above methods can realize the color cast recognition of the image, they still cannot provide a relatively ideal recognition effect when performing color cast recognition on the ID card portrait with a very low color cast tolerance.
[0061] In order to solve the above problems, the present application provides a color cast identification method, device, equipment and readable storage medium. By using the idea of machine learning, a feature extraction model that can extract color feature information related to color in an image is trained. Therefore, when it is necessary to perform color cast identification on the document image to be identified, the feature extraction model can be used to extract the image features of the document image and the image features of the corresponding portrait film, and determine whether the image features of the two are similar, so as to determine the color cast identification result of the document image. Specifically, the color cast identification method is usually set in the color cast identification device in the form of a computer program, and the color cast identification device is usually set in the computer device in the form of a processor. The color cast identification device in the computer device executes the computer program corresponding to the color cast identification method to execute the color cast identification method provided in the embodiment of the present application.
[0062] For details, please refer to Figure 1 , Figure 1 A schematic diagram of a color cast identification method provided in an embodiment of the present application, specifically, comprising steps S110 to S130:
[0063] S110, obtaining a document image to be recognized and a portrait base image corresponding to the document image.
[0064] In the embodiments of the present application, combined with the aforementioned description of the relevant application scenarios, it can be known that the document image to be identified usually refers to the document image obtained by photographing the document containing a portrait, for example, the more common one is the document image obtained by photographing the portrait on the passport. The portrait base map corresponding to the document image usually refers to the portrait photo used in the document printing process. In the actual printing process, due to the influence of the ink nozzle blockage and the like, various abnormal printing color casts will usually appear on the document portrait in the passport, that is, there will be color difference compared with the portrait base map. Therefore, the color cast identification of the document portrait usually needs to be determined by comparing the color difference between the document image obtained by photographing the document portrait and the portrait base map.
[0065] S120, processing the document image and the portrait base image respectively by using the trained feature extraction model to obtain a first image feature of the document image and a second image feature of the portrait base image.
[0066] In the embodiments of the present application, the feature extraction model generally refers to a type of neural network model that is trained based on machine learning ideas using specific samples and is capable of processing images to extract corresponding image features from the image, so as to subsequently use the similarity between image features to determine whether the image has sufficiently similar color features, that is, it can be used to determine whether there is color cast. For example, more common neural network models include deep neural networks, convolutional neural networks, etc. Of course, it is also feasible to use other network model structures, which are not limited in the embodiments of the present application. Specifically, in order for the feature extraction model to effectively extract color-related image features in the image, the sample image is usually required to contain different color information for training the feature extraction model.
[0067] Of course, based on the aforementioned application embodiment, considering that there are multiple neural network model structures, different neural network models obtained through training often have different color cast recognition effects, for example, different color cast recognition accuracy rates. Therefore, as a further feasible implementation scheme of the present application, the present application embodiment further provides a scheme for a feature extraction model obtained through training to ensure that it can be effectively applied to color cast recognition of document images with low tolerance for color cast. For details, please refer to Figure 2 , Figure 2 A schematic flow chart of the steps of training a feature extraction model provided in an embodiment of the present application includes steps S210 to S240:
[0068] S210, obtaining a sample portrait base map and sample ID images corresponding to the sample portrait base map; the sample ID images include positive sample ID images and negative sample ID images.
[0069] In the embodiment of the present application, the sample portrait base map refers to a series of portrait images collected in advance for printing. For example, it can be obtained through network technology means, such as crawlers or extracted from a portrait database. The embodiment of the present application does not limit the method of obtaining the sample portrait base map. The sample ID image corresponding to the sample portrait base map refers to the photographed image of the ID portrait obtained by printing the sample portrait base map. Based on whether the printed ID portrait has color cast, the sample ID images here also include two types, namely, positive sample ID images corresponding to ID portraits without color cast and negative sample ID images corresponding to ID portraits with color cast. Of course, the above sample ID portraits can also be obtained through network technology means, such as crawlers or extracted from a portrait database.
[0070] However, in actual application scenarios, considering the difference between the printed color cast and the printed non-color cast Figure 1 Generally, they are mutually exclusive, that is, in the process of making certificates, if the printed certificate has no color cast or other printing quality problems, it will not be printed repeatedly, which will result in the number of printed color cast images, that is, the number of negative sample certificate images will be much lower than the number of printed non-color cast images, that is, the number of positive sample certificate images. Therefore, in order to enrich the training sample pairs of the obtained sample portrait base map and the corresponding sample certificate image to improve the training effect of the model, as another feasible embodiment of the present application, the present application also provides an implementation scheme for expanding the sample certificate image. For details, please refer to Figure 3 , Figure 3 A schematic diagram of a process flow for obtaining a sample document image provided in an embodiment of the present application includes steps S310 to S330:
[0071] S310, obtaining a sample portrait base image and a positive sample document image in a first color space corresponding to the sample portrait base image.
[0072] In the embodiment of the present application, combined with the above-mentioned related description, since there are few negative sample ID images with color cast corresponding to the sample portrait base map, the sample portrait base map and the positive sample ID image corresponding to the sample portrait base map in the first color space can be read from the database first. The first color space here is usually an RGB (red, green, blue, three primary colors of red, green and blue light) color space, that is, a color space based on the principle of color additive mixing.
[0073] S320: Convert the positive sample document image into a reference document image in a second color space.
[0074] Considering that the printing process is usually carried out in a color space based on the color subtraction principle, that is, in the CMYK (cyan, magenta, yellow, black, i.e., printing is performed using four colors of ink, cyan, magenta, yellow, and black) color space, the color cast of the real ID portrait is usually also changed due to the ratio of the above four colors. Therefore, in order to fit a more realistic negative sample ID image, in the embodiment of the present application, the positive sample ID image in the corresponding first color space, that is, the RGB color space, will be converted into a reference ID image in the CMYK color space. Among them, the conversion formula between the RGB color space and the CMYK color space is not specifically described in detail in the embodiment of the present application.
[0075] S330, adjusting the values of each color channel in the reference document image to obtain a negative sample document image corresponding to the sample portrait base image.
[0076] In an embodiment of the present application, by appropriately adjusting the values of each color channel, that is, C, M, Y, and K, in a reference document image in a second color space, that is, the CMYK color space used for printing, a negative sample document image having a color cast error relative to the sample portrait base image can be formed.
[0077] For example, as a common feasible implementation scheme, in CMYK space, the value range of each color channel is 0 to 100. Therefore, we can choose 10 as a unit to ensure that each color channel has 11 different values (0, 10, 20, ..., 100). In this way, each color channel can have 11 variations. For each sample ID portrait, a total of 14641 (11×11×11×11) different color cast images can be generated as negative sample ID images. Of course, in actual application, the number of negative sample ID images can be set based on actual needs. Therefore, this application can usually obtain an appropriate number of negative sample ID images for subsequent model training by appropriately adjusting the values of each color channel in the reference ID image.
[0078] The embodiment of the present application provides a method for generating negative sample ID images by converting the positive sample ID images in the RGB color space into the CMYK space used for printing, and by adjusting the values of each color channel in the CMYK color space. This method can better fit the color cast problem of the ID images caused by changes in the proportion of ink used during the printing process. Compared with the ID images obtained by directly adjusting the color channel values in the RGB color space, the negative sample ID images with color differences in the CMYK color space obtained in batches can further effectively improve the effect of the feature extraction model on color cast recognition in the CMYK color space when used for subsequent model training, thereby improving the color cast recognition effect on printed ID portraits.
[0079] S220, inputting the sample portrait base image and the sample ID image into an initial feature extraction model to obtain a first prediction feature of the sample portrait base image, a second prediction feature of the positive sample ID image, and a third prediction feature of the negative sample ID image.
[0080] After extracting the portrait base map and the positive and negative sample ID images from the portrait database, or processing the ID images to expand the sample images, the sample portrait base map and the sample ID images are input into the initial feature extraction model to obtain the first predicted feature of the sample portrait base map, the second predicted feature of the positive sample ID image, and the third predicted feature of the negative sample ID image.
[0081] In the embodiments of the present application, the initial feature extraction model generally refers to a neural network model with a specific network model structure designed based on a conventional neural network model structure, but the parameters in the neural network model are in an initialized state, and the feature extraction effect on the image is not necessarily ideal. The model training utilizes the sample portrait base map and the sample document image to complete the training of the parameters in the model, so that the obtained initial feature extraction model can effectively extract feature information in the image, such as color feature information, for subsequent color cast identification.
[0082] As a feasible embodiment of the present application, the network model structure of the initial feature extraction model can be based on a conventional neural network, such as a deep neural network model, for example, including multiple hidden layers with initialized random parameters, etc. However, in order to improve the feature effect on the image, the embodiment of the present application provides a specific network structure of a feature extraction model. Specifically, the feature extraction model is mainly composed of a number of convolutional layers, activation function layers, batch normalization layers, fully connected layers, and L2 normalization layers, so that it can be used to focus on extracting feature information such as shallow features such as color and texture in the image, so as to better identify color and texture deviations in document portraits. For details, please refer to Figure 4a , Figure 4a A schematic diagram of the model structure of a feature extraction model provided in an embodiment of the present application.
[0083] For details, please refer to Figure 4a The input image is first processed by a sub-network structure composed of several convolutional layers, activation function layers, and batch normalization layers, and then processed again by the above sub-network structure based on the residual connection. The final result will pass through the global average pooling layer, the fully connected layer, the L2 normalization layer and the fully connected layer in turn, and finally output the extracted feature model. Among them, the number of convolutional layers, activation function layers, and batch normalization layers contained in each sub-network structure in the above model structure can be set based on actual needs, and the number of residual connections can also be set based on actual needs, that is, the conventional improvement designs made on the basis of the above network structure are within the scope of protection required by this application.
[0084] S230: Determine a model loss value corresponding to the initial feature extraction model according to the first prediction feature, the second prediction feature, and the third prediction feature.
[0085] In the embodiment of the present application, combined with the above-mentioned related description, since the parameters in the initial feature extraction model are initially randomly generated, it may not be possible to accurately and effectively extract the color feature information in the image. For example, under normal circumstances, the image features between the sample portrait base map and the positive sample ID image without color cast should be more similar, and the image features between the sample portrait base map and the positive sample ID image without color cast should be dissimilar. Therefore, in the model training process, the model loss value corresponding to the initial feature extraction model can be determined according to the feature similarity between the first prediction feature, the second prediction feature and the third prediction feature, which is used to describe whether the initial feature extraction model can effectively extract the feature information such as color texture from the image. Specifically, it can be understood that for the same group of sample portrait base maps and sample ID images corresponding to the same portrait, when the feature similarity between the first prediction feature and the second prediction feature is higher, and the feature similarity between the first prediction feature and the third prediction feature is lower, it indicates that the feature extraction model has a more ideal feature extraction effect on the image. On the contrary, when the feature similarity between the first prediction feature and the second prediction feature is lower, and the feature similarity between the first prediction feature and the third prediction feature is higher, it indicates that the feature extraction model has an unsatisfactory feature extraction effect on the image.
[0086] Among them, it is considered that features usually exist in the form of feature vectors or feature matrices. Therefore, the calculation of similarity between similar features can usually be calculated by the cosine similarity calculation formula. Of course, it is also feasible to use the distance between vectors to describe the similarity between features. For example, the distance between features is calculated by Euclidean distance, cosine distance, Mahalanobis distance, etc., so as to measure the similarity between features. The farther the distance between features, the lower the similarity between features. Specifically, to facilitate understanding of the above content, take the portrait base image X a , positive sample document image X p , negative sample document image X n ,f(X a )、f(X p ) and f(X n ) represent the predicted features extracted by the feature extraction model for the portrait base image, the positive sample ID image and the negative sample ID image, namely the first predicted feature, the second predicted feature and the third predicted feature. At this time, the Euclidean distance between the first predicted feature corresponding to the portrait base image and the second predicted feature corresponding to the positive sample ID image can be calculated. And the Euclidean distance between the first predicted feature corresponding to the portrait base image and the third predicted feature corresponding to the negative sample document image At this time, for each set of sample portrait base image and sample ID image, the Euclidean distance d(X a , X p ) and the Euclidean distance d(X a , X n ) can finally determine the model loss value corresponding to the feature extraction model. It can be understood that the Euclidean distance d(X a , X p ) and the Euclidean distance d(X a , X n ), the larger the difference between the first prediction feature and the second prediction feature, the lower the feature similarity between the first prediction feature and the third prediction feature, and the higher the feature similarity between the first prediction feature and the third prediction feature. At this time, the model loss value is also higher, and the feature extraction effect of the feature extraction model on the image is not ideal.
[0087] For more information, please refer to Figure 4b , Figure 4b The effect diagram of a training feature extraction model provided in the embodiment of the present application is described in detail as follows. a , positive sample document image X p and negative sample document image X n After being input into the feature extraction model, i.e., the color feature extractor, the image color features f(Xa )、f(X p ) and f(X n ), and then calculate f(X a ) and f(X p ) and f(X a ) and f(X n ) can be used to obtain the model loss value for further training of the feature extraction model.
[0088] It can be seen that, by using the same group of sample portrait base maps and sample ID images corresponding to the same portrait, the feature similarity between the first prediction feature and the second prediction feature and the feature similarity between the first prediction feature and the third prediction feature are used to describe the model loss value corresponding to the feature extraction model, so as to update the parameters of the feature extraction model. In this way, the feature extraction model can continuously learn relevant experience from the sample images, thereby continuously narrowing the feature distance between the sample portrait base map and the positive sample ID image, improving the similarity between the first prediction feature and the second prediction feature, and at the same time, widening the feature distance between the sample portrait base map and the negative sample ID image, so as to reduce the similarity between the first prediction feature and the third prediction feature, so as to facilitate the subsequent effective recognition of color cast of the image.
[0089] In this process, in order to further reduce the influence of semantic features on the extraction of image features, so that the feature extraction model can better focus on the color and texture feature information of the image, thereby reducing the interference of the portrait itself on the image feature extraction, as a further optional implementation scheme of the present application, in the aforementioned method of calculating the model loss value corresponding to the feature extraction model based on the predicted features obtained from the same group of sample portrait base maps and sample document images corresponding to the same portrait, the present application further provides an embodiment of describing the model loss value by constructing a triple data combination. Specifically, in the present embodiment, the sample portrait base map includes a first portrait base map corresponding to the first portrait; the positive sample ID image includes a first positive sample ID image corresponding to the first portrait and a second positive sample ID image corresponding to the second portrait; the negative sample ID image includes a first negative sample ID image corresponding to the first portrait, a second negative sample ID image corresponding to the second portrait, and a third negative sample ID image corresponding to the third portrait, wherein it should be noted that the first portrait, the second portrait, and the third portrait here refer to different portraits in the database, that is, in the process of describing the model loss value, in addition to considering the feature differences between the sample portrait base map and the sample ID image corresponding to the same portrait, the feature differences between the sample portrait base map and the sample ID image corresponding to different portraits will also be further considered. At this time, please refer to Figure 5 , Figure 5 A schematic flow chart of a step of determining a model loss value provided in an embodiment of the present application, specifically, comprising steps S510 to S540:
[0090] S510, determining a first model loss value corresponding to the initial feature extraction model based on feature differences between the predicted features of the first portrait base image and the predicted features of the first positive sample ID image, and feature differences between the predicted features of the first portrait base image and the predicted features of the first negative sample ID image.
[0091] In the steps of this embodiment, the first portrait base map, the first positive sample ID image and the first negative sample ID image all correspond to the same first portrait. Therefore, in combination with the above-mentioned related description, the greater the feature difference between the predicted features of the first portrait base map and the predicted features of the first positive sample ID image, and the smaller the feature difference between the predicted features of the first portrait base map and the predicted features of the first negative sample ID image, the higher the first model loss value corresponding to the feature extraction model, indicating that the training effect of the model is worse.
[0092] S520, determining a second model loss value corresponding to the initial feature extraction model based on feature differences between the predicted features of the first portrait base image and the predicted features of the second positive sample ID image, and feature differences between the predicted features of the first portrait base image and the predicted features of the second negative sample ID image.
[0093] In the steps of this embodiment, the first portrait base map corresponds to the first portrait, and the second positive sample ID image and the second negative sample ID image both correspond to the second portrait different from the first portrait. Therefore, by calculating the model loss value through the feature difference between the predicted features of the first portrait base map and the predicted features of the second positive sample ID image and the feature difference between the predicted features of the first portrait base map and the predicted features of the second negative sample ID image, it is possible to avoid the feature extraction model from over-focusing on features related to the portrait and weakening the extraction of feature information such as color texture in the image, thereby further improving the training effect of the model. Specifically, in this step, similar to the aforementioned step, the greater the feature difference between the predicted features of the first portrait base map and the predicted features of the second positive sample ID image, and the smaller the feature difference between the predicted features of the first portrait base map and the predicted features of the second negative sample ID image, the higher the second model loss value corresponding to the feature extraction model, indicating that the training effect of the model is worse.
[0094] S530, determining a third model loss value corresponding to the initial feature extraction model based on feature differences between the predicted features of the first portrait base image and the predicted features of the second positive sample ID image, and feature differences between the predicted features of the first portrait base image and the predicted features of the third negative sample ID image.
[0095] In the steps of this embodiment, the first portrait base map corresponds to the first portrait, the second positive sample ID image corresponds to the second portrait different from the first portrait, and the third negative sample ID image corresponds to the third portrait different from both the first and second portraits, that is, the first portrait base map, the second positive sample ID image and the third negative sample ID image all correspond to different portraits. At this time, the model loss value is determined by calculating the feature difference between the predicted features of the first portrait base map and the predicted features of the second positive sample ID image, and the feature difference between the predicted features of the first portrait base map and the predicted features of the third negative sample ID image, which can further reduce the interference of semantic information such as portraits on the model loss value. Similarly, in this step, the greater the feature difference between the predicted features of the first portrait base map and the predicted features of the second positive sample ID image, and the smaller the feature difference between the predicted features of the first portrait base map and the predicted features of the third negative sample ID image, the higher the third model loss value corresponding to the feature extraction model, indicating that the training effect of the model is worse.
[0096] S540: Determine a model loss value corresponding to the initial feature extraction model according to the first model loss value, the second model loss value, and the third model loss value.
[0097] In the embodiment of the present application, by fusing the first model loss value, the second model loss value, and the third model loss value obtained above as the model loss value corresponding to the initial feature extraction model for training the initial feature extraction model, the interference of semantic information on the feature extraction model can be reduced, and the effect of the feature extraction model in extracting feature information such as color texture can be improved, thereby further improving the effect of color cast recognition in the field of document portraits. Specifically, the fusion of the first model loss value, the second model loss value, and the third model loss value can generally refer to the fusion of the first model loss value, the second model loss value, and the third model loss value according to a certain weighting coefficient.
[0098] Specifically, in order to facilitate understanding of the implementation scheme of calculating the model loss value by different data combinations provided in the embodiment of the present application, the following will be explained with reference to specific examples. a include Positive ID image X p include Negative sample document image X n include At this time, for the first model loss value L1, its calculation formula is:
[0099]
[0100] For the second model loss value L2, its calculation formula is:
[0101]
[0102] For the third model loss value L3, its calculation formula is:
[0103]
[0104] Among them, in the above calculation formula, θ, and γ are preset hyperparameters used to control the interval between the positive and negative sample distances of different data combinations, [·] + Indicates a non-negative value, the subscript i represents the i-th portrait in the set, and the corresponding irand1, irand2 and irand3 represent other images in the corresponding set other than the i-th portrait, for example Indicates other images other than the i-th portrait in the corresponding positive sample document image, for example, the j-th portrait. Similarly, represents the image corresponding to the jth portrait in the negative sample document image, represents the image corresponding to the lth portrait in the positive sample document image, Then it can represent the image corresponding to the mth portrait in the corresponding positive sample document image.
[0105] As for the first model loss value L1, the second model loss value L2 and the third model loss value L3 obtained by the above calculation, by further weighting the first model loss value L1, the second model loss value L2 and the third model loss value L3 according to the preset weight coefficient, the final model loss value L tol , specifically, L tol =αL1+βL2+λL3, where α, β and λ are weight parameters corresponding to three types of losses, satisfying α+β+λ=1. In specific application scenarios, α, β and λ can be set based on actual needs, but in order to ensure the training effect of the model, as a common feasible implementation scheme, α is set to 0.7, β is set to 0.2, and λ is set to 0.1, which can effectively ensure the recognition effect of image color cast while reducing the interference of portrait semantic information, thereby ensuring the training effect of the model to the greatest extent.
[0106] Of course, as a further implementation scheme of the present application, the weight coefficient provided above can also be dynamically updated and adjusted based on the training rounds of the model, that is, the model loss value corresponding to the initial feature extraction model is determined according to the first model loss value, the second model loss value and the third model loss value, specifically including:
[0107] Determining a training round corresponding to the initial feature extraction model;
[0108] The first model loss value, the second model loss value, and the third model loss value are weighted according to the weight coefficient corresponding to the training round to obtain a model loss value corresponding to the initial feature extraction model.
[0109] For example, as a common feasible implementation scheme, when the number of training rounds is small, that is, in the first few training rounds, the weight of the first model loss value can be set higher, such as 0.9, and the weights of the second model loss value and the third model loss value can be set lower, such as 0.05, so as to ensure that the model can quickly learn the difference in feature information of the image in the initial training rounds, thereby improving the model training efficiency. At the same time, in order to avoid the model paying too much attention to the portrait semantic features of the image, as the subsequent training rounds gradually increase, the weight of the first model loss value can be gradually reduced, for example, from 0.9 to 0.7, and the weights of the second model loss value and the third model loss value can be gradually increased, for example, from 0.05 to 0.1, 0.2, etc., so as to further improve the model's focus on extracting feature information such as color texture of the image, thereby ensuring the model's recognition effect on color cast.
[0110] By calculating the model loss value through different data combinations designed above and using it for model training, the model's recognition effect on image color cast can be further improved, and it can perform better in the field of ID portraits with low tolerance for color cast recognition.
[0111] S240, updating the initial feature extraction model according to the model loss value, until the model loss value obtained by inputting the sample portrait base map and the sample document image into the updated feature extraction model meets the preset conditions, and determining the current updated feature extraction model as the trained feature extraction model.
[0112] In the embodiment of the present application, after determining the loss value of the feature extraction model as mentioned above, based on the idea of back propagation, the parameters of the initial feature extraction model are optimized by using the model loss value, that is, the initial feature extraction model is updated, so that the updated feature extraction model can shorten the feature distance between the positive sample document image without color cast and the sample portrait base map, and increase the feature distance between the negative sample document image with color cast and the sample portrait base map, that is, the model loss value obtained by inputting the sample portrait base map and the sample document image into the updated feature extraction model will gradually decrease, and the color cast recognition effect of the model will be more ideal. Through multiple repeated training processes, that is, the feature extraction model is continuously updated and optimized based on the latest model loss value, until the model loss value obtained by inputting the sample portrait base map and the sample document image into the updated feature extraction model meets the preset conditions, for example, if it is less than the preset loss value threshold for several consecutive rounds, it can be considered that the feature extraction model has been optimized. At this time, the current feature extraction model can be determined as a trained feature extraction model, which can be used for feature extraction of the document image and the portrait base map to be identified in the color cast recognition process to complete the color cast recognition.
[0113] In addition, considering that in the document image, the user may have different tolerances for color cast in different areas, for example, the user may have a higher tolerance for color cast in the background-related area, while a lower tolerance for color cast in the portrait-related area, because this may result in anomalies in the identification failure. Therefore, as a further optional embodiment of the present application, in the process of processing the document image and the portrait base map respectively by using the trained feature extraction model, the portrait area of the document image and the portrait area in the portrait base map may be compared, that is, the color cast identification method further includes:
[0114] Performing image recognition on the document image and the portrait base image to obtain a first portrait region in the document image and a second portrait region in the portrait base image;
[0115] The first portrait region and the second portrait region are processed respectively by a trained feature extraction model to obtain first image features of the document image and second image features of the portrait base image.
[0116] In the embodiment of the present application, the recognition of the portrait area in the document image and the portrait base image can be achieved through face detection or other image detection models. The embodiment of the present application does not elaborate on the implementation scheme for extracting the portrait area.
[0117] By using the trained feature extraction model for the first portrait area in the ID image and the second portrait area in the portrait base image, the model can pay more attention to whether there is color cast in the portrait area in the ID image, thereby further improving the recognition accuracy of color cast.
[0118] S130: Determine a color cast recognition result of the document image according to a feature similarity between the first image feature and the second image feature.
[0119] In the embodiment of the present application, combined with the above-mentioned related description, it can be known that the feature extraction model trained by the above-mentioned method can accurately and effectively extract the image features related to color texture in the image. Therefore, in practical applications, the color cast recognition result of the document image can be determined according to the feature similarity between the first image feature and the second image feature, or the feature distance. For example, as the most common feasible implementation scheme, by comparing the feature similarity between the first image feature and the second image feature with a preset similarity threshold, when the feature similarity between the first image feature and the second image feature is higher than the preset similarity threshold, it can be considered that the color texture in the document image and the portrait base image is similar enough, and at this time, it can be considered that the color cast recognition result of the document image is that there is no color cast. On the contrary, when the feature similarity between the first image feature and the second image feature is lower than the preset similarity threshold, it can be considered that the color cast recognition result of the document image is that there is color cast. It should be noted that the similarity threshold here can be dynamically set based on the actual color cast tolerance requirement. When the color cast tolerance is low, the similarity threshold can be set higher, and vice versa, the similarity threshold can be set lower, thereby satisfying the dynamic adjustment of different color cast tolerances for different document portraits.
[0120] Of course, in addition to the aforementioned scheme of realizing color cast recognition of images through similarity threshold comparison, in order to further improve the accuracy of the color cast recognition results of the document images, it is considered to make full use of different training data combinations in the model training process to reduce the interference of the portrait semantics in the image on the feature extraction model. Therefore, as another feasible embodiment of the present application, the document images with color cast that appeared in the past can be used to further improve the color cast recognition results of the document images. For details, please refer to Figure 6a , Figure 6a Another schematic flow chart of steps for determining a color cast recognition result provided in an embodiment of the present application, specifically, includes steps S610 to S630:
[0121] S610, obtaining a historical document image with color cast.
[0122] In the embodiment of the present application, the historical document image with color cast refers to the document portrait that was identified as having color cast during the historical printing process. Of course, in order to further improve the color cast recognition result of the image, the acquired historical document images may include multiple ones.
[0123] S620: Process the historical document image by using the trained feature extraction model to obtain a third image feature of the historical document image.
[0124] In the embodiment of the present application, similar to the aforementioned processing of the document image and the portrait base map by the feature extraction model, the historical document image is processed by the trained feature extraction model, and the third image feature related to the color texture in the historical document image with color cast can also be extracted. Of course, in the case where there are multiple historical document images, the third image feature of the historical document image also includes multiple.
[0125] S630: Determine a color cast recognition result of the document image according to a feature similarity between the first image feature and the second image feature, and a feature similarity between the first image feature and the third image feature.
[0126] In order to more clearly understand the complete implementation process of the color cast identification method provided in the embodiment of the present application, please refer to Figure 6b , Figure 6b The schematic diagram of the complete process of a color cast identification method provided in an embodiment of the present application specifically includes the following steps:
[0127] The portrait base map, the ID image to be identified, and the ID image with color cast in history are input into the weight-sharing color feature extractor to obtain the corresponding image vector, base map feature vector, image feature vector to be identified, and a set of historical color cast image feature vectors, respectively. Then, the feature distance between the base map feature vector and the image feature vector to be identified, as well as the feature distance between the image feature vector to be identified and the feature vectors in the set of historical color cast image feature vectors are calculated. Finally, the two feature distances are weighted to determine whether the ID image to be identified is more likely to have color cast or not.
[0128] In the embodiment of the present application, since the interference of the portrait semantics on the feature extraction model is reduced, the feature extraction model can pay more attention to the color and texture features in the image. At this time, according to the feature similarity between the first image feature and the second image feature, and the feature similarity between the first image feature and the third image feature, it can be understood that if the feature similarity between the first image feature and the third image feature is higher, it means that the color and texture features of the certificate image are more similar to the color and texture features of the historical certificate image with color cast, indicating that the certificate image has a higher possibility of color cast. When there are multiple historical certificate images, at this time, the color cast recognition of the certificate image can be realized by calculating the average similarity of the feature similarity between the first image feature and the third image feature, and the embodiment of the present application will not be repeated here.
[0129] In addition, similar to the aforementioned dynamic setting of the similarity threshold based on color cast tolerance, in the embodiment of the present application, since the acquired historical document images are usually images that are manually determined to have color cast, the flexibility of color cast recognition can also be improved to a certain extent based on the different existing color cast images selected by the user.
[0130] The color cast identification method provided in the embodiment of the present application obtains the document image to be identified and the portrait base map corresponding to the document image, processes the document image and the portrait base map respectively through the trained feature extraction model, obtains the first image feature of the document image and the second image feature of the portrait base map, and then determines the color cast identification result of the document image based on the first image feature and the second image. The feature extraction model trained by machine learning can effectively extract the color-related feature information in the document image and the portrait base map, so as to facilitate the subsequent determination of the color cast identification result of the document image by the similarity between these feature information, and can be effectively used for the color cast identification of the document portrait, so as to avoid the problem of recognition error caused by the color cast of the document portrait in the automatic identity recognition system.
[0131] In order to facilitate understanding of the color cast identification method provided in the embodiment of the present application, the following will be combined with the aforementioned Figure 1 The content provided in Figure 6 provides a complete implementation scenario of the color cast identification method, which includes model training and model application stages. Specifically, the following steps are included:
[0132] (1) A triplet of data consisting of a sample portrait base image, a positive ID image, and a negative ID image is constructed from the portrait dataset. Specifically, a photo of a person used for printing is used as the sample portrait base image, and a printed ID image without color cast is used as the positive ID image. The negative ID image is a printed ID image with color cast.
[0133] (2) Considering the difference between the printed color deviation and the printed non-color deviation in the actual printing process Figure 1 Generally, they are mutually exclusive, that is, in the process of making certificates, if the printed certificate has no color cast or other printing quality problems, it will not be printed repeatedly. Compared with the printed non-color cast images, the printed color cast images are also less likely to be generated. Therefore, in order to construct a rich triplet data combination, the negative sample certificate images of different color cast categories can be expanded;
[0134] (3) Considering that printing uses CMYK color space, the positive sample ID image in RGB color space can be converted into a reference ID image in CMYK color space, and then the value range of each color channel is adjusted in units of 10 to have 11 different values (for example: 0, 10, 20, ... 100). In this way, a certain number of color cast images can be generated as negative sample ID images;
[0135] (4) After the sample is ready, a color feature extractor based on a convolutional neural network is constructed to effectively extract shallow information such as color features in the portrait image, providing a basis for subsequent distance calculation or classification. The color feature extractor includes three parallel sub-networks, each of which shares the same weight parameters to ensure that the input feature representation is compared in the same feature space, that is, the feature extraction model. The model input is a triple data combination, specifically a sample portrait base map, a positive sample ID image, and a negative sample ID image. The triple data combination is input into the parallel sub-network, that is, the feature extraction model. Each sub-network can convert the input image into a fixed-length and normalized feature vector. The sub-network model structure is a shallow feature information extraction network, which is mainly composed of several convolutional layers, activation function layers, batch normalization layers, fully connected layers, and L2 normalization layers, etc., and is used to extract shallow features that focus on color, texture, etc.;
[0136] (5) After inputting each triplet data combination (sample portrait base map, positive sample ID image and negative sample ID image) into the parameter-initialized feature extraction model, different feature vectors can be obtained, such as the first prediction feature, the second prediction feature and the third prediction feature. Then, the weighted triplet loss is used to construct the loss function, and the training weights of the color feature extractor are continuously back-propagated and updated, so that the feature vectors of samples of the same category are closer and the feature vectors of samples of different categories are farther, so that it can accurately identify whether the printed ID portrait has color cast problems, thereby improving the color cast recognition accuracy of the model. The feature vector distance here can be Euclidean distance, cosine distance or Mahalanobis distance;
[0137] (6) In the above training process, in order to reduce the influence of semantic features and fully extract color features, a weighted triplet loss can be constructed according to three data combinations, specifically: the sample portrait base map, the positive sample ID image and the negative sample ID image are from the portrait of the same ID, constructing the first loss L1; the positive sample ID image and the negative sample ID image are from the portrait of the same ID, and the sample portrait base map is from the portrait of another randomly selected ID, constructing the second loss L2; the positive sample ID image, the negative sample ID image and the sample portrait base map are from the portraits of different IDs, respectively, constructing the third loss L3, then the final loss value can be the weighted loss value of the first loss, the second loss and the third loss, where the weight coefficient can be dynamically updated based on the training round;
[0138] (7) After the training of the feature extraction model is completed, the obtained feature extraction model can be used for subsequent color cast recognition. Specifically, the document image to be recognized, the corresponding portrait base map and the historical document image with color cast are input into the feature extraction model, and the image feature vector of the document image to be recognized, the image feature vector of the corresponding portrait base map and the image feature vector of the historical document image with color cast are extracted respectively. Then, the feature vector of the document image to be recognized is compared with the feature vector of the corresponding portrait base map and the feature vector of the historical document image with color cast, and the Euclidean distance or cosine similarity between the feature vector of the base map and the average distance between the feature vector and the topK, that is, the K document images with the highest similarity or the closest distance in the historical document image are calculated respectively. On this basis, the weighted size of the two is compared to further determine whether the document image to be recognized has color cast.
[0139] In order to better implement the color cast identification method provided in the embodiment of the present application, on the basis of the color cast identification method provided in the embodiment of the present application, a color cast identification device is also provided in the embodiment of the present application, such as Figure 7 As shown, the color cast identification device comprises:
[0140] An acquisition module 710 is used to acquire a document image to be recognized and a portrait base image corresponding to the document image;
[0141] A processing module 720 is used to process the document image and the portrait base image respectively by using a trained feature extraction model to obtain a first image feature of the document image and a second image feature of the portrait base image;
[0142] The determination module 730 is used to determine the color cast recognition result of the document image according to the feature similarity between the first image feature and the second image feature.
[0143] In some embodiments of the present application, the processing module 720 is used to train the feature extraction model by performing the following steps:
[0144] Acquire a sample portrait base map and a sample ID image corresponding to the sample portrait base map; the sample ID image includes a positive sample ID image and a negative sample ID image;
[0145] Inputting the sample portrait base image and the sample ID image into an initial feature extraction model to obtain a first prediction feature of the sample portrait base image, a second prediction feature of the positive sample ID image, and a third prediction feature of the negative sample ID image;
[0146] Determine a model loss value corresponding to the initial feature extraction model according to the first prediction feature, the second prediction feature, and the third prediction feature;
[0147] The initial feature extraction model is updated according to the model loss value until the model loss value obtained by inputting the sample portrait base map and the sample ID image into the updated feature extraction model meets the preset conditions, and the currently updated feature extraction model is determined as the trained feature extraction model.
[0148] In some embodiments of the present application, the processing module 720 is further used to obtain a sample portrait base map and a positive sample document image in a first color space corresponding to the sample portrait base map;
[0149] Converting the positive sample document image into a reference document image in a second color space;
[0150] The values of each color channel in the reference document image are adjusted to obtain a negative sample document image corresponding to the sample portrait base image.
[0151] In some embodiments of the present application, the processing module 720 is further used to determine a first model loss value corresponding to the initial feature extraction model according to a feature difference between the predicted features of the first portrait base image and the predicted features of the first positive sample ID image, and a feature difference between the predicted features of the first portrait base image and the predicted features of the first negative sample ID image;
[0152] Determining a second model loss value corresponding to the initial feature extraction model according to feature differences between the predicted features of the first portrait base image and the predicted features of the second positive sample ID image, and feature differences between the predicted features of the first portrait base image and the predicted features of the second negative sample ID image;
[0153] Determining a third model loss value corresponding to the initial feature extraction model according to a feature difference between the predicted features of the first portrait base image and the predicted features of the second positive sample ID image, and a feature difference between the predicted features of the first portrait base image and the predicted features of the third negative sample ID image;
[0154] Determine a model loss value corresponding to the initial feature extraction model according to the first model loss value, the second model loss value and the third model loss value.
[0155] In some embodiments of the present application, the processing module 720 is further used to determine the training round corresponding to the initial feature extraction model;
[0156] The first model loss value, the second model loss value, and the third model loss value are weighted according to the weight coefficient corresponding to the training round to obtain a model loss value corresponding to the initial feature extraction model.
[0157] In some embodiments of the present application, the determination module 730 is further used to obtain a historical document image with color cast;
[0158] Processing the historical document image by using the trained feature extraction model to obtain a third image feature of the historical document image;
[0159] The color cast recognition result of the document image is determined according to the feature similarity between the first image feature and the second image feature, and the feature similarity between the first image feature and the third image feature.
[0160] In some embodiments of the present application, the processing module 720 is further used to perform image recognition on the document image and the portrait base map to obtain a first portrait region in the document image and a second portrait region in the portrait base map;
[0161] The first portrait region and the second portrait region are processed respectively by a trained feature extraction model to obtain first image features of the document image and second image features of the portrait base image.
[0162] The specific definition of the color cast identification device can be found in the definition of the color cast identification method above, which will not be repeated here. Each module in the above-mentioned color cast identification device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0163] In some embodiments of the present application, the color cast identification device can be implemented in the form of a computer program. The computer program can be used in Figure 8 The computer device is run on the computer device shown. The memory of the computer device can store various program modules constituting the color cast identification device, for example, Figure 7 The acquisition module 710, the processing module 720 and the determination module 730 are shown. The computer program composed of various program modules enables the processor to execute the steps of the color cast identification method of each embodiment of the present application described in this specification.
[0164] For example, Figure 8 The computer device shown can be Figure 7The acquisition module 710 in the color cast identification device shown executes step S110. The computer device can execute step S120 through the processing module 720. The computer device can execute step S130 through the determination module 730. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external computer device through a network connection. When the computer program is executed by the processor, a color cast identification method is implemented.
[0165] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0166] In some embodiments of the present application, a computer device is provided, comprising one or more processors; a memory; and one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the following steps:
[0167] Obtaining a document image to be identified and a portrait base image corresponding to the document image;
[0168] The document image and the portrait base image are processed respectively by a trained feature extraction model to obtain a first image feature of the document image and a second image feature of the portrait base image;
[0169] The color cast recognition result of the document image is determined according to the feature similarity between the first image feature and the second image feature.
[0170] In some embodiments of the present application, a computer-readable storage medium is provided, which stores a computer program. The computer program is loaded by a processor, so that the processor performs the following steps:
[0171] Obtaining a document image to be identified and a portrait base image corresponding to the document image;
[0172] The document image and the portrait base image are processed respectively by a trained feature extraction model to obtain a first image feature of the document image and a second image feature of the portrait base image;
[0173] The color cast recognition result of the document image is determined according to the feature similarity between the first image feature and the second image feature.
[0174] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Any reference to memory, storage, information library or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0175] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0176] The above is a detailed introduction to a color cast identification method, device, computer equipment and storage medium provided in the embodiments of the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the ideas of the present invention, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A color cast identification method, characterized in that: include: Obtaining a document image to be identified and a portrait base image corresponding to the document image; The document image and the portrait base image are processed respectively by a trained feature extraction model to obtain a first image feature of the document image and a second image feature of the portrait base image; The color cast recognition result of the document image is determined according to the feature similarity between the first image feature and the second image feature.
2. The method according to claim 1, characterized in that The trained feature extraction model is obtained by training through the following steps: Acquire a sample portrait base map and a sample ID image corresponding to the sample portrait base map; the sample ID image includes a positive sample ID image and a negative sample ID image; Inputting the sample portrait base image and the sample ID image into an initial feature extraction model to obtain a first prediction feature of the sample portrait base image, a second prediction feature of the positive sample ID image, and a third prediction feature of the negative sample ID image; Determine a model loss value corresponding to the initial feature extraction model according to the first prediction feature, the second prediction feature, and the third prediction feature; The initial feature extraction model is updated according to the model loss value until the model loss value obtained by inputting the sample portrait base map and the sample ID image into the updated feature extraction model meets the preset conditions, and the currently updated feature extraction model is determined as the trained feature extraction model.
3. The method according to claim 2, characterized in that The step of obtaining a sample portrait base map and a sample ID image corresponding to the sample portrait base map includes: Obtain a sample portrait base image and a positive sample document image in a first color space corresponding to the sample portrait base image; Converting the positive sample document image into a reference document image in a second color space; The values of each color channel in the reference document image are adjusted to obtain a negative sample document image corresponding to the sample portrait base image.
4. The method according to claim 2, characterized in that: The sample portrait base image includes a first portrait base image corresponding to a first portrait; the positive sample ID image includes a first positive sample ID image corresponding to the first portrait and a second positive sample ID image corresponding to a second portrait; the negative sample ID image includes a first negative sample ID image corresponding to the first portrait, a second negative sample ID image corresponding to the second portrait, and a third negative sample ID image corresponding to a third portrait; The determining the model loss value corresponding to the initial feature extraction model according to the first prediction feature, the second prediction feature, and the third prediction feature includes: Determining a first model loss value corresponding to the initial feature extraction model according to a feature difference between the predicted features of the first portrait base image and the predicted features of the first positive sample ID image, and a feature difference between the predicted features of the first portrait base image and the predicted features of the first negative sample ID image; Determining a second model loss value corresponding to the initial feature extraction model according to feature differences between the predicted features of the first portrait base image and the predicted features of the second positive sample ID image, and feature differences between the predicted features of the first portrait base image and the predicted features of the second negative sample ID image; Determining a third model loss value corresponding to the initial feature extraction model according to a feature difference between the predicted features of the first portrait base image and the predicted features of the second positive sample ID image, and a feature difference between the predicted features of the first portrait base image and the predicted features of the third negative sample ID image; Determine a model loss value corresponding to the initial feature extraction model according to the first model loss value, the second model loss value and the third model loss value.
5. The method according to claim 4, characterized in that The determining the model loss value corresponding to the initial feature extraction model according to the first model loss value, the second model loss value, and the third model loss value includes: Determining a training round corresponding to the initial feature extraction model; The first model loss value, the second model loss value, and the third model loss value are weighted according to the weight coefficient corresponding to the training round to obtain a model loss value corresponding to the initial feature extraction model.
6. The method according to claim 1, characterized in that The determining the color cast recognition result of the document image according to the feature similarity between the first image feature and the second image feature includes: Acquire historical document images with color cast; Processing the historical document image by using the trained feature extraction model to obtain a third image feature of the historical document image; The color cast recognition result of the document image is determined according to the feature similarity between the first image feature and the second image feature, and the feature similarity between the first image feature and the third image feature.
7. The method according to any one of claims 1 to 6, characterized in that: The method of processing the document image and the portrait base image respectively by using the trained feature extraction model to obtain a first image feature of the document image and a second image feature of the portrait base image includes: Performing image recognition on the document image and the portrait base image to obtain a first portrait region in the document image and a second portrait region in the portrait base image; The first portrait region and the second portrait region are processed respectively by a trained feature extraction model to obtain first image features of the document image and second image features of the portrait base image.
8. A color cast identification device, characterized in that: include: An acquisition module, used to acquire a document image to be identified and a portrait base image corresponding to the document image; A processing module, used to process the document image and the portrait base image respectively through a trained feature extraction model to obtain a first image feature of the document image and a second image feature of the portrait base image; A determination module is used to determine the color cast recognition result of the document image according to the feature similarity between the first image feature and the second image feature.
9. A computer device, characterized in that: The computer device comprises: one or more processors; Memory; and One or more application programs, wherein the one or more application programs are stored in the memory and are configured to be executed by the processor to implement the color cast identification method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and the computer program is loaded by a processor to execute the color cast identification method according to any one of claims 1 to 7.