Image classification method, system, electronic device and storage medium

By introducing a target activation function with adaptive and trainable parameters into the image classification model, the problem of insufficient utilization of complex scene data by the image classification model is solved, and the generalization and recognition rate of the model are improved, especially in face recognition and Recognition rate of complex scenes.

CN114708460BActive Publication Date: 2024-09-17JINAN BOGUAN INTELLIGENT TECH CO LTD
View PDF 12 Cites 0 Cited by

Patent Information

Application Number
CN202210378910.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-12
Publication Date
2024-09-17
Estimated Expiration
2042-04-12

AI Technical Summary

Technical Problem

Existing image classification models lack complex scene data during the training process, resulting in insufficient model generalization and recognition rate, and cannot meet the needs of high tolerance and fine scenes.

Method used

The target activation function of adaptive parameters and trainable parameters is used to update the image classification model by calculating the sample feature matrix and loss function value, making full use of the training data to improve the generalization and recognition rate of the model.

Benefits of technology

It improves the accuracy of image classification and the flexibility of the model, especially the recognition rate in complex scenes such as face recognition, wearing masks and searching for pictures by pictures.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114708460B
    Figure CN114708460B
Patent Text Reader

Abstract

The present application discloses an image classification method, including: setting a target activation function of an image classification model; determining a current batch of samples, and using the target activation function to calculate a sample feature matrix corresponding to the current batch of samples; calculating a loss function value according to the sample feature matrix, and using the loss function value to update the network parameters of the image classification model, so as to train the image classification model; if an unknown image is received, the image category of the unknown image is output using the trained image classification model, and the present application can improve the image classification accuracy. The present application also discloses an image classification system, a storage medium, and an electronic device, which have the above beneficial effects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence, and in particular to an image classification method, system, electronic device and storage medium. Background Art

[0002] With the continuous emergence of new demands in the field of image classification, scene classification in the existing image classification model training process is becoming more and more sophisticated, and the model needs to be more and more inclusive of various scenes. Only a high recognition rate in ordinary scenes can no longer meet the existing needs. Since there is no data for these special scenes in the conventional training set, it is necessary to add training data for more comprehensive, complex, and difficult scenes to improve the flexibility and generalization of the model. However, the training data for these complex scenes is often quite different from the existing training data. When the data of such scenes is added, the conventional activation function performs the same activation operation on the neurons by channel, and the rich training data is not fully utilized, which is not conducive to improving the generalization of the model and reduces the accuracy of image classification.

[0003] Therefore, how to improve the accuracy of image classification is a technical problem that technicians in this field currently need to solve. Summary of the invention

[0004] The purpose of this application is to provide an image classification method, system, electronic device and storage medium, which can improve the accuracy of image classification.

[0005] In order to solve the above technical problems, the present application provides an image classification method, which includes:

[0006] Setting a target activation function for the image classification model; wherein the target activation function includes an adaptive parameter and a trainable parameter, the adaptive parameter is used to control whether the neuron performs an activation operation, and the trainable parameter is used to control the degree of the activation operation;

[0007] Determine a current batch of samples, and use the target activation function to calculate a sample feature matrix corresponding to the current batch of samples;

[0008] Calculating a loss function value according to the sample feature matrix, and using the loss function value to update a network parameter of the image classification model so as to train the image classification model;

[0009] If an unknown image is received, the trained image classification model is used to output the image category of the unknown image.

[0010] Optionally, calculating the loss function value according to the sample feature matrix includes:

[0011] Multiplying the sample feature matrix of the image sample with the corresponding sample label matrix to obtain the correct classification feature value of each of the image samples;

[0012] Adding the correct classification feature value, the fixed angle interval and the interval random parameter to obtain the similarity between the training sample and the correct classification class center; wherein the interval random parameter is the value of the normal distribution function;

[0013] A loss function value is calculated according to the similarity.

[0014] Optionally, the loss function L of the image classification model is Delta for:

[0015]

[0016] N is the number of samples in the current batch, i is the i-th sample, e is the natural logarithm, s is the radian of the normalized hypersphere, n is the total number of categories, j is the j-th category, cosθ yi is the correct classification feature value of the i-th sample, cosθ j is the feature value of the i-th sample that is misclassified except for the correct classification, y i is the label of the i-th sample, m is the angle interval, and Δ is the interval random parameter.

[0017] Optionally, set the target activation function for the image classification model, including:

