Image detection model compression method with low precision loss

By combining structure cropping and knowledge distillation in image detection model compression, and using the multi-layer output of the teacher model to perform iterative pruning and loss function adjustment, the problem of accuracy loss in the model compression process in the existing technology is solved, and the edge device is realized high recognition accuracy.

CN118734922APending Publication Date: 2024-10-01NORTHWESTERN POLYTECHNICAL UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410820121.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-24
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

Existing technology cannot effectively avoid accuracy loss during the model compression process. Especially when knowledge distillation is performed after cutting the pre-trained model, it is difficult for the student model to learn the larger teacher model, resulting in a decrease in recognition accuracy when deployed on edge devices.

Method used

By obtaining the image data set and the student and teacher models to be compressed, structural clipping and knowledge distillation are performed, and the multi-layer output of the teacher model is used for iterative pruning and loss function adjustment to ensure that the pruned student model is consistent in the high-dimensional feature space. The expression error is small, avoiding the accumulation of errors caused by the local optimal structure, and improving the recognition accuracy by adjusting the loss function.

Benefits of technology

It effectively avoids the accuracy loss of the model during the compression process, ensures the recognition accuracy of the pruned student model on edge devices, and can fully utilize the knowledge of the teacher model to improve the learning ability and recognition performance of the student model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118734922A_ABST
    Figure CN118734922A_ABST
Patent Text Reader

Abstract

The invention discloses an image detection model compression method with low precision loss. The method comprises the following steps: acquiring an image data set, a to-be-compressed student model and a to-be-compressed teacher model; performing structure cutting on the student model to obtain a cut student model; training a teacher model and the cut student model by using the training data set, and performing knowledge distillation on the cut student model by using the teacher model in the training process to obtain a distilled student model; respectively testing the student model after cutting and the student model after distillation by using a test set, and adjusting a loss function of the student model after distillation according to a test result; and S4, when the pruning rate meets a preset pruning rate, outputting the student model after distillation, otherwise, repeating the steps S2-S4. The method can effectively guarantee that the student model to be deployed is cut to a specified pruning rate, and improves the precision of the student model after pruning compared with the student model before pruning.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of model processing, and in particular to a compression method for an image detection model with low precision loss. Background Art

[0002] At present, most neural network models are mainly developed for cloud environments. Although the model has high recognition accuracy, its computational cost is usually relatively high. With the support of high-computing power platforms in the cloud, such models can maintain high computing efficiency. However, in some lightweight edge devices such as small drones and unmanned vehicles, due to physical factors such as power consumption and weight, the computing power of their algorithm acceleration devices is usually lower than that of cloud and terminal devices, resulting in devices developed for personal computers being difficult to directly apply to embedded platforms with limited computing power. Therefore, it is necessary and urgent to conduct research on the compression of neural networks. For example, the strategy for selecting the compression process for domestic NPU (neural network processor) platforms also needs to match the hardware instruction set of the platform.

[0003] Currently, the commonly used model compression methods include model pruning, quantization, distillation, low-rank decomposition, neural network search, etc. Model pruning aims to simplify the network structure by removing parts that have little impact on the output, thereby reducing the number of model parameters and computational complexity. Although model pruning has great potential in theory, it still faces some application bottlenecks in edge device deployment:

[0004] Pre-trained model: Pruning methods generally require a pre-trained model that has been fully trained on the target dataset as input. The performance of the pre-trained model directly affects the final pruning effect.

[0005] Pruning strategy selection: There are currently many pruning strategies, such as weight pruning and structural pruning. Each strategy has its own characteristics and applicable scenarios. Choosing the most appropriate pruning strategy requires a deep understanding of the model and business requirements.

[0006] Knowledge distillation is a model compression technique that transfers the knowledge of a large and complex teacher model to a smaller student model in order to reduce the model size and computational requirements while maintaining performance. The main problems with its deployment on edge devices are:

[0007] Selection of teacher model: Selecting an appropriate teacher model is crucial to the success of knowledge distillation. A strong teacher model can provide more knowledge but may be too complex for the student model to fully learn.

[0008] Source of knowledge: Appropriate selection of outputs from the teacher model as knowledge transferred to the student model is directly related to the final results.

