A knowledge distillation method of a smoking and calling classification attention model

By configuring additional datasets and dynamically adjusting the data ratio in the smoking and phone call classification, and combining the prediction results of the teacher network and student network for knowledge distillation training, the problem of limited data volume is solved, and the classification performance and robustness of the attention model are improved.

CN115482581BActive Publication Date: 2026-02-10WUHAN UNIV OF SCI & TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211000837.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-19
Publication Date
2026-02-10
Estimated Expiration
2042-08-19

AI Technical Summary

Technical Problem

In the scenario of classifying smoking and making phone calls, the dataset is limited, the attention model is prone to getting stuck in local optima, and the performance of the student network cannot match that of the corresponding CNN teacher network. Existing knowledge distillation training methods are not effective.

Method used

By configuring an additional dataset to mix with the smoking and phone call dataset, the dataset ratio and prediction label error correction are dynamically adjusted. Knowledge distillation training is performed by combining the prediction results of the teacher network and the student network. ResNet50 is used as the teacher network and ViT attention model is used as the student network. Cosine loss function is used for loss calculation and backpropagation.

Benefits of technology

With limited data, the classification performance of the attention model was improved, the dependence on the amount of data was reduced, the performance of the student network reached or exceeded that of the teacher network, and it had better robustness and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115482581B_ABST
    Figure CN115482581B_ABST
Patent Text Reader

Abstract

The application discloses a kind of knowledge distillation methods of smoking and making phone classification attention model, comprising: S1, obtaining smoking and making phone dataset and pre-processing;S2, the pre-processed smoking and making phone dataset is input into the teacher network established in advance and is trained;S3, according to smoking and making phone dataset, additional dataset is configured to be mixed, and mixed dataset is obtained;S4, mixed dataset is respectively input into the teacher network and student network that are trained, and prediction result is respectively obtained;S5, the prediction result of teacher network and student network is compared with real label respectively, and the label that is predicted to be wrong is digested and corrected;S6, by knowledge distillation training iteration, the prediction result of student network is carried out loss calculation with the result of digestion and correction, and the loss value calculated is back propagated, to complete the knowledge distillation training process.The method of the application reduces the dependence on data volume, and has better classification effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer vision technology, specifically to a knowledge distillation method for a smoking and phone call classification attention model. Background Technology

[0002] Due to the successful application of attention mechanisms in natural language processing, their application in the field of vision is highly anticipated and has attracted increasing attention from scholars. Image classification algorithms based on attention mechanisms, with their unique attention mechanism, are more biologically similar to human vision and have outperformed convolutional neural networks on the large public dataset ImageNet. However, in most practical vision tasks, the stability of attention models is still inferior to that of convolutional neural networks. Therefore, applying attention models in practical applications is a very valuable research topic.

[0003] Currently, knowledge distillation is a relatively easy method to implement for training attention models. Knowledge distillation is a training method in deep learning models that utilizes a powerful teacher network to guide student networks in joint training. The student networks learn by incorporating the soft-label probability distribution output by the teacher network. Therefore, it improves the performance of the student networks while reducing data dependencies without increasing their complexity. Consequently, many practical engineers and researchers use knowledge distillation for model training.

[0004] The main steps of current mainstream knowledge distillation algorithms are as follows: Figure 1 As shown, first, the image data is processed by the teacher network and the student network to obtain their respective predicted labels; then, the predicted labels of the teacher network and the student network are used to calculate the loss; next, the predicted labels of the student network are used to calculate the loss again with the real image labels; finally, the two losses are weighted and combined to obtain the final loss value.

[0005] In complex real-world engineering scenarios, a good knowledge distillation method can often enable the attention model to learn more semantic information about the image, thereby improving the performance of the attention model. However, the existing knowledge distillation training of the attention model in the smoking and phone call classification scenario still has the following problems: (1) In the smoking and phone call classification scenario, the amount of dataset is limited, and the attention model gets trapped in local optima too early; (2) The performance of the attention model as a student network cannot reach that of the corresponding CNN teacher network. Summary of the Invention