[0018] The activation function of the last N blocks of the image classification model is set to the target activation function.

[0019] Optionally, the target activation function Y Ada for:

[0020]

[0021] a1 and a2 are the trainable parameters, β is the adaptive parameter, and x is the input feature of the target activation function.

[0022] Optionally, the calculation process of the adaptive parameter includes: performing a global average pooling operation on the input features of the target activation function in two dimensions, height and width, to obtain the target features, and performing a convolution calculation on the target features to obtain the adaptive parameter;

[0023] Correspondingly, it also includes:

[0024] A target activation function value is calculated according to the adaptive parameter and the input feature of the target activation function.

[0025] Optionally, performing convolution calculation on the target feature to obtain the adaptive parameter includes:

[0026] A 1×1 convolution calculation with output channels of C / r and C is performed on the target feature to obtain the adaptive parameter; C is the number of channels of the input feature of the target activation function, and r is the scaling factor.

[0027] The present application also provides an image classification system, the system comprising:

[0028] An activation parameter setting module, used to set a target activation function of the image classification model; wherein the target activation function includes an adaptive parameter and a trainable parameter, the adaptive parameter is used to control whether the neuron performs an activation operation, and the trainable parameter is used to control the degree of the activation operation;

[0029] An activation function module, used to determine the current batch of samples, and calculate the sample feature matrix corresponding to the current batch of samples using the target activation function;

[0030] An updating module, used to calculate a loss function value according to the sample feature matrix, and use the loss function value to update the network parameters of the image classification model so as to train the image classification model;

[0031] The classification module is used to output the image category of the unknown image using the trained image classification model if an unknown image is received.

[0032] The present application also provides a storage medium on which a computer program is stored, and when the computer program is executed, the steps of the above-mentioned image classification method are implemented.

[0033] The present application also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above-mentioned image classification method when calling the computer program in the memory.

[0034] The present application provides an image classification method, comprising: setting a target activation function of an image classification model; wherein the target activation function comprises an adaptive parameter and a trainable parameter, the adaptive parameter is used to control whether a neuron performs an activation operation, and the trainable parameter is used to control the degree of the activation operation; determining a current batch of samples, and using the target activation function to calculate a sample feature matrix corresponding to the current batch of samples; calculating a loss function value according to the sample feature matrix, and using the loss function value to update a network parameter of the image classification model, so as to train the image classification model; if an unknown image is received, using the trained image classification model to output the image category of the unknown image.

[0035] The present application sets a target activation function for the image classification model, and the target activation function includes adaptive parameters and trainable parameters. After determining the current batch of samples, the above target activation function can be used to obtain the corresponding sample feature matrix. Since the adaptive parameters in the activation function can control whether the neuron performs an activation operation, and the trainable parameters can control the degree of the activation operation, the image classification model can choose whether to activate the current batch of samples and to what extent the activation operation is performed, thereby making full use of the current batch of samples. The image classification model trained in the above manner has good generalization and can improve the accuracy of image classification. The present application also provides an image classification system, a storage medium and an electronic device, which have the above-mentioned beneficial effects and are not repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0037] Figure 1 A flowchart of an image classification method provided in an embodiment of the present application;

[0038] Figure 2 A schematic diagram of the classification boundary division of an Arcface loss provided in an embodiment of the present application;

[0039] Figure 3 A schematic diagram of the classification boundary division of a Delta_arcface loss provided in an embodiment of the present application;

[0040] Figure 4 A schematic diagram of the structure of an image classification system provided in an embodiment of the present application. DETAILED DESCRIPTION

[0041] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0042] See below Figure 1 , Figure 1 A flowchart of an image classification method provided in an embodiment of the present application.

[0043] Specific steps may include:

[0044] S101: Setting the target activation function of the image classification model;

[0045] Among them, this embodiment can be applied to an electronic device including an image classification model. In this step, a target activation function of the image classification model can be set, and the target activation function includes an adaptive parameter and a trainable parameter. The adaptive parameter is used to control whether the neuron performs an activation operation, and the trainable parameter is used to control the degree of the activation operation. The target activation function including the adaptive parameter and the trainable parameter can select whether to perform the activation operation, and can also select the degree of the activation operation.

[0046] S102: Determine a current batch of samples, and use the target activation function to calculate a sample feature matrix corresponding to the current batch of samples;