[0009] Currently, there are a lot of research on compression techniques in both model pruning and knowledge distillation, but there are few methods that combine the two methods. The existing technology prunes the pre-trained model to a certain extent and then uses knowledge distillation as fine-tuning. The existing technology prunes the teacher model before knowledge distillation because the student model is difficult to learn a larger teacher model. The existing technology designs Homodistil for task-agnostic knowledge distillation. Specifically, the author initializes the student model from the teacher model and iteratively prunes the student's neurons until the target width is reached. This method maintains a small difference between the teacher and student predictions throughout the distillation process, which ensures the effectiveness of knowledge transfer.

[0010] Some of the above methods perform pruning and knowledge distillation independently, while others use knowledge distillation loss as a constraint in the pruning process. These design ideas are usually based on the premise that the size difference between the teacher model and the student model architecture cannot be too large. However, the above existing technologies cannot guarantee the accuracy loss of the model during the compression process. Summary of the invention

[0011] In view of the above-mentioned deficiencies in the prior art, the present invention provides a low-precision loss image detection model compression method, which solves the problem of large precision loss of the model in the prior art during the compression process.

[0012] In order to achieve the above-mentioned object of the invention, the technical solution adopted by the present invention is: a low-precision loss image detection model compression method, comprising the following steps:

[0013] S1. Obtain an image dataset, a student model to be compressed, and a teacher model. The image dataset includes a training dataset and a test dataset. The student model to be compressed and the teacher model are applied to an application scenario of the image dataset.

[0014] S2, perform structural trimming on the student model to obtain a trimmed student model;

[0015] S3, using the training data set to train the teacher model and the pruned student model respectively, and using the teacher model to perform knowledge distillation on the pruned student model during the training process to obtain a distilled student model;

[0016] S4. Use the test set to test the pruned student model and the distilled student model respectively, and adjust the loss function of the distilled student model according to the test results;

[0017] S5. When the pruning rate meets the preset pruning rate, output the distilled student model, otherwise, repeat steps S2-S4.

[0018] The beneficial effects of the above scheme are:

[0019] (1) The present invention uses the knowledge of a large model to guide the structural compression and weight optimization of the model, and uses the expression error of the pruned network in the high-dimensional feature space as the basis for evaluating information loss, thereby avoiding the error accumulation problem caused by the local optimal structure pruned during the optimization process, so that the model can retain the original recognition accuracy or only produce a lower accuracy loss after structural compression.

[0020] (2) The present invention allows the pre-deployed student model to receive the output of multiple layers in the teacher model as much as possible, making full use of various types of knowledge in the teacher model, which is equivalent to being fully trained before each round of pruning; at the same time, setting up knowledge distillation in iterative pruning can effectively avoid the impact caused by the large gap between the teacher and student models, and can effectively ensure that the pre-deployed student model is pruned to the specified pruning rate while significantly improving the accuracy compared to the unpruned model.

[0021] Further, step S2 specifically includes:

[0022] S21, obtaining the weight of the model structure in the student model;

[0023] S22. Sort the importance of the model structures according to the weights;

[0024] S23. According to the sorting result, use a pruning algorithm to perform structural pruning on the student model to obtain a pruned student model.

[0025] Further, the pruned student model includes a first feature extraction module, a second feature extraction module, a third feature extraction module, a fourth feature extraction module, a first feature fusion module, a second feature fusion module and a third feature fusion module;

[0026] Wherein, the first feature extraction module, the second feature extraction module, the third feature extraction module and the fourth feature extraction module are connected in sequence;

[0027] The second feature extraction module is connected to the first feature fusion module, the third feature extraction module is connected to the second feature fusion module, and the fourth feature extraction module is connected to the third feature fusion module;

[0028] The third feature fusion module, the second feature fusion module and the first feature fusion module are connected in sequence;

[0029] The teacher model includes a fifth feature extraction module, a sixth feature extraction module, a seventh feature extraction module, an eighth feature extraction module, a fourth feature fusion module, a fifth feature fusion module and a sixth feature fusion module;

[0030] Wherein, the fifth feature extraction module, the sixth feature extraction module, the seventh feature extraction module and the eighth feature extraction module are connected in sequence;