[0006] To overcome the shortcomings of the above-mentioned technologies, this invention provides a knowledge distillation method for classifying attention models related to smoking and phone calls. Attention models trained using the knowledge distillation method described in this invention reduce their dependence on the amount of data; and compared to traditional knowledge distillation methods, this invention achieves better classification results for attention models.

[0007] The technical solution adopted by this invention to overcome its technical problems is:

[0008] A knowledge distillation method for a smoking and phone-phone-classification attention model includes the following steps:

[0009] S1. Obtain the smoking and phone call dataset and preprocess the smoking and phone call dataset;

[0010] S2. Input the preprocessed smoking and phone call dataset into the pre-established teacher network for training;

[0011] S3. Based on the smoking and phone call dataset, configure an additional dataset to mix them, resulting in a mixed dataset. The additional dataset is a dataset that is mutually exclusive with the smoking and phone call dataset.

[0012] S4. Input the mixed dataset into the teacher network trained in step S2 and the student network based on knowledge distillation, respectively, and obtain the prediction results.

[0013] S5. Compare the prediction results of the teacher network and the prediction results of the student network with the real labels respectively, and correct the labels that were predicted incorrectly.

[0014] S6. Through knowledge distillation training iteration, the digestion and error correction results obtained in step S5 are compared with the prediction results of the student network to calculate the loss. The calculated loss value is then backpropagated to complete the knowledge distillation training process.

[0015] Furthermore, the teacher network uses ResNet50; the student network based on knowledge distillation uses the ViT attention model.

[0016] Furthermore, step S1 specifically includes:

[0017] In actual engineering scenarios at different times and under different weather conditions, pedestrian sample images were collected from different angles and of different ages. The categories of pedestrian sample images included pedestrians who smoked, pedestrians who made phone calls, and pedestrians who neither smoked nor made phone calls.

[0018] From the sample set, a pixel image of a preset size is selected with the face as the center point of key local information, and the selected key local information image is used as the input image for subsequent similarity calculation.

[0019] Extract Hog features from key local information images, and calculate cosine similarity between the extracted Hog feature vectors and feature vectors in the similarity queue;

[0020] The cosine similarity is used to determine whether a sample is invalid or not used as a training sample for knowledge distillation. If the similarity is higher than a set threshold, the sample is invalid and will not be used as a training sample for knowledge distillation. If the similarity is lower than a set threshold, the sample is valid and will be used as a training sample for knowledge distillation. At the same time, the sample will be added to the similarity queue as a similarity comparison sample.

[0021] Furthermore, Hog feature extraction includes the following steps:

[0022] 1) Convert the RGB 3D image to grayscale:

[0023] I(x,y)=0.3*I R (x,y)+0.59I G (x,y)+0.11I B (x,y) (1)

[0024] In the above formula, I(x,y) is the image pixel value after grayscale conversion. R (x,y),I G (x,y),I B (x,y) are the pixel values ​​in the R, G, and B three-dimensional channels of the image, respectively;

[0025] 2) Perform Gamma correction on the grayscale image:

[0026]

[0027] In the above formula, G(x,y) is the corrected image pixel value;

[0028] 3) Calculate the gradient of each pixel in the image:

[0029]

[0030] In the above formula, T x (x,y),T y (x,y) are the horizontal and vertical gradients of the image pixel values, respectively, and T(x,y) is the gradient value of each pixel in the image.

[0031] 4) Divide the image into small cells and calculate the gradient of the pixels in each cell to form a cell descriptor;

[0032] 5) Group several cells into a block, and combine the cell descriptors in the block to obtain the block's descriptor;

[0033] 6) Concatenating the descriptors of all blocks forms the Hog feature of the image.

[0034] Furthermore, in step S3, the mixing ratio of the smoking and phone call dataset with the additional dataset is set to N1:N2. During the knowledge distillation training process, the sum of N1 and N2 remains unchanged.

[0035] Furthermore, in step S6, at the beginning of the knowledge distillation training, N1 < N2; as the number of iterations of the knowledge distillation training increases, N1 increases dynamically while N2 decreases dynamically, and the number of pedestrians in the three categories of smoking pedestrians, pedestrians making phone calls and pedestrians who neither smoke nor make phone calls also increases dynamically; at the end of the knowledge distillation training, N1 > N2.