[0047] In this step, the current batch of samples can be selected from the sample set, and the samples in the current batch of samples can specifically be images containing labels. In this embodiment, the target activation function can be used to calculate the sample feature matrix corresponding to each sample in the current batch of samples.

[0048] S103: Calculating a loss function value according to the sample feature matrix, and using the loss function value to update a network parameter of the image classification model, so as to train the image classification model;

[0049] After obtaining the sample feature matrix, the loss function of the image classification model can be used to calculate the loss function value, and then the network parameters of the image classification model can be updated using the loss function value to train the image classification model. Specifically, in this embodiment, there can be multiple iterations of the image classification model training operation. After the network parameters of the image classification model are updated using the loss function value, a new current batch of samples can be determined, and then the related operations of S102 to S103 can be repeatedly performed until the iteration termination condition is met.

[0050] S104: If an unknown image is received, the image category of the unknown image is output using the trained image classification model.

[0051] Among them, the unknown image is an image of uncertain image category. In this step, the unknown image can be input into the trained image classification model to obtain the image category of the unknown image.

[0052] This embodiment sets the target activation function of the image classification model, and the target activation function includes adaptive parameters and trainable parameters. After determining the current batch of samples, the above activation function can be used to obtain the corresponding sample feature matrix. Since the adaptive parameters in the activation function can control whether the neuron is activated, and the trainable parameters can control the degree of activation, the image classification model can choose whether to activate the current batch of samples and to what extent the activation operation is performed, thereby making full use of the current batch of samples. The image classification model trained in the above manner has good generalization and can improve the accuracy of image classification.

[0053] As for Figure 1 Further introduction to the corresponding embodiment, since there are trainable parameters in the target activation function, the number of model parameters will increase. There are usually multiple blocks in the image classification model. If each block is set with a target activation function, the network parameters will become very large, affecting the normal training of the image classification model. Therefore, in this embodiment, the activation function of the last N blocks of the image classification model can be set to the target activation function. The value of N can be 2, 3 or 4.

[0054] In this embodiment, the target activation function can be obtained by adjusting the existing activation function. The target activation function Y constructed based on Prelu Ada for:

[0055]

[0056] a1 and a2 are the trainable parameters, β is the adaptive parameter (when β is 0, no activation operation is performed), x is the input feature of the target activation function, and σ is the sigmoid function.

[0057] Specifically, the calculation process of the above-mentioned adaptive parameters includes: performing a global average pooling operation on the input features of the target activation function in the two dimensions of height and width to obtain the target features, and performing a convolution calculation on the target features to obtain the adaptive parameters. This embodiment can also calculate the target activation function value based on the adaptive parameters and the input features of the target activation function. The above-mentioned process of performing a convolution calculation on the target features to obtain the adaptive parameters is: performing a 1×1 convolution calculation with output channels of C / r and C on the target features to obtain the adaptive parameters; C is the number of channels of the input features of the target activation function, and r is the scaling factor.

[0058] The above embodiment provides an activation function of an image classification model. The above target activation function can update adaptive parameters based on the training data currently input, adjust whether the neurons in the recognition network are activated, and to what extent the activation operation is performed, thereby improving the recognition rate of the model. The target activation function proposed in this embodiment can replace a part of the original activation function in the Resnet structure to reduce the number of model parameters. In practical applications, the above image classification model can be a face recognition model. By setting the above target activation function for the face recognition model, the accuracy of face recognition can be improved while avoiding a surge in the number of model parameters.

[0059] As for Figure 1 Further introduction to the corresponding embodiment, the loss function value can be calculated in the following way: multiply the sample feature matrix of the image sample with the corresponding sample label matrix to obtain the correct classification feature value of each image sample; add the correct classification feature value, fixed angle interval and interval random parameter to obtain the similarity between the training sample and the correct classification class center; wherein the interval random parameter is the value of the normal distribution function; and calculate the loss function value based on the similarity.

[0060] The loss function L of the above image classification model is Delta for:

[0061]

[0062] N is the number of samples in the current batch, i is the i-th sample, e is the natural logarithm, s is the radian of the normalized hypersphere, n is the total number of categories, j is the j-th category, cosθ yi is the correct classification feature value of the i-th sample, cosθ j is the feature value of the i-th sample that is misclassified except for the correct classification, y i is the label of the i-th sample, m is the angle interval, and Δ is the interval random parameter.

