Chemical fiber spinning cake appearance defect detection network compression method based on filtering and pruning
Through the filtering and pruning method based on BN layer coefficients, the real-time reasoning of the deep learning model on the embedded development board and the redundancy problem of the chemical fiber silk cake detection model are solved, and the model size is reduced and the detection performance is maintained, proving that this method can be used in chemical fiber Effectiveness in detecting appearance defects of silk cakes.
Patent Information
- Application Number
- CN202410143211.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-01
- Publication Date
- 2024-09-06
AI Technical Summary
It is difficult to implement real-time reasoning of deep learning models on embedded development boards with existing technology, and the chemical fiber fiber cake appearance defect detection model has redundant parts and poor detection results.
A filter pruning method based on BN layer coefficients is used to process the γ coefficient through sparsity regularization, identify and prune unimportant channels, obtain a lightweight network model, and adjust the accuracy through fine-tuning. The pruning formula is: zout = γ * ( zin - μB) / sB + β, introducing λ balanced sparsity loss.
The model size is reduced to less than a quarter of the original model while maintaining detection performance, effectively removing unnecessary structures in the network and ensuring the stability of detection accuracy.
Smart Images

Figure CN118608446A
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of image processing and relates to a network compression method for detecting appearance defects of chemical fiber cakes based on filtering and pruning. Background Art
[0002] In recent years, with the promotion of artificial intelligence technology, deep learning methods with high image recognition rates have been increasingly widely used. The advantages of embedded systems, such as good portability and high stability, have led to widespread demand for embedded deployment of deep learning models. However, they cannot be directly used on embedded development boards. Due to the limited resources of embedded development boards, it is difficult to complete real-time reasoning of deep learning models. Therefore, using model compression to reduce the model size, the memory occupied by the model during reasoning, and the number of computing units to achieve real-time model reasoning has become a hot topic of research in recent years.
[0003] The state of the art includes exploring the full range of pruning granularities and evaluating the trade-off between model regularization and accuracy. It is demonstrated that coarse-grained pruning can achieve similar or even better compression rates than fine-grained pruning, even though it achieves less sparsity.
[0004] It also includes unstructured pruning methods. Unstructured pruning can only be completed by designing dedicated software libraries and hardware to complete model parsing. The runtime memory is not significantly reduced because most of the memory space is consumed by function mapping rather than the weight loading itself.
[0005] It also includes structured pruning, which is well compatible with hardware and software libraries. After pruning, the model structure is streamlined and model reasoning is accelerated. Coarse-grained structured pruning mainly involves channel dimension pruning and convolution kernel dimension pruning, which is itself structured pruning. Summary of the invention
[0006] In view of the above problems, the present invention optimizes and adapts the detection method and detection algorithm to address the problem that the detection effect of some defects in the appearance defects of chemical fiber cakes is poor. Since many pictures will be collected during the detection process and there are many redundant parts in the detection model.
[0007] The present invention provides a network compression method for detecting appearance defects of chemical fiber cakes based on filtering and pruning. The original network structure is connected with each channel of the convolutional layer by relying on the γ coefficient weight, and pruning is performed based on the BN layer coefficient, wherein the γ coefficient is a trainable affine transformation parameter.
[0008] Preferably, the method comprises the following steps:
[0009] S10, using sparsity regularization to process the γ coefficients to distinguish them from each other;
[0010] S20, identifying channels outside a preset threshold, i.e., unimportant channels, and cutting out the unimportant channels;
[0011] S30, after cropping, a lightweight network model is obtained, and then fine-tuned to obtain a detection model with an accuracy similarity within a threshold with the original network model.
[0012] Preferably, the output after S30 is returned to S10 for iteration.
[0013] Preferably, the formula for pruning based on the BN layer coefficient is:
[0014]
[0015]
[0016]
[0017] In the formula, μ B and B refers to the input activation z in The mean and standard deviation on the BN layer; γ and β are trainable affine transformation parameters, representing scale and offset respectively, and e is a constant. is the original output activation, z out is the output activation after the operation; (x, y) represents the training input and training target, W represents the trainable parameter, Γ represents all channels, L represents the regularized output, l(f(x,W),y) corresponds to the loss function of the default training, f(x,W) is the activation function, g(γ) is the loss caused by the sparsity of the scaling factor, and λ is introduced for balance.
[0018] The beneficial effects of the present invention include at least: after the present invention uses the BN layer-based pruning method to prune the chemical fiber cake appearance defect detection network model, the detection performance of the lightweight detection model is not much different from that of the original detection model, but its model size is only less than a quarter of the original detection model, proving that the algorithm has a good effect on the chemical fiber cake appearance defect detection network model. The pruning method based on the BN layer coefficient is used to prune the method in this paper, effectively removing unnecessary network structures in the network while ensuring that the detection accuracy does not change too much. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 It is a schematic diagram of the principle of the network compression method for detecting appearance defects of chemical fiber cakes based on filtering and pruning of the present invention;
[0020] Figure 2 The present invention is a flow chart of a network compression method for detecting appearance defects of chemical fiber cakes based on filtering and pruning. DETAILED DESCRIPTION
[0021] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0022] On the contrary, the present invention covers any substitution, modification, equivalent method and scheme made on the essence and scope of the present invention as defined by the claims. Further, in order to make the public have a better understanding of the present invention, some specific details are described in detail in the detailed description of the present invention below. Those skilled in the art can fully understand the present invention without the description of these details.
[0023] See also Figure 1 , which is an embodiment of the present invention, the technical solution of the present invention is a principle schematic diagram of a network compression method for detecting appearance defects of chemical fiber cakes based on filtering and pruning. The original network structure relies on the γ coefficient weight to connect with each channel of the convolutional layer, and pruning is performed based on the BN layer coefficient, wherein the γ coefficient is a trainable affine transformation parameter.
[0024] See also Figure 2 , is a flow chart of a network compression method for detecting appearance defects of chemical fiber cakes based on filtering and pruning of the present invention, comprising the following steps:
[0025] S10, using sparsity regularization to process the γ coefficients to distinguish them from each other;
[0026] S20, identifying channels outside a preset threshold, i.e., unimportant channels, and cutting out the unimportant channels;
[0027] S30, after cropping, a lightweight network model is obtained, and then fine-tuned to obtain a detection model with an accuracy similarity within a threshold with the original network model.
[0028] In a specific embodiment, the output after S30 is returned to S10 for iteration.
[0029] The formula for pruning based on the BN layer coefficient is:
[0030]
[0031]
[0032]
[0033] In the formula, μ B and B refers to the input activation z inThe mean and standard deviation on the BN layer; γ and β are trainable affine transformation parameters, representing scale and offset respectively, and e is a constant. is the original output activation, z out is the output activation after the operation; (x, y) represents the training input and training target, W represents the trainable parameter, Γ represents all channels, L represents the regularized output, l(f(x,W),y) corresponds to the loss function of the default training, f(x,W) is the activation function, g(γ) is the loss caused by the sparsity of the scaling factor, and λ is introduced for balance.
[0034] The pruning method is used to prune the chemical fiber cake detection model. The processing results are shown in Table 1:
[0035] Table 1 Comparison of pruning process models based on BN layer pruning method
[0036]
[0037] The model after sparse training is the model output after S10, the model after preliminary pruning is the model output after S20, and the model after fine-tuning is the model output after S30.
[0038] It can be seen from the experimental results that after pruning the network model of chemical fiber silk cake appearance defect detection using the BN layer-based pruning method, the detection performance of the lightweight detection model is not much different from that of the original detection model, but its model size is only less than a quarter of the original detection model, proving that the algorithm has a good effect on the network model of chemical fiber silk cake appearance defect detection.
[0039] The pruning method based on the BN layer coefficient is used for pruning, which effectively removes unnecessary network structures in the network while ensuring that the detection accuracy does not change too much.
[0040] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A network compression method for detecting appearance defects of chemical fiber cakes based on filtering and pruning, characterized in that: The original network structure relies on the γ coefficient weight to connect each channel of the convolutional layer and prunes based on the BN layer coefficient, where the γ coefficient is a trainable affine transformation parameter.
2. According to claim 1, a network compression method for detecting appearance defects of chemical fiber cakes based on filtering and pruning is characterized in that: The following steps are involved: S10, using sparsity regularization to process the γ coefficients to distinguish them from each other; S20, identifying channels outside a preset threshold, i.e., unimportant channels, and cutting out the unimportant channels; S30, after cropping, a lightweight network model is obtained, and then fine-tuned to obtain a detection model with an accuracy similarity within a threshold with the original network model.
3. According to claim 2, a network compression method for detecting appearance defects of chemical fiber cakes based on filtering and pruning is characterized in that: The output after S30 is returned to S10 for iteration.
4. The network compression method for detecting appearance defects of chemical fiber cakes based on filtering and pruning according to claim 1 is characterized in that: The formula for pruning based on the BN layer coefficient is: In the formula, μ B and B refers to the input activation z in The mean and standard deviation on the BN layer; γ and β are trainable affine transformation parameters, representing scale and offset respectively, and e is a constant. is the original output activation, z out is the output activation after the operation; (x, y) represents the training input and training target, W represents the trainable parameter, Γ represents all channels, L represents the regularized output, l(f(x,W),y) corresponds to the loss function of the default training, f(x,W) is the activation function, g(γ) is the loss caused by the sparsity of the scaling factor, and λ is introduced for balance.