[0036] Furthermore, at the beginning of the knowledge distillation training, N1:N2 = 14:50, and the ratio of the number of pedestrians in N1 who smoke, pedestrians who make phone calls, and pedestrians who neither smoke nor make phone calls is 5:5:4; in the final stage of the knowledge distillation training, N1:N2 = 50:14, and the ratio of the number of pedestrians in N1 who smoke, pedestrians who make phone calls, and pedestrians who neither smoke nor make phone calls is 17:17:16.

[0037] Furthermore, in step S4,

[0038] The prediction results of the teacher network are expressed as

[0039] The predicted results of the student network are

[0040] Where n represents the number of categories of the sample, t represents the teacher network predicted category index value, and s represents the teacher network predicted category index value.

[0041] Since the smoking data samples and the phone call data samples are not mutually exclusive (i.e., images can simultaneously show both smoking and phone calls), both the teacher network and the student network use the sigmoid activation function. The expression for the sigmoid activation function is as follows:

[0042]

[0043] In the above formula, z is the input label of the last layer of the network.

[0044] Furthermore, in step S5, let the index of the maximum predicted label of the teacher network be m1, the index of the maximum predicted label of the student network be m2, and the index of the maximum actual label be m3. If m1 ≠ m3, it means that the predicted label of the teacher network is wrong; if m2 ≠ m3, it means that the predicted label of the student network is wrong.

[0045] For labels that are incorrectly predicted, error correction is required. The formula for error correction is as follows:

[0046] In the above formula, y is the predicted label, and α is a random number where 0 < α ≤ 1.

[0047] Furthermore, in step S6, the loss function used for loss calculation is the cosine loss function σ(x), and its calculation formula is as follows:

[0048]

[0049] In the above formula, x1 is the predicted label of the student network, and x2 is the predicted label after digestion and error correction.

[0050] Let the predicted label of the student network be y. s Predicted label y of teacher network t After digesting and correcting errors, the predicted labels for students' networks are: The predicted labels for the teacher network after digesting and correcting errors are: The current number of knowledge distillation training iterations is k, y s , Substituting k into formula (6), the final loss is obtained, and the final loss function is calculated as follows:

[0051]

[0052] The beneficial effects of this invention are:

[0053] This invention adjusts the mixed dataset of the training input for knowledge distillation, specifically by configuring an additional dataset and setting the ratio of the smoking and phone call dataset to the additional dataset, so that the network can perform well even with limited data samples, reducing the dependence on the amount of data.

[0054] This invention adjusts the predicted labels of the teacher and student networks. Specifically, it compares the predictions of the teacher and student networks with the true labels, corrects incorrect predictions, and ensures that the student network learns the correct knowledge, thus avoiding the student network receiving incorrect information from the teacher network and achieving performance comparable to the teacher network. During the knowledge distillation training process, this invention fully considers the inconsistency in the performance of the teacher and student networks in classifying smoking and phone calls, maximizing the role of samples in knowledge distillation and achieving better classification results compared to traditional knowledge distillation methods.

[0055] Besides its application in classifying smoking and phone calls, the method of this invention can be extended to other industrial scene image classification fields. The knowledge distillation method based on this invention can be applied to image classification in simple scenarios, such as safety helmet classification and pedestrian gender classification. During training, the method of this invention enhances the different roles of the teacher and student networks based on their performance on samples. This approach can be applied to most knowledge distillation applications and has significant potential for wider application. Attached Figure Description

[0056] Figure 1 This is a flowchart illustrating the traditional knowledge distillation algorithm.

[0057] Figure 2 This is a schematic diagram of the preprocessing process for the smoking and phone call dataset in an embodiment of the present invention.

[0058] Figure 3 This is a schematic diagram illustrating the process of mixing the smoking and phone call dataset and the additional dataset in an embodiment of the present invention.

[0059] Figure 4 This is a schematic flowchart of the knowledge distillation method according to an embodiment of the present invention.

[0060] Figure 5 The figure shows the experimental verification results of an embodiment of the present invention, wherein, Figure 5 (a) is the curve showing the change in the accuracy of the student network on the training set during training. Figure 5 (b) is the curve showing the change in the loss value of the student network on the test set during training. Detailed Implementation