[0063] The above embodiment provides a training method for an image classification model, which is trained based on a loss function that can improve classification flexibility. Taking the face recognition model as an example, the loss function better adjusts the distance division within and between classes by adding interval random parameters, and ultimately improves the classification precision and accuracy of the face recognition model, which is more effective for image search and mask wearing scenes. The above loss function can exist after the classification layer of the network structure, and its implementation and existence do not affect any part of the recognition network. Therefore, it can be used in other network structures such as SENet and GCNet, and can also replace more parts when the performance of video memory is higher, so as to be applicable to a variety of recognition networks and a variety of training environments.

[0064] The process described in the above embodiment is explained below by taking a face recognition model as an example in actual application as an image classification model.

[0065] Face recognition is a classification task in a broad sense. During training, one person is treated as one class, so that different people are separated as much as possible in the feature space. The traditional classification task is a closed set task, that is, the number of classes during training is the same as that during use, and only a clear dividing line between classes is required. Face recognition through deep learning is different from the traditional classification task. First, the number of training classes for face recognition tasks is different from that during use, and it is an open set task; second, due to the diversity of recognition classes, face recognition tasks require more layers of network structures to extract high-dimensional face features. In the process of exploring deep learning, it is found that the expansion of depth is far better than the expansion of breadth, because the more neurons learn features, the higher the degree of abstraction. But in fact, the accuracy of a convolutional neural network model that is too deep will decrease. The reason is that due to multiplication transmission, the deeper the depth, the more serious the problems of gradient vanishing and gradient explosion will be. The residual network Resnet uses residual learning to make it easier for information to flow between layers, provide feature reuse during forward propagation, and alleviate gradient vanishing during back propagation. Therefore, this field chooses Resnet for face recognition model training.

[0066] In the face recognition network composed of the Resnet structure, both the activation function and the loss function are indispensable: high-dimensional face features are extracted through a multi-layer residual network structure and finally passed to the loss function to cluster similar face features, and the face recognition model is obtained after optimization. In subsequent tests, the test images and the base photos are compared with the high-dimensional features obtained by the model, and they can only be judged as the same person if the similarity is greater than a certain threshold. Therefore, the loss function plays a role in the face recognition process; and the activation function introduces nonlinearity to the entire network, strengthening the network's learning ability.

[0067] With the continuous emergence of new demands in the field of face recognition, the classification of races, scenes, and age groups in the existing face recognition model training process has become more and more refined, and the model needs to be more and more inclusive of various scenes. Only a high recognition rate in ordinary scenes can no longer meet the existing needs. It is also necessary to have good recognition performance in different regions / skin colors, small pixels, wearing masks, image search, monitoring, access control and other usage scenarios. Since there is no data for these special scenes in the conventional training set, it is necessary to add more comprehensive, complex, and difficult scene training data to improve the flexibility and generalization of the model. However, the training data of these complex scenes is often quite different from the existing training data. Therefore, when adding data from such scenes, the loss function and activation function will encounter different problems.

[0068] The loss functions of face recognition models in existing solutions, such as Cos_Face and Arcface, inherit the idea of ​​the softmax classification loss function and minimize the intra-class distance and maximize the inter-class distance by adding margin. However, since a fixed value of margin is added, all data are treated equally during the training process, and the same constraints are imposed on the intra-class and inter-class of each classification. The newly added data is quite different from the regular training data, which can easily limit the judgment ability and robustness of the face recognition model. On the other hand, the activation functions commonly used in face recognition models, such as relu and prelu, generally perform activation operations in the channel dimension, and all neurons in each channel will participate in the same degree of activation, but the above method does not fully utilize the diversity of samples.

[0069] In view of the defects of the above-mentioned commonly used face recognition models, this embodiment provides a face recognition model training method that can make full use of data diversity and give the model flexibility. On the basis of selecting the existing residual network, the loss function and some activation function modules in the face recognition network are improved: interval random parameters are added to make the margin vary within a certain range, and the compactness within the class and the distinction between classes are strengthened in a more flexible way; according to the different training samples in each mini-batch, the trainable parameters in the activation function are adaptively adjusted to achieve the maximum utilization of training data for various scenes. The face recognition model trained after adding the new loss function and activation function module improves the generalization and stability of the model, and the recognition rate in each scene is improved. The recognition rate improvement effect of the scene of image search and mask recognition is better. Mini-batch refers to the batch size, that is, the number of samples selected before each training iteration. After selection, the samples of the batch are sent to the network, and their corresponding parameter adjustment values ​​are calculated. Finally, all the adjustment values ​​are averaged as the final adjustment value, so as to update and optimize the network parameters.

