A method for training a network model, a method for object recognition, and related equipment.
By training the training sets in different scenarios separately and performing mutual learning of network parameters, the problem of poor training performance of network models in multi-scene image recognition is solved, achieving high-precision multi-scene recognition and reducing computational costs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-16
- Publication Date
- 2026-03-10
AI Technical Summary
Existing network models suffer from poor training performance, inability to converge, and poor generalization ability in multi-scene image recognition, resulting in low recognition accuracy.
By acquiring training sets from different application scenarios, the corresponding network models are trained individually, and mutual learning is performed when the iterative training reaches the preset conditions to adjust the network parameters and improve the generalization ability.
It improves the recognition accuracy of the network model in multiple scenarios, reduces the computational cost, and enhances the ease of use and generalization ability of the model.
Smart Images

Figure CN115471671B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of target recognition, and in particular to a network model training method, a target recognition method, and related equipment. BACKGROUND
[0002] The performance of a network model is strongly related to a training sample set used for network model training, and training sample images collected in different application scenarios usually have great differences. In order to ensure the training effect of the network model, different types of training sample sets can be used in the training phase of the network model. However, since the image data distribution of different types of training sample sets has great differences, training the network model by introducing multiple different types of training sample sets may have an adverse effect on the training of the network model, and in severe cases, may even cause the training of the network model to fail to converge. If different types of training sample sets are used to train different network models for different application scenarios, the generalization ability of a single network model itself is poor, and the network model cannot have target recognition capability in multiple scene images, and the recognition accuracy is poor. In summary, the current network model does not have the recognition capability for multiple scene images. SUMMARY
[0003] The present application provides a network model training method, a target recognition method, and related equipment, which can accurately identify images in multiple scenes.
[0004] To solve the above technical problems, the technical solution adopted by the present application is: a network model training method is provided, which includes: obtaining at least two training sets; each training set contains multiple training sample images in different application scenarios; obtaining at least two network models corresponding to the number of training sets, wherein the at least two network models have the same network structure; iteratively training the corresponding network model using the training sample images in each training set, so that the network model adjusts its network parameters based on the training sample images; in response to the iterative training reaching a preset mutual learning condition, performing mutual learning between the network parameters at the same position of the at least two network models; in response to the at least two network models not being trained, returning to the step of iteratively training the corresponding network model using the training sample images in each training set; and in response to the at least two network models being trained, determining a final network model from the at least two network models.
[0005] To solve the above technical problems, the technical scheme adopted by the present application is to provide a target identification method, which comprises: inputting a to-be-identified image into a network model to obtain a to-be-identified feature of a target object; wherein the network model is a final network model trained by the training method of the network model in the above technical scheme; performing similarity calculation on the to-be-identified feature and a comparison feature to obtain a similarity value; and obtaining a target identification result based on the similarity value.
[0006] To solve the above technical problems, another technical scheme adopted by the present application is to provide a network model training device, which comprises a memory and a processor connected to each other, wherein the memory is used to store a computer program, and the computer program is used to implement the training method of the network model in the above technical scheme when executed by the processor.
[0007] To solve the above technical problems, another technical scheme adopted by the present application is to provide a target identification device, which comprises a memory and a processor connected to each other, wherein the memory is used to store a computer program, and the computer program is used to implement the target identification method in the above technical scheme when executed by the processor.
[0008] Still another technical scheme adopted by the present application is to provide a computer readable storage medium, which is used to store a computer program, and the computer program is used to implement the training method of the network model or the target identification method in the above technical scheme when executed by a processor.
[0009] Through the above scheme, the beneficial effects of the present application are: by training the corresponding network model with different types of training sets, the situation that the network model cannot converge due to mutual interference of multiple different types of training sets in the training process can be avoided, and the training effect is improved; at the same time, when the iterative training reaches the preset mutual learning condition, mutual learning is performed between the network parameters at the same position of at least two network models, so that each network model can learn the feature recognition ability in the corresponding scene, and can also learn from other network models to learn the feature recognition ability in other scenes, thereby greatly improving the generalization ability of the network model, enabling the trained network model to accurately identify images in multiple scenes, solving the technical problem that the network model can only identify images in a single scene; at the same time, the multiple training sets do not need to be associated, so that the training sets are easier to obtain; in addition, after all the network models are trained, only one of the network models needs to be retained, which can improve the identification accuracy while reducing the calculation cost and improving the usability of the network model. BRIEF DESCRIPTION OF DRAWINGS
[0010] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. Wherein:
[0011] Figure 1 This is a flowchart illustrating an embodiment of the network model training method provided in this application;
[0012] Figure 2 This is a schematic diagram of the network model training structure provided in this application;
[0013] Figure 3 This is a flowchart illustrating another embodiment of the training method for the network model provided in this application;
[0014] Figure 4 This is a flowchart illustrating an embodiment of step 34 provided in this application;
[0015] Figure 5 This is a flowchart illustrating an embodiment of the target recognition method provided in this application;
[0016] Figure 6 This is a schematic diagram of the structure of an embodiment of the training device for the network model provided in this application;
[0017] Figure 7 This is a schematic diagram of the structure of an embodiment of the target recognition device provided in this application;
[0018] Figure 8 This is a schematic diagram of an embodiment of the computer-readable storage medium provided in this application. Detailed Implementation
[0019] The present application will now be described in further detail with reference to the accompanying drawings and embodiments. It should be particularly noted that the following embodiments are for illustrative purposes only and do not limit the scope of the application. Similarly, the following embodiments are only some, not all, embodiments of the present application, and all other embodiments obtained by those skilled in the art without inventive effort are within the scope of protection of the present application.
[0020] In this application, the reference to "embodiment" means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0021] It should be noted that the terms "first," "second," and "third" in this application are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined as "first," "second," or "third" may explicitly or implicitly include at least one of that feature. In the description of this application, "multiple" means at least two, such as two, three, etc., unless otherwise explicitly specified. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses.
[0022] Please see Figure 1 , Figure 1 This is a flowchart illustrating an embodiment of the network model training method provided in this application. The method includes:
[0023] Step 11: Obtain at least two training sets.
[0024] Obtain at least two training sets, each of which may contain multiple training sample images from different application scenarios. The training sample images input to the network model may be images that have undergone image processing such as cropping, alignment, or scaling to meet the input size of the network model.
[0025] Specifically, the training set may include training sample images and their corresponding real labels. Training sample images from different application scenarios can be collected, and then all training sample images are labeled with real labels. Then, all labeled training sample images are classified to obtain at least two training sets. By utilizing training sample images from real application scenarios, the recognition performance of the network model in real business scenarios can be guaranteed.
[0026] Taking facial recognition as an example, the facial images captured in different application scenarios often vary significantly. For instance, cameras at entrance and exit gates typically capture unobstructed, frontal facial images; building surveillance equipment, due to its installation height and angle, usually captures facial images with a certain degree of distortion; while in crowded places such as buses or hospitals, the facial images captured by cameras are often obstructed; and for cameras on highways, due to the long capture distance and the need to consider structured information such as vehicles or license plates, the captured facial images often have problems such as being blurry, small in size, or obstructed by car windows.
[0027] Furthermore, during the training process of the network model, if only face images from a single application scenario, as illustrated in the example above, are used as the training set, the network model's generalization ability is likely to be poor, and it will be unable to accurately identify targets in other scenarios. Therefore, in order to improve the accuracy of face recognition, training sample images from different application scenarios can be obtained as the training set. In other words, training sample images collected from different application scenarios or training sample images collected from different angles within the same application scenario can be used as the training set to improve the generalization ability of the network model in different scenarios, enabling the network model to accurately identify images in multiple scenarios.
[0028] Step 12: Obtain at least two network models corresponding to the number of training sets.
[0029] The number of network models is the same as the number of different types of training sets. After obtaining at least two network models, each network model can be initialized separately to prepare for subsequent training steps. Specifically, network initialization may include setting the initial network parameters and training parameters of the network model. The training parameters may include the learning rate, loss function, or maximum number of iterations.
[0030] Understandably, the type of network model can be selected according to the actual application. It can be a biometric recognition model or a non-biometric recognition model, such as a face recognition model or a vehicle recognition model. Specifically, each network model has the same network structure. The specific network structure of the network model can be designed by the user or an existing neural network model for feature recognition can be used, such as a deep residual network (ResNet) or GoogleNet (Google Inception Net). The type and specific network structure of the network model are not limited here.
[0031] Step 13: Use the training sample images from each training set to iteratively train the corresponding network model so that the network model can adjust its network parameters based on the training sample images.
[0032] Iterative training of the corresponding network model using various training sets allows the network model to adjust its parameters based on training sample images. Specifically, different network models can be trained separately using training sets from different application scenarios, enabling each model to independently learn target recognition capabilities for different scenarios. By iteratively training the corresponding network model using various training sets, the problem of network model failing to converge due to mutual interference between training sets from different application scenarios can be avoided when training the same network model using multiple training sets from different application scenarios. This effectively improves training results and enhances the network model's recognition accuracy for images in multiple scenarios.
[0033] Understandably, the training process of each network model is independent of each other. The training methods of each network model can be the same or different, and the iterative training process of each network model can be synchronous or asynchronous. Here, we do not limit the training method of each network model.
[0034] Step 14: In response to the iterative training reaching the preset mutual learning conditions, perform mutual learning between network parameters at the same location in at least two network models.
[0035] In response to the preset mutual learning conditions reached during iterative training, mutual learning is performed between the network parameters at the same position in at least two network models. Through mutual learning among the network models, each network model can learn the target recognition capabilities in different scenarios, thereby making the network models universally applicable in multiple different application scenarios. Specifically, there are two or more network models, and mutual learning is performed between the network parameters at the same position in at least two network models when the preset mutual learning conditions are reached during the iterative training of each network model; wherein, the network parameters at the same position can represent the network parameters corresponding to the same network layer.
[0036] like Figure 2As shown, taking at least two training sets, including training set A and training set B, and at least two network models, including network model 1 and network model 2, as an example, network model 1 and network model 2 can be trained separately using standard neural network training methods. That is, training set A is input into network model 1, and training set B is input into network model 2. Training sets A and B are respectively passed through the forward propagation of network model 1 and network model 2 to obtain their respective network outputs. Then, network model 1 calculates the loss function value L1 based on its obtained network output and the corresponding real labels of training set A, and network model 2 calculates the loss function value L2 based on its obtained network output and the corresponding real labels of training set B. Then, network model 1 and network model 2 respectively adjust their network parameters using the error back propagation (BP) algorithm based on their respective loss function values. After network model 1 and network model 2 reach the preset mutual learning conditions, network model 1 and network model 2 perform mutual learning between the network parameters at the same position.
[0037] Step 15: In response to the completion of training of at least two network models, determine the final network model from the at least two network models.
[0038] If at least two network models have not been trained, return to step 13; if at least two network models have been trained, the final network model can be determined from the at least two network models; specifically, a network model can be randomly selected from the at least two network models as the final network model, or a network model can be selected as the final network model based on the accuracy test results of each network model. The selection process of the final network model is not limited here.
[0039] Furthermore, the training termination conditions for the completion of network model training may include: loss convergence, that is, the difference between the previous loss and the current loss value is less than a set value; determining whether the current loss value is less than a preset loss, which is a pre-set loss threshold. If the current loss value is less than the preset loss, then the preset stopping condition is determined to be met; the number of iterations reaches the maximum number of iterations (e.g., 10,000 training iterations); or the accuracy obtained when testing with the test set reaches a set condition (e.g., exceeding the preset accuracy), etc.
[0040] This embodiment utilizes different types of training sets to train the corresponding network models separately, avoiding mutual interference between different types of training sets during training, which could lead to the network models failing to converge and thus improving training effectiveness. Simultaneously, when iterative training reaches the preset mutual learning conditions, mutual learning occurs between network parameters at the same positions of at least two network models. This allows each network model to independently learn feature recognition capabilities for its corresponding scene, and also to learn feature recognition capabilities for other scenes from other network models, significantly improving the generalization ability of the network models. This enables the trained network models to accurately recognize images in multiple scenes, solving the technical problem that network models can only recognize images in a single scene. Furthermore, there is no need to associate multiple training sets, making training sets easier to obtain. Moreover, after all network models have been trained, only one network model needs to be retained, which improves recognition accuracy while reducing computational costs and enhancing the usability of the network models.
[0041] Please see Figure 3 , Figure 3 This is a flowchart illustrating another embodiment of the network model training method provided in this application, the method comprising:
[0042] Step 31: Obtain at least two training sets.
[0043] Step 31 is the same as step 11 in the above embodiments, and is not limited here.
[0044] Step 32: Obtain at least two network models corresponding to the number of training sets.
[0045] Step 32 is the same as step 12 in the above embodiments, and is not limited here.
[0046] Step 33: Use the training sample images from each training set to iteratively train the corresponding network model so that the network model can adjust its network parameters based on the training sample images.
[0047] Step 33 is the same as step 13 in the above embodiments, and is not limited here.
[0048] Step 34: In response to the iterative training reaching the preset mutual learning conditions, perform mutual learning between network parameters at the same location in at least two network models.
[0049] In response to the iterative training reaching a preset mutual learning condition, mutual learning is performed between network parameters at the same location in at least two network models; specifically, such as... Figure 4 As shown, the specific content of step 34 is as shown in steps 41 to 44:
[0050] Step 41: In response to the current iteration count of each network model reaching a preset threshold, determine that the iterative training has reached the mutual learning condition.
[0051] In response to the current iteration count of each network model reaching a preset threshold, it is determined that the iterative training has reached the mutual learning condition. The preset threshold can be one, two, or more. The number and specific value of the preset threshold can be set according to actual experience or application. Understandably, when setting multiple preset thresholds, an interval setting method can be adopted so that the individual training and mutual learning of each network model alternate. The interval between each preset threshold can be equal or unequal, which is not limited here. For example, if it is known from experience that performing mutual learning once after every 10 iterations of training of each network model can achieve a better learning effect, then multiple thresholds can be set at equal intervals, such as 10, 20, 30, etc.
[0052] Specifically, since the training process of each network model is independent, the progress of iterative training of each network model can be synchronous or different. When the progress of iterative training of network models is inconsistent, the network model that reaches the preset number of iterations first can pause training and wait for the number of iterations of other network models to reach the preset number of iterations before starting to perform subsequent mutual learning operations.
[0053] Understandably, the preset threshold number of iterations is less than the maximum number of iterations for each network model, and the maximum number of iterations for each network model is the same, thus ensuring that the mutual learning progress of each network model remains consistent. The first preset threshold number of iterations can be set in the later stages of training. In the early stages of network model training, the performance of the network models is unstable, and their recognition ability is limited. Each network model needs to improve its feature recognition ability for a specific scene based more on its corresponding training set. In the later stages of network model training, the feature recognition ability of each network model for the corresponding scene has reached a high level. At this point, mutual learning can be performed between the network parameters at the same position in each network model, thereby improving the robustness and generalization ability of the model and achieving better training results.
[0054] Step 42: Select any one of the at least two network models as the network model to be updated.
[0055] Step 43: Perform a weighted summation of the network parameters in the same position in the network model to be updated and other network models, and use the summation value as the network parameters after mutual learning of the network model to be updated.
[0056] Select a network model to be updated from at least two network models, and then perform a weighted sum of the network parameters of the network model to be updated and the network parameters of the same position in the other network models. This adjusts the network parameters of the network model to be updated at each position, thereby learning the feature recognition capabilities of the other network models.
[0057] Specifically, a weighted summation of network parameters in the same position in the network model to be updated and other network models can include: obtaining a first weight and a second weight; then using the first weight as the weight value of the network parameters in the network model to be updated, and using the second weight as the weight value of the network parameters in other network models. The first weight gradually decreases with iterative training, and / or the second weight gradually increases with iterative training. This ensures that, in addition to being adjusted according to its corresponding training set, the network parameters in the network model to be updated begin to learn the network parameters of other network models as the number of iterations increases, thereby learning feature recognition capabilities in different scenarios. This improves the robustness and generalization ability of the network model, and the dynamic adjustment of the weights also prevents overfitting.
[0058] Furthermore, the scheme for obtaining the first weight and the second weight may include: calculating the first weight based on the total number of at least two network models, the current iteration number, and the maximum iteration number; and calculating the second weight based on the first weight and the total number of at least two network models; wherein the first weight is negatively correlated with the current iteration number, and the second weight is negatively correlated with the first weight.
[0059] Specifically, the first weight can be calculated using the following formula (1):
[0060]
[0061] In equation (1) above, b1 is the first weight, N is the total number of at least two network models, x is the current iteration number, and E is the maximum iteration number.
[0062] The second weight can be calculated using the following formula (2):
[0063]
[0064] In equation (2) above, b2 is the second weight.
[0065] As can be seen from the above formulas (1) and (2), when the number of iterations is 0, the first weight b1 equals 1 and the second weight b2 equals 0. At this time, the network model only learns based on its corresponding training set and does not learn the network parameters of other network models. As the current number of iterations increases, the first weight b1 gradually decreases and the second weight b2 gradually increases. The current network model begins to focus on learning the network parameters of other network models. Until the current number of iterations reaches the maximum number of iterations, the first weight b1 and the second weight are both 1 / N, and the network model achieves a balance in learning the training set and other network models.
[0066] In summary, the network parameters in the same position in the network model to be updated and other network models can be weighted and summed using the following formula (3):
[0067]
[0068] In equation (3) above, w' represents the network parameters before mutual learning, w represents the network parameters of the network model to be updated before mutual learning, and wi represents the network parameters of the i-th network model and the network model to be updated that are in the same position.
[0069] Step 44: After the network parameters of the network model to be updated are updated, select another network model from at least two network models as the network model to be updated, until all network models have been traversed.
[0070] After the network parameters of the network model to be updated are updated, another network model is selected from at least two network models as the network model to be updated, until all network models have been traversed; it is understood that in other implementations, each network model can perform mutual learning operations at the same time, that is, each network model can execute step 43 at the same time to obtain its corresponding mutually learned network parameters.
[0071] Specifically, after each network model to be updated obtains its corresponding mutually learned network parameters, it is also necessary to determine whether it needs to be updated, as shown in steps 35 to 38.
[0072] Step 35: Obtain the first loss value of the network model to be updated under the network parameters before mutual learning and the corresponding second loss value under the network parameters after mutual learning.
[0073] The process involves obtaining the first loss value of the network model to be updated under the network parameters before mutual learning and the corresponding second loss value under the network parameters after mutual learning. Specifically, training sample images can be input into the network model to be updated under the network parameters before mutual learning to obtain a first recognition result; training sample images can be input into the network model to be updated under the network parameters after mutual learning to obtain a second recognition result; then, based on the first recognition result and the corresponding ground truth label, the first loss value is calculated; and based on the second recognition result and the corresponding ground truth label, the second loss value is calculated. It is understood that the loss function used to calculate the first and second loss values is not limited here; the loss function can be a conventional loss function used in model training, such as the cross-entropy loss function.
[0074] Step 36: Subtract the first loss value from the second loss value to obtain the change in loss value.
[0075] Subtracting the first loss value from the second loss value yields the change in loss value. Specifically, a change in loss value greater than 0 indicates that the loss value of the network model after mutual learning has decreased, while a change in loss value less than 0 indicates that the loss value of the network model after mutual learning has increased.
[0076] Understandably, in other implementations, the second loss value can be subtracted from the first loss value to obtain the loss change value. When the loss change value is greater than 0, it indicates that the loss value of the network model after mutual learning has increased; when the loss change value is less than 0, it indicates that the loss value of the network model after mutual learning has decreased. The calculation process of the loss change value is not limited here.
[0077] Step 37: Calculate the update probability value based on the change in loss.
[0078] Based on the change in loss, an update probability value is calculated. Specifically, in this embodiment, the update probability value represents the probability that the network model to be updated will update its network parameters. The larger the update probability value, the smaller the probability that the network model to be updated will update its network parameters; conversely, the smaller the update probability value, the larger the probability that the network model to be updated will update its network parameters. The update probability value is positively correlated with the change in loss. In response to the change in loss being greater than a preset loss threshold, the update probability value can be determined to be a first preset value. In response to the change in loss being less than or equal to the loss threshold, the update probability value is calculated based on a preset annealing temperature value and the change in loss. The preset loss threshold can be 0, and the first preset value can be 1. When the change in loss is greater than 0, it indicates that the loss value of the network model after mutual learning has decreased, so the update probability value can be determined to be 1, indicating that the probability of the network model to be updated updating its network parameters is relatively small. When the change in loss is less than or equal to 0, it indicates that the loss value of the network model after mutual learning remains unchanged or increases, so the update probability value is further calculated based on the preset annealing temperature value and the change in loss.
[0079] Furthermore, the update probability value is negatively correlated with the annealing temperature value. The annealing temperature value gradually decreases with iterative training, so in the early stage of network model training, the network model can maximize the search space and accept network parameter updates that would worsen the network model with a certain probability (i.e., the probability corresponding to the update probability value), thus avoiding the network model from getting trapped in local optima. As the number of iterations increases, the annealing temperature value gradually decreases, the update probability value increases, and the probability of the network model accepting network parameter updates decreases. This allows the network model to focus more on exploring the depth of the solution space in the later stage of network model training, enabling the network to converge to a better solution.
[0080] Specifically, the method for calculating the update probability value based on the preset annealing temperature value and the loss change value is shown in the following formula (4):
[0081]
[0082] In equation (4) above, P is the update probability value, ΔL is the loss change value, and T is the preset annealing temperature value.
[0083] Step 38: Based on the update probability value, determine whether to update the network parameters before mutual learning using the network parameters after mutual learning.
[0084] Based on the update probability value, it is determined whether to update the network parameters before mutual learning using the network parameters after mutual learning. Specifically, for each network parameter of the network model to be updated, a random number can be generated within a preset numerical range. Then, in response to the random number being greater than the update probability value, the network parameters before mutual learning remain unchanged; in response to the random number being less than or equal to the update probability value, the network parameters before mutual learning are updated using the network parameters after mutual learning. The preset numerical range can be [0, 1]. A random number can be generated within this numerical range, and the relationship between the random number and the update probability value is used to select whether to update the network parameters of the network model to be updated.
[0085] In another embodiment, the network parameters before mutual learning can be kept unchanged in response to the random number being less than or equal to the update probability value, and the network parameters before mutual learning can be updated using the network parameters after mutual learning in response to the random number being greater than the update probability value. This is not limited here.
[0086] Step 39: In response to the completion of training of at least two network models, determine the final network model from the at least two network models.
[0087] Step 39 is the same as step 15 in the above embodiment, and will not be described again here.
[0088] The following explanation uses a network model for facial feature recognition as an example. The training method of the network model in this embodiment can be used to train a facial feature recognition model that can recognize facial features in both scenarios where the face is covered by a mask and scenarios where the face is not covered. The specific training steps are shown in S1 to S6 below.
[0089] S1: Obtain two training sets: training set A and training set B. Training set A contains face sample images with faces covered by masks, and training set B contains face sample images without faces covered.
[0090] S2: Obtain two face feature recognition models with the same network structure based on the residual network: face feature recognition model A and face feature recognition model B. Then, initialize the networks for face feature recognition model A and face feature recognition model B respectively. The iteration interval for mutual learning is set to 10 and the maximum number of iterations is set to 100.
[0091] S3: Based on the Additive Angular Margin Loss (ArcFace) function, face feature recognition model A can be trained using training set A, and face feature recognition model B can be trained using training set B.
[0092] S4: Every 10 iterations, proceed to S5. If the current iteration count has reached the maximum iteration count of 100, proceed to S6.
[0093] S5: Perform mutual learning between the network parameters at the same locations in face feature recognition model A and face feature recognition model B, specifically including a~e:
[0094] a. Calculate the first weight and the second weight according to the above formulas (1) and (2).
[0095] b. Using face recognition model A as the network model to be updated, based on the first weight and the second weight, the network parameters in the same position in face recognition model A and face recognition model B are weighted and summed to obtain the mutual-learned network parameters corresponding to each network layer in face recognition model A; similarly, using face recognition model B as the network model to be updated, based on the first weight and the second weight, the network parameters in the same position in face recognition model B and face recognition model A are weighted and summed to obtain the mutual-learned network parameters corresponding to each network layer in face recognition model B.
[0096] c. For face feature recognition model A, the loss value is calculated based on the network parameters before and after mutual learning, and the change in loss between the two loss values is calculated. Then, the update probability value is calculated based on the change in loss value. Similarly, for face feature recognition model B, the loss value is calculated based on the network parameters before and after mutual learning, and the change in loss between the two loss values is calculated. Then, the update probability value is calculated based on the change in loss value.
[0097] d. Face feature recognition model A and face feature recognition model B update the network parameters of each network layer according to their respective update probability values.
[0098] e. End the mutual learning between face feature recognition model A and face feature recognition model B, and return to S3.
[0099] S6: Face feature recognition model A and face feature recognition model B are trained. Retain face feature recognition model A / face feature recognition model B, and remove the classification layer in the retained face feature recognition model A / face feature recognition model B to obtain the final face feature recognition model.
[0100] This embodiment first trains each network model individually using a single type of training set. Then, network parameters are mutually learned between each network layer of each network model. This allows each network model to learn not only from the training set of the current scene but also from the feature recognition capabilities of other network models in other scenes. The learning in the current scene complements and promotes the learning in other scenes, further improving the performance of the network model and giving it good generalization ability. It can obtain a network model that can recognize features in various scenes simultaneously. At the same time, each network model is trained only on a specific type of training set. During training, the training sample images have better consistency, enabling the network model to converge better and avoiding mutual interference between training sample images of different types. In addition, the weights used to train the network model adaptively change with the number of iterations. This allows the network model to focus more on improving its own performance in the specific scene in the early stage of training and more on the generalization ability of the network model in different scenes in the later stage of training. This improves the versatility of the network model while ensuring the convergence stability of the network model as much as possible. Furthermore, determining whether to update the network parameters before mutual learning using the network parameters after mutual learning based on the update probability value allows the network model to focus more on the breadth of the solution space in the early stage of training, avoiding premature convergence to local optima, and to focus more on the depth of the solution space in the later stage of training, so that the network model has higher feature recognition performance, greatly improves the robustness of the model, and further improves the multi-scene image recognition capability of the network model.
[0101] Please see Figure 5 , Figure 5 This is a flowchart illustrating an embodiment of the target recognition method provided in this application. The method includes:
[0102] Step 51: Input the image to be recognized into the network model to obtain the features to be recognized of the target object.
[0103] The target object can be either biological or non-biological. In other words, the target recognition method in this embodiment can be used for biometric recognition such as facial recognition or non-biological recognition such as vehicle recognition, and is not limited here.
[0104] Taking a face feature recognition model as an example, the feature to be recognized can be the face feature vector of the face image to be recognized. Specifically, the network model can be the final network model trained using the network model training method in the above embodiment. After the network model is trained using the network model training method in the above embodiment, the classification layer of the final network model can be removed, and only the last fully connected layer can be retained. The feature to be recognized is the feature vector extracted from the fully connected layer of the final network model.
[0105] Step 52: Calculate the similarity between the feature to be identified and the feature to be compared, and obtain the similarity value.
[0106] The comparison features can be feature vectors from a preset feature base. By calculating the similarity between the feature to be identified and the comparison features, it is possible to determine whether the comparison features are consistent with the features in the preset feature base.
[0107] Step 53: Obtain the target recognition result based on the similarity value.
[0108] Based on the similarity value, the target recognition result is obtained. Specifically, it can be determined whether the similarity value is greater than a preset threshold. If the similarity value is greater than the preset threshold, the comparison is considered successful, and then the target recognition result is used for recognition or classification. The preset threshold can be set according to the actual situation and is not limited here.
[0109] This embodiment can use a network model with multi-scene recognition capabilities to perform feature recognition on the image to be recognized, and obtain the features to be recognized of the target object; then, based on the similarity value between the features to be recognized and the comparison features, the target recognition result is obtained, which can greatly improve the target recognition accuracy.
[0110] Please see Figure 6 , Figure 6This is a schematic diagram of an embodiment of the network model training device provided in this application. The network model training device 60 includes a memory 61 and a processor 62 connected to each other. The memory 61 is used to store computer programs. When the computer programs are executed by the processor 62, they are used to implement the network model training method in the above embodiment.
[0111] Please see Figure 7 , Figure 7 This is a schematic diagram of an embodiment of the target recognition device provided in this application. The target recognition device 70 includes a memory 71 and a processor 72 connected to each other. The memory 71 is used to store computer programs. When the computer programs are executed by the processor 72, they are used to implement the target recognition method in the above embodiment.
[0112] Please see Figure 8 , Figure 8 This is a schematic diagram of an embodiment of a computer-readable storage medium provided in this application. The computer-readable storage medium 80 is used to store a computer program 81. When the computer program 81 is executed by a processor, it is used to implement the target recognition method or the network model training method in the above embodiment.
[0113] The computer-readable storage medium 80 can be any medium capable of storing program code, such as a server, USB flash drive, portable hard drive, read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.
[0114] In the several embodiments provided in this application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and there may be other division methods in actual implementation. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.
[0115] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0116] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0117] If the technical solution of this application involves personal information, the product using this technical solution has clearly informed the user of the personal information processing rules and obtained the user's voluntary consent before processing the personal information. If the technical solution of this application involves sensitive personal information, the product using this technical solution has obtained the user's separate consent before processing the sensitive personal information, and also meets the requirement of "express consent". For example, at personal information collection devices such as cameras, clear and prominent signs are set up to inform users that they have entered the scope of personal information collection and that personal information will be collected. If an individual voluntarily enters the collection scope, it is deemed that they have agreed to the collection of their personal information; or on the personal information processing device, with clear signs / information informing users of the personal information processing rules, authorization is obtained from the individual through pop-up information or by asking the individual to upload their personal information; wherein, the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the types of personal information processed.
[0118] The above are merely embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
Claims
1. A method for training a network model, characterized in that, The method comprises the following steps: Collecting training sample images in different application scenarios, labeling real labels for all the training sample images, classifying all the labeled training sample images, and obtaining at least two training sets, each of which contains multiple training sample images in different application scenarios; Obtaining at least two network models corresponding to the number of training sets, wherein the at least two network models have the same network structure; Iteratively training the corresponding network model using the training sample images in each training set, so that the network model adjusts its network parameters based on the training sample images; In response to the iterative training reaching a preset mutual learning condition, mutual learning is performed between the network parameters at the same position of the at least two network models; In response to the at least two network models not being trained, returning to the step of iteratively training the corresponding network model using the training sample images in each training set; In response to the at least two network models being trained, determining a final network model from the at least two network models. 2.The method of Claim 1, wherein, The step of performing mutual learning between the network parameters at the same position of the at least two network models in response to the iterative training reaching a preset mutual learning condition comprises: In response to the current iteration number of each network model reaching a preset number threshold, it is determined that the iterative training reaches the mutual learning condition.
3. The network model training method of claim 1, wherein the step of performing mutual learning between the network parameters at the same position of the at least two network models in response to the iterative training reaching a preset mutual learning condition further comprises: Selecting any network model from the at least two network models as a to-be-updated network model; Weighted summing the network parameters at the same position of the to-be-updated network model and other network models to obtain a sum value as the mutual learning network parameters of the to-be-updated network model; After the network parameter update of the to-be-updated network model is completed, selecting another network model from the at least two network models as a to-be-updated network model until all network models are traversed. The step of weighted summing the network parameters at the same position of the to-be-updated network model and other network models comprises: 4.The method of Claim 3, wherein, Obtaining a first weight and a second weight; Taking the first weight as the weight value of the network parameters of the to-be-updated network model and taking the second weight as the weight value of the network parameters of other network models, wherein the first weight gradually decreases with the iterative training, and / or the second weight gradually increases with the iterative training. The step of obtaining a first weight and a second weight comprises: 5.The method of Claim 4, wherein, Based on the total number of the at least two network models, the current iteration number, and the maximum iteration number, the first weight is calculated, wherein the first weight is negatively correlated with the current iteration number; Based on the first weight and the total number of the at least two network models, the second weight is calculated, wherein the second weight is negatively correlated with the first weight. 6.The method of Claim 1, wherein, The step of performing mutual learning between network parameters at the same position of the at least two network models in response to the iterative training reaching the preset mutual learning condition further comprises: obtaining a first loss value of the network parameters of the network model to be updated before mutual learning and a corresponding second loss value of the network parameters after mutual learning; subtracting the first loss value from the second loss value to obtain a loss change value; based on the loss change value, calculating an update probability value, wherein the update probability value is positively correlated with the loss change value; based on the update probability value, determining whether to update the network parameters before mutual learning with the network parameters after mutual learning.
7. The method of claim 6, wherein, The step of calculating an update probability value based on the loss change value comprises: in response to the loss change value being greater than a preset loss threshold, determining the update probability value to be a first preset value; in response to the loss change value being less than or equal to the loss threshold, calculating the update probability value based on a preset annealing temperature value and the loss change value, wherein the update probability value is further negatively correlated with the annealing temperature value, and the annealing temperature value gradually decreases with the iterative training. 8.The method of Claim 6, wherein, The step of determining whether to update the network parameters before mutual learning with the network parameters after mutual learning based on the update probability value comprises: for each network parameter of the network model to be updated, generating a random number in a preset value range; in response to the random number being greater than the update probability value, keeping the network parameters before mutual learning unchanged, and in response to the random number being less than or equal to the update probability value, updating the network parameters before mutual learning with the network parameters after mutual learning; or in response to the random number being less than or equal to the update probability value, keeping the network parameters before mutual learning unchanged, and in response to the random number being greater than the update probability value, updating the network parameters before mutual learning with the network parameters after mutual learning.
9. A target recognition method characterized by, comprising: inputting an image to be identified into a network model to obtain an identification feature of a target object; wherein the network model is a final network model trained by the network model training method of any one of claims 1-8; performing similarity calculation on the identification feature and the comparison feature to obtain a similarity value; based on the similarity value, obtaining a target identification result.
10. A training device for a network model, characterized in that, comprising a memory and a processor connected to each other, wherein the memory is used to store a computer program, and the computer program is used to implement the network model training method of any one of claims 1-8 when executed by the processor.
11. A target recognition device, characterized by comprising a memory and a processor connected to each other, wherein the memory is used to store a computer program, and the computer program is used to implement the target identification method of claim 9 when executed by the processor.
12. A computer readable storage medium for storing a computer program, characterized in that, The computer program is used to implement the network model training method of any one of claims 1-8 or the target identification method of claim 9 when executed by the processor.
Citation Information
Patent Citations
Method and device for improving the prediction performance of a depth learning network, and a storage medium
CN109376615A