[0061] To facilitate a better understanding of the present invention by those skilled in the art, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. The following are merely exemplary and do not limit the scope of protection of the present invention.

[0062] The knowledge distillation method for a smoking and phone call classification attention model described in this embodiment includes the following steps:

[0063] S1. Obtain the smoking and phone call dataset and preprocess it.

[0064] (1) In this embodiment, obtaining the smoking and phone call dataset specifically includes the following:

[0065] The pedestrian sample images were obtained from the surveillance video. Specifically, the images were collected from different angles and age groups in actual engineering scenarios at different times and in different weather conditions. The categories of pedestrian sample images included pedestrians who smoked, pedestrians who made phone calls, and pedestrians who neither smoked nor made phone calls.

[0066] (2) Considering that the data collection method involves real-time camera capture, resulting in too many images of the same pedestrian, the similarity between images becomes too high. Therefore, this embodiment preprocesses the captured images to remove samples with excessively high similarity. For example... Figure 2 As shown, the preprocessing of the smoking and phone call dataset includes the following:

[0067] It should be understood that the obtained pedestrian sample images are of inconsistent sizes, and in addition to key information, there is also a lot of interference information in the images, such as the influence of lighting and pedestrian distance. Therefore, in this embodiment, based on the pedestrian sample images, the face is used as the center point of key local information, and a region with a pixel size of 128*128 is selected from the sample set as the key local information image, which is used as the input image for subsequent similarity calculation.

[0068] Hog features are extracted from key local information images, and cosine similarity is calculated between the extracted Hog feature vectors and the feature vectors in the similarity queue. Hog features are histograms of oriented gradients, and their core idea is that the shape and appearance of local targets in an image can be well described by the distribution of gradients or edge directions.

[0069] The cosine similarity is used to determine whether a sample is valid. If the similarity is higher than a set threshold, the sample is invalid and will not be used as a training sample for knowledge distillation. If the similarity is lower than the set threshold, the sample is valid and will be used as a training sample for knowledge distillation. Simultaneously, the sample is added to the similarity queue as a similarity comparison sample. Specifically, the capacity of the similarity queue is preset to 100 dimensions. During cosine similarity calculation, the input sample is compared with all samples in the queue. Only when all results are <0.9 is the input sample considered valid. When a valid sample enters the queue, the sample at the head of the queue is removed. The remaining samples in the queue are shifted forward one position, and the valid sample is stored at the end of the queue.

[0070] Specifically, Hog feature extraction includes the following steps:

[0071] 1) Convert the RGB 3D image to grayscale:

[0072] I(x,y)=0.3*I R (x,y)+0.59I G (x,y)+0.11I B (x,y) (1)

[0073] In the above formula, I(x,y) is the image pixel value after grayscale conversion. R (x,y),I G (x,y),I B (x,y) are the pixel values ​​in the R, G, and B three-dimensional channels of the image, respectively;

[0074] 2) Perform Gamma correction on the grayscale image to reduce image noise interference:

[0075]

[0076] In the above formula, G(x,y) is the corrected image pixel value;

[0077] 3) Calculate the gradient of each pixel in the image:

[0078]

[0079] In the above formula, T x (x,y),T y (x,y) are the horizontal and vertical gradients of the image pixel values, respectively, and T(x,y) is the gradient value of each pixel in the image.

[0080] 4) Divide the image into small cells. Preferably, each small cell is 16*16 pixels. At the same time, calculate the gradient of the pixels in each cell to form a cell descriptor.

[0081] 5) Group several cells into a block. Preferably, 4*4 cells form a block, and the cell descriptors in the block are combined to obtain the block's descriptor.

[0082] 6) Concatenating the descriptors of all blocks forms the Hog feature of the image.

[0083] S2. Input the preprocessed smoking and phone call dataset into the pre-established teacher network for training. Preferably, the teacher network adopts ResNet50. The purpose of adopting ResNet50 is that ResNet50 introduces the residual structure into the traditional deep learning model to solve the gradient vanishing problem, so that its performance is improved while the network depth increases.