[0070] The main purpose of this embodiment is to improve the recognition rate of face recognition models in image search, mask wearing, and small pixel scenes. To improve the recognition rate of these complex scenes, improve the flexibility and generalization of the model, more similar scene training data must be added, and the use of these training data must be strengthened. However, these newly added data are in sharp contrast with the training data of previous conventional scenes, and the differences within and between classes are also uneven. If a loss function with a fixed angle interval margin like arcface is still used, the model will not be able to learn this difference well, and ultimately limit the flexibility and discrimination ability of the model; if an activation function like prelu is still used, the representative features of these newly added data cannot be fully utilized, which ultimately affects the generalization and recognition rate of the model. Therefore, the main improvement of this embodiment is to adjust the loss function and activation function of the face recognition model.

[0071] The improvement of the loss function is described as follows:

[0072] Conventional loss functions, such as Arcface and Cosface, mainly add an angle interval m (i.e., margin) to the correctly classified θ based on the Softmax function, which then corresponds to the arc in the normalized hypersphere, ultimately achieving a stricter classification boundary. Figure 2 As shown, m is a hyperparameter with a fixed value, and Class1 and Class2 are two categories, so all input training data are subject to the same constraint. When the number of categories in the training set is large, the differences between categories will also be very large, and there will be a large gap between the intra-class distance and the inter-class distance. If a fixed margin is used, it will be very unfavorable to improve the generalization of the model. In response to the above problems, this embodiment proposes a new loss function Delta_arcface loss, defines an interval random parameter Δ, so that the angular interval m of the loss function can vary within a certain range, and uses the new random angular interval to make the recognition model more flexible and universal in classification learning. Its classification boundary division is as follows Figure 3 As shown:

[0073] The function expression of the loss function Delta_arcface loss is as follows:

[0074]

[0075] Among them, Δ is a normal distribution function with a mean of 0 and a standard deviation of σ. When the high-dimensional features of the training data are input into Delta_arcface loss, the correctly classified θ yi The angle interval m and the random interval operator Δ are added, and the classification boundary of any training sample in each Mini-Batch is randomly selected according to Δ. When σ=0, Delta_arcfaceloss is equivalent to the original Arcface loss. The way to implement Δ using numpy is as follows:

[0076] Delta=np.random_normal(loc=0.0, scale=0.05, size=(cfg.batch_size,1)).

[0077] After adjusting the interval random parameter Δ, the compactness within the class and the distinction between classes become more flexible, and the generalization of the face recognition model will be better.

[0078] The update process of the loss function Delta_arcface loss includes:

[0079] Step A1: define and initialize the interval random parameter Δ. In this embodiment, Δ can be set to a random number that obeys a normal distribution, with a mean of 0 and a standard deviation of 0.05.

[0080] Step A2: Multiply the normalized sample feature matrix of the current training batch output by the face recognition forward network by the sample label matrix of the current training batch to obtain the correct classification feature value of each sample.

[0081] Step A3: Add the correct classification features obtained in step A2 to the fixed angle interval m and the interval random parameter Δ to obtain the cosine similarity between the new training sample and the center of the correct classification class.

[0082] Step A4: After the parameters are updated, find the current Delta_arcface loss value, merge it into Loss_op, and use the optimizer to update the network parameters. Loss_op is the total loss function of the face recognition model.

[0083] The improvements to the activation function are as follows:

[0084] Commonly used activation functions such as Prelu give a learnable gradient parameter α to the x<0 part, which can preserve the effective features of the x<0 part. However, it applies the same activation operation to the neurons in each channel, and cannot make full use of the newly added complex scene training data. In view of the above defects, this embodiment proposes a target activation function Ada_Prelu. The function expression of Ada_Prelu is as follows:

[0085]

[0086] Among them, σ is the sigmoid function, β is an adaptive parameter of size (N, 1, 1, C), which controls whether the neurons of this channel are activated (β is 0 if not activated). C1 is a 1x1 convolution with an output channel of C / r, C2 is a 1x1 convolution with an output channel of C, and r is the scaling factor. In this embodiment, the average of x in the H and W dimensions is first calculated, and then two 1x1 convolutions are performed. Finally, a sigmoid function is used to obtain a number between (0, 1) to control whether to activate. The implementation method using Tensorflow is as follows:

[0087] x_mean=tf.nn.avg_pool(X_input,ksize=[1,k,k,1], strides=[1,1,1,1],padding='VALID')

[0088] x_mean=tf.layers.conv2d(x_mean, filters=filters / 16, kernel_size=1, padding='SAME', use_bias=False, trainable=training, kernel_regularizer=tfc.layers.l2_regularizer(cfg.weight_decay), name='ada_con1')

[0089] x_mean=tf.layers.conv2d(x_mean, filters=filters, kernel_size=1, padding='SAME', use_bias=False, trainable=training, kernel_regularizer=tfc.layers.l2_regularizer(cfg.weight_decay), name='ada_con2')

[0090] beta=tf.nn.sigmoid(x_mean,name='ada_sig1')

[0091] a1 and a2 are trainable parameters that adaptively adjust the activation function. The final implementation of the activation function is as follows:

[0092] S=tf.square(a1)-2*a2)*x*tf.nn.sigmoid(beta*(tf.square(a1)-2*a2)*x)+2*a2*x.

[0093] In this embodiment, trainable parameters are added to Ada_Prelu, so the number of model parameters will increase slightly. If each Prelu is changed to Ada_Prelu in each block, the network parameters will become very large and cannot be trained in the current training environment. In this embodiment, in the three blocks of the last stage, the Prelu module is replaced with the above-mentioned Ada_Prelu module. The size of the model trained in this way only increases by 0.3M. The above method only increases some trainable parameters of the activation function, does not add complex and incompatible functions, and the model size only increases by 0.3M. Therefore, while improving the model recognition rate, subsequent operations such as productization can be carried out normally.

[0094] The update process of the activation function Ada_Prelu includes:

[0095] Step B1: define the adaptive parameter β, and train the parameters a1 and a2 and initialize them. In this embodiment, the initial values ​​of the parameters can be set as: a1 = 1, a2 = 0.25.

[0096] Step B2: Perform global average pooling on the features of the input Ada_Prelu module in both height H and width W dimensions so that the features of each channel share a weight. Perform two 1x1 convolutions on the obtained features to find the value of β.

[0097] Step B3: Combine the β obtained in step B2 with the trainable parameters a1 and a2 to obtain the output features of the Ada_Prelu activation function.

[0098] Combining β, a1 and a2 gives:

[0099] Step B4: Update the Prelu module in the last three blocks to the Ada_Prelu module, and send the obtained high-dimensional features to the Delta_arcface loss to optimize the recognition network parameters.

[0100] In order to verify the effectiveness of the improved face recognition model of the present invention, this embodiment uses two test sets for testing: 12,500 types of dynamic face data as the test base library, first use the base library and 6,800 error set face pictures to test the threshold of the error recognition rate, and then select 22,000 test pictures for testing under the threshold condition of 0.1% error recognition rate; 24,500 pictures of image search scene pictures as the test base library, select 1,454 machine non-human test pictures and 350 test pictures of wearing masks, and test the top1 and top5 recognition rates of the image search scene respectively. The recognition results are shown in Table 1:

[0101] Table 1 Recognition rate comparison table

[0102]

[0103] As can be seen from Table 1, the model trained by the Delta_arcface loss and Ada_Prelu modules proposed in this embodiment has improved the recognition rate of each scene to a certain extent compared with the conventional baseline model, and the recognition rate of the image search scene and the mask wearing scene, which were previously relatively weak, has been significantly improved. It can be seen that the loss function and activation function proposed in this embodiment can significantly improve the face recognition rate of various scenes and significantly improve the generalization of the model.

[0104] This embodiment makes full use of the training data collected from different scenes, different time periods and people of different age groups, and better combines the features of each data instance with the updated statistical information in the mini-batch, so that the data features are in a stable distribution, and the intra-class and inter-class distances can be adjusted more flexibly, and the parameters are adaptively adjusted through representative features, focusing on solving the problem of low recognition rate of face recognition models in complex scenes such as image search and wearing masks, and finally achieving the purpose of optimizing the model recognition rate. In the new loss function, an interval random parameter Δ is defined, so that the margin of the loss function can vary within a certain range, and finally the model can more flexibly control the compactness within the class and the distinction between classes; in the new activation function module, trainable parameters β, a1, and a2 are defined, and the values ​​of β, a1, and a2 are adaptively adjusted using input features, and finally β is used to control whether the neuron is activated, and a1 and a2 are used to control the degree of activation operation. Through these trainable parameters, the purpose of adaptively optimizing the face recognition model by using the diversity of training sample features is achieved.