[0031] The sixth feature extraction module is connected to the fourth feature fusion module, the seventh feature extraction module is connected to the fifth feature fusion module, and the eighth feature extraction module is connected to the sixth feature fusion module;

[0032] The sixth feature fusion module, the fifth feature fusion module and the fourth feature fusion module are connected in sequence;

[0033] The image input module is connected to the first feature extraction module and the fifth feature extraction module respectively, and is used to input an image data set.

[0034] Furthermore, the sizes of the feature maps extracted by the first feature extraction module, the second feature extraction module, the third feature extraction module and the fourth feature extraction module are reduced to 1 / 4, 1 / 8, 1 / 16 and 1 / 32 respectively compared to the original image;

[0035] The sizes of the feature maps extracted by the fifth feature extraction module, the sixth feature extraction module, the seventh feature extraction module, and the eighth feature extraction module are reduced to 1 / 4, 1 / 8, 1 / 16, and 1 / 32, respectively, compared with the original image;

[0036] The original image is the data in the image dataset.

[0037] Furthermore, step S3 specifically includes:

[0038] Use the feature maps output by the fourth feature fusion module, the feature maps output by the fifth feature fusion module, and the feature maps output by the sixth feature fusion module to perform knowledge distillation on the first feature fusion module, the second feature fusion module, and the third feature fusion module to obtain the distilled student model.

[0039] Furthermore, the feature map output by the fourth feature fusion module, the feature map output by the fifth feature fusion module, and the feature map output by the sixth feature fusion module are used to perform knowledge distillation on the first feature fusion module, the second feature fusion module, and the third feature fusion module, and the loss function used is:

[0040]

[0041] Among them, t(·) and s(·) represent the teacher model and the student model respectively, w and h represent the size of the feature map, i and j jointly represent the channel index, and t(x) ij Represents the value of the pixel in the i-th row and j-th column in the feature map output by the teacher model, s(x) ij Represents the value of the pixel in the i-th row and j-th column in the feature map output by the student model.

[0042] The beneficial effect of the above further scheme is that it can speed up the training of the student model, so that the student model can inherit the experience of the teacher model, thereby having better performance and enhancing the student model's understanding and learning ability of the teacher model's knowledge.

[0043] Furthermore, the loss function of the student model includes classification loss, localization loss, object loss, loss of feature maps corresponding to the teacher model, and loss of the classification layer output by the teacher model;

[0044] The loss function of the student model is:

[0045] L total =λ cls L cls +λ obj L obj +λ loc L loc +λ fea L fea +λ logit L logit

[0046] Among them, L cls represents the classification loss of the student model, L obj represents the object loss of the student model, L loc represents the localization loss of the student model, L fea represents the loss of the feature map corresponding to the teacher model of the student model, L logit represents the classification layer loss of the student model and the teacher model output, λ cls represents the proportion of classification loss, λ obj represents the proportion of object loss, λ loc represents the ratio of positioning loss, λ fea represents the ratio of the loss of the feature map corresponding to the teacher model, λ logit Represents the ratio of the classification layer loss to the teacher model output.

[0047] Further, step S4 specifically includes:

[0048] S41. Use the test set to test the pruned student model and the distilled student model respectively, and obtain the classification loss, positioning loss, object loss, loss of the feature map corresponding to the teacher model, and loss of the output classification layer of the teacher model of the pruned student model, as well as the classification loss, positioning loss, object loss, loss of the feature map corresponding to the teacher model, and loss of the output classification layer of the teacher model of the distilled student model;

[0049] S42. When the classification loss of the student model after distillation increases compared to the classification loss of the student model after cropping, the ratio of the classification layer loss of the student model after distillation to the output layer of the teacher model is increased according to the first preset function; when the positioning loss of the student model after distillation increases compared to the positioning loss of the student model after cropping, the ratio of the loss of the corresponding feature map of the student model after distillation to the feature map of the teacher model is increased according to the first preset function.

[0050] Furthermore, the first preset function is:

[0051] μ=f(L1,L1…L n )

[0052] L dis =μL dis