[0084] S3. Based on the smoking and phone call dataset, configure an additional dataset to mix with it, resulting in a mixed dataset. The additional dataset is a dataset that is mutually exclusive with the smoking and phone call dataset.

[0085] Specifically, the additional dataset is an image classification dataset. To avoid interference with the smoking and phone call dataset, the additional dataset and the smoking and phone call dataset need to be mutually exclusive, that is, the image categories need to be mutually exclusive. At the same time, the amount of data in the additional dataset cannot be too small. Therefore, the additional dataset selected in this embodiment is the CIFAR-10 dataset. The CIFAR-10 dataset has 10 categories, with 6,000 images in each category. The additional dataset has a total of 60,000 images, of which 50,000 images are the training set and 10,000 images are the test set.

[0086] The smoking and phone call dataset and the additional dataset are mixed to obtain a hybrid dataset. Let the mixing ratio of the smoking and phone call dataset and the additional dataset be N1:N2, as follows: Figure 3 The diagram shows the hybrid process of this embodiment.

[0087] The sum of N1 and N2 represents the number of samples input for each batch of knowledge distillation training. The sum of N1 and N2 remains constant. In this embodiment, the number of samples input for each batch of knowledge distillation training is 64, therefore N1 + N2 = 64. The larger the proportion of a certain dataset in each batch of samples, the greater the guiding effect of that dataset on knowledge distillation training. Therefore, in the initial stage of knowledge distillation training in this embodiment, the dataset N1 (for smoking and making phone calls) is set to be less than the additional dataset N2, preferably N1:N2 = 14:50. This increases the guiding effect of the additional dataset on the student network during training, allowing the student network to warm up more quickly. Secondly, as the number of knowledge distillation training iterations increases, N1 is dynamically increased while N2 is dynamically decreased to strengthen the guiding role of the smoking and phone-calling dataset on the student network during training. Simultaneously, during training, the proportions of the three categories of pedestrians in N1—smoking, phone-calling, and neither smoking nor phone-calling—also change dynamically. Therefore, the number of samples in each category of the dataset also needs to be dynamically adjusted. At the beginning of the knowledge distillation training, the proportion of the smoking and phone-calling dataset in N1 is 14, and the ratio of the three categories in N1 is 5:5:4. In the final stage of knowledge distillation training, N1 > N2, specifically N1:N2 = 50:14, and the ratio of the three categories in N1 is 17:17:16. Therefore, the number of the three categories of pedestrians in N1 dynamically increases from 5:5:4 to 17:17:16 during training.

[0088] S4. Input the mixed dataset into the teacher network trained in step S2 and the student network based on knowledge distillation, respectively, and obtain the prediction results.

[0089] In this embodiment, the student network based on knowledge distillation preferably adopts the ViT attention model. The purpose of adopting the ViT attention model is that ViT, as an attention structure, has achieved state-of-the-art (SOTA) performance in many benchmark tests.

[0090] The prediction results of the teacher network are expressed as

[0091] The predicted results of the student network are

[0092] Where n represents the number of categories of the sample, t represents the teacher network predicted category index value, and s represents the teacher network predicted category index value.

[0093] Since the smoking data samples and the phone call data samples are not mutually exclusive (i.e., images can simultaneously contain both smoking and phone call images), both the teacher network and the student network use the sigmoid activation function. This improves the network's prediction ability for multi-labeled images. The expression for the sigmoid activation function is as follows:

[0094]

[0095] In the above formula, z is the input label of the last layer of the network (specifically, the teacher network or the student network).

[0096] S5. Compare the prediction results of the teacher network and the prediction results of the student network with the actual labels respectively, and correct the labels that were predicted incorrectly.

[0097] like Figure 4 The diagram shown is a flowchart of the knowledge distillation method in this embodiment. The knowledge distillation method includes the following steps:

[0098] Let m1 be the index of the maximum predicted label of the teacher network, m2 be the index of the maximum predicted label of the student network, and m3 be the index of the maximum actual label. If m1 ≠ m3, it means that the predicted label of the teacher network is wrong. If m2 ≠ m3, it means that the predicted label of the student network is wrong.