[0105] See also Figure 4 , Figure 4 A schematic diagram of the structure of an image classification system provided in an embodiment of the present application;

[0106] The system may include:

[0107] An activation parameter setting module 401 is used to set a target activation function of the image classification model; wherein the target activation function includes an adaptive parameter and a trainable parameter, the adaptive parameter is used to control whether the neuron performs an activation operation, and the trainable parameter is used to control the degree of the activation operation;

[0108] An activation function module 402 is used to determine the current batch of samples and calculate the sample feature matrix corresponding to the current batch of samples using the target activation function;

[0109] An updating module 403, configured to calculate a loss function value according to the sample feature matrix, and use the loss function value to update a network parameter of the image classification model so as to train the image classification model;

[0110] The classification module 404 is configured to output the image category of the unknown image using the trained image classification model if an unknown image is received.

[0111] The present application sets a target activation function for the image classification model, and the target activation function includes adaptive parameters and trainable parameters. After determining the current batch of samples, the above activation function can be used to obtain the corresponding sample feature matrix. Since the adaptive parameters in the activation function can control whether the neuron is activated, and the trainable parameters can control the degree of activation, the image classification model can choose whether to activate the current batch of samples and to what extent the activation operation is performed, thereby making full use of the current batch of samples. The image classification model trained in the above manner has good generalization and can improve the accuracy of image classification.

[0112] Furthermore, the process of updating module 403 calculating the loss function value according to the sample feature matrix includes: multiplying the sample feature matrix of the image sample with the corresponding sample label matrix to obtain the correct classification feature value of each image sample; adding the correct classification feature value, fixed angle interval and interval random parameter to obtain the similarity between the training sample and the correct classification class center; wherein the interval random parameter is the value of the normal distribution function; and calculating the loss function value according to the similarity.

[0113] Furthermore, the loss function L of the image classification model is Delta for:

[0114]

[0115] N is the number of samples in the current batch, i is the i-th sample, e is the natural logarithm, s is the radian of the normalized hypersphere, n is the total number of categories, j is the j-th category, cosθ yi is the correct classification feature value of the i-th sample, cosθ j is the feature value of the i-th sample that is misclassified except for the correct classification, y i is the label of the i-th sample, m is the angle interval, and Δ is the interval random parameter.

[0116] Furthermore, the activation parameter setting module 401 is used to set the activation function of the last N blocks of the image classification model as the target activation function.

[0117] Furthermore, the target activation function Y Ada for:

[0118]

[0119] a1 and a2 are the trainable parameters, β is the adaptive parameter, and x is the input feature of the target activation function.

[0120] Furthermore, it also includes:

[0121] An adaptive parameter calculation module, used for performing a global average pooling operation on the input features of the target activation function in two dimensions, height and width, to obtain a target feature, and performing a convolution calculation on the target feature to obtain the adaptive parameter;

[0122] The function value calculation module is used to calculate the target activation function value according to the adaptive parameters and the input characteristics of the target activation function.

[0123] Furthermore, the process in which the adaptive parameter calculation module performs convolution calculation on the target feature to obtain the adaptive parameter includes: performing a 1×1 convolution calculation with output channels of C / r and C on the target feature to obtain the adaptive parameter; C is the number of channels of the input feature of the target activation function, and r is the scaling factor.

[0124] Since the embodiments of the system part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the system part, which will not be repeated here.

[0125] The present application also provides a storage medium on which a computer program is stored, and when the computer program is executed, the steps provided in the above embodiment can be implemented. The storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.

[0126] The present application also provides an electronic device, which may include a memory and a processor, wherein a computer program is stored in the memory, and when the processor calls the computer program in the memory, the steps provided in the above embodiment may be implemented. Of course, the electronic device may also include various network interfaces, power supplies and other components.

[0127] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the various embodiments can be referred to each other. For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of this application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of this application.

[0128] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprises", "comprising" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.

Claims