[0053] Among them, μ represents the proportion of distillation loss in the loss function of the student model, f(L1, L1…L n ) represents the ratio of the distillation loss calculated by calculating the adjacent difference of the internal data of the classification loss or positioning loss list in n trainings, L dis Represents the loss of the feature map corresponding to the teacher model or the loss of the classification layer output by the teacher model.

[0054] Furthermore, in step S5, the calculation formula of the pruning rate is:

[0055]

[0056] Among them, R represents the pruning rate, MACs post and MACs pre Represent the computational cost of the student model before and after compression, respectively.

[0057] The beneficial effect of the above further scheme is that by adjusting the loss function of the student model, the loss accuracy of the student model can be guaranteed as much as possible during the training process of the student model, thereby improving the recognition accuracy of the student model. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] Figure 1 A flowchart of a low-precision loss image detection model compression method;

[0059] Figure 2 Schematic diagram of the model structure of an image detection model compression method with low precision loss. DETAILED DESCRIPTION

[0060] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments.

[0061] like Figure 1As shown, a low-precision loss image detection model compression method includes the following steps:

[0062] S1. Obtain an image dataset, a student model to be compressed, and a teacher model. The image dataset includes a training dataset and a test dataset. The student model to be compressed and the teacher model are applied to an application scenario of the image dataset.

[0063] In this embodiment, the image dataset may be a VisDrone dataset. The VisDrone dataset is captured by a small drone camera and covers a wide range of scenes. The entire dataset includes 288 video clips, consisting of 261,908 frames and 10,209 static images, with a total of approximately 2.6 million bounding box annotations of objects, such as pedestrians, cars, bicycles, and tricycles.

[0064] S2. Perform structural trimming on the student model to obtain a trimmed student model.

[0065] In this embodiment, step S2 specifically includes:

[0066] S21, obtaining the weight of the model structure in the student model;

[0067] S22. Sort the importance of the model structures according to the weights;

[0068] S23. According to the sorting result, use a pruning algorithm to perform structural pruning on the student model to obtain a pruned student model.

[0069] like Figure 2 As shown, Figure 2 Schematic diagram of a model structure of a low-precision image detection model compression method. In this embodiment, Figure 2 The cropped student model shown in comprises a first feature extraction module, a second feature extraction module, a third feature extraction module, a fourth feature extraction module, a first feature fusion module, a second feature fusion module and a third feature fusion module;

[0070] Wherein, the first feature extraction module, the second feature extraction module, the third feature extraction module and the fourth feature extraction module are connected in sequence;

[0071] The second feature extraction module is connected to the first feature fusion module, the third feature extraction module is connected to the second feature fusion module, and the fourth feature extraction module is connected to the third feature fusion module;

[0072] The third feature fusion module, the second feature fusion module and the first feature fusion module are connected in sequence;

[0073] The teacher model includes a fifth feature extraction module, a sixth feature extraction module, a seventh feature extraction module, an eighth feature extraction module, a fourth feature fusion module, a fifth feature fusion module and a sixth feature fusion module;

[0074] Wherein, the fifth feature extraction module, the sixth feature extraction module, the seventh feature extraction module and the eighth feature extraction module are connected in sequence;

[0075] The sixth feature extraction module is connected to the fourth feature fusion module, the seventh feature extraction module is connected to the fifth feature fusion module, and the eighth feature extraction module is connected to the sixth feature fusion module;

[0076] The sixth feature fusion module, the fifth feature fusion module and the fourth feature fusion module are connected in sequence;

[0077] The image input module is connected to the first feature extraction module and the fifth feature extraction module respectively, and is used to input an image data set.

[0078] In this embodiment, the first feature fusion module, the second feature fusion module, the third feature fusion module, the fourth feature fusion module, the fifth feature fusion module and the sixth feature fusion module can be used to process the upsampled and spliced ​​feature maps. This multi-scale feature fusion is very critical for target detection tasks because it allows the model to simultaneously utilize low-level detail information and high-level semantic information.

[0079] In this embodiment, the fourth feature fusion module is connected to the sixth feature extraction module, the fifth feature fusion module is connected to the seventh feature extraction module, and the sixth feature fusion module is connected to the eighth feature extraction module, so that the student model can learn the feature map distribution of the teacher model (same layer).