[0099] For labels that are incorrectly predicted, error correction is required. The formula for error correction is as follows:

[0100]

[0101] In the above formula, y is the predicted label, and α is a random number where 0 < α ≤ 1.

[0102] S6. Through knowledge distillation training iteration, the digestion and error correction results obtained in step S5 are compared with the prediction results of the student network to calculate the loss. The calculated loss value is then backpropagated to complete the knowledge distillation training process.

[0103] In step S6, the loss function used for loss calculation is the cosine loss function σ(x), and its calculation formula is as follows:

[0104]

[0105] In the above formula, x1 is the predicted label of the student network, and x2 is the predicted label after digestion and error correction.

[0106] Let the predicted label of the student network be y. s Predicted label y of teacher network t After digesting and correcting errors, the predicted labels for students' networks are: The predicted labels for the teacher network after digesting and correcting errors are: The current number of knowledge distillation training iterations is k, y s , Substituting k into formula (6), the final loss is obtained, and the final loss function is calculated as follows:

[0107]

[0108] To ensure the objectivity of this experiment, this embodiment preferably divides the dataset into a training set and a test set in a mutually exclusive random manner, with a division ratio of 7:3, that is, the training set accounts for 70% and the test set accounts for 30%, and the knowledge distillation training and testing are carried out respectively.

[0109] Table 1 compares the knowledge distillation method of the attention model described in this embodiment with conventional image classification methods. The selected image classification methods include different versions of ResNet, EfficientNet, a version of ViT without knowledge distillation, and different versions of DeiT.

[0110] Table 1

[0111]

[0112] As shown in Table 1, the method of this invention improves the accuracy of the ViT attention model from 70.3% to 88.71%, and is approximately one point higher than the 87.78% accuracy of the knowledge distillation teacher network (ResNet-50), demonstrating better robustness and higher accuracy. The changes in the accuracy and loss curves of the knowledge distillation of the student network in this invention are shown in Table 1. Figure 5 of Figure 5 (a) and Figure 5 As shown in (b).

[0113] The above description only outlines the basic principles and preferred embodiments of the present invention. Those skilled in the art can make many changes and modifications based on the above description, and these changes and modifications should fall within the protection scope of the present invention.

Claims

1. A knowledge distillation method for a smoking and phone-phone-classification attention model, characterized in that, Includes the following steps: S1. Obtain the smoking and phone call dataset and preprocess the smoking and phone call dataset; S2. Input the preprocessed smoking and phone call dataset into the pre-established teacher network for training; S3. Based on the smoking and phone-calling dataset, configure an additional dataset for mixing to obtain a mixed dataset. The additional dataset is mutually exclusive with the smoking and phone-calling dataset. Let the mixing ratio of the smoking and phone-calling dataset and the additional dataset be N1:N2. During the knowledge distillation training process, the sum of N1 and N2 remains constant. At the beginning of the knowledge distillation training, N1 < N2. As the number of iterations of the knowledge distillation training increases, N1 dynamically increases while N2 dynamically decreases. The number of pedestrians in the three categories of smoking pedestrians, phone-calling pedestrians, and pedestrians who neither smoke nor make phone calls in N1 also dynamically increases. In the final stage of the knowledge distillation training, N1 > N2. S4. Input the mixed dataset into the teacher network trained in step S2 and the student network based on knowledge distillation, respectively, and obtain the prediction results. S5. Compare the prediction results of the teacher network and the prediction results of the student network with the real labels respectively, and correct the labels that were predicted incorrectly. S6. Through knowledge distillation training iteration, the digestion and error correction results obtained in step S5 are compared with the prediction results of the student network to calculate the loss. The calculated loss value is then backpropagated to complete the knowledge distillation training process.

2. The knowledge distillation method for the smoking and phone call classification attention model according to claim 1, characterized in that, The teacher network uses ResNet50; the student network based on knowledge distillation uses the ViT attention model.

