Method and apparatus for training a face recognition model
By filtering and enhancing multi-format image samples, constructing single-batch processing samples, and adjusting model parameters, the problem of decreased recognition accuracy caused by format differences in the intelligent park face recognition model was solved, thus improving the robustness and accuracy of the model.
Patent Information
- Application Number
- CN202511394047.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-28
- Publication Date
- 2025-12-30
- Estimated Expiration
- 2045-09-28
AI Technical Summary
In smart park scenarios, the pixel matrix difference between the JPG format images used for training face recognition models and the BMP format images used in actual applications leads to a decrease in recognition accuracy. Existing technologies struggle to effectively address the robustness issue of multi-format image recognition.
By acquiring multiple face scene images, the second format images are selected based on the similarity comparison results between the first and second format images, a single batch processing sample is constructed, and the parameters of the face recognition model are updated and adjusted, including image enhancement and feature extraction, to improve the model's robustness to recognition of images of different formats.
While increasing the number of training samples in multiple image formats, the memory pressure was reduced, the model's recognition accuracy and robustness for images of different formats were improved, and the problem of decreased recognition accuracy caused by format differences was solved.
Smart Images

Figure CN120877356B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to a method and apparatus for training a face recognition model. Background Technology
[0002] In face recognition model training, tens of millions or even hundreds of millions of face data samples are often needed to improve model accuracy. While such a large amount of data provides more feature information, it puts significant pressure on daily data storage and the transmission and retrieval of datasets during training. Common image storage formats include BMP and JPG. Under the same pixel conditions, a BMP image is 6 to 8 times larger than a JPG image. Therefore, considering the rationality of storage space and training server memory, JPG images are usually used for model training.
[0003] However, in the application of facial recognition models in smart park scenarios, due to business process regulations, the images saved from the video stream and transmitted to the recognition model are in BMP format, which differs from the JPG image format used for training. This results in a certain difference in their pixel matrices (some elements differ by 1 to 5 pixels). This difference is amplified after the image is transformed into high-dimensional features by the facial recognition model, thus affecting the cosine similarity comparison results between features. Ultimately, this leads to a significant decrease in the model's recognition accuracy for BMP format images, impacting business applications. Summary of the Invention
[0004] This invention provides a training method and apparatus for a face recognition model to solve the robustness problem of face recognition models in recognizing images of various formats.
[0005] According to one aspect of the present invention, a method for training a face recognition model is provided, comprising:
[0006] Multiple face scene images are acquired, and a first format image and a second format image corresponding to each face are obtained based on the face scene images;
[0007] The second format images are filtered based on the similarity comparison results of the first format image and the second format image corresponding to each face to obtain the second format training set;
[0008] A single batch of samples is determined based on a first preset number of first-format images and a second preset number of second-format images in the second-format training set.
[0009] The parameters of the face recognition model are updated and adjusted based on each batch of samples to obtain the trained face recognition model.
[0010] According to another aspect of the present invention, a training apparatus for a face recognition model is provided, comprising:
[0011] A multi-format image determination module is used to acquire multiple face scene images and obtain a first format image and a second format image corresponding to each face based on the face scene images;
[0012] The second format image filtering module is used to filter the second format images based on the similarity comparison results of the first format image and the second format image corresponding to each face, so as to obtain the second format training set.
[0013] A single batch processing sample determination module is used to determine a single batch processing sample based on a first preset number of first format images and a second preset number of second format images in the second format training set.
[0014] The model parameter adjustment module is used to update and adjust the parameters of the face recognition model according to each batch of samples to obtain the trained face recognition model.
[0015] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0016] At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores a computer program executable by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the training method for the face recognition model according to any embodiment of the present invention.
[0017] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the training method of the face recognition model according to any embodiment of the present invention.
[0018] The technical solution of this invention filters the second format image based on the similarity between the first format image and the second format image, and then constructs a single batch of samples based on the filtered second format image and the first format image. This achieves the goal of increasing the robustness of the model by adding multi-format images to the training samples of the model, while reducing the memory pressure caused by the addition of training images of different formats.
[0019] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a flowchart of a training method for a face recognition model according to an embodiment of the present invention;
[0022] Figure 2 This is a flowchart of another training method for a face recognition model provided according to an embodiment of the present invention;
[0023] Figure 3 This is the process for constructing a single batch processing sample according to an embodiment of the present invention;
[0024] Figure 4 This is a flowchart of another training method for a face recognition model provided according to an embodiment of the present invention;
[0025] Figure 5 This is a schematic diagram illustrating the separation of single-batch sample features corresponding to a single-batch processing sample according to an embodiment of the present invention, and the loss calculation of the separated features respectively;
[0026] Figure 6 This is a schematic diagram of the structure of a training device for a face recognition model according to an embodiment of the present invention;
[0027] Figure 7 This is a schematic diagram of the structure of an electronic device that implements the training method of the face recognition model in the embodiments of the present invention. Detailed Implementation
[0028] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0029] It should be noted that the terms "candidate," "target," etc., used in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0030] Figure 1 This invention provides a flowchart of a method for training a face recognition model. This embodiment is applicable to improving the robustness of face recognition models in recognizing images of various formats. The method can be executed by a face recognition model training device, which can be implemented in hardware and / or software and can be configured on a server with computing power. Figure 1 As shown, the method includes:
[0031] S110. Obtain multiple face scene images, and obtain the first format image and the second format image corresponding to each face based on the face scene images.
[0032] Here, a face scene image refers to a scene image captured by an image acquisition device that includes at least one face, such as a scene image of a park including pedestrians captured by cameras deployed in a smart park. Since face recognition models require a large number of training samples, a large number of face scene images need to be collected.
[0033] Face detection and localization are performed on the face scene image to determine the region where the face is located. This region is then cropped to obtain a corresponding small face image. These small face images are saved in a first format and a second format, resulting in a first-format image and a second-format image corresponding to the small face image. Both the first-format and second-format images contain a face. The first format differs from the second format, and the memory size of the first-format image corresponding to the same small face image is smaller than that of the second-format image. For example, the first format is JPG and the second format is BMP. Further, different first and second formats can be determined according to the actual needs of the scene.
[0034] For example, face detection and localization are performed on each face scene image by a detection localization model to determine the location of each face region. The face mini-image is then cropped based on the region location, and similarity transformations, such as proportional scaling and face rotation, are performed on the cropped face mini-image. After similarity transformation, the images are saved in different formats to obtain a first format image and a second format image.
[0035] S120. Based on the similarity comparison results between the first format image and the second format image corresponding to each face, the second format images are filtered to obtain the second format training set.
[0036] Existing conventional face recognition model training processes first feed the training set into a data input device, which performs operations such as segmentation, shuffling, and data augmentation as required, before feeding it into the network according to the batch size. The network then processes the high-dimensional facial features obtained from the model to calculate the loss function, and finally performs gradient backpropagation and updates. However, a problem exists in the actual use of training sets: the sheer volume of face recognition training data, typically tens of millions or even hundreds of millions of images, places enormous pressure on both the hard drive during storage and the memory during training. After detecting and fixing points in the face scene images, the small face images are saved as JPG format. A JPG format training set generally requires 600-700GB of hard drive storage space, and the training server requires 1TB of memory. BMP format images are 6 to 8 times larger than JPG format images. Therefore, considering the rationality of storage space and training server memory, only JPG format sample images can be used for model training. However, after training the model based on JPG format sample images, most of the images input into the model in subsequent practical applications are in BMP format, which is different from the format of the training sample images. This leads to differences in the pixel matrix. Furthermore, after the recognition network in the model extracts high-dimensional features from BMP format images, the differences between the pixel matrices of different formats are further amplified, affecting the accuracy of feature comparison in the trained model and reducing the recognition accuracy.
[0037] Therefore, a portion of the face thumbnail samples corresponding to the complete face thumbnail training set in the face scene image can be selected and saved in BMP format as a training set for training. In this step, the second format images are filtered according to the similarity comparison results of the first format images and the second format images to reduce the size of the training set of the second format images. Furthermore, the second format images in the second format training set have low similarity with the corresponding first format images. By filtering out the second format images with large feature differences corresponding to the same recognition target through the similarity comparison results, the second format images are also selected to participate in the model training. This can improve the training effect of the model on images of different formats and enhance the robustness of the model in recognizing images of different formats.
[0038] Specifically, a feature extraction model is used to extract features from the first and second format images corresponding to each face, and the similarity between the feature information corresponding to the first and second format images is determined. If the similarity is lower than the similarity threshold, it indicates that the difference between the second and first format images corresponding to the face is large, and the second format image corresponding to the face is saved in the second format training set. If the similarity is greater than or equal to the similarity threshold, it indicates that the difference between the second and first format images corresponding to the face is small, and the second format image can be ignored. For example, the feature extraction model can be a baseline recognition model, which can be a face recognition model trained using the first format image as a training sample. Based on this, the baseline recognition model is used to extract features from the first and second format images, ensuring the accuracy of feature extraction. In this embodiment, a sample selection module is set up to select image pairs of different formats with similarity below the current face scene image, adding a batch of BMP format training sets for subsequent training and preparing data. The sample selection module includes a detection point model, a baseline recognition model, and a selection unit, which selects BMP format images that meet the requirements according to preset selection rules to form the second format training set.
[0039] In one feasible embodiment, S120 includes:
[0040] Determine the first feature matrix of all first-format images and the second feature matrix of all second-format images;
[0041] The first similarity matrix is determined based on the first feature matrix and the second feature matrix;
[0042] Based on the first similarity matrix, a first target face is determined corresponding to the first format image and the second format image having a similarity lower than the first similarity threshold. A second format training set is then constructed based on the second format image corresponding to the first target face.
[0043] Since the face recognition model is pre-trained once based on the first format image, as the smart park develops, it is necessary to add training samples of the second format image. Therefore, it may face the loss of face scene images during the initial training, or the fact that the first and second format images are determined in batches, resulting in the first and second format images not being able to correspond one-to-one. That is, it is impossible to accurately determine the first and second format images corresponding to the same face. Therefore, it is impossible to directly perform one-to-one similarity comparison and screening based on the feature extraction results. Accordingly, similarity screening is performed based on the first feature matrix of the first format images corresponding to all face scene images and the second feature matrix of the second format images corresponding to some face scene images. That is, similarity screening is performed based on the first feature matrix of all stored first format images and the second feature matrix of the second format images obtained from the currently saved remaining face scene images.
[0044] Specifically, we determine m first-format images and n second-format images. Since face scene images may be lost, m may not be equal to n. We input the m first-format images into the feature extraction model to obtain the first feature matrix, and input the n second-format images into the feature extraction model to obtain the second feature matrix. We calculate the similarity based on the first and second feature matrices to obtain the first similarity matrix. Each element in the first similarity matrix represents the similarity between any first-format image and any second-format image. The specific first-format and second-format images represented can be determined based on the position of each element in the first similarity matrix, the position of each first-format image represented in the first feature matrix, and the position of each second-format image represented in the second feature matrix. For example, the matrix multiplication result of the transpose of the first feature matrix and the second feature matrix is the first similarity matrix. The feature information in the first row of the first feature matrix represents the features of the first first format image in the input feature extraction model, and so on. Similarly, the feature information in the first row of the second feature matrix represents the features of the first second format image in the input feature extraction model, and so on. Therefore, the element value in the i-th row and j-th column of the first similarity matrix represents the similarity between the i-th first format image and the j-th second format image. The index of the first format image and the second format image is determined according to the order in which they are input into the feature extraction model.
[0045] Since the first and second feature matrices include all image features of the corresponding format, and the consistency of the face order in the first and second feature matrices cannot be determined, the positions of elements in the first similarity matrix whose values are greater than a first threshold and less than a second threshold are determined. Based on these element positions, the first target face corresponding to a similarity between the first and second format images that is less than the first similarity threshold is determined. If the element value in the i-th row and j-th column of the first similarity matrix is greater than the first threshold, it indicates that the i-th first format image and the j-th second format image correspond to the same target face. Furthermore, if the element value in the i-th row and j-th column of the first similarity matrix is greater than the first threshold and less than the second threshold, it indicates that the similarity between the i-th first format image and the j-th second format image corresponding to the same face is less than the first similarity threshold, and these j-th second format images are added to the second format training set. The first threshold is determined based on the format feature difference results between the first and second format images determined by experimental data, and this value can be adjusted according to the actual scenario; the second threshold is determined based on the first similarity threshold and adjusted according to actual accuracy and memory requirements, and its specific value is not limited here.
[0046] For example, m JPG format face images are processed by a baseline recognition model to output an m*512 dimensional feature matrix A; n BMP format training images output an n*512 feature matrix B. The first feature matrix A and the second feature matrix B are input together into the filtering calculation module for calculation, according to the following formula:
[0047] ;
[0048] in The transpose of B is represented by a matrix of size 512*n. The resulting matrix xsd after the collision has a size of m*n. Elements with values in the (low, high) interval are selected from the matrix, with a first threshold of low = 0.92 and a second threshold of high = 0.995. The threshold interval boundaries are determined based on the statistical analysis of the similarity distribution between the same large image saved as smaller images in two different formats. Based on this threshold interval, BMP format images with similarity below the similarity threshold corresponding to the same face target can be filtered out. Finally, these BMP format images are added to the second format training set for subsequent optimization training. This approach both supplements the limited second format image data and avoids placing too much additional pressure on the hard drive and memory.
[0049] S130. Determine a single batch of samples based on a first preset number of first format images and a second preset number of second format images in the second format training set.
[0050] Since a single batch of samples represents the number of samples used to iteratively adjust the parameters of the face recognition model, each batch includes a first preset number of first-format images and a second preset number of filtered second-format images to ensure that the distinguishing features between the first-format and second-format images are considered during each parameter adjustment. For example, a first preset number of first-format images are randomly selected from the first-format training set (comprising all first-format images), and a second preset number of second-format images are randomly selected from the second-format training set to form the single batch of samples for each training iteration. The size of the first and second preset numbers is not limited and is determined based on the set batch_size. The first preset number of first-format images is used for regular model weight parameter iteration updates; the second preset number of second-format images improves the model's robustness.
[0051] S140. Update and adjust the parameters of the face recognition model according to each batch of samples to obtain the trained face recognition model.
[0052] Each batch of processed samples is input into the face recognition model. The feature layer of the face recognition model outputs the corresponding high-dimensional face features, which are then fed into the classification layer module of the face recognition model. The loss value is determined based on the obtained classification prediction results and the pre-determined label information of each image in the batch of processed samples. The overall parameters in the face recognition model are updated and adjusted based on the loss value. After reaching the required number of iterations, the trained face recognition model is obtained.
[0053] The technical solution of this embodiment filters the second format image based on the similarity between the first format image and the second format image, and then constructs a single batch of samples based on the filtered second format image and the first format image. This achieves the goal of increasing the robustness of the model by adding multi-format images to the training samples of the model, while reducing the memory pressure caused by the addition of training images of different formats.
[0054] Figure 2 This is a flowchart illustrating another training method for a face recognition model provided by an embodiment of the present invention. This embodiment further refines the process of determining single-batch samples in the above embodiments. Figure 2 As shown, the method includes:
[0055] S210. Obtain multiple face scene images, and obtain the first format image and the second format image corresponding to each face based on the face scene images.
[0056] S220. Based on the similarity comparison results between the first format image and the second format image corresponding to each face, the second format images are filtered to obtain the second format training set.
[0057] S230. Copy a second preset number of second format images to obtain a second preset number of second format copied images.
[0058] After expanding the training dataset, the supplementary second-format images need to be added to the training data through data reading. Conventional data input modules have two types: base data input and triplet data input. Both of these modules have two drawbacks: 1. They can only randomly select images for each batch from a dataset, not specific portions; 2. All data can only undergo the same data augmentation with a certain probability, making it impossible to perform specific augmentations on specific data. The face recognition model trained in this invention needs to address the problem of large differences in feature similarity between images of different formats. Therefore, it is necessary to perform targeted augmentation on the newly added second-format training data to improve the robustness of the face recognition model to different image formats.
[0059] Specifically, before performing enhancement in a specified direction on the second format image, in order to ensure that the original data information is preserved, a second preset number of second format images are randomly selected from the second format training set, and the second preset number of second format images are copied to obtain a second preset number of second format copied images, that is, the second format copied images are exactly the same as the second format images.
[0060] S240. Enhance the second preset number of second format copied images to obtain second format enhanced images.
[0061] Since the present invention aims to address the problem of significant differences between the second format image and the first format image, the direction of image enhancement for the second format copy image is to increase the similarity between the enhanced second format image and the corresponding first format image. This reduces the differences between the enhanced second format image and the first format image during model training, thereby improving the recognition accuracy of the trained face recognition model for the second format image.
[0062] Specifically, an image enhancement direction is determined based on the image difference characteristics between the first and second formats. Then, each second-format copy image is processed according to this enhancement direction to obtain a second-format enhanced image. For example, the pixel relationship between the first and second format images is determined based on the statistical results of the image difference distribution between the first and second formats. This pixel relationship can be represented by a function. The values of each pixel in the second-format copy image are then transformed according to this pixel relationship to obtain the corresponding second-format enhanced image. The similarity between this second-format enhanced image and the corresponding first-format image is greater than the similarity between the corresponding second-format image and the first-format image.
[0063] In one feasible embodiment, S240 includes:
[0064] The second format copy images are encoded according to the format characteristics of the first format image to obtain the encoding result of the second format copy image;
[0065] The encoding results of the second-format copied images are decoded to obtain the second-format enhanced images corresponding to each second-format copied image.
[0066] The encoding rules are determined based on the format characteristics of the first format image, and the second format copy image is encoded according to the encoding rules to obtain the encoding result of the second format copy image. Then, the encoding result of the second format copy image is decoded to obtain the second format enhanced image.
[0067] For example, the following formula is used to enhance a second-format copied image:
[0068] ;
[0069] Where q represents the compression mass, which is a random integer between 92 and 98. This represents a fixed parameter for compression towards JPG format. The value of this parameter can be adjusted based on the comparison between the encoded image and the corresponding JPG format image; its specific value is not limited here. `immencode` represents the encoding function, and `imdecode` represents the decoding function, used to encode and decode the image into the specified format. These functions can be from the OpenCV library. `img` represents a copy of the image in a second format. This indicates the result of copying the image in the second format. This is a second-format enhanced image corresponding to a second-format copied image. Encoding and decoding are performed according to a set compression quality range, which can control the similarity of image features before and after enhancement within a preset range, so that the features of a BMP format image, after image enhancement, can be approximately equivalent to the features of a JPG format image.
[0070] The image enhancement method of this invention reduces the gap between the enhanced image in the second format and the image in the first format, providing a rich data foundation for subsequent model training.
[0071] S250. Perform image enhancement on a first preset number of first format images to obtain first format enhanced images.
[0072] To improve data accuracy, image enhancement is performed on the first-format images before training. However, the image enhancement method for the first-format images differs from that for the second-format images. Since image enhancement for the second-format images aims to reduce the gap with the first-format images, image enhancement for the first-format images aims to enhance overall or local features, amplify the differences between different features, and improve image quality. For example, frequency domain or spatial domain methods can be used to enhance the first-format images, resulting in enhanced first-format images where facial clarity is greater than in the original first-format images. This invention does not limit the specific image enhancement method used for the first-format images.
[0073] S260. Arrange the first format enhanced image, the second format enhanced image, and a second preset number of second format images in a preset order to obtain a single batch processing sample.
[0074] In this process, images of different types are input into the face recognition model in a preset order for each batch of samples, with images of the same type being adjacent in the preset order.
[0075] Specifically, the first format enhanced image, the second format enhanced image, and the second format image corresponding to the second format enhanced image are combined in a preset order to form a single batch processing sample. The preset order does not restrict the order of each type, but ensures that images of the same type are adjacent, that is, there will be no situation where images of different types are interspersed in the single batch processing sample. The images in the single batch processing sample are input into the face recognition model in the preset order.
[0076] like Figure 3 The diagram illustrates the process of constructing a single batch of samples. Data_b1 represents the second-format image, Data_b2 represents a copy of the second-format image, Data_b1 and Data_b2 are identical data from the second-format training set, batch_b is the number of images included in Data_b1 and Data_b2, Data_a is the data from the first-format training set, batch_a is the number of images included in Data_a, and all_batch is the total batch size input to the model in each iteration. The second-format image retains its original data, the first-format image undergoes a first image enhancement process (e.g., normal data enhancement), and the second-format copied image undergoes a second image enhancement process (e.g., data enhancement based on the feature direction of the first format). These original second-format images, the first-format enhanced image, and the second-format enhanced image constitute the single-batch processing samples fed into the model in each iteration. Furthermore, the single-batch processing samples are input into the model in a left-to-right order; however, this embodiment of the invention does not limit the preset order of the second-format image, the first-format enhanced image, and the second-format enhanced image in the single-batch processing samples.
[0077] S270. Update and adjust the parameters of the face recognition model according to each batch of samples to obtain the trained face recognition model.
[0078] The technical solution of this embodiment improves the sample richness in a single batch of processed samples by including an enhanced first format image, an original second format image, and an enhanced second format image in the single batch of processed samples, thereby ultimately achieving the goal of improving the model's accuracy and robustness.
[0079] Figure 4 This is a flowchart illustrating another training method for a face recognition model provided by an embodiment of the present invention. This embodiment further refines the parameter update and adjustment process in the above embodiments. Figure 4 As shown, the method includes:
[0080] S410. Obtain multiple face scene images, and obtain the first format image and the second format image corresponding to each face based on the face scene images.
[0081] S420. Based on the similarity comparison results between the first format image and the second format image corresponding to each face, the second format images are filtered to obtain the second format training set.
[0082] S430. Determine a single batch of samples based on a first preset number of first format images and a second preset number of second format images in the second format training set.
[0083] S440. Determine the first format image features and the second format image features based on the feature recognition results of each batch of processed samples.
[0084] Feature extraction is performed on a single batch of processed samples to obtain the sample features corresponding to each sample image in the single batch. Based on the positional relationship between the first-format and second-format images in the single batch, the sample features corresponding to the single batch are separated to obtain first-format image features and second-format image features. For example, the sample features corresponding to a single batch are a feature matrix, where each row corresponds to the feature information of one image. The corresponding first-format and second-format image features are extracted from the feature matrix according to the number and order of each format image in the single batch.
[0085] In one feasible embodiment, S440 includes:
[0086] Based on the feature recognition results of each batch of processed samples, the first format image features corresponding to the first format enhanced image, the second format enhanced image features corresponding to the second format enhanced image, and the second format original image features corresponding to the second format image are determined; wherein, the second format enhanced image features and the second format original image features constitute the second format image features.
[0087] In the above embodiments, a single batch of processed samples includes a first-format enhanced image, a second-format image, and a corresponding second-format enhanced image. Therefore, the first-format image features corresponding to the first-format enhanced image, the second-format original image features corresponding to the second-format image, and the second-format enhanced image features corresponding to the second-format enhanced image can be extracted from the single batch sample features corresponding to the single batch of processed samples. For example, the sample features corresponding to a single batch of processed samples are a feature matrix, where each row of the matrix corresponds to the feature information of an image. Based on the number and arrangement order of the first-format enhanced images, second-format images, and corresponding second-format enhanced images in the single batch of processed samples, the corresponding first-format image features, second-format original image features, and second-format enhanced image features are sequentially extracted from the feature matrix.
[0088] For example, a single batch of processed samples obtains an n*512 dimensional combined feature Fc512_all of two image formats through the feature extraction module, where n is the value of the combined feature Fc512_all in the example above. To differentiate between features of different formats, the combined features are separated into three parts: first-format image feature a_fc512, second-format original image feature b1_fc512, and second-format enhanced image feature b2_fc512. a_fc512 is the JPG image feature input to Data_a, and b1_fc512 and b2_fc512 are the BMP image features input to Data_b1 and Data_b2, respectively. The principle behind separating the combined features is shown in the following formula:
[0089] ;
[0090] Where batch_b is the number of images included in Data_b1 or Data_b2, and batch_a is the number of images included in Data_a. Since each row in the matrix corresponding to the combined features corresponds to the feature information of one image, and since different types of images are input into the face recognition model in a preset order in a single batch of samples, the features of the three types of images are separated row by row according to the preset order and the number of images of each type.
[0091] S450. Update and adjust the parameters of the face recognition model based on the classification prediction results of the first format image features and the second format image features to obtain the trained face recognition model.
[0092] Loss calculations were performed on the classification prediction results corresponding to the first and second format image features respectively, in order to distinguish the impact of the differences in image features on model training.
[0093] Specifically, the first format image features are input into the classification layer to obtain the first classification prediction result. The first format loss value is then determined between the first classification prediction result and the label information corresponding to a single batch of samples. The second format image features are input into the classification layer to obtain the second classification prediction result. The second format loss value is then determined between the second classification prediction result and the label information corresponding to a single batch of samples. The total loss is determined by the weighted sum of the first and second format losses. The parameters of the face recognition model are updated and adjusted based on the total loss corresponding to the current single batch of samples until a preset number of iterations is reached, resulting in a trained face recognition model. The loss functions used for calculating the losses of the first and second classification prediction results can be the same or different. The weights of the first and second format losses can be adjusted according to the actual situation and are not restricted here.
[0094] In one feasible embodiment, S450 includes:
[0095] The first loss function is used to determine the classification prediction results of the first format image features and the second format image features respectively;
[0096] The second loss function is used to determine the second loss corresponding to the image features of the second format.
[0097] The total loss is determined based on the first loss and the second loss, and the parameters of the face recognition model are updated and adjusted based on the total loss.
[0098] The first format image features are input into the classification layer to obtain the first classification prediction result. A first loss function is used to determine the first format loss value between the first classification prediction result and the label information corresponding to a single batch of processed samples. The second format image features are input into the classification layer to obtain the second classification prediction result. The first loss function is used to determine the second format loss value between the second classification prediction result and the label information corresponding to a single batch of processed samples. The first loss is determined based on the sum of the first and second format loss values. Then, a second loss function is used based on the similarity information between the second and first format image features to obtain the second loss. The total loss is determined based on the weighted value of the first and second losses. The weights corresponding to the first and second losses can be adjusted according to the actual scenario requirements, and there is no restriction on the specific values here. For example, arcface_loss is chosen as the first loss function. When determining the second loss, the second loss represents the difference loss between the first format image features and the corresponding second format image features. Since each batch may not be able to obtain exactly the first format image and the second format image corresponding to the same face target, and the feature enhancement direction of the second format enhanced image features is to increase the similarity between the enhanced second format image and the corresponding first format image, the similarity between the second format enhanced image features and the corresponding first format image features is relatively high. The second format enhanced image features can be used to approximate the first format image features corresponding to the second format image features. Therefore, the second loss can be determined based on the difference information between the original second format image features and the corresponding second format enhanced image features. For example, the second loss function can be determined based on the similarity calculation formula between the original second format image features and the corresponding second format enhanced image features.
[0099] This embodiment uses a first loss function to determine the accuracy of classification prediction results for image features of different formats, and a second loss function to determine the similarity gap between image features of different formats. Then, based on the first and second losses, the total loss for parameter adjustment is determined, highlighting the influence of image features of different formats on the model's recognition accuracy, thereby improving the accuracy of model training.
[0100] In one feasible embodiment, a second loss function is used to determine a second loss corresponding to the second format image features, including:
[0101] Determine the second similarity matrix between the second-format enhanced image features and the second-format original image features;
[0102] Based on the second similarity matrix, determine the second target face corresponding to the second format enhanced image feature and the second format original image feature having a similarity lower than the second similarity threshold, and determine the target feature similarity of the second target face in the second similarity matrix;
[0103] The second loss is determined based on the similarity of the target features.
[0104] The significant difference in feature extraction results between BMP and JPG formats for the same image stems from the fact that face recognition models are trained without BMP images. This causes the model's parameter updates to favor JPG image features, gradually amplifying subtle differences in the pixel matrices between BMP and JPG formats during high-dimensional feature extraction. To address this, this invention employs a second loss mechanism to apply penalties based on the feature differences between different formats of the same image. The lower the similarity of image features between different formats, the stronger the penalty, thereby improving the model's robustness to different feature formats.
[0105] Since it cannot be guaranteed that the first format image and the second format image in a single batch of processed samples correspond to the same face, and the second format enhanced image in the single batch of processed samples is obtained by enhancing the second format copy image that is exactly the same as the second format image, and the image enhancement direction is the first format feature direction, the second format enhanced image in the single batch of processed samples is used as a substitute image for the first format image. The similarity between the features of the second format enhanced image and the features of the second format original image is used to represent the similarity between different formats in the single batch of processed samples, so as to obtain the second loss.
[0106] Specifically, a similarity calculation is performed based on the features of the enhanced image in the second format and the features of the original image in the second format to obtain a second similarity matrix. Each element value in the second similarity matrix represents the similarity between any second format image and any second format enhanced image. The specific second format image and the second format enhanced image represented can be determined based on the position of each element in the second similarity matrix and the position of each second format image represented in the features of the original image in the second format.
[0107] For example, the matrix multiplication of the feature matrix corresponding to the second format enhanced image feature and the transpose of the feature matrix corresponding to the second format original image feature is the second similarity matrix. Since the second format image corresponding to the second format original image feature and the second format enhanced image corresponding to the second format enhanced image feature are in one-to-one correspondence, the element value in the i-th row and i-th column of the second similarity matrix represents the similarity between the i-th second format original image feature and the corresponding second format enhanced image feature.
[0108] The position of the element with a value greater than the third threshold and less than the fourth threshold in the i-th row and i-th column of the second similarity matrix is determined. Based on this element position, the second target face corresponding to the second format original image feature and the second format enhanced image feature having a similarity lower than the second similarity threshold is determined. This can be interpreted as follows: if the element with a value greater than the third threshold in the i-th row and i-th column of the second feature matrix, it indicates that the i-th second format original image feature and the second format enhanced image feature correspond to the same second format image, i.e., the same face, avoiding errors caused by disordered processing order of the second format enhanced image. Furthermore, if the element with a value greater than the third threshold and less than the fourth threshold in the i-th row and i-th column of the second feature matrix, it indicates that the similarity between the i-th second format original image feature and the i-th second format enhanced image feature corresponding to the same face is lower than the second similarity threshold. Therefore, the similarity between the i-th second format original image feature and the i-th second format enhanced image feature in the second similarity matrix is determined as the target feature similarity, and the second loss is determined based on the average of all target feature similarities.
[0109] The third threshold is determined based on the similarity between the original image features in the second format and the enhanced image features in the second format, and can be adjusted according to the actual scenario; the fourth threshold is determined based on the second similarity threshold, and can be adjusted according to the actual accuracy requirements and memory requirements, but its specific value is not limited here.
[0110] In one feasible embodiment, determining a second loss based on target feature similarity includes:
[0111] The second loss is determined according to the following formula:
[0112]
[0113] in, This indicates the second loss. The similarity of the target features corresponding to the i-th second target face is defined as the similarity between the i-th original image feature of the second format and the i-th enhanced image feature of the second format corresponding to the same face being lower than the second similarity threshold. n represents the total number of second target faces.
[0114] Specifically, the formula for determining the second loss is as follows:
[0115] ;
[0116] In the above formula, and Represents the original image feature matrix and the enhanced image feature matrix after high-dimensional feature extraction of the second-format image and the second-format enhanced image, respectively. jz is the second similarity matrix between the original image features and the enhanced image features of each BMP image obtained by matrix cross product. eye represents the corresponding... and The identity matrix of dimension 1 is multiplied by the identity matrix to make the second similarity matrix a diagonal matrix. That is, the second similarity matrix only includes the similarity between the original image features of the second format and the enhanced image features of the second format corresponding to the same second format image. The index is used to represent the feature position where the similarity is within the range of the third threshold and the fourth threshold. The index can be used to extract the target feature similarity at the position that meets the threshold condition from the second similarity matrix. Here, a1 represents the third threshold and a2 represents the fourth threshold. Their specific values can be set according to the actual situation. For example, a1 is 0.92 and a2 is 0.998. n represents the number of target feature similarities that meet the threshold condition. The value represents the similarity value at the i-th row position in the second similarity matrix. The lower the similarity value, the worse the robustness of the model in recognizing the original image features of the second format and the enhanced image features of the second format. Stronger penalty measures need to be applied to constrain the weights during the update. The values m1 and m2 are used to represent the constraint weights. The specific values of m1 and m2 can be adjusted and determined according to the experimental verification results. For example, m1 is 1 and m2 is 2. Finally, the average value is calculated and taken as the second loss for this round of training.
[0117] In a single training run based on batch samples, if there are more BMP feature pairs with low similarity, that is, the lower the similarity between the second format image features and the first format image features corresponding to the same face, it proves that the face recognition model is less robust to such images. Therefore, by enhancing the corresponding second loss value, stronger training constraints are applied to improve the robustness of the face recognition model to multi-format images.
[0118] like Figure 5The diagram illustrates the separation of single-batch sample features and the calculation of loss for each separated feature. Specifically, Data represents the single-batch sample in each iteration. Each single-batch sample includes a first-format enhanced image, a second-format enhanced image, and a second-format image corresponding to the second-format enhanced image that has not undergone enhancement. The single-batch sample undergoes high-dimensional feature extraction via a feature extraction module to obtain the single-batch sample feature Fc512_all. Fc512_all is then separated to obtain the first-format image feature. The first loss, `base_loss`, is calculated by taking the original image features `a_fc512`, the second-formatted original image features `b1_fc512`, and the second-formatted enhanced image features `b2_fc512`. All three features (`a_fc512`, `b1_fc512`, and `b2_fc512`) are fed into a traditional classification layer. The second loss, `base_loss`, is then calculated based on the similarity between the second-formatted features `b1_fc512` and `b2_fc512`. Finally, the total loss `All_Loss` is calculated based on the first and second losses, and subsequent parameter updates are performed based on the total loss. For example, , where a represents the weight of the second loss, which can be adjusted according to the actual situation, for example a=0.2, and the specific value is not limited.
[0119] In this embodiment of the invention, the feature extraction module for extracting features from a single batch of processed samples can be the same as or different from the aforementioned feature extraction module for extracting features from the first format image and the second format image. The specific network structure can be adjusted according to actual needs and is not limited here.
[0120] The technical solution of this embodiment uses different loss functions to calculate image features of different formats, so as to highlight the different effects of image features of different formats on model updates and iterations, thereby improving the robustness of the model while ensuring the accuracy of model training.
[0121] In summary, the training system proposed in this invention, which utilizes two training image formats to improve the robustness of face recognition models in smart park scenarios, has the following specific operation flow:
[0122] The existing face scene images are sent to the sample selection module, and BMP small images that meet the requirements are selected according to the designed selection rules to generate the corresponding training set.
[0123] The BMP training set and the original JPG training set are combined to obtain single-batch samples according to the set batch_size. The images included in the single-batch samples are the images after their respective data augmentation. The augmented single-batch samples are then fed into the recognition network of the face recognition model for high-dimensional feature extraction.
[0124] The high-dimensional features obtained through the recognition network are separated according to feature order and feature length, and the features corresponding to different image formats are sent to the corresponding loss calculation module.
[0125] After feeding all features into the classification layer, calculate the base loss, and then feed the corresponding features from the BMP training set into the classification layer. A second loss is calculated, and these losses are combined to form the total loss for gradient backpropagation and parameter updates. Finally, the entire process is iterated over to complete the model iteration.
[0126] This invention also includes a face recognition method, in which an image to be recognized is input into a face recognition model trained according to any embodiment of this invention to obtain a face recognition result. The image to be recognized can be a first-format image or a second-format image acquired by an image acquisition device in a smart park scenario, and the face recognition result refers to the comparison result between the person in the image to be recognized and the face in the database.
[0127] Specifically, after obtaining the trained face recognition model, it is applied to the smart park scenario. BMP and JPG format images obtained in the scenario are directly input into the trained face recognition model. The model outputs the face recognition results for BMP or JPG format images, realizing the robustness of the model to recognize different image formats.
[0128] Figure 6 This is a schematic diagram of a training device for a face recognition model provided in an embodiment of the present invention. Figure 6 As shown, the device includes:
[0129] The multi-format image determination module 610 is used to acquire multiple face scene images and obtain a first format image and a second format image corresponding to each face based on the face scene images;
[0130] The second format image filtering module 620 is used to filter the second format images based on the similarity comparison results of the first format image and the second format image corresponding to each face, so as to obtain the second format training set.
[0131] The single batch processing sample determination module 630 is used to determine a single batch processing sample based on a first preset number of first format images and a second preset number of second format images in the second format training set.
[0132] The model parameter adjustment module 640 is used to update and adjust the parameters of the face recognition model according to each batch of samples to obtain the trained face recognition model.
[0133] The technical solution of this embodiment filters the second format image based on the similarity between the first format image and the second format image, and then constructs a single batch of samples based on the filtered second format image and the first format image. This achieves the goal of increasing the robustness of the model by adding multi-format images to the training samples of the model, while reducing the memory pressure caused by the addition of training images of different formats.
[0134] Optional, a second-format image filtering module, specifically used for:
[0135] Determine the first feature matrix of all first-format images and the second feature matrix of all second-format images;
[0136] The first similarity matrix is determined based on the first feature matrix and the second feature matrix;
[0137] Based on the first similarity matrix, a first target face is determined corresponding to the first format image and the second format image having a similarity lower than a first similarity threshold. A second format training set is then constructed based on the second format image corresponding to the first target face.
[0138] Optional, a single-batch sample determination module includes:
[0139] The second format image copying unit is used to copy the second preset number of second format images to obtain the second preset number of second format copied images;
[0140] The second format copy image enhancement unit is used to enhance the second preset number of second format copy images respectively to obtain a second format enhanced image;
[0141] The first format image enhancement unit is used to enhance the first preset number of first format images respectively to obtain a first format enhanced image;
[0142] A single batch processing sample construction unit is used to arrange the first format enhanced image, the second format enhanced image, and the second preset number of second format images in a preset order to obtain a single batch processing sample; wherein, the single batch processing sample inputs different types of images into the face recognition model in the preset order, and images of the same type are adjacent in the preset order.
[0143] Optionally, a second-format copy image enhancement unit is used specifically for:
[0144] The second format copy images are encoded according to the format characteristics of the first format image to obtain the encoding result of the second format copy image;
[0145] The encoding result of the second format copied image is decoded to obtain the second format enhanced image corresponding to each second format copied image.
[0146] Optional, the model parameter tuning module includes:
[0147] A multi-format image feature extraction unit is used to determine first-format image features and second-format image features based on the feature recognition results of each batch of processed samples.
[0148] The parameter adjustment unit is used to update and adjust the parameters of the face recognition model based on the classification prediction results of the first format image features and the second format image features, so as to obtain the trained face recognition model.
[0149] Optional, multi-format image feature extraction unit, specifically used for:
[0150] Based on the feature recognition results of each batch of processed samples, determine the first format image features corresponding to the first format enhanced image, the second format enhanced image features corresponding to the second format enhanced image, and the second format original image features corresponding to the second format image; wherein, the second format enhanced image features and the second format original image features constitute the second format image features.
[0151] Optional parameter adjustment unit, including:
[0152] The first loss determination subunit is used to determine the first loss corresponding to the classification prediction results of the first format image features and the second format image features respectively using a first loss function;
[0153] The second loss determination subunit is used to determine the second loss corresponding to the second format image features using a second loss function;
[0154] The total loss adjustment subunit is used to determine the total loss based on the first loss and the second loss, and to update and adjust the parameters of the face recognition model based on the total loss.
[0155] Optionally, the second loss determination subunit is specifically used for:
[0156] Determine a second similarity matrix between the enhanced image features of the second format and the original image features of the second format;
[0157] Based on the second similarity matrix, determine the second target face corresponding to the second format enhanced image feature and the second format original image feature having a similarity lower than the second similarity threshold, and determine the target feature similarity of the second target face in the second similarity matrix;
[0158] The second loss is determined based on the similarity of the target features.
[0159] Optionally, the second loss determination subunit includes:
[0160] The second loss is determined according to the following formula:
[0161]
[0162] in, This indicates the second loss. The similarity of the target features corresponding to the i-th second target face is defined as the similarity between the i-th original image feature of the second format and the i-th enhanced image feature of the second format corresponding to the same face being lower than the second similarity threshold. n represents the total number of second target faces.
[0163] The face recognition model training device provided in this embodiment of the invention can execute the face recognition model training method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method. The acquisition, storage, use, and processing of data in this application comply with relevant laws and regulations and do not violate public order and good morals.
[0164] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0165] Figure 7 A schematic diagram of an electronic device 10 that can be used to implement embodiments of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (such as helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0166] like Figure 7As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 can also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0167] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0168] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as the training of a face recognition model.
[0169] In some embodiments, the training of the method face recognition model can be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the training of the method face recognition model described above can be performed. Alternatively, in other embodiments, processor 11 can be configured to perform the training of the method face recognition model by any other suitable means (e.g., by means of firmware).
[0170] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific reference products (ASSPs), systems-on-a-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0171] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0172] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0173] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0174] The systems and technologies described herein can be implemented in computing systems that include back-end components (e.g., as data servers), or computing systems that include switching components (e.g., application servers), or computing systems that include front-end components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such back-end, switching, or front-end components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0175] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through a communication network. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0176] In particular, according to embodiments of the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present invention include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication unit 19, or installed from storage unit 18, or installed from ROM 12. When the computer program is executed by processor 11, it performs the functions defined in the methods of the embodiments of the present invention.
[0177] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0178] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A method for training a face recognition model, the method comprising: The method comprises: obtaining a plurality of face scene graphs, and obtaining a first format image and a second format image corresponding to each face according to the face scene graph; wherein the first format image and the second format image comprise a face, the first format is different from the second format, and the memory size of the first format image corresponding to the same face subgraph is smaller than that of the second format image; determining a first feature matrix of all first format images and a second feature matrix of all second format images, determining a first similarity matrix according to the first feature matrix and the second feature matrix, determining a first target face corresponding to a similarity between the first format image and the second format image being lower than a first similarity threshold according to the first similarity matrix, and constructing a second format training set according to the second format image corresponding to the first target face; determining a single batch processing sample according to a first preset number of first format images and a second preset number of second format images in the second format training set; updating and adjusting the parameters of the face recognition model according to each single batch processing sample to obtain a trained face recognition model; inputting the first format image or the second format image obtained in the scene into the trained face recognition model, and outputting a face recognition result of the first format image or the second format image by the face recognition model.
2. The method of claim 1, wherein, Determining a single batch processing sample according to a first preset number of first format images and a second preset number of second format images in the second format training set comprises: copying the second preset number of second format images to obtain a second preset number of second format copy images; performing image enhancement on the second preset number of second format copy images respectively to obtain second format enhanced images; performing image enhancement on the first preset number of first format images respectively to obtain first format enhanced images; arranging the first format enhanced images, the second format enhanced images and the second preset number of second format images in a preset order to obtain a single batch processing sample; wherein different types of images are input into the face recognition model according to the preset order, and images of the same type are adjacent in the preset order.
3. The method of claim 2, wherein, Performing image enhancement on the second preset number of second format copy images respectively to obtain second format enhanced images comprises: encoding each second format copy image according to the format characteristics of the first format image to obtain a second format copy image encoding result; decoding the second format copy image encoding result to obtain a second format enhanced image corresponding to each second format copy image.
4. The method of claim 2, wherein, Updating and adjusting the parameters of the face recognition model according to each single batch processing sample to obtain a trained face recognition model comprises: determining first format image features and second format image features according to the feature recognition results of each single batch processing sample; updating and adjusting the parameters of the face recognition model according to the classification prediction results of the first format image features and the second format image features to obtain a trained face recognition model.
5. The method of claim 4, wherein, The first format image features and the second format image features are determined according to the feature recognition results of the single batch processing samples, and the determination includes: The first format image features corresponding to the first format enhanced image, the second format enhanced image features corresponding to the second format enhanced image, and the second format original image features corresponding to the second format image are determined according to the feature recognition results of the single batch processing samples; wherein the second format enhanced image features and the second format original image features constitute the second format image features.
6. The method of claim 5, wherein, The parameters of the face recognition model are updated and adjusted according to the classification prediction results of the first format image features and the second format image features, and the updating and adjusting includes: A first loss function is used to determine a first loss corresponding to the classification prediction results of the first format image features and the second format image features respectively; A second loss function is used to determine a second loss corresponding to the second format image features; The total loss is determined according to the first loss and the second loss, and the parameters of the face recognition model are updated and adjusted according to the total loss.
7. The method of claim 6, wherein, The second loss corresponding to the second format image features is determined by using a second loss function, and the determination includes: A second similarity matrix between the second format enhanced image features and the second format original image features is determined; A second target face whose similarity between the second format enhanced image features and the second format original image features is lower than a second similarity threshold is determined according to the second similarity matrix, and a target feature similarity corresponding to the second target face in the second similarity matrix is determined; The second loss is determined according to the target feature similarity.
8. The method of claim 7, wherein, The second loss is determined according to the target feature similarity, and the determination includes: The second loss is determined according to the following formula: ; wherein, denotes a second loss, denotes a target feature similarity corresponding to the i-th second target face, and n denotes a total number of second target faces. 9.A device for training a face recognition model, characterized in that, The device includes: A multi-format image determination module is configured to obtain multiple face scene graphs, and obtain a first format image and a second format image corresponding to each face according to the face scene graphs; wherein a face is included in the first format image and the second format image, the first format is different from the second format, and the memory size of the first format image corresponding to the same face subgraph is smaller than that of the second format image; A second format image screening module is configured to determine a first feature matrix of all first format images and a second feature matrix of all second format images, determine a first similarity matrix according to the first feature matrix and the second feature matrix, determine a first target face whose similarity between the first format image and the second format image is lower than a first similarity threshold according to the first similarity matrix, and construct a second format training set according to the second format image corresponding to the first target face; A single batch processing sample determination module is configured to determine a single batch processing sample according to a first preset number of first format images and a second preset number of second format images in the second format training set. The model parameter adjustment module is configured to update and adjust parameters of the face recognition model according to each single batch of samples, to obtain a trained face recognition model; and input the first format image or the second format image obtained in the scene into the trained face recognition model, and the face recognition model outputs a face recognition result of the first format image or the second format image.
Citation Information
Patent Citations
Face recognition method and device, electronic equipment and storage medium
CN117037231A
Identification apparatus, identification method, and training method
US20230025814A1