[0080] In this embodiment, the feature maps extracted by the first feature extraction module, the second feature extraction module, the third feature extraction module, and the fourth feature extraction module are reduced in size to 1 / 4, 1 / 8, 1 / 16, and 1 / 32, respectively, compared to the original image;

[0081] The sizes of the feature maps extracted by the fifth feature extraction module, the sixth feature extraction module, the seventh feature extraction module, and the eighth feature extraction module are reduced to 1 / 4, 1 / 8, 1 / 16, and 1 / 32, respectively, compared with the original image;

[0082] The original image is the data in the image dataset.

[0083] S3. Use the training data set to train the teacher model and the pruned student model respectively, and use the teacher model to perform knowledge distillation on the pruned student model during the training process to obtain the distilled student model.

[0084] In this embodiment, step S3 specifically includes:

[0085] Use the feature maps output by the fourth feature fusion module, the feature maps output by the fifth feature fusion module, and the feature maps output by the sixth feature fusion module to perform knowledge distillation on the first feature fusion module, the second feature fusion module, and the third feature fusion module to obtain the distilled student model.

[0086] Optionally, the first feature fusion module, the second feature fusion module and the third feature fusion module can be used to detect small, medium and large-sized targets respectively.

[0087] Optionally, the fourth feature fusion module, the fifth feature fusion module and the sixth feature fusion module can be used to detect small, medium and large-sized targets respectively.

[0088] In this embodiment, the feature map output by the fourth feature fusion module, the feature map output by the fifth feature fusion module, and the feature map output by the sixth feature fusion module can be used to perform knowledge distillation on the first feature fusion module, the second feature fusion module, and the third feature fusion module, and the loss function used is:

[0089]

[0090] Among them, t(·) and s(·) represent the teacher model and the student model respectively, w and h represent the size of the feature map, i and j jointly represent the channel index, and t(x) ij Represents the value of the pixel in the i-th row and j-th column in the feature map output by the teacher model, s(x) ij Represents the value of the pixel in the i-th row and j-th column in the feature map output by the student model.

[0091] In this embodiment, the loss function of the student model includes classification loss, positioning loss, object loss, loss of the feature map corresponding to the teacher model, and loss of the output classification layer of the teacher model.

[0092] The loss function of the student model is:

[0093] L total =λ cls L cls +λ obj L obj +λ loc L loc +λ fea L fea +λ logit L logit

[0094] Among them, L cls represents the classification loss of the student model, L obj represents the object loss of the student model, Lloc represents the localization loss of the student model, L fea represents the loss of the feature map corresponding to the teacher model of the student model, L logit represents the classification layer loss of the student model and the teacher model output, λ cls represents the proportion of classification loss, λ obj represents the proportion of object loss, λ loc represents the ratio of positioning loss, λ fea represents the ratio of the loss of the feature map corresponding to the teacher model, λ logit Represents the ratio of the classification layer loss to the teacher model output.

[0095] In the loss function of the above student model, the classification loss is used to evaluate the difference between the predicted category and the actual category. Binary cross entropy can be used, and the classification loss can be:

[0096] L cls (p, q) = -qlog(p)

[0097] Among them, p represents the probability of belonging to a certain category predicted by the student model, and q represents the true label.

[0098] In the loss function of the student model above, the localization loss is used to measure the position difference between the predicted bounding box and the true bounding box, taking into account the overlapping area, center point distance and aspect ratio of the bounding box. The localization loss can be:

[0099] L obj (p, q) = 1 - IoU (p, q)

[0100] Among them, p represents the probability of belonging to a certain category predicted by the student model, and q represents the true label.

[0101] Optionally, the data in the loss function output by the student model can be subtracted from the internal adjacent data. The positive numbers in the two lists obtained represent that the loss increases with training, and negative numbers represent that the loss decreases, thereby obtaining the changes in the growth or decrease of the two types of losses.

[0102] S4. Use the test set to test the pruned student model and the distilled student model respectively, and adjust the loss function of the distilled student model based on the test results.

[0103] In this embodiment, step S4 specifically includes:

[0104] S41. Use the test set to test the pruned student model and the distilled student model respectively, and obtain the classification loss, positioning loss, object loss, loss of the feature map corresponding to the teacher model, and loss of the output classification layer of the teacher model of the pruned student model, as well as the classification loss, positioning loss, object loss, loss of the feature map corresponding to the teacher model, and loss of the output classification layer of the teacher model of the distilled student model;

