Training methods, devices, computer equipment, and storage media for feature recognition models
By employing the knowledge distillation method and utilizing a feature cache queue to calculate the feature distribution loss of teacher and student models, and updating the student model parameters, the problem of low accuracy in training small network models is solved, and efficient object recognition is achieved.
Patent Information
- Application Number
- CN202211285808.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-20
- Publication Date
- 2026-11-17
- Estimated Expiration
- 2042-10-20
AI Technical Summary
Existing small-scale network object recognition models are prone to getting stuck in local minima during training, resulting in low recognition accuracy and making it difficult to achieve high-accuracy object recognition in a short period of time.
The knowledge distillation method is adopted. By calculating the feature distribution loss between a pre-trained large teacher recognition model and an untrained small student recognition model, knowledge transfer is performed using a feature cache queue to update the network parameters of the student model so that it is closer to the feature distribution of the teacher model.
It improves the accuracy of the object recognition model, ensures that the student model converges to the nearest point of the teacher model during training, and achieves efficient feature recognition and object recognition.
Smart Images

Figure CN117036844B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to a method, apparatus, computer device, storage medium, and computer program product for training a feature recognition model. Background Technology
[0002] With the development of computer technology, object recognition technology has emerged. Object recognition is a recognition technology that identifies objects based on their characteristic information. It involves a series of related technologies that use cameras or webcams to capture images or video streams containing objects, automatically detect objects in the images, and then identify the detected objects.
[0003] Currently, object recognition systems applied in real-world scenarios such as smart locks, payments, and access control place high demands on the running time and accuracy of object recognition models. They require higher recognition accuracy with minimal inference time. To meet these time requirements, in real-world scenarios, small networks trained with large amounts of data are typically used as the recognition inference model.
[0004] However, because small networks have relatively low fitting ability, they may get stuck in local minima of the constraint function during training and then start to oscillate and cannot be further optimized. Using small networks trained with a large amount of data as recognition and inference models results in low object recognition accuracy. Summary of the Invention
[0005] Therefore, it is necessary to provide a training method, apparatus, computer device, computer-readable storage medium, and computer program product that can support the improvement of object recognition accuracy for the aforementioned technical problems, as well as an object recognition method, apparatus, computer device, storage medium, and computer program product that can improve object recognition accuracy.
[0006] Firstly, this application provides a method for training a feature recognition model. The method includes:
[0007] Obtain a feature cache queue filled with features, a pre-trained teacher recognition model, and an untrained student recognition model. The teacher recognition model has more network parameters than the student recognition model.
[0008] Read the feature recognition training data, input the read feature recognition training data into the teacher recognition model to obtain the first recognition feature, and input the read feature recognition training data into the student recognition model to obtain the second recognition feature;
[0009] Based on the feature cache queue, the feature distribution loss between the first identification feature and the second identification feature is calculated, and the features in the feature cache queue are updated based on the first identification feature and the second identification feature.
[0010] The network parameters of the student recognition model are updated based on the feature distribution loss. The process then jumps to the step of reading the feature recognition training data until the termination condition for model training is met. The latest student recognition model is then used as the feature recognition model.
[0011] Secondly, this application also provides a training apparatus for a feature recognition model. The apparatus includes:
[0012] The data acquisition module is used to acquire a feature cache queue filled with features, a pre-trained teacher recognition model, and an untrained student recognition model. The teacher recognition model has more network parameters than the student recognition model.
[0013] The data recognition module is used to read feature recognition training data, input the read feature recognition training data into the teacher recognition model to obtain the first recognition feature, and input the read feature recognition training data into the student recognition model to obtain the second recognition feature;
[0014] The feature processing module is used to calculate the feature distribution loss between the first identification feature and the second identification feature based on the feature cache queue, and update the features in the feature cache queue based on the first identification feature and the second identification feature;
[0015] The model adjustment module is used to update the network parameters of the student recognition model based on the feature distribution loss, jump to the step of reading the feature recognition training data, until the termination of model training conditions are met, and use the latest student recognition model as the feature recognition model.
[0016] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:
[0017] Obtain a feature cache queue filled with features, a pre-trained teacher recognition model, and an untrained student recognition model. The teacher recognition model has more network parameters than the student recognition model.
[0018] Read the feature recognition training data, input the read feature recognition training data into the teacher recognition model to obtain the first recognition feature, and input the read feature recognition training data into the student recognition model to obtain the second recognition feature;
[0019] Based on the feature cache queue, the feature distribution loss between the first identification feature and the second identification feature is calculated, and the features in the feature cache queue are updated based on the first identification feature and the second identification feature.
[0020] The network parameters of the student recognition model are updated based on the feature distribution loss. The process then jumps to the step of reading the feature recognition training data until the termination condition for model training is met. The latest student recognition model is then used as the feature recognition model.
[0021] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:
[0022] Obtain a feature cache queue filled with features, a pre-trained teacher recognition model, and an untrained student recognition model. The teacher recognition model has more network parameters than the student recognition model.
[0023] Read the feature recognition training data, input the read feature recognition training data into the teacher recognition model to obtain the first recognition feature, and input the read feature recognition training data into the student recognition model to obtain the second recognition feature;
[0024] Based on the feature cache queue, the feature distribution loss between the first identification feature and the second identification feature is calculated, and the features in the feature cache queue are updated based on the first identification feature and the second identification feature.
[0025] The network parameters of the student recognition model are updated based on the feature distribution loss. The process then jumps to the step of reading the feature recognition training data until the termination condition for model training is met. The latest student recognition model is then used as the feature recognition model.
[0026] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:
[0027] Obtain a feature cache queue filled with features, a pre-trained teacher recognition model, and an untrained student recognition model. The teacher recognition model has more network parameters than the student recognition model.
[0028] Read the feature recognition training data, input the read feature recognition training data into the teacher recognition model to obtain the first recognition feature, and input the read feature recognition training data into the student recognition model to obtain the second recognition feature;
[0029] Based on the feature cache queue, the feature distribution loss between the first identification feature and the second identification feature is calculated, and the features in the feature cache queue are updated based on the first identification feature and the second identification feature.
[0030] The network parameters of the student recognition model are updated based on the feature distribution loss. The process then jumps to the step of reading the feature recognition training data until the termination condition for model training is met. The latest student recognition model is then used as the feature recognition model.
[0031] Sixthly, this application provides an object recognition method. The method includes:
[0032] Acquire the image of the object to be identified;
[0033] The pre-trained feature recognition model extracts features from the image of the object to be recognized, and obtains the corresponding image features of the image of the object to be recognized. The pre-trained special recognition model is obtained through the training method of the above feature recognition model.
[0034] Based on image features, feature comparison and recognition are performed to obtain object recognition results.
[0035] Seventhly, this application also provides an object recognition device. The device includes:
[0036] The image acquisition module is used to acquire images of the object to be identified.
[0037] The feature recognition module is used to extract features from the image of the object to be recognized through a pre-trained feature recognition model, thereby obtaining the corresponding image features of the image of the object to be recognized. The pre-trained feature recognition model is obtained through the training method of the aforementioned feature recognition model.
[0038] The feature comparison and search module is used to perform feature comparison and recognition based on image features to obtain object recognition results.
[0039] Eighthly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:
[0040] Acquire the image of the object to be identified;
[0041] The pre-trained feature recognition model extracts features from the image of the object to be recognized, and obtains the corresponding image features of the image of the object to be recognized. The pre-trained special recognition model is obtained through the training method of the above feature recognition model.
[0042] Based on image features, feature comparison and recognition are performed to obtain object recognition results.
[0043] Ninthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:
[0044] Acquire the image of the object to be identified;
[0045] The pre-trained feature recognition model extracts features from the image of the object to be recognized, and obtains the corresponding image features of the image of the object to be recognized. The pre-trained special recognition model is obtained through the training method of the above feature recognition model.
[0046] Based on image features, feature comparison and recognition are performed to obtain object recognition results.
[0047] Tenthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:
[0048] Acquire the image of the object to be identified;
[0049] The pre-trained feature recognition model extracts features from the image of the object to be recognized, and obtains the corresponding image features of the image of the object to be recognized. The pre-trained special recognition model is obtained through the training method of the above feature recognition model.
[0050] Based on image features, feature comparison and recognition are performed to obtain object recognition results.
[0051] The aforementioned training method, apparatus, computer equipment, storage medium, and computer program product for the feature recognition model employ a feature cache queue during the training process to calculate the feature distribution loss between the first recognition feature obtained from the teacher recognition model and the second recognition feature obtained from the student recognition model. The features in the feature cache queue are updated based on the first and second recognition features. This constrains the distribution of the student recognition model to be consistent with that of the teacher recognition model. Therefore, the student recognition model can learn the feature distribution of the teacher recognition model. In other words, by using a pre-trained teacher recognition model and a feature cache queue to perform knowledge distillation on the untrained student recognition model, the feature distribution of the teacher recognition model can be transferred to the student recognition model. This ensures that during the training process of the student recognition model, the convergence position of the features extracted by the student recognition model is a neighboring point to the convergence of the teacher recognition model. Consequently, the student recognition model obtained based on knowledge distillation can achieve accurate feature recognition, and thus, the accuracy of object recognition can be improved by utilizing a student recognition model that can achieve accurate feature recognition.
[0052] The aforementioned object recognition methods, apparatus, computer devices, storage media, and computer program products, by utilizing a pre-trained feature recognition model capable of accurate feature recognition to extract features from the image of the object to be recognized, can obtain accurate image features, and then use these accurate image features for feature comparison and recognition, thereby achieving accurate object recognition, obtaining object recognition results, and improving the accuracy of object recognition. Attached Figure Description
[0053] Figure 1 This is a diagram illustrating the application environment of a training method for a feature recognition model in one embodiment.
[0054] Figure 2 This is a flowchart illustrating the training method of a feature recognition model in one embodiment;
[0055] Figure 3 This is a flowchart illustrating the training process for training a teacher recognition model in one embodiment.
[0056] Figure 4 This is a flowchart illustrating the training method of the feature recognition model in another embodiment;
[0057] Figure 5 This is a flowchart illustrating the training process of a small recognition model using queue-based contrastive learning in one embodiment.
[0058] Figure 6 The following is a flowchart of the training process for a small model that is initially optimized using queue-based contrastive learning in another embodiment;
[0059] Figure 7 This is a schematic diagram illustrating network module training and network model deployment in one embodiment;
[0060] Figure 8 This is a schematic diagram of the network model deployment in one embodiment;
[0061] Figure 9 This is a diagram illustrating the application environment of an object recognition method in one embodiment;
[0062] Figure 10 This is a flowchart illustrating an object recognition method in one embodiment;
[0063] Figure 11 This is a structural block diagram of a training device for a feature recognition model in one embodiment;
[0064] Figure 12 This is a structural block diagram of an object recognition device in one embodiment;
[0065] Figure 13 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0066] This application relates to the field of artificial intelligence (AI). AI is the theory, methods, technology, and application systems that utilize digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that attempts to understand the essence of intelligence and produce a new type of intelligent machine capable of reacting in a manner similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to possess perception, reasoning, and decision-making capabilities.
[0067] Artificial intelligence (AI) is a comprehensive discipline encompassing a wide range of fields, including both hardware and software technologies. Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies primarily include computer vision, speech processing, natural language processing, and machine learning / deep learning. This application mainly focuses on computer vision and machine learning / deep learning.
[0068] Computer vision (CV) is the science that studies how to enable machines to "see." More specifically, it refers to machine vision, which uses cameras and computers to replace human eyes in recognizing and measuring targets, and then performs image processing to create images more suitable for human observation or transmission to instruments. As a scientific discipline, computer vision studies related theories and technologies, attempting to build artificial intelligence systems capable of extracting information from images or multidimensional data. Computer vision technologies typically include image processing, image recognition, image semantic understanding, image retrieval, OCR, video processing, video semantic understanding, video content / behavior recognition, 3D object reconstruction, 3D technology, virtual reality, augmented reality, simultaneous localization and mapping (SLAM), and biometric recognition technologies such as object recognition and fingerprint recognition.
[0069] Machine Learning (ML) is a multidisciplinary field involving probability theory, statistics, approximation theory, convex analysis, and algorithm complexity theory. It specifically studies how computers can simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to endow computers with intelligence; its applications span all areas of artificial intelligence. Machine learning and deep learning typically include techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and instructional learning.
[0070] Specifically, this application mainly involves a knowledge distillation method. This method uses a large neural network model trained on a large feature recognition training dataset as the teacher model and another neural network model as the student model. The student model is trained using the teacher model, overcoming the training difficulties of small neural network models on large datasets. After training, the student model can achieve test results close to or exceeding those of the teacher model on the task. This method can be seen as a knowledge transfer technique, transferring knowledge from the teacher model to the student model through training.
[0071] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0072] The training method for the feature recognition model provided in this application embodiment can be applied to, for example... Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or placed on a cloud or other server. Server 104 obtains from terminal 102 a feature cache queue filled with features, a pre-trained teacher recognition model, and an untrained student recognition model. The teacher recognition model has more network parameters than the student recognition model. It reads feature recognition training data, inputs the read feature recognition training data into the teacher recognition model to obtain the first recognition feature, and inputs the read feature recognition training data into the student recognition model to obtain the second recognition feature. Based on the feature cache queue, it calculates the feature distribution loss between the first and second recognition features, updates the features in the feature cache queue based on the first and second recognition features, updates the network parameters of the student recognition model based on the feature distribution loss, and then jumps to the step of reading feature recognition training data until the model training termination condition is met. The latest student recognition model is then used as the feature recognition model.
[0073] The terminal 102 can be, but is not limited to, various desktop computers, laptops, smartphones, tablets, IoT devices, portable wearable devices, and aircraft. IoT devices can include smart speakers, smart TVs, smart air conditioners, and smart in-vehicle systems. Portable wearable devices can include smartwatches, smart bracelets, and head-mounted devices. The server 104 can be implemented using a standalone server or a server cluster consisting of multiple servers.
[0074] In one embodiment, such as Figure 2 As shown, a method for training a feature recognition model is provided. This method can be executed by a terminal or a server alone, or by both the terminal and the server collaboratively. In this embodiment, the method is described using a server as an example, and includes the following steps:
[0075] Step 202: Obtain a feature cache queue filled with features, a pre-trained teacher recognition model, and an untrained student recognition model. The teacher recognition model has more network parameters than the student recognition model.
[0076] In this context, a feature cache queue refers to a queue filled with features as queue elements. A queue is a special type of linear list, unique in that it only allows deletion operations at the front of the list and insertion operations at the back. Like a stack, a queue is a linear list with restricted operations. The end where insertion occurs is called the tail, and the end where deletion occurs is called the head. A queue without elements is called an empty queue. The data elements of a queue are also called queue elements. In this embodiment, a queue element refers to the features cached in the queue. Inserting a queue element into the queue is called enqueueing, and deleting a queue element is called dequeueing. Because a queue only allows insertion at one end and deletion at the other, only the element that entered the queue earliest can be deleted first; therefore, a queue is also called a first-in, first-out (FIFO) linear list. In this embodiment, the size of the queue and the number of features it contains can be configured according to the actual application scenario. The types of features filled in can be the same as the first recognition feature output by the teacher recognition model and the second recognition feature output by the student recognition model. For example, when the first and second recognition features are image features, the filled features are image features.
[0077] In this context, the pre-trained teacher recognition model refers to a large-scale pre-trained neural network model, while the untrained student recognition model refers to a small-scale untrained neural network model. The teacher recognition model has more network parameters than the student recognition model. Network parameters can be used to characterize the model size; more network parameters indicate a larger model size. In this embodiment, the fact that the teacher recognition model has more network parameters than the student recognition model means that the teacher recognition model is larger than the student recognition model. It should be noted that the model structure of the teacher recognition model is similar to that of the student recognition model. Because the student recognition model has fewer network parameters than the teacher recognition model, the forward inference time required for the student recognition model is shorter. For example, the model structure of the teacher recognition model can be a convolutional neural network, including operations such as convolution calculation, non-linear activation function calculation, and pooling calculation. Similarly, the model structure of the student recognition model can also be a convolutional neural network, including operations such as convolution calculation, non-linear activation function calculation, and pooling calculation.
[0078] Specifically, when training the feature recognition model, the server will obtain a feature cache queue filled with features, a pre-trained teacher recognition model, and an untrained student recognition model. The teacher recognition model has more network parameters than the student recognition model. The server can perform distillation training on the untrained student recognition model based on the feature cache queue filled with features and the pre-trained teacher recognition model, so as to obtain the feature recognition model based on the student recognition model obtained from the distillation training.
[0079] Step 204: Read the feature recognition training data, input the read feature recognition training data into the teacher recognition model to obtain the first recognition feature, and input the read feature recognition training data into the student recognition model to obtain the second recognition feature.
[0080] In this context, feature recognition training data refers to the data used to train an untrained student recognition model. For example, feature recognition training data refers to images used to train an untrained student recognition model. Specifically, feature recognition training data can refer to object images used to train an untrained student recognition model. In a specific application, feature recognition training data can specifically refer to face images used to train an untrained student recognition model.
[0081] Specifically, the server reads feature recognition training data from the pre-configured feature recognition training dataset, inputs the read feature recognition training data into the teacher recognition model so that the teacher recognition model outputs the first recognition feature, and inputs the read feature recognition training data into the student recognition model so that the student recognition model outputs the second recognition model.
[0082] In practical applications, after the read feature recognition training data is input into the teacher recognition model, the teacher recognition model can output the first recognition feature through operations such as convolution calculation, non-linear activation function calculation, and pooling calculation. Similarly, after the read feature recognition training data is input into the student recognition model, the student recognition model can also output the second recognition model through operations such as convolution calculation, non-linear activation function calculation, and pooling calculation.
[0083] In specific applications, the feature recognition training data can be a batch of data including at least one data. After the read feature recognition training data is input into the teacher recognition model, the obtained first recognition feature includes the first feature corresponding to each of the at least one data. After the read feature recognition training data is input into the student recognition model, the obtained second recognition feature includes the second feature corresponding to each of the at least one data.
[0084] In a specific application, the feature recognition training data may specifically be a batch of images including at least one image. The obtained first recognition feature includes a first feature corresponding to each of the at least one image, and the obtained second recognition feature includes a second feature corresponding to each of the at least one image.
[0085] Step 206: Based on the feature cache queue, calculate the feature distribution loss between the first identification feature and the second identification feature, and update the features in the feature cache queue based on the first identification feature and the second identification feature.
[0086] The feature distribution loss describes the difference in feature distribution between the first feature distribution corresponding to the first recognition feature and the second feature distribution corresponding to the second recognition feature, and is used to characterize the distribution distance between the teacher recognition model and the student recognition model. The smaller the feature distribution loss, the smaller the distribution distance between the teacher recognition model and the student recognition model, that is, the closer the distributions of the teacher recognition model and the student recognition model are.
[0087] Specifically, the server calculates the feature distributions for the first and second identification features based on the feature cache queue, obtaining a first feature distribution corresponding to the first identification feature and a second feature distribution corresponding to the second identification feature. Then, based on the first and second feature distributions, it calculates the feature distribution loss between the first and second identification features. Here, the first feature distribution refers to the distribution of the first identification feature in the feature cache queue, and the second feature distribution refers to the distribution of the second identification feature in the feature cache queue.
[0088] Specifically, after calculating the feature distribution loss between the first and second identification features, the server updates the features in the feature cache queue based on the first and second identification features. During the update, the server determines the number and type of queues in the feature cache queue, determines the identification features that need to enter the feature cache queue based on the number and type of queues, updates the identification features that need to enter the feature cache queue to the feature cache queue, and deletes a corresponding number of features from the feature cache queue based on the number of identification features entering the feature cache queue, so that the number of features in the position feature cache queue remains unchanged.
[0089] The number and type of queues can be configured according to the actual application scenario. For example, the feature cache queue can contain one queue, which is the first cache queue corresponding to the teacher recognition model. Alternatively, the feature cache queue can contain two queues, including a first cache queue corresponding to the teacher recognition model and a second cache queue corresponding to the student recognition model.
[0090] Step 208: Update the network parameters of the student recognition model based on the feature distribution loss, and jump to the step of reading the feature recognition training data until the termination model training condition is met, and use the latest student recognition model as the feature recognition model.
[0091] The termination condition refers to the condition for stopping the training of the student recognition model, and can be configured according to the actual application scenario. For example, the termination condition could be that the number of training iterations meets a set threshold. Another example is that the feature distribution loss is less than a set loss threshold. Yet another example is that the feature distribution loss converges.
[0092] Specifically, the server updates the network parameters of the student recognition model based on the feature distribution loss, then jumps to the step of reading feature recognition training data to continue training the student recognition model. During each training session, the server inputs the read feature recognition training data into the teacher recognition model to obtain the first recognition feature, and inputs the read feature recognition training data into the student recognition model to obtain the second recognition feature. Based on the feature cache queue, the server calculates the feature distribution loss between the first and second recognition features until the model training termination condition is met, indicating that the student recognition model has been trained. The server then uses the latest student recognition model as the feature recognition model.
[0093] In this embodiment, no specific limitation is placed on the method of updating the network parameters of the student recognition model based on feature distribution loss, as long as the network parameters can be updated. In specific applications, the server can update the network parameters of the student recognition model based on gradient descent combined with feature distribution loss. In a specific application, the gradient descent method can be stochastic gradient descent, stochastic gradient descent with moving averages, etc.
[0094] In practical applications, the feature cache queue used during each training session is continuously updated. Specifically, after calculating the feature distribution loss during each training session, the server updates the feature cache queue based on the first and second recognition features obtained in the current training. It also removes a corresponding number of features from the feature cache queue based on the number of features added to it. The updated feature cache queue can then be used for the next training session. The feature cache queue used in the current training session is obtained by updating the feature cache queue used in the previous training session based on the first and second recognition features obtained in the corresponding previous training session.
[0095] The training method for the aforementioned feature recognition model employs a feature cache queue to calculate the feature distribution loss between the first recognition feature obtained from the teacher recognition model and the second recognition feature obtained from the student recognition model during the training process. The features in the feature cache queue are updated based on the first and second recognition features, which constrains the distribution of the student recognition model to be consistent with that of the teacher recognition model. Therefore, the student recognition model can learn the feature distribution of the teacher recognition model. In other words, by using a pre-trained teacher recognition model and a feature cache queue to perform knowledge distillation on the untrained student recognition model, the feature distribution of the teacher recognition model can be transferred to the student recognition model. This ensures that during the training process of the student recognition model, the convergence position of the features extracted by the student recognition model is a neighboring point to the convergence of the teacher recognition model. Consequently, the student recognition model obtained based on knowledge distillation can achieve accurate feature recognition, and thus, the accuracy of object recognition can be improved by utilizing a student recognition model that can achieve accurate feature recognition.
[0096] In one embodiment, calculating the feature distribution loss between the first and second identified features based on the feature cache queue includes:
[0097] Based on the feature cache queue, feature distribution calculations are performed on the first identification feature and the second identification feature respectively to obtain the first feature distribution corresponding to the first identification feature and the second feature distribution corresponding to the second identification feature.
[0098] Based on the first feature distribution and the second feature distribution, the feature distribution loss between the first recognition feature and the second recognition feature is obtained.
[0099] Feature distribution calculation refers to calculating the relationship between the identified feature (first identified feature or second identified feature) and the features in the feature cache queue. Based on this relationship, the distribution of the identified feature in the feature cache queue is determined. For example, feature distribution calculation can specifically refer to calculating the similarity between the identified feature and the features in the feature cache queue, and determining the distribution of the identified feature in the feature cache queue based on this similarity.
[0100] Here, the first feature distribution refers to the distribution of the first recognition feature in the feature cache queue. The second feature distribution refers to the distribution of the second recognition feature in the feature cache queue. If the difference between the first feature distribution and the second feature distribution is small, it means that the difference between the first recognition feature and the second recognition feature is small. Since the first and second recognition features were obtained by processing the same feature recognition training data, if the difference between the first and second recognition features is small, it can be considered that the difference between the teacher recognition model and the student recognition model is small, and the student recognition model has learned the feature distribution of the teacher recognition model, that is, the feature distribution of the teacher recognition model has been transferred to the student recognition model.
[0101] Specifically, the server determines the number and type of queues in the feature cache queue, and then calculates the feature distribution for the first and second identification features based on the number and type of queues. This yields the first feature distribution corresponding to the first identification feature and the second feature distribution corresponding to the second identification feature. The server then calculates the feature distribution difference between the first and second feature distributions to obtain the feature distribution loss between the first and second identification features.
[0102] In practical applications, if the feature cache queue contains only one cache queue, the server can directly calculate the feature distribution for the first and second identification features based on the features in that cache queue. If the feature cache queue contains cache queues corresponding to the teacher identification model and the student identification model, respectively, the server will calculate the feature distribution for the first identification feature based on the features in the cache queue corresponding to the teacher identification model, and calculate the feature distribution for the second identification feature based on the features in the cache queue corresponding to the student identification model.
[0103] In specific applications, the feature recognition training data can be a batch of data including at least one data point. The resulting first recognition feature includes a first feature corresponding to each of the at least one data point, and the resulting second recognition feature includes a second feature corresponding to each of the at least one data point. During feature distribution calculation, the server performs feature distribution calculations on the first features corresponding to each of the at least one data point, obtaining the feature distribution corresponding to the first features of each of the at least one data point, and then performs feature distribution calculations on the second features corresponding to each of the at least one data point, obtaining the feature distribution corresponding to the second features of each of the at least one data point. That is, the first feature distribution includes the feature distribution corresponding to the first features of each of the at least one data point, and the second feature distribution includes the feature distribution corresponding to the second features of each of the at least one data point.
[0104] In a specific application, if the first feature distribution includes a feature distribution corresponding to the first feature of each of the at least one data points, and the second feature distribution includes a feature distribution corresponding to the second feature of each of the at least one data points, when calculating the feature distribution difference between the first feature distribution and the second feature distribution, for each of the at least one data points, the server will first calculate the feature distribution difference between the feature distribution corresponding to the first feature of the data point and the feature distribution corresponding to the second feature of the data point, and then obtain the feature distribution loss between the first recognition feature and the second recognition feature based on the feature distribution difference corresponding to each data point.
[0105] In this embodiment, by calculating the feature distribution of the first identification feature and the second identification feature based on the feature cache queue, the first feature distribution corresponding to the first identification feature and the second feature distribution corresponding to the second identification feature can be obtained. Then, based on the first feature distribution and the second feature distribution, the feature distribution difference can be determined and the feature distribution loss between the first identification feature and the second identification feature can be obtained.
[0106] In one embodiment, the feature cache queue includes a first cache queue corresponding to the teacher identification model;
[0107] Based on the feature cache queue, feature distributions are calculated for the first identification feature and the second identification feature, respectively, to obtain the first feature distribution corresponding to the first identification feature and the second feature distribution corresponding to the second identification feature, including:
[0108] The first feature distribution is obtained by calculating the feature distribution of the first identification feature based on the first cache queue, and the second feature distribution is obtained by calculating the feature distribution of the second identification feature based on the first cache queue.
[0109] Updating features in the feature cache queue based on the first and second identification features includes:
[0110] The first identification feature is updated in the first cache queue, and features corresponding to the number of the first identification features are deleted from the first cache queue.
[0111] Specifically, if the feature cache queue only includes the first cache queue corresponding to the teacher recognition model, when calculating the feature distribution, the server will calculate the feature distribution of the first recognition feature based on the first cache queue to determine the distribution of the first recognition feature in the first cache queue, thus obtaining the first feature distribution. Then, based on the first cache queue, the server will calculate the feature distribution of the second recognition feature to determine the distribution of the second recognition feature in the first cache queue, thus obtaining the second feature distribution. In other words, the server uses the features in the first cache queue as a reference to measure the difference between the first and second recognition features. When updating the features in the feature cache queue, the server will directly update the first recognition feature to the first cache queue and delete features corresponding to the number of first recognition features from the first cache queue to maintain the number of features in the first cache queue unchanged.
[0112] In specific applications, the number of features in the first recognition feature corresponds to the number of data included in the feature recognition training data. That is, if the feature recognition training data is a batch of data including at least one data, then the first recognition model includes a first feature corresponding to each of the at least one data. Therefore, when updating the features in the feature cache queue, the server will delete features corresponding to the number of first features from the first cache queue to keep the number of features in the first cache queue unchanged.
[0113] In a specific application, assuming the number of features in the feature cache queue is n and the number of first features included in the first recognition model is m, when updating the features in the feature cache queue, the server will first update the first cache queue with m first features and then delete the m first-in features from the first cache queue to maintain the number of features in the first cache queue at n.
[0114] In this embodiment, when the feature cache queue includes a first cache queue corresponding to the teacher recognition model, the feature distribution calculation is performed on the first recognition feature and the second recognition feature based on the first cache queue, thereby enabling the determination of the first feature distribution and the second feature distribution. By updating the first recognition feature to the first cache queue and deleting features corresponding to the number of first recognition features from the first cache queue, real-time updating of the first cache queue can be achieved.
[0115] In one embodiment, the feature cache queue includes a first cache queue corresponding to the teacher identification model and a second cache queue corresponding to the student identification model;
[0116] Based on the feature cache queue, feature distributions are calculated for the first identification feature and the second identification feature, respectively, to obtain the first feature distribution corresponding to the first identification feature and the second feature distribution corresponding to the second identification feature, including:
[0117] The first feature distribution is obtained by calculating the feature distribution of the first identification feature based on the first cache queue, and the second feature distribution is obtained by calculating the feature distribution of the second identification feature based on the second cache queue.
[0118] Updating features in the feature cache queue based on the first and second identification features includes:
[0119] Update the first identification feature to the first cache queue, and delete features from the first cache queue corresponding to the number of the first identification features;
[0120] Update the second identification feature to the second cache queue, and delete the feature corresponding to the number of the second identification features from the second cache queue.
[0121] Specifically, if the feature cache queue includes a first cache queue corresponding to the teacher recognition model and a second cache queue corresponding to the student recognition model, when performing feature distribution calculation, the server will perform feature distribution calculation on the first recognition model based on the first cache queue to determine the distribution of the first recognition features in the first cache queue and obtain the first feature distribution. Then, it will perform feature distribution calculation on the second recognition features based on the second cache queue to determine the distribution of the second recognition features in the second cache queue and obtain the second feature distribution. That is, the difference between the first recognition features and the second recognition features is measured with reference to the features in the first cache queue and the features in the second cache queue.
[0122] Specifically, when updating features in the feature cache queue, the first cache queue and the second cache queue also need to be updated separately. The server updates the first identification feature to the first cache queue and deletes features corresponding to the number of the first identification features from the first cache queue to maintain the number of features in the first cache queue unchanged. Similarly, the server updates the second identification feature to the second cache queue and deletes features corresponding to the number of the second identification features from the second cache queue to maintain the number of features in the second cache queue unchanged. In practical applications, the method of updating the second identification feature to the second cache queue and deleting features corresponding to the number of the second identification features from the second cache queue is similar to the method of updating the first identification feature to the first cache queue and deleting features corresponding to the number of the first identification features from the first cache queue, and will not be described in detail here.
[0123] In this embodiment, when the feature cache queue includes a first cache queue corresponding to the teacher recognition model and a second cache queue corresponding to the student recognition model, the feature distribution calculation is performed on the first recognition feature based on the first cache queue, and the feature distribution calculation is performed on the second recognition feature based on the second cache queue. This enables the determination of the first feature distribution and the second feature distribution. By updating the first recognition feature to the first cache queue and deleting features corresponding to the number of first recognition features from the first cache queue, real-time updates to the first cache queue can be achieved. Similarly, by updating the second recognition model to the second cache queue and deleting features corresponding to the number of second recognition features from the second cache queue, real-time updates to the second cache queue can be achieved.
[0124] In one embodiment, the feature recognition training data includes at least one piece of data; the first recognition feature includes a first feature corresponding to each of the at least one piece of data; and the first feature distribution is obtained by calculating the feature distribution of the first recognition feature based on the first cache queue, including:
[0125] For each of the first features corresponding to at least one data point, calculate the first feature association probability between the targeted first feature and each feature in the first cache queue, and obtain the feature distribution corresponding to the targeted first feature based on the first feature association probability corresponding to the targeted first feature.
[0126] A first feature distribution is obtained based on the feature distribution corresponding to the first feature of each of at least one data point.
[0127] The first feature association probability describes the relationship between the targeted first feature and one of the features in the first cache queue. For example, the first feature association probability can be used to describe the similarity between the targeted first feature and one of the features in the first cache queue.
[0128] Specifically, the feature recognition training data can be a batch of data including at least one data. The first recognition feature includes a first feature corresponding to each of the at least one data. When calculating the feature distribution of the first recognition feature based on the first cache queue, for each of the first features corresponding to each of the at least one data, the server will calculate the first feature association probability between the targeted first feature and each feature in the first cache queue, and then add the first feature association probabilities corresponding to the targeted first feature to obtain the first probability sum corresponding to the targeted first feature. The ratio of the first feature association probability corresponding to the targeted first feature to the first probability sum will be calculated to obtain the feature distribution corresponding to the targeted first feature. The feature distribution corresponding to the first feature corresponding to each of the at least one data will then be used as the first feature distribution.
[0129] In specific applications, the method for calculating the association probability of the first feature between the targeted first feature and each feature in the first cache queue can be configured according to the actual application scenario. This embodiment does not limit the method for calculating the association probability of the first feature, as long as the relationship between the targeted first feature and each feature in the first cache queue can be determined. In a specific application, the server first transposes the features in the first cache queue, then calculates the product of the transposed feature and the targeted first feature, and finally obtains the association probability of the first feature based on the product of the transposed feature and the targeted first feature. It should be noted that the features in the first cache queue and the targeted first feature have the same size; therefore, the product of the transposed feature and the targeted first feature can be a single value.
[0130] In a specific application, the association probability of the first feature can be expressed by the formula... The calculation is performed, where exp() represents an exponential function with base e, and f... i q f represents the i-th feature in the first cache queue. i qT This represents the transpose of the i-th feature. This represents the first feature targeted in the first identification feature (the j-th feature in the first identification feature), and γ is a hyperparameter that can be configured according to the actual application scenario. Correspondingly, the first probability sum can be expressed by the formula... Where n is the number of features in the first cache queue. This represents the k-th feature in the first cache queue. This represents the transpose of the k-th feature. Let represent the first feature targeted in the first identification feature (this first feature is the j-th feature in the first identification feature), and γ be a hyperparameter. Then, the distribution value of the i-th feature included in the feature distribution corresponding to the first feature can be expressed by the formula... Calculation. For each feature in the first cache queue, there will be a corresponding distribution value in the feature distribution corresponding to the first feature.
[0131] In this embodiment, by calculating the first feature association probability between the first feature and each feature in the first cache queue for each first feature corresponding to at least one data, the feature distribution corresponding to the first feature can be obtained based on the first feature association probability corresponding to the first feature. Then, the first feature distribution can be obtained based on the feature distribution corresponding to each first feature.
[0132] In one embodiment, the feature recognition training data includes at least one piece of data; the second recognition feature includes a second feature corresponding to each of the at least one piece of data; and the second feature distribution is obtained by calculating the feature distribution of the second recognition feature based on the first cache queue, including:
[0133] For each of the second features corresponding to at least one data point, calculate the second feature association probability between the targeted second feature and each feature in the first cache queue, and obtain the feature distribution corresponding to the targeted second feature based on the second feature association probability corresponding to the targeted second feature.
[0134] A second feature distribution is obtained based on the feature distribution corresponding to at least one second feature of each data point.
[0135] Specifically, the method for calculating the second feature association probability between the targeted second feature and each feature in the first cache queue in this embodiment is similar to the method for calculating the first feature association probability between the targeted first feature and each feature in the first cache queue, and will not be repeated here. The method for obtaining the feature distribution corresponding to the targeted second feature based on the second feature association probability in this embodiment is similar to the method for obtaining the feature distribution corresponding to the targeted first feature based on the first feature association probability, and will not be repeated here.
[0136] In one embodiment, the feature recognition training data includes at least one data point; the second recognition feature includes a second feature corresponding to each of the at least one data point; and the second feature distribution is obtained by calculating the feature distribution of the second recognition feature based on the second cache queue, including:
[0137] For each of the second features corresponding to at least one data point, calculate the third feature association probability between the targeted second feature and each feature in the second cache queue. Based on the third feature association probability corresponding to the targeted second feature, obtain the feature distribution corresponding to the targeted second feature.
[0138] A second feature distribution is obtained based on the feature distribution corresponding to at least one second feature of each data point.
[0139] Specifically, the method for calculating the probability of association of the third feature between the targeted second feature and each feature in the second cache queue in this embodiment is similar to the method for calculating the probability of association of the first feature between the targeted first feature and each feature in the first cache queue, and will not be repeated here. The method for obtaining the feature distribution corresponding to the targeted second feature based on the probability of association of the third feature corresponding to the targeted second feature in this embodiment is similar to the method for obtaining the feature distribution corresponding to the targeted first feature based on the probability of association of the first feature corresponding to the targeted first feature, and will not be repeated here.
[0140] In one embodiment, obtaining the feature distribution loss between the first and second recognition features based on the first feature distribution and the second feature distribution includes:
[0141] Calculate the divergence distance between the first characteristic distribution and the second characteristic distribution;
[0142] The divergence distance is used as the feature distribution loss between the first and second recognition features.
[0143] The divergence distance is used to measure the difference between two probability distributions.
[0144] Specifically, the server calculates the divergence distance between the first feature distribution and the second feature distribution, and uses this divergence distance as the feature distribution loss between the first and second recognition features. In specific applications, the calculated divergence distance can be either KL divergence distance or JS divergence distance; this embodiment does not limit the type of divergence distance.
[0145] In specific applications, the feature recognition training data can be a batch of data including at least one data point. The obtained first recognition feature includes a first feature corresponding to each of the at least one data point, the obtained second recognition feature includes a second feature corresponding to each of the at least one data point, the obtained first feature distribution includes a feature distribution corresponding to the first feature corresponding to each of the at least one data point, and the obtained second feature distribution includes a feature distribution corresponding to the second feature corresponding to each of the at least one data point. Therefore, when calculating the divergence distance between the first feature distribution and the second feature distribution, for each data point, the server first calculates the divergence distance between the feature distribution corresponding to the first feature of the data point and the feature distribution corresponding to the second feature of the data point, and then obtains the divergence distance between the first recognition feature and the second recognition feature based on the divergence distance corresponding to each data point.
[0146] In a specific application, the calculated divergence distance can be the KL divergence distance. The divergence distance between the feature distribution corresponding to the first feature of the data and the feature distribution corresponding to the second feature of the data can be expressed by the formula L(t, s) = ∑ i KL(p i (t)||p i (s) represents, where i represents the data being targeted (the i-th data in the feature recognition training data), p i (t) represents the feature distribution corresponding to the first feature of the data being studied, p i (s) represents the feature distribution corresponding to the second feature of the data being targeted.
[0147] In this embodiment, the divergence distance can be used to measure the feature distribution loss between the first and second identification features.
[0148] In one embodiment, after using the latest student identification model as the feature identification model, the method further includes:
[0149] Read the scene training data, input the read scene training data into the teacher recognition model to obtain the third recognition feature, and input the read scene training data into the feature recognition model to obtain the fourth recognition feature;
[0150] Based on the feature cache queue, the target distribution loss between the third and fourth identification features is calculated, and the features in the feature cache queue are updated based on the third and fourth identification features.
[0151] The network parameters of the feature recognition model are updated based on the target distribution loss. The process then jumps to the step of reading the scene training data until the termination scene adaptation condition is met. The latest feature recognition model is then used as the scene-adapted feature recognition model.
[0152] Scenario training data refers to the data used in training the feature recognition model for scenario-based adaptation. For example, scenario training data can specifically be deployment scenario data. A deployment scenario refers to the scenario in which the feature recognition model is deployed. For example, if the deployment scenario is an object recognition scenario, the server will perform scenario-based adaptation on the feature recognition model to obtain a scenario-adapted feature recognition model. Deployment scenario data refers to the data collected in the scenario where the feature recognition model needs to be deployed. For example, when the scenario where the feature recognition model needs to be deployed is an object recognition scenario, deployment scenario data can specifically refer to the data collected in that object recognition scenario. Furthermore, scenario training data can specifically include deployment scenario data and feature recognition training data used in the process of training the latest student recognition model. For example, in training iterations, the batch size ratio of scenario data and feature recognition training data can be one to one. Through scenario-based adaptation, the feature recognition model can be more closely matched to the deployment scenario, which is beneficial for achieving more accurate feature recognition in the deployment scenario and improving feature recognition accuracy.
[0153] The target distribution loss describes the difference in feature distributions between the third feature distribution corresponding to the third recognition feature and the fourth feature distribution corresponding to the fourth recognition feature, thus representing the distribution distance between the teacher recognition model and the feature recognition model. The third feature distribution refers to the distribution of the third recognition feature in the feature cache queue. The fourth feature distribution refers to the distribution of the fourth recognition feature in the feature cache queue. A smaller target distribution loss indicates a smaller distribution distance between the teacher recognition model and the feature recognition model, meaning their distributions are closer.
[0154] The termination scenario adaptation condition refers to the condition for terminating the training of the feature recognition model, which can be configured according to the actual application scenario. For example, the termination scenario adaptation condition can be that the number of training iterations meets a set training number threshold. Another example is that the target distribution loss is less than a set loss threshold. Yet another example is that the target distribution loss converges.
[0155] Specifically, the server reads scene training data from a pre-configured scene training dataset and inputs it into the teacher recognition model to output a third recognition feature. It then inputs the same scene training data into a feature recognition model to output a fourth recognition feature. After obtaining the third and fourth recognition features, the server calculates the feature distributions for both features based on a feature cache queue. It then calculates the target distribution loss between the third and fourth recognition features based on these distributions. After calculating the target distribution loss, the server updates the features in the feature cache queue based on the third and fourth recognition features. Following this update, the server updates the network parameters of the feature recognition model based on the target distribution loss and then proceeds to the step of reading scene training data to continue training the feature recognition model. This process continues until the termination condition for scene adaptation is met, indicating that scene adaptation of the feature recognition model is complete. The server then uses the latest feature recognition model as the scene-adapted feature recognition model.
[0156] In specific applications, the implementation method of obtaining a scene-adapted feature recognition model by adapting the feature recognition model to a specific scenario is similar to the implementation method of obtaining a feature recognition model by training an untrained student recognition model as described above. The only difference is the training data used. Therefore, the specific limitations of obtaining a scene-adapted feature recognition model by adapting the feature recognition model to a specific scenario in this embodiment can refer to the limitations of obtaining a feature recognition model by training an untrained student recognition model as described above, and will not be repeated here.
[0157] In this embodiment, by adapting to specific scenarios, the feature recognition model can be made more compatible with the deployment scenario, which is conducive to achieving more accurate feature recognition in the deployment scenario and can improve the feature recognition accuracy.
[0158] In one embodiment, the pre-trained teacher identification model is obtained through a training step, which includes:
[0159] Obtain the model training dataset and the corresponding training labels for each model training data in the model training dataset;
[0160] Cluster the training data of the model according to their respective training labels to obtain the cluster centers of each training label.
[0161] Based on the model training data, the corresponding training labels of each model training data, and the cluster centers of each training label in the model training dataset, the untrained teacher recognition model is trained to obtain a pre-trained teacher recognition model.
[0162] In this context, "model training data" refers to the data used to train an untrained teacher recognition model. For example, model training data could specifically be images used to train an untrained teacher recognition model. "Training labels" are the labels used during training to distinguish the model training data. For example, training labels could specifically refer to the categories of the model training data. "Cluster centers" are vectors used to describe the training labels.
[0163] Specifically, when training an untrained teacher recognition model, the server obtains the model training dataset and the corresponding training labels for each training data point within the dataset. It then clusters these training labels to obtain cluster centers for each label. The untrained teacher recognition model is then input into the training dataset to obtain its corresponding training data features. For each training data feature, a matrix operation is performed on the target feature and the corresponding cluster centers to determine the predicted probability of the target training data point belonging to each training label. This prediction is based on pre-configured... The objective function is compared with the predicted probability values of the model training data belonging to each training label and the corresponding training labels of the model training data for the targeted training data features to obtain the training loss corresponding to the targeted training data features. Based on the training loss corresponding to each training data feature, an objective function value that can be used to optimize the untrained teacher recognition model is obtained. The untrained teacher recognition model is optimized based on the objective function value, and then the optimized teacher recognition model is trained again. That is, new model training datasets and the corresponding training labels of the model training data in the model training datasets are obtained to train the optimized teacher recognition model until the termination training condition of the teacher recognition model is reached, and a pre-trained teacher recognition model is obtained.
[0164] In specific applications, the pre-configured objective function can be configured according to the actual application scenario. In this embodiment, the configured objective function is not specifically limited. In specific applications, the objective function can be a classification function. In a specific application, the objective function can be a softmax function or a softmax function with margin.
[0165] In practical applications, the termination condition refers to the condition for stopping the training of the teacher recognition model, and it can be configured according to the actual application scenario. For example, the termination condition can be that the number of training iterations meets a set threshold. Another example is that the objective function value is less than a set target threshold. Yet another example is that the objective function value converges.
[0166] In specific applications, this embodiment does not limit the method of optimizing the untrained teacher recognition model based on the objective function value, as long as the teacher recognition model can be optimized. In specific applications, the server can optimize the teacher recognition model based on gradient descent combined with the objective function value. In a specific application, the gradient descent method can be stochastic gradient descent, stochastic gradient descent with moving averages, etc.
[0167] In practical applications, the untrained teacher recognition model can be a convolutional neural network, including operations such as convolution, non-linear activation function calculation, and pooling. After the training data is input into the untrained teacher recognition model, the model will extract features from the training data through convolution, non-linear activation function calculation, and pooling, outputting the corresponding training data features for each training label. The shape of the cluster center for each training label can be (d×m), where d is the feature dimension and m is the number of training labels.
[0168] In a specific application, the training steps involved in this embodiment can be implemented as follows: Figure 3 The training flowchart shown illustrates the following steps: In the training data preparation stage, model training data is read and batched into a large recognition network unit (i.e., the teacher recognition model). Feature extraction is performed through the large recognition network unit to obtain training data features. Matrix operations are performed on the stored training data category centers and training data features to determine the predicted probability values of the model training data corresponding to each training label. Based on the predicted probability values of the model training data corresponding to each training label and the corresponding training labels, the objective function value is calculated. If the conditions for terminating the basic model (i.e., the large recognition network unit) training are met, the large recognition network unit optimization is completed, and a pre-trained large recognition network unit is obtained. If the conditions for terminating the basic model training are not met, objective function optimization is performed, i.e., optimization of the entire network (including the large recognition network unit). The process then jumps back to the step of reading model training data in the training data preparation stage and continues training the large recognition network unit until the conditions for terminating the basic model training are met, the large recognition network unit optimization is completed, and a pre-trained large recognition network unit is obtained.
[0169] In practical applications, the large recognition network unit, or teacher recognition model, initially serves as an untrained model. Subsequent training refines it into an optimized model. This large recognition network unit typically employs a convolutional neural network structure, incorporating operations such as convolution, non-linear activation function calculations, and pooling. The training data consists of images used for training. The large recognition network unit primarily extracts spatial features, and the output training data retains the spatial structure information of the images used for training. In a specific application, the training images can be object images.
[0170] In practical applications, the cluster centers of each category in the stored training data are obtained by clustering the corresponding training labels of the model training data. The shape of each category center of the training data can be (d×m), where d is the feature dimension and m is the number of training labels. By performing matrix operations on the training data features and the category centers of the training data, the predicted probability value of the model training data belonging to each training label can be determined.
[0171] In practical applications, the objective function value is calculated based on the predicted probability value of the model training data belonging to each training label and the corresponding training label of the model training data, corresponding to the training data features. That is, for each training data feature in the corresponding training data features of the model training data, the predicted probability value of the model training data belonging to each training label and the corresponding training label of the model training data are compared based on the pre-configured objective function to obtain the training loss corresponding to the training data feature. Based on the training loss corresponding to each training data feature, the objective function value that can be used to optimize large recognition network units is obtained.
[0172] In practical applications, if the conditions for terminating the training of the basic model are not met, and it is necessary to optimize the entire network based on the objective function, gradient descent can be used to train and optimize the entire network. In a specific application, gradient descent can be stochastic gradient descent, stochastic gradient descent with a moving average term, etc. This embodiment does not specifically limit the gradient descent method.
[0173] In this embodiment, by obtaining the model training dataset and the corresponding training labels of each model training data in the model training dataset, and clustering the corresponding training labels of each model training data to obtain the cluster center of each training label, it is possible to train the untrained teacher recognition model based on the model training data in the model training dataset, the corresponding training labels of each model training data, and the cluster center of each training label, and obtain a pre-trained teacher recognition model.
[0174] In one embodiment, such as Figure 4 As shown in the diagram, the training method of the feature recognition model of this application is illustrated by a flowchart. The training method of the feature recognition model specifically includes the following steps:
[0175] Step 402: Train large recognition network units (i.e., teacher recognition model).
[0176] Specifically, the server obtains the model training dataset and the corresponding training labels of each training data in the model training dataset. It then clusters the corresponding training labels of each training data to obtain the cluster centers for each training label. Based on the model training data, the corresponding training labels of each training data, and the cluster centers for each training label, the server trains the untrained teacher recognition model to obtain a pre-trained teacher recognition model.
[0177] Step 404: Use queue-based contrastive learning to initially optimize the small recognition model (i.e., the student recognition model).
[0178] Specifically, the server retrieves a feature cache queue filled with features, a pre-trained teacher recognition model, and an untrained student recognition model. The teacher recognition model has more network parameters than the student recognition model. It reads feature recognition training data, inputs this data into the teacher recognition model to obtain the first recognition feature, and inputs the same data into the student recognition model to obtain the second recognition feature. Based on the feature cache queue, it calculates the feature distribution for both the first and second recognition features, obtaining a first feature distribution corresponding to the first feature and a second feature distribution corresponding to the second feature. Based on these distributions, it calculates the feature distribution loss between the first and second recognition features. It then updates the features in the feature cache queue based on the first and second features, updates the network parameters of the student recognition model based on the feature distribution loss, and jumps back to the step of reading feature recognition training data. This process continues until the model training termination condition is met, resulting in the latest student recognition model, which is then used as the feature recognition model.
[0179] In practical applications, the queue-based contrastive learning-based preliminary optimization of the identification small model involved in this embodiment can be achieved through methods such as... Figure 5 The training flowchart shown illustrates the implementation of this training process, which specifically includes the following steps: In the training data preparation stage, feature recognition training data is read; the read feature recognition training data is input into the teacher recognition model to obtain the first recognition feature; and the read feature recognition training data is input into the student recognition model to obtain the second recognition feature. This is based on a feature cache queue filled with features (such as...). Figure 5As shown, the system includes feature cache queues corresponding to large and small recognition network units, respectively. Feature distributions are calculated for the first and second recognition features to obtain a first feature distribution corresponding to the first recognition feature and a second feature distribution corresponding to the second recognition feature. Based on the first and second feature distributions, the feature distribution loss between the first and second recognition features is calculated. Features in the feature cache queue corresponding to the large recognition network unit are updated based on the first recognition feature, and the feature cache queue corresponding to the small recognition network unit is updated based on the second recognition feature. If the termination condition for model training is not met, the distribution loss objective function is optimized, i.e., the student recognition model is optimized based on the distribution loss objective function (i.e., network parameter update). After the network parameter update is completed, the system jumps to the step of reading feature recognition training data in the training data preparation stage and continues model training until the termination condition for model training is met, the small network unit optimization is completed, and the latest student recognition model is obtained.
[0180] In practical applications, the queue-based contrastive learning-based preliminary optimization of the identification small model involved in this embodiment can be achieved through methods such as... Figure 6 The training flowchart shown illustrates the implementation of this training process, which specifically includes the following steps: In the training data preparation stage, feature recognition training data is read; the read feature recognition training data is input into the teacher recognition model to obtain the first recognition feature; and the read feature recognition training data is input into the student recognition model to obtain the second recognition feature. This is based on a feature cache queue filled with features (such as...). Figure 5 As shown, this only includes the feature cache queue corresponding to the large recognition network unit. Feature distributions are calculated for the first and second recognition features respectively, obtaining a first feature distribution corresponding to the first recognition feature and a second feature distribution corresponding to the second recognition feature. Based on the first and second feature distributions, the feature distribution loss between the first and second recognition features is calculated. The features in the feature cache queue corresponding to the large recognition network unit are updated based on the first recognition feature. If the termination condition for model training is not met, the student recognition model is optimized based on the distribution loss objective function, i.e., the network parameters of the student recognition model are updated based on the feature distribution loss. After the network parameter update is completed, the process jumps to the step of reading feature recognition training data in the training data preparation stage and continues model training until the termination condition for model training is met, the small network unit optimization is completed, and the latest student recognition model is obtained. If the termination condition for model training is met, the small network unit optimization is completed, and the latest student recognition model is obtained.
[0181] Step 406: Use features from a large recognition network to optimize the small model for specific scenarios.
[0182] Specifically, the server reads the scene training data, inputs the read scene training data into the teacher recognition model to obtain the third recognition feature, and inputs the read scene training data into the latest small model (i.e., the feature recognition model) to obtain the fourth recognition feature. Based on the feature cache queue, the target distribution loss between the third and fourth recognition features is calculated. Based on the third and fourth recognition features, the features in the feature cache queue are updated. Based on the target distribution loss, the network parameters of the feature recognition model are updated. The process then jumps to the step of reading scene training data until the termination scene adaptation condition is met. The latest feature recognition model is then used as the scene-adapted feature recognition model.
[0183] In this embodiment, the obtained scene-adapted feature recognition model is a small model that can be applied to real-world scenarios. Compared to directly using a small network trained with a large amount of data as a recognition and inference model, this small model, because it is based on a student recognition model obtained through knowledge distillation, can achieve accurate feature recognition. Therefore, this small model can be deployed by stacking it with other models, such as... Figure 7 As shown, after the small model is trained during the network module training phase, the server will overlay the small model with other modules for deployment during the network module integration and deployment phase. In a specific application, such as... Figure 8 As shown, a small model (set to) can be used. Figure 8 The model is deployed by overlaying a feature comparison search module and an image acquisition input module within the recognition network module. The deployed model can be applied to object recognition systems in practical scenarios such as smart locks, payment systems, and access control systems. The deployed model acquires images of the object to be recognized through the image acquisition input module, inputs these images into the recognition network module to extract features, and then inputs the extracted features into the feature comparison search module for recognition. The recognition network in this module is derived from a larger recognition network with stronger expressive capabilities through knowledge transfer. The feature distribution it extracts has a high similarity to the feature distribution of the larger recognition network, thus achieving higher recognition accuracy. In a specific application, the object recognition system can specifically refer to a face recognition system.
[0184] Furthermore, the inventors believe that in traditional technologies, training models for object recognition systems and adapting them to different deployment scenarios typically requires collecting data with identity tags, which may threaten user privacy. Accurately labeled data also consumes enormous resources. The feature recognition model training method proposed in this application employs a queue-based contrastive learning approach during distillation. This method maintains a feature cache queue, and during model distillation, it only needs to perform distribution calculations with the features in the queue, without using the identity tags of the training data. Therefore, when training and adjusting small models for specific scenarios, only unlabeled scene data is needed for distillation training to obtain a relatively accurate deployment model. In other words, the label information of object images is not required as a supervision signal during the distillation training of small models, and labeled scene data is not required during scenario-specific adaptation training of small models, thus protecting user privacy.
[0185] Furthermore, the training method of the feature recognition model in this application does not require scaling up the model and then using quantization pruning to compress the model, or using combined quantized models to improve performance. Compared with traditional techniques that use relatively large models for training, quantize the trained models to shorten the time, or combine multiple quantized models and use the combined features for recognition, this method is easier to deploy and apply, and ensures compatibility with object recognition systems.
[0186] The object recognition method provided in this application embodiment can be applied to, for example, Figure 9 In the application environment shown, terminal 902 communicates with server 904 via a network. A data storage system can store the data that server 904 needs to process. The data storage system can be integrated onto server 904, or it can be located in the cloud or on other servers. Terminal 902 acquires an image of the object to be identified and uploads it to server 94. Server 904 acquires the image of the object to be identified, extracts features from the image using a pre-trained feature recognition model, obtains the corresponding image features of the object, performs feature comparison and recognition based on the image features, obtains the object recognition result, and returns the object recognition result to terminal 902. Terminal 902 can be, but is not limited to, various desktop computers, laptops, smartphones, tablets, IoT devices, portable wearable devices, and aircraft. IoT devices can be smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, etc. Portable wearable devices can be smartwatches, smart bracelets, head-mounted devices, etc. Server 904 can be implemented using a standalone server or a server cluster composed of multiple servers.
[0187] In one embodiment, such as Figure 10As shown, an object recognition method is provided. This method can be executed by a terminal or a server alone, or by both a terminal and a server working together. In this embodiment, the method is described using a server as an example, and includes the following steps:
[0188] Step 1002: Obtain the image of the object to be identified;
[0189] Step 1004: Extract features from the image of the object to be identified using a pre-trained feature recognition model to obtain the corresponding image features of the image of the object to be identified. The pre-trained special recognition model is obtained through the training method of the feature recognition model described above.
[0190] Step 1006: Perform feature comparison and recognition based on image features to obtain object recognition results.
[0191] Specifically, when object recognition is required, the server acquires an image of the object to be recognized, extracts features from the image using a pre-trained feature recognition model, obtains the corresponding image features, and then performs feature comparison and recognition based on these image features to obtain the object recognition result. The pre-trained feature recognition model is obtained using the training method described above.
[0192] In practical applications, when performing feature comparison and recognition based on image features, the server compares the image features with feature information in a feature information database. If a target feature in the feature information database has a similarity greater than a similarity threshold with the image feature, the object recognition result is determined to be successful. If the similarity between the image feature and the feature information in the feature information database is less than a pre-configured similarity threshold, the object recognition result is determined to be unsuccessful. The feature information database stores accurate object-related feature information. In a specific application…
[0193] The object recognition method described above extracts features from the image of the object to be recognized by using a pre-trained feature recognition model that can achieve accurate feature recognition. This allows for the acquisition of accurate image features, which can then be used for feature comparison and recognition to achieve accurate object recognition and obtain object recognition results, thereby improving the accuracy of object recognition.
[0194] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0195] Based on the same inventive concept, this application also provides a training apparatus for a feature recognition model to implement the training method for the feature recognition model described above. The solution provided by this apparatus is similar to the implementation described in the above method. Therefore, the specific limitations of one or more feature recognition model training apparatus embodiments provided below can be found in the limitations of the feature recognition model training method described above, and will not be repeated here.
[0196] In one embodiment, such as Figure 11 As shown, a training device for a feature recognition model is provided, comprising: a data acquisition module 1102, a data recognition module 1104, a feature processing module 1106, and a feature processing module 1108, wherein:
[0197] The data acquisition module 1102 is used to acquire a feature cache queue filled with features, a pre-trained teacher recognition model, and an untrained student recognition model. The teacher recognition model has more network parameters than the student recognition model.
[0198] The data recognition module 1104 is used to read feature recognition training data, input the read feature recognition training data into the teacher recognition model to obtain the first recognition feature, and input the read feature recognition training data into the student recognition model to obtain the second recognition feature;
[0199] Feature processing module 1106 is used to calculate the feature distribution loss between the first identification feature and the second identification feature based on the feature cache queue, and update the features in the feature cache queue based on the first identification feature and the second identification feature;
[0200] The model adjustment module 1108 is used to update the network parameters of the student recognition model based on the feature distribution loss, jump to the step of reading the feature recognition training data, until the termination model training condition is met, and use the latest student recognition model as the feature recognition model.
[0201] The training device for the aforementioned feature recognition model employs a feature cache queue to calculate the feature distribution loss between the first recognition feature obtained from the teacher recognition model and the second recognition feature obtained from the student recognition model during the training process. The features in the feature cache queue are updated based on the first and second recognition features, which constrains the distribution of the student recognition model to be consistent with that of the teacher recognition model. Therefore, the student recognition model can learn the feature distribution of the teacher recognition model. In other words, by using a pre-trained teacher recognition model and a feature cache queue to perform knowledge distillation on the untrained student recognition model, the feature distribution of the teacher recognition model can be transferred to the student recognition model. This ensures that during the training process of the student recognition model, the convergence position of the features extracted by the student recognition model is a neighboring point to the convergence of the teacher recognition model. Consequently, the student recognition model obtained based on knowledge distillation can achieve accurate feature recognition, and thus, the accuracy of object recognition can be improved by utilizing the student recognition model that can achieve accurate feature recognition.
[0202] In one embodiment, the feature processing module is further configured to perform feature distribution calculations on the first identification feature and the second identification feature based on the feature cache queue, respectively, to obtain a first feature distribution corresponding to the first identification feature and a second feature distribution corresponding to the second identification feature, and to obtain the feature distribution loss between the first identification feature and the second identification feature based on the first feature distribution and the second feature distribution.
[0203] In one embodiment, the feature cache queue includes a first cache queue corresponding to the teacher recognition model; the feature processing module is further configured to perform feature distribution calculation on the first recognition feature based on the first cache queue to obtain a first feature distribution, and perform feature distribution calculation on the second recognition feature based on the first cache queue to obtain a second feature distribution, update the first recognition feature to the first cache queue, and delete features corresponding to the number of the first recognition features from the first cache queue.
[0204] In one embodiment, the feature cache queue includes a first cache queue corresponding to the teacher recognition model and a second cache queue corresponding to the student recognition model; the feature processing module is further configured to perform feature distribution calculation on the first recognition feature based on the first cache queue to obtain a first feature distribution, and perform feature distribution calculation on the second recognition feature based on the second cache queue to obtain a second feature distribution, update the first recognition feature to the first cache queue, delete features corresponding to the number of the first recognition feature from the first cache queue, update the second recognition feature to the second cache queue, and delete features corresponding to the number of the second recognition feature from the second cache queue.
[0205] In one embodiment, the feature recognition training data includes at least one data; the first recognition feature includes a first feature corresponding to each of the at least one data; the feature processing module is further configured to calculate, for each of the first features corresponding to each of the at least one data, a first feature association probability between the targeted first feature and each feature in the first cache queue, obtain a feature distribution corresponding to the targeted first feature based on the first feature association probability corresponding to the targeted first feature, and obtain a first feature distribution based on the feature distribution corresponding to the first feature corresponding to each of the at least one data.
[0206] In one embodiment, the feature recognition training data includes at least one data; the second recognition feature includes a second feature corresponding to each of the at least one data; the feature processing module is further configured to calculate, for each of the second features corresponding to each of the at least one data, the second feature association probability between the targeted second feature and each feature in the first cache queue, obtain the feature distribution corresponding to the targeted second feature based on the second feature association probability corresponding to the targeted second feature, and obtain the second feature distribution based on the feature distribution corresponding to each of the at least one data.
[0207] In one embodiment, the feature recognition training data includes at least one data; the second recognition feature includes a second feature corresponding to each of the at least one data; the feature processing module is further configured to calculate, for each of the second features corresponding to each of the at least one data, a third feature association probability between the targeted second feature and each feature in the second cache queue, obtain the feature distribution corresponding to the targeted second feature based on the third feature association probability corresponding to the targeted second feature, and obtain the second feature distribution based on the feature distribution corresponding to each of the at least one data.
[0208] In one embodiment, the feature processing module is further configured to calculate the divergence distance between the first feature distribution and the second feature distribution, and use the divergence distance as the feature distribution loss between the first identification feature and the second identification feature.
[0209] In one embodiment, the model adjustment module is further configured to read scene training data, input the read scene training data into the teacher recognition model to obtain a third recognition feature, input the read scene training data into the feature recognition model to obtain a fourth recognition feature, calculate the target distribution loss between the third and fourth recognition features based on the feature cache queue, update the features in the feature cache queue based on the third and fourth recognition features, update the network parameters of the feature recognition model based on the target distribution loss, jump to the step of reading scene training data, until the termination scene adaptation condition is met, and use the latest feature recognition model as the scene-adapted feature recognition model.
[0210] In one embodiment, the training device for the feature recognition model further includes a teacher model training module. The teacher model training module is used to obtain the model training dataset and the corresponding training labels of the model training data in the model training dataset, to cluster the corresponding training labels of the model training data to obtain the cluster center of each training label, and to train the untrained teacher recognition model based on the model training data in the model training dataset, the corresponding training labels of the model training data, and the cluster center of each training label to obtain the pre-trained teacher recognition model.
[0211] Based on the same inventive concept, this application also provides an object recognition device for implementing the object recognition method described above. The solution provided by this device is similar to the implementation described in the above method; therefore, the specific limitations in one or more object recognition device embodiments provided below can be found in the limitations of the object recognition method described above, and will not be repeated here.
[0212] In one embodiment, such as Figure 12 As shown, an object recognition device is provided, including: an image acquisition module 1202, a feature recognition module 1204, and a feature comparison and search module 1206, wherein:
[0213] Image acquisition module 1202 is used to acquire images of the object to be identified;
[0214] The feature recognition module 1204 is used to extract features from the image of the object to be recognized through a pre-trained feature recognition model to obtain the corresponding image features of the image of the object to be recognized. The pre-trained feature recognition model is obtained through the training method of the above-mentioned feature recognition model.
[0215] The feature comparison and search module 1206 is used to perform feature comparison and recognition based on image features to obtain object recognition results.
[0216] The aforementioned object recognition device extracts features from the image of the object to be recognized by using a pre-trained feature recognition model that can achieve accurate feature recognition. This allows for the acquisition of accurate image features, which can then be used for feature comparison and recognition to achieve accurate object recognition and obtain object recognition results, thereby improving the accuracy of object recognition.
[0217] The training device for the aforementioned feature recognition model and each module in the object recognition device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the corresponding operations of each module.
[0218] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 13 As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores data such as feature recognition training data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network. When executed by the processor, the computer program implements a feature recognition model training method and an object recognition method.
[0219] Those skilled in the art will understand that Figure 13 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0220] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0221] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.
[0222] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0223] It should be noted that the user information (including but not limited to images of the objects to be identified) and data (including but not limited to data used for analysis, data stored, data displayed) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0224] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0225] The technical features of the above embodiments can be combined in any way. For the sake of brevity, 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.
[0226] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for training a face recognition model, characterized in that, The method includes: Obtain a feature cache queue filled with features, a pre-trained teacher recognition model, and an untrained student recognition model, wherein the teacher recognition model has more network parameters than the student recognition model; Read the feature recognition training data, input the read feature recognition training data into the teacher recognition model to obtain the first recognition feature, and input the read feature recognition training data into the student recognition model to obtain the second recognition feature; the feature recognition training data is a face image used to train the untrained student recognition model; Based on the feature cache queue, calculate the feature distribution loss between the first identification feature and the second identification feature, and update the features in the feature cache queue based on the first identification feature and the second identification feature; Based on the feature distribution loss, the network parameters of the student recognition model are updated, and the process jumps to the step of reading the feature recognition training data until the termination model training condition is met, and the latest student recognition model is used as the feature recognition model. Read the scene training data, input the read scene training data into the teacher recognition model to obtain the third recognition feature, and input the read scene training data into the feature recognition model to obtain the fourth recognition feature; Based on the feature cache queue, calculate the target distribution loss between the third identification feature and the fourth identification feature, and update the features in the feature cache queue based on the third identification feature and the fourth identification feature; The network parameters of the feature recognition model are updated based on the target distribution loss, and the process jumps to the step of reading the scene training data until the termination scene adaptation condition is met. The latest feature recognition model is then used as the scene-adapted feature recognition model.
2. The method according to claim 1, characterized in that, The step of calculating the feature distribution loss between the first identification feature and the second identification feature based on the feature cache queue includes: Based on the feature cache queue, feature distribution calculations are performed on the first identification feature and the second identification feature respectively to obtain a first feature distribution corresponding to the first identification feature and a second feature distribution corresponding to the second identification feature; Based on the first feature distribution and the second feature distribution, the feature distribution loss between the first recognition feature and the second recognition feature is obtained.
3. The method according to claim 2, characterized in that, The feature cache queue includes a first cache queue corresponding to the teacher recognition model; The step of calculating feature distributions for the first identification feature and the second identification feature based on the feature cache queue to obtain a first feature distribution corresponding to the first identification feature and a second feature distribution corresponding to the second identification feature includes: Based on the first cache queue, the feature distribution of the first identification feature is calculated to obtain the first feature distribution, and based on the first cache queue, the feature distribution of the second identification feature is calculated to obtain the second feature distribution; The step of updating the features in the feature cache queue based on the first identification feature and the second identification feature includes: The first identification feature is updated in the first cache queue, and features corresponding to the number of the first identification features are deleted from the first cache queue.
4. The method according to claim 2, characterized in that, The feature cache queue includes a first cache queue corresponding to the teacher identification model and a second cache queue corresponding to the student identification model; The step of calculating feature distributions for the first identification feature and the second identification feature based on the feature cache queue to obtain a first feature distribution corresponding to the first identification feature and a second feature distribution corresponding to the second identification feature includes: Based on the first cache queue, the feature distribution of the first identification feature is calculated to obtain a first feature distribution, and based on the second cache queue, the feature distribution of the second identification feature is calculated to obtain a second feature distribution; The step of updating the features in the feature cache queue based on the first identification feature and the second identification feature includes: Update the first identification feature to the first cache queue, and delete the feature corresponding to the number of the first identification features from the first cache queue; The second identification feature is updated in the second cache queue, and features corresponding to the number of the second identification features are deleted from the second cache queue.
5. The method according to claim 3 or 4, characterized in that, The feature recognition training data includes at least one data point; the first recognition feature includes a first feature corresponding to each of the at least one data point; the step of calculating the feature distribution of the first recognition feature based on the first cache queue to obtain the first feature distribution includes: For each of the first features corresponding to the at least one data, calculate the first feature association probability between the targeted first feature and each feature in the first cache queue, and obtain the feature distribution corresponding to the targeted first feature based on the first feature association probability corresponding to the targeted first feature. A first feature distribution is obtained based on the feature distribution corresponding to the first feature of each of the at least one data points.
6. The method according to claim 2, characterized in that, The step of obtaining the feature distribution loss between the first recognition feature and the second recognition feature based on the first feature distribution and the second feature distribution includes: Calculate the divergence distance between the first feature distribution and the second feature distribution; The divergence distance is used as the feature distribution loss between the first identification feature and the second identification feature.
7. The method according to claim 1, characterized in that, The pre-trained teacher identification model is obtained through a training step, which includes: Obtain the model training dataset and the corresponding training labels for each model training data in the model training dataset; Cluster the training data of the model according to their respective training labels to obtain the cluster center of each training label. Based on the model training data in the model training dataset, the corresponding training labels of each model training data, and the cluster centers of each training label, the untrained teacher recognition model is trained to obtain a pre-trained teacher recognition model.
8. A training device for a face recognition model, characterized in that, The device includes: The data acquisition module is used to acquire a feature cache queue filled with features, a pre-trained teacher recognition model, and an untrained student recognition model, wherein the network parameters of the teacher recognition model are more than those of the student recognition model. The data recognition module is used to read feature recognition training data, input the read feature recognition training data into the teacher recognition model to obtain a first recognition feature, and input the read feature recognition training data into the student recognition model to obtain a second recognition feature; the feature recognition training data is a face image used to train the untrained student recognition model; The feature processing module is used to calculate the feature distribution loss between the first identification feature and the second identification feature based on the feature cache queue, and update the features in the feature cache queue based on the first identification feature and the second identification feature; The model adjustment module is used to update the network parameters of the student recognition model based on the feature distribution loss, jump to the step of reading feature recognition training data, until the termination model training condition is met, and use the latest student recognition model as the feature recognition model. The data recognition module is also used to read scene training data, input the read scene training data into the teacher recognition model to obtain a third recognition feature, and input the read scene training data into the feature recognition model to obtain a fourth recognition feature; The feature processing module is further configured to calculate the target distribution loss between the third identification feature and the fourth identification feature based on the feature cache queue, and update the features in the feature cache queue based on the third identification feature and the fourth identification feature; The model adjustment module is also used to update the network parameters of the feature recognition model based on the target distribution loss, jump to the step of reading scene training data, until the termination scene adaptation condition is met, and use the latest feature recognition model as the scene-adapted feature recognition model.
9. The apparatus according to claim 8, characterized in that, The feature processing module is further configured to perform feature distribution calculations on the first identification feature and the second identification feature based on the feature cache queue, respectively, to obtain a first feature distribution corresponding to the first identification feature and a second feature distribution corresponding to the second identification feature; and to obtain the feature distribution loss between the first identification feature and the second identification feature based on the first feature distribution and the second feature distribution.
10. The apparatus according to claim 9, characterized in that, The feature cache queue includes a first cache queue corresponding to the teacher recognition model; The feature processing module is further configured to perform feature distribution calculation on the first identification feature based on the first cache queue to obtain a first feature distribution, and perform feature distribution calculation on the second identification feature based on the first cache queue to obtain a second feature distribution; update the first identification feature to the first cache queue, and delete features corresponding to the number of the first identification features from the first cache queue.
11. The apparatus according to claim 9, characterized in that, The feature cache queue includes a first cache queue corresponding to the teacher identification model and a second cache queue corresponding to the student identification model; The feature processing module is further configured to perform feature distribution calculation on the first identification feature based on the first cache queue to obtain a first feature distribution, and perform feature distribution calculation on the second identification feature based on the second cache queue to obtain a second feature distribution; update the first identification feature to the first cache queue, and delete features corresponding to the number of the first identification features from the first cache queue; The second identification feature is updated in the second cache queue, and features corresponding to the number of the second identification features are deleted from the second cache queue.
12. The apparatus according to claim 10 or 11, characterized in that, The feature recognition training data includes at least one data point; the first recognition feature includes a first feature corresponding to each of the at least one data point. The feature processing module is further configured to calculate, for each of the first features corresponding to the at least one data, the first feature association probability between the targeted first feature and each feature in the first cache queue, and obtain the feature distribution corresponding to the targeted first feature based on the first feature association probability corresponding to the targeted first feature; and obtain the first feature distribution based on the feature distribution corresponding to the first feature corresponding to the at least one data.
13. The apparatus according to claim 9, characterized in that, The feature processing module is further configured to calculate the divergence distance between the first feature distribution and the second feature distribution; and to use the divergence distance as the feature distribution loss between the first identification feature and the second identification feature.
14. The apparatus according to claim 8, characterized in that, The device also includes a teacher model training module, which is used to obtain the model training dataset and the corresponding training labels of the model training data in the model training dataset. Cluster the training labels of the model training data to obtain cluster centers for each training label; based on the model training data in the model training dataset, the training labels of the model training data, and the cluster centers for each training label, train the untrained teacher recognition model to obtain a pre-trained teacher recognition model.
15. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.
16. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.
17. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Distillation method and device of neural network model and electronic system
CN114037046A
Feature extraction model training method, image retrieval method, device and equipment
CN114417046A