3. The knowledge distillation method for the smoking and phone call classification attention model according to claim 1, characterized in that, Step S1 specifically includes: In actual engineering scenarios at different times and under different weather conditions, pedestrian sample images were collected from different angles and of different ages. The categories of pedestrian sample images included pedestrians who smoked, pedestrians who made phone calls, and pedestrians who neither smoked nor made phone calls. From the sample set, a pixel image of a preset size is selected with the face as the center point of key local information, and the selected key local information image is used as the input image for subsequent similarity calculation. Extract Hog features from key local information images, and calculate cosine similarity between the extracted Hog feature vectors and feature vectors in the similarity queue; The cosine similarity is used to determine whether a sample is invalid or not used as a training sample for knowledge distillation. If the similarity is higher than a set threshold, the sample is invalid and will not be used as a training sample for knowledge distillation. If the similarity is lower than a set threshold, the sample is valid and will be used as a training sample for knowledge distillation. At the same time, the sample will be added to the similarity queue as a similarity comparison sample.

4. The knowledge distillation method for the smoking and phone call classification attention model according to claim 3, characterized in that, Hog feature extraction includes the following steps: 1) Convert RGB 3D images to grayscale: (1) In the above formula, These are the pixel values ​​of the image after grayscale conversion. These are the pixel values ​​in the R, G, and B three-dimensional channels of the image, respectively. 2) Perform Gamma correction on the grayscale image: (2) In the above formula, These are the pixel values ​​of the corrected image; 3) Calculate the gradient of each pixel in the image: (3) In the above formula, These represent the gradients of the image pixel values ​​in the horizontal and vertical directions, respectively. The gradient value at each pixel of the image; 4) Divide the image into small cells and calculate the gradient of the pixels in each cell to form a cell descriptor; 5) Group several cells into a block, and combine the cell descriptors in the block to obtain the block's descriptor; 6) Concatenating the descriptors of all blocks forms the Hog feature of the image.

5. The knowledge distillation method for the smoking and phone call classification attention model according to claim 3, characterized in that, At the beginning of the knowledge distillation training, N1:N2=14:50, and the ratio of pedestrians smoking, pedestrians making phone calls, and pedestrians who neither smoke nor make phone calls in N1 is 5:5:4; in the final stage of the knowledge distillation training, N1:N2=50:14, and the ratio of pedestrians smoking, pedestrians making phone calls, and pedestrians who neither smoke nor make phone calls in N1 is 17:17:

16.

6. The knowledge distillation method for the smoking and phone call classification attention model according to claim 1, characterized in that, In step S4, The prediction results of the teacher network are expressed as ; The predicted results of the student network are ; Where n represents the number of categories of the sample, t represents the teacher network predicted category index value, and s represents the teacher network predicted category index value. Since the smoking data samples and the phone call data samples are not mutually exclusive (i.e., images can simultaneously show both smoking and phone calls), both the teacher network and the student network use the sigmoid activation function. The expression for the sigmoid activation function is as follows: (4) In the above formula, z is the input label of the last layer of the network.

7. The knowledge distillation method for the smoking and phone call classification attention model according to claim 1, characterized in that, In step S5, Let the index of the maximum value of the teacher's network predicted label be . The index of the maximum value of the student's network predicted label is The index of the true maximum value of the label is ,like This indicates that the teacher network's predicted labels are incorrect. If so, it means that the predicted labels for the student network are incorrect; For labels that are incorrectly predicted, error correction is required. The formula for error correction is as follows: (5) In the above formula, For predicting labels, are random numbers and .

8. The knowledge distillation method for the smoking and phone call classification attention model according to claim 7, characterized in that, In step S6, the loss function used for loss calculation is the cosine loss function. The calculation formula is as follows: (6) In the above formula, x1 is the predicted label of the student network, and x2 is the predicted label after digestion and error correction. Let the predicted label of the student network be... Predicted labels for teacher networks After digesting and correcting errors, the predicted labels for students' networks are: After digesting and correcting errors, the predicted labels for the teacher network are: The current number of knowledge distillation training iterations is k. Substituting into formula (6), the final loss is obtained, and the final loss function is calculated as follows: (7)。

Citation Information

Patent Citations

  • Abnormal behavior detection method and device and vehicle-mounted equipment

    CN109886209A

  • Target detection method and target detection terminal based on knowledge distillation

    CN113743514A