[0105] S42. When the classification loss of the student model after distillation increases compared to the classification loss of the student model after cropping, the ratio of the classification layer loss of the student model after distillation to the output layer of the teacher model is increased according to the first preset function; when the positioning loss of the student model after distillation increases compared to the positioning loss of the student model after cropping, the ratio of the loss of the corresponding feature map of the student model after distillation to the feature map of the teacher model is increased according to the first preset function.

[0106] In this embodiment, the first preset function is:

[0107] μ=f(L1,L1…L n )

[0108] L dis =μL dis

[0109] Among them, μ represents the proportion of distillation loss in the loss function of the student model, f(L1, L1…L n ) represents the ratio of the distillation loss calculated by calculating the adjacent difference of the internal data of the classification loss or positioning loss list in n trainings, L dis Represents the loss of the feature map corresponding to the teacher model or the loss of the classification layer output by the teacher model.

[0110] S5. When the pruning rate meets the preset pruning rate, output the distilled student model, otherwise, repeat steps S2-S4.

[0111] In this embodiment, the calculation formula of the pruning rate is:

[0112]

[0113] Among them, R represents the pruning rate, MACs post and MACs pre Represent the computational cost of the student model before and after compression, respectively.

[0114] Optionally, the preset pruning rate can be modified according to actual needs and is not specifically limited here.

[0115] Those skilled in the art will appreciate that the embodiments described herein are intended to help readers understand the principles of the present invention, and should be understood that the protection scope of the present invention is not limited to such specific statements and embodiments. Those skilled in the art can make various other specific variations and combinations that do not deviate from the essence of the present invention based on the technical revelations disclosed by the present invention, and these variations and combinations are still within the protection scope of the invention.

Claims

1. A low-precision loss image detection model compression method, characterized in that: The method comprises: S1. Obtain an image dataset, a student model to be compressed, and a teacher model, wherein the image dataset includes a training dataset and a test dataset, and the student model to be compressed and the teacher model are applied to an application scenario of the image dataset; S2, performing structural trimming on the student model to obtain a trimmed student model; S3, using the training data set to train the teacher model and the pruned student model respectively, and using the teacher model to perform knowledge distillation on the pruned student model during the training process to obtain a distilled student model; S4, using the test set to test the pruned student model and the distilled student model respectively, and adjusting the loss function of the distilled student model according to the test results; S5. When the pruning rate meets the preset pruning rate, output the distilled student model; otherwise, repeat steps S2-S4.

2. The method according to claim 1, characterized in that: The step S2 specifically includes: S21, obtaining the weight of the model structure in the student model; S22, ranking the model structures in importance according to the weights; S23. According to the sorting result, use a pruning algorithm to perform structural pruning on the student model to obtain the pruned student model.

3. The method according to claim 1, characterized in that The cropped student model includes a first feature extraction module, a second feature extraction module, a third feature extraction module, a fourth feature extraction module, a first feature fusion module, a second feature fusion module and a third feature fusion module; Wherein, the first feature extraction module, the second feature extraction module, the third feature extraction module and the fourth feature extraction module are connected in sequence; The second feature extraction module is connected to the first feature fusion module, the third feature extraction module is connected to the second feature fusion module, and the fourth feature extraction module is connected to the third feature fusion module; The third feature fusion module, the second feature fusion module and the first feature fusion module are connected in sequence; The teacher model includes a fifth feature extraction module, a sixth feature extraction module, a seventh feature extraction module, an eighth feature extraction module, a fourth feature fusion module, a fifth feature fusion module and a sixth feature fusion module; Wherein, the fifth feature extraction module, the sixth feature extraction module, the seventh feature extraction module and the eighth feature extraction module are connected in sequence; The sixth feature extraction module is connected to the fourth feature fusion module, the seventh feature extraction module is connected to the fifth feature fusion module, and the eighth feature extraction module is connected to the sixth feature fusion module; The sixth feature fusion module, the fifth feature fusion module and the fourth feature fusion module are connected in sequence; The image input module is connected to the first feature extraction module and the fifth feature extraction module respectively, and is used to input the image data set.