1. A face recognition method based on image classification, characterized in that: include: Setting a target activation function for an image classification model; wherein the target activation function includes an adaptive parameter and a trainable parameter, the adaptive parameter is used to control whether a neuron performs an activation operation, and the trainable parameter is used to control the degree of the activation operation, and the image classification model is a face recognition model; Determine a current batch of samples, and use the target activation function to calculate a sample feature matrix corresponding to the current batch of samples; Calculating a loss function value according to the sample feature matrix, and using the loss function value to update a network parameter of the image classification model so as to train the image classification model; If an unknown image is received, the trained image classification model is used to output the image category of the unknown image, and a corresponding face recognition result is determined according to the image category; Among them, the target activation function Y Ada for: ; a1 and a2 are the trainable parameters, β is the adaptive parameter, x is the input feature of the target activation function, and σ is the sigmoid function.

2. The face recognition method based on image classification according to claim 1, characterized in that: Calculating the loss function value according to the sample feature matrix includes: Multiplying the sample feature matrix of the current batch of samples with the corresponding sample label matrix to obtain the correct classification feature value of each of the current batch of samples; Adding the correct classification feature value, the fixed angle interval and the interval random parameter to obtain the similarity between the training sample and the correct classification class center; wherein the interval random parameter is the value of the normal distribution function; A loss function value is calculated according to the similarity.

3. The face recognition method based on image classification according to claim 2, characterized in that: The loss function L of the image classification model Delta for: ; N is the number of samples in the current batch, i is the i-th sample, e is the natural logarithm, s is the radian of the normalized hypersphere, n is the total number of categories, j is the j-th category, cosθ yi is the correct classification feature value of the i-th sample, cosθ j is the feature value of the i-th sample that is misclassified except for the correct classification, y i is the label of the i-th sample, m is the angle interval, and Δ is the interval random parameter.

4. The face recognition method based on image classification according to claim 1, characterized in that: The setting of the target activation function of the image classification model includes: The activation function of the last N blocks of the image classification model is set to the target activation function.

5. The face recognition method based on image classification according to claim 1, characterized in that: The calculation process of the adaptive parameter includes: performing a global average pooling operation on the input features of the target activation function in two dimensions, height and width, to obtain the target features, and performing a convolution calculation on the target features to obtain the adaptive parameter; Correspondingly, it also includes: A target activation function value is calculated according to the adaptive parameter and the input feature of the target activation function.

6. The face recognition method based on image classification according to claim 5, characterized in that: Performing convolution calculation on the target feature to obtain the adaptive parameter includes: A 1×1 convolution calculation with output channels of C / r and C is performed on the target feature to obtain the adaptive parameter; C is the number of channels of the input feature of the target activation function, and r is the scaling factor.

7. A face recognition system based on image classification, characterized in that: include: An activation parameter setting module, used to set a target activation function of an image classification model; wherein the target activation function includes an adaptive parameter and a trainable parameter, the adaptive parameter is used to control whether a neuron performs an activation operation, and the trainable parameter is used to control the degree of the activation operation, and the image classification model is a face recognition model; An activation function module, used to determine the current batch of samples, and calculate the sample feature matrix corresponding to the current batch of samples using the target activation function; An updating module, used to calculate a loss function value according to the sample feature matrix, and use the loss function value to update the network parameters of the image classification model so as to train the image classification model; A classification module, for, if an unknown image is received, outputting the image category of the unknown image using the trained image classification model, and determining a corresponding face recognition result according to the image category; Among them, the target activation function Y Ada for: ; a1 and a2 are the trainable parameters, β is the adaptive parameter, x is the input feature of the target activation function, and σ is the sigmoid function.

8. An electronic device, characterized in that: It comprises a memory and a processor, wherein the memory stores a computer program, and when the processor calls the computer program in the memory, the steps of the face recognition method based on image classification as claimed in any one of claims 1 to 6 are implemented.

9. A storage medium, characterized in that: The storage medium stores computer executable instructions, and when the computer executable instructions are loaded and executed by the processor, the steps of the face recognition method based on image classification as claimed in any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Image classification method based on high-constraint high-dispersion principal component analysis network

    CN106485259A

  • Image quality evaluation method based on combination neural network and classification neural network

    CN108665460A

  • Adaptive activation function parameter adjustment method facing deep neural network

    CN108898213A

  • Image confrontation sample generation device and method based on mobility

    CN112215292A

  • Image classification method and device and related components

    CN112270343A