4. The method according to claim 3, characterized in that: The sizes of the feature maps extracted by the first feature extraction module, the second feature extraction module, the third feature extraction module and the fourth feature extraction module are reduced to 1 / 4, 1 / 8, 1 / 16 and 1 / 32 respectively compared with the original image; The sizes of the feature maps extracted by the fifth feature extraction module, the sixth feature extraction module, the seventh feature extraction module, and the eighth feature extraction module are reduced to 1 / 4, 1 / 8, 1 / 16, and 1 / 32, respectively, compared with the original image; The original image is the data in the image data set.

5. The method according to claim 3, characterized in that: The step S3 specifically includes: Use the feature map output by the fourth feature fusion module, the feature map output by the fifth feature fusion module and the feature map output by the sixth feature fusion module to perform knowledge distillation on the first feature fusion module, the second feature fusion module and the third feature fusion module respectively to obtain a distilled student model.

6. The method according to claim 5, characterized in that The feature map output by the fourth feature fusion module, the feature map output by the fifth feature fusion module and the feature map output by the sixth feature fusion module are used to perform knowledge distillation on the first feature fusion module, the second feature fusion module and the third feature fusion module, and the loss function used is: Among them, t(·) and s(·) represent the teacher model and the student model respectively, w and h represent the size of the feature map, i and j jointly represent the channel index, and t(x) ij Represents the value of the pixel in the i-th row and j-th column in the feature map output by the teacher model, s(x) ij Represents the value of the pixel in the i-th row and j-th column in the feature map output by the student model.

7. The method according to claim 1, characterized in that The loss function of the student model includes classification loss, positioning loss, object loss, loss of feature maps corresponding to the teacher model, and loss of the output classification layer of the teacher model; The loss function of the student model is: L total =λ cls L cls +λ obj L obj +λ loc L loc +λ fea L fea +λ logit L logit Among them, L cls represents the classification loss of the student model, L obj represents the object loss of the student model, L loc represents the localization loss of the student model, L fea represents the loss of the feature map corresponding to the teacher model of the student model, L logit represents the classification layer loss of the student model and the teacher model output, λ cls represents the proportion of classification loss, λ obj represents the proportion of object loss, λ loc represents the ratio of positioning loss, λ fea represents the ratio of the loss of the feature map corresponding to the teacher model, λ logit Represents the ratio of the classification layer loss to the teacher model output.

8. The method according to claims 1 and 6, characterized in that The step S4 specifically includes: S41, using the test set to test the pruned student model and the distilled student model respectively, to obtain the classification loss, positioning loss, object loss, loss of the feature map corresponding to the teacher model, and loss of the output classification layer of the teacher model of the pruned student model, as well as the classification loss, positioning loss, object loss, loss of the feature map corresponding to the teacher model, and loss of the output classification layer of the teacher model of the distilled student model; S42. When the classification loss of the distilled student model increases compared to the classification loss of the cropped student model, the ratio of the classification layer loss of the distilled student model to the output layer of the teacher model is increased according to a first preset function; when the positioning loss of the distilled student model increases compared to the positioning loss of the cropped student model, the ratio of the loss of the corresponding feature map of the distilled student model to the feature map of the teacher model is increased according to the first preset function.

9. The method according to claim 7, characterized in that: The first preset function is: μ=f(L1,L1…L n ) L dis =μL dis Among them, μ represents the proportion of distillation loss in the loss function of the student model, f(L1, L1…L n ) represents the ratio of the distillation loss calculated by calculating the adjacent difference of the internal data of the classification loss or positioning loss list in n trainings, L dis Represents the loss of the feature map corresponding to the teacher model or the loss of the classification layer output by the teacher model.

10. The method according to claim 1, characterized in that In step S5, the calculation formula of the pruning rate is: Among them, R represents the pruning rate, MACs post and MACs pre Represent the computational cost of the student model before and after compression, respectively.

Citation Information

Patent Citations

  • Convolutional neural network model compression method combining pruning and knowledge distillation

    CN113159173A

  • Target detection-oriented model compression method combining iterative pruning and knowledge distillation

    CN116563645A