Lightweight image target detection network based on low-rank tensor decomposition and structured pruning
By employing low-rank tensor decomposition and structured pruning, the model complexity and computational cost are reduced, improving the real-time performance and cross-condition generalization ability of steel plate surface defect detection. This solves the real-time performance and storage cost issues in high-resolution image detection, enabling efficient online monitoring.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-03
- Publication Date
- 2026-03-10
AI Technical Summary
Existing technologies for high-resolution image target detection suffer from problems such as high model complexity, poor real-time performance, high storage costs, and weak generalization ability across working conditions. In particular, it is difficult to achieve efficient and robust online monitoring in the detection of defects on steel plate surfaces.
A lightweight image object detection network employing low-rank tensor decomposition and structured pruning is proposed. By replacing the convolution of the object detection network YOLOv1 with Conv2d_BN which supports low-rank tensor decomposition, the network is decomposed into three low-rank matrices and unimportant rank components are pruned. Combined with adaptive inpainting of the detection head, the model parameters are compressed and the computational cost is reduced, while maintaining detection accuracy and robustness.
It significantly reduces the number of parameters and computational load, improves the real-time performance and cross-condition generalization ability of detection, maintains the fine-grained defect feature detection accuracy of high-resolution images, and is suitable for online monitoring of steel plate surface quality.
Smart Images

Figure CN121640160A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the technical field of image target detection methods, specifically relating to a lightweight image target detection network based on low-rank tensor decomposition and structured pruning. Background Technology
[0002] With the intelligent upgrading of the steel industry, steel plates are susceptible to mechanical impact, scratches, and oxidation during rolling, handling, and storage, resulting in defects such as scratches, indentations, corrosion spots, and coating abnormalities, which directly threaten product yield and downstream application stability. To achieve online, full-range, and real-time quality monitoring, surface defect detection systems based on deep learning are gradually becoming mainstream. However, large-scale deployment still faces multiple challenges: First, to meet high-precision inspection requirements, production lines generally use high-resolution industrial cameras to acquire 2K×2K BMP raw images. Although these images fully preserve subtle textures and weak contrast defects, companies typically require long-term retention and batch archiving, resulting in a massive backlog of uncompressed raw images, significantly increasing storage, retrieval, and maintenance costs. Second, the model needs continuous iteration to adapt to changes in steel grade, process, lighting, and contamination levels. Training relies on centralized high-performance servers, requiring the aggregation of large-volume raw image samples from multiple production lines and locations. Training and online testing are conducted in different physical locations, and data backhaul and synchronization incur considerable transmission costs and latency. Furthermore, unknown distortions in real production lines (such as motion blur, environmental noise, oil atomization, and uneven lighting) still introduce source and target domain offsets, weakening the model's generalization ability under actual working conditions. This requires the inspection model to maintain high accuracy while possessing higher computational efficiency and robustness.
[0003] In the lightweight direction, existing methods mainly include: reducing computational power with structural designs such as depthwise separable / grouped convolutions and reparameterization; quantization (PTQ / QAT, INT8 / FP16) to compress storage and accelerate inference; knowledge distillation to transfer knowledge from teacher models to small models; irregular sparsity to improve parameter sparsity but with limited acceleration; and structured pruning at the channel / layer granularity to obtain deployable acceleration; in addition, low-rank decomposition (such as Tucker / CP / CPD) controls complexity by factorizing convolution weights to continuously control the "rank". Compared to the aforementioned approaches, this paper adopts an integrated solution of "low-rank tensor decomposition + structured pruning + adaptive head repair" on the YOLOv12 object detection network. This solution replaces standard convolutions with factorized sequences with minimal modifications, uses importance parameters for finely adjustable structured compression of complexity, and automatically reconstructs CV2 / CV3 channels and correction groups after pruning. A 1×1 adaptation layer is inserted when necessary to ensure dimensionality consistency. Combined with minimal fine-tuning and parallel inference, a closed loop of "decomposition → pruning → adaptive repair → fine-tuning → efficient deployment" is achieved. In 2K×2K BMP original image scenarios, this method is more effective than simple quantization or large-scale pruning in preserving fine-grained defect features, balancing accuracy, throughput, and edge-side deployability, demonstrating superior overall advantages.
[0004] To address the aforementioned challenges, we constructed a seven-category defect detection network and data closed-loop scheme for steel plate surfaces, covering typical defect types such as scratches, edge anomalies, abrasions, rust spots, indentations, oil spots, and oil stains. On the model side, we combined high-resolution and multi-scale feature fusion, and applied robust constraints and feature consistency regularization to detail-sensitive channels. On the data side, based on the original BMP image, we designed degradation simulation and domain alignment strategies close to the production line (such as parametric modeling and hybrid sampling for motion blur / dirt / illumination disturbances) to improve cross-device / cross-condition generalization. On the deployment side, lightweight design and parallel inference acceleration ensure stable real-time detection under production line cycle time. This system maintains the original high-fidelity image information while considering recall capability for minor defects and cross-condition generalization performance, making it suitable for large-scale deployment of online monitoring of steel plate surface quality. Summary of the Invention
[0005] This invention addresses the issues of model complexity and real-time performance under high-resolution original image conditions by proposing a lightweight image object detection network based on low-rank tensor decomposition and structured pruning. First, the convolutions in the backbone and neck of the YOLOv12 object detection network are replaced with Conv2d_BN supporting low-rank tensor decomposition. The original weights are then... Decomposed into three low-rank matrices (Output channel factor) (Intermediate connecting factor) (Input channel factor); then for For each rank component of a factor, the absolute sum of its values is calculated as an importance index. The rank components with the highest importance are then selected in descending order to form a set S. Subsequently, the factors are analyzed according to set S. , , Three factors for simultaneous pruning ( , (Importance not calculated separately), the factors after pruning , , The model is updated back to reduce the number of model parameters; then, the detection heads in the detection network are adaptively repaired; finally, accuracy and robustness are restored through minor fine-tuning. This method significantly reduces the number of parameters and computational cost while maintaining or improving detection accuracy and real-time performance under high-fidelity BMP original image conditions.
[0006] To achieve the above objectives, this invention is implemented through the following technical solution: a lightweight image target detection network based on low-rank tensor decomposition and structured pruning, specifically following these steps:
[0007] Step S1: Replace Conv2d in all original Conv modules in the YOLOv12 object detection network with Conv2d_BN that supports low-rank decomposition.
[0008] Step S2: Adjust the original weights According to formula (1), it can be decomposed into three low-rank matrices:
[0009] (1)
[0010] Where "^T" represents the transpose of a matrix, "@" represents matrix multiplication, and the output channel factor is... It can be represented as [ [rank], intermediate linking factor It can be represented as [rank, rank], where the input channel factor is [rank, rank]. It can be represented as [ ,rank], where, Number of output channels is the number of input channels, and rank is the decomposition rank.
[0011] Step S3: Perform structural pruning on the three low-rank matrices resulting from the decomposition. For each rank component of a factor, the absolute sum of its values is calculated as an importance index. The rank components with the highest importance are then selected in descending order to form a set S. Subsequently, the factors are analyzed according to set S. , , Three factors for simultaneous pruning ( , (Importance not calculated separately), the factors after pruning , , Update back to the model to achieve compression of model parameters.
[0012] Step S4: Adaptive repair of the detection head in the detection network. First, read the compressed model and set the baseline parameters. Then, check the regression and classification branches of each scale of the detection head layer by layer, that is, verify the three conditions of dimension matching correctness, group convolution correctness and output constraint correctness according to formula (8). If all three conditions are met, conservative repair is performed. If any condition is not met, it is marked as a problem layer and enters the reconstruction process (reconstructing the convolutional layer structure, transferring the alignable weights, and handling the group incompatibility problem according to formula (9)). Finally, all scales are checked until the detection head repair is completed.
[0013] Step S5: Fine-tune the model parameters, including the number of training epochs, learning rate, early stopping patience value, weight decay, and learning rate decay. Specifically, the number of training epochs is set to 250, the learning rate to 0.01, the early stopping patience value to 35, the weight decay to 0.001, and the learning rate decay to 0.05. After the main training is complete, the weight file path is automatically passed to the fine-tuning function.
[0014] Furthermore, the specific process of low-rank tensor decomposition in step S2 is as follows:
[0015] Original convolution kernel tensor:
[0016] (2)
[0017] Where K is the convolution weight tensor with size . , The number of input channels for the convolutional layer. This represents the number of output channels of the convolutional layer. , This represents the dimensions of the convolution kernel in the height and width directions;
[0018] Let rank be the number of rank components retained after decomposition. The convolution kernel is decomposed into three groups of factors using low-rank decomposition:
[0019] , , (3)
[0020] Furthermore, the specific process of pruning in step S3 is as follows:
[0021] Factor importance assessment and structured pruning, importance score , according to the pabs criterion, based on the column L1 norm of s ("L1 norm" is the "sum of absolute values", which is commonly used to evaluate importance and filter out small weights during pruning), calculate the importance score for each s , and cut off the corresponding columns (basis / intermediate channels) in ascending order of the scores, and retain those with larger scores:
[0022] (4)
[0023] Among them, is the importance score of the s-th rank component, represents the s-th column vector of represents the element in the o-th row and s-th column of is the number of output channels of the convolutional layer, is the L1 norm of the s-th column, and the right summation formula is its definition;
[0024] Select the retained rank set S and retain k < rank components;
[0025] (5)
[0026] Among them, S is the set of retained rank components, |S| = k, which is obtained by taking the Top-k of the importance scores of each component, and k (k ≤ rank) is the rank after pruning, that is, the number of finally actually retained rank components;
[0027] Simultaneously prune the three factors and lower the rank:
[0028] (6)
[0029] Among them, represents the s-th column vector of represents the s-th column vector of represents the s-th column vector, " " means updating the left variable with the right matrix, that is, completing the synchronous pruning, and rank[[ID=
[0034] Read and baseline fixation: Load the decomposed and pruned model, and set the number of defect categories. The number of levels in the detection head, i.e., the number of scales Z, and the actual number of upstream feature channels at each scale. Set the target channel for the detection head: the regression branch cv2 Cv3 is a classification branch. ,in, For the target channel of the regression branch, cv2 is the standard setting for the regression branch of the output channel. , indicating that there are 5 regressors for each category; For the target channel of the classification branch, cv3 is the standard setting for the output channel classification branch. One classification channel for each category;
[0035] Rapid inspection and problem localization: For each scale Z, cv2 and cv3 are inspected layer by layer, and the following three conditions must be met simultaneously:
[0036] Dimension matching correctness verification: verification Is it equal to the input channel dimension of the convolution weights? ,in, is the input channel dimension of the convolution weights;
[0037] Grouped convolution correctness verification:
[0038] and (8)
[0039] Wherein, "%" indicates "divisibility". The output channel dimension of the convolution weights. The number of upstream input channels must be divisible by the number of groups in order to divide the input into groups. The output channel dimension of this layer must also be divisible by the number of groups in order to distribute the output evenly among the groups;
[0040] Output constraint correctness verification: Verification Are they respectively equal to , ;
[0041] If any of the above three conditions is not met, the layer will be marked as a problem layer, and the problem type will be labeled as: input mismatch only / groups incompatibility only / both / output was mistakenly modified.
[0042] Strategy Selection: If a direct forward pass is possible, conservative repairs are performed, only checking and recording without modifying the structure; if a direct forward pass is not possible or a problematic layer is identified, a refactoring process is initiated. This refactoring process includes rebuilding the convolutional layer structure, migrating alignable weights, and handling incompatible grouping.
[0043] Reconstructing the convolutional layer structure: First, obtain the actual number of channels of the upstream features. Then reconstruct the convolutional layer parameters: number of input channels of the convolutional layer. Equal to the actual number of upstream feature channels at each scale Number of output channels of convolutional layer Equal to the target number of output channels In addition, the kernel size, stride, and padding pixel count of the convolutional layer remain the same as those of the original layer, and the output size remains the same as the input size.
[0044] The migration can align weights: First, align channels: the original convolutional layer weight tensors are transformed into reconstructed weight tensors, and their shapes are adjusted according to the new number of channels. Then, perform appropriate initialization for missing channels: the reconstructed weight tensors are initialized or zero-initialized. Finally, redundant channels are discarded directly.
[0045] Handling grouping incompatibility: First, calculate the greatest common divisor of the corrected grouping numbers. :
[0046] (9)
[0047] Where gcd is used to calculate the greatest common divisor;
[0048] Finally, if And if the integer is , then let groups equal to Conversely, set groups = 1.
[0049] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0050] 1. This invention proposes an end-to-end lightweight detection framework for high-resolution raw images. By combining low-rank decomposition and structured pruning, and adaptively repairing the detection head in the detection network, it significantly reduces the number of parameters and FLOPs while preserving subtle defect features and avoiding structural mismatch. Simultaneously, it designs… , , A three-factor linked structural pruning method, based on Factor importance is evaluated by summing the absolute values of factors and combining them with global constraints, which effectively ensures the performance stability of the pruned model.
[0051] 2. In the adaptive repair step of the detection head in the detection network, the present invention performs targeted consistency correction and robustness. The correctness of the dimension, grouping and output constraints is verified by formula (8) in the reconstruction of the detection head, and the number of groups is adaptively determined by formula (9) to reflect consistency correction. At the same time, robustness is ensured by fine-tuning the training.
[0052] 3. This invention provides adjustable decomposition and rank parameters, hierarchical rank configuration, and automatic rank detection, facilitating users to flexibly balance accuracy, speed, and parameter quantity, and to ensure experimental reproducibility. It employs a hierarchical adaptive rank scheduling strategy, assigning differentiated rank values to different convolutional layers based on the number of channels, receptive field, and layer importance, achieving more refined model compression control.
[0053] 4. Outstanding empirical results: The number of parameters decreased from approximately 2.57M to approximately 147K–317K, the single-frame latency decreased from approximately 110.85ms to approximately 100.27ms, and the mAP50 remained at approximately 90% (see details). Figure 4 ). Attached Figure Description
[0054] Figure 1 Here is the algorithm flowchart for step S2.
[0055] Figure 2 Here is the algorithm flowchart for step S3.
[0056] Figure 3 Here is the algorithm flowchart for step S4.
[0057] Figure 4 To compare the performance of the method of this invention with the original object detection networks YOLOv12 and YOLOv12-StarNet under different parameter configurations. Detailed Implementation
[0058] The embodiments of the present invention will be described in detail below with reference to the accompanying drawings and examples, so as to fully understand how the present invention uses technical means to solve technical problems and achieve technical effects and to implement it accordingly.
[0059] A lightweight image target detection method based on low-rank tensor decomposition and structured pruning is implemented according to the following steps:
[0060] Step S1: Replace Conv2d in all original Conv modules in the YOLOv12 object detection network with Conv2d_BN that supports low-rank decomposition;
[0061] This invention is based on the general structure of the object detection network YOLOv12 (Ultralytics YOLOv12 basic structure) file (this file is the model configuration, used to define the overall network structure and hyperparameters, covering the depth and width coefficients of multi-scale variants, as well as the hierarchical connections between the backbone and the detection head, upsampling and feature fusion, and the final detection layer). Under the condition of not using pre-trained weights and starting training from random initialization, a lightweight object detection network based on low-rank tensor decomposition and structured pruning is adopted.
[0062] The Conv2d_BN module of this invention is a convolutional module integrating low-rank decomposition, used to replace the original Conv module in the YOLOv12 object detection network. The advantages of the Conv2d_BN module are: support for different rank settings (e.g., 1, 2, 4, 8, etc.), different compression ratios for different layers, preservation of the original convolution's spatial receptive field, consistent input / output interfaces with the original Conv2d, direct replacement of existing Conv2d modules, support for end-to-end training, and fine-tuning to restore accuracy. Through this design, the Conv2d_BN module significantly reduces the number of model parameters and computational complexity while maintaining detection accuracy.
[0063] Step S2: Adjust the original weights According to formula (1), it can be decomposed into three low-rank matrices:
[0064] (1)
[0065] Where "^T" represents the transpose of a matrix, "@" represents matrix multiplication, and the output channel factor is... It can be represented as [ [rank], intermediate linking factor It can be represented as [rank, rank], where the input channel factor is [rank, rank]. It can be represented as [ ,rank], where, Number of output channels is the number of input channels, and rank is the decomposition rank.
[0066] like Figure 1 As shown, the specific process is as follows:
[0067] Original convolution kernel tensor:
[0068] (2)
[0069] Where K is the convolution weight tensor with size . , The number of input channels for the convolutional layer. This represents the number of output channels of the convolutional layer. , This represents the dimensions of the convolution kernel in the height and width directions;
[0070] Let rank be the number of rank components retained after decomposition. The convolution kernel is decomposed into three groups of factors using low-rank decomposition:
[0071] , , (3)
[0072] Through this decomposition, the total number of parameters is reduced from to , achieving significant model compression.
[0073] Step S3: Perform structural pruning on the three decomposed low-rank matrices. Calculate the sum of absolute values of each rank component of the factor as the importance index, and sort it in descending order to select and retain the rank components with the highest importance indices to form a set S. Subsequently, synchronously prune the , , three factors ( , not calculating importance separately), and update the pruned factors , , back to the model to achieve compression of the model parameter quantity.
[0074] As Figure 2 shown, the specific process is as follows:
[0075] Factor importance evaluation and structural pruning, importance score , following the pabs criterion, based on the column L1 norm of s ("L1 norm" is the "sum of absolute values", which is commonly used to evaluate importance and filter out small weights during pruning), calculate the importance score for each s, and cut off the corresponding columns (basis / intermediate channels) in ascending order of the score, retaining those with large scores: [[ID=4E]]
[0076] [[ID=4E]] (4)
[0077] Among them, is the importance score of the s-th rank component, represents the s-th column vector of , ] / >represents the element at the o-th row and s-th column of , is the number of output channels of the convolutional layer, <000]0300>Select the retained rank set S, retaining k < rank components;
[0079] (5)
[0080] Among them, S is the set of retained rank components, |S| = k, obtained by taking the Top-k of the importance scores of each component, and k (k ≤ rank) is the rank after pruning, that is, the number of rank components actually retained finally;
[0081] Simultaneously prune all three factors and downgrade their rank:
[0082] (6)
[0083] in, express The s-th column vector, express The s-th column vector, express The s-th column vector, "" indicates that the left-hand variable is updated using the right-hand matrix, thus completing the synchronous pruning, rank k indicates that the rank parameter of the current layer will be updated to k;
[0084] Post-pruning parameters:
[0085] (7)
[0086] in, This is an approximation of the parameters after pruning to k.
[0087] Compared to the number of parameters in the original convolution:
[0088] (8)
[0089] As can be seen from the two formulas above, the number of parameters after pruning in this invention is significantly smaller than that of the original convolution.
[0090] Step S4: Adaptive repair of the detection head in the detection network. First, read the compressed model and set the baseline parameters. Then, check the regression and classification branches of each scale of the detection head layer by layer, that is, verify the three conditions of dimension matching correctness, group convolution correctness and output constraint correctness according to formula (9). If the above three conditions are met, conservative repair is performed. If any condition is not met, it is marked as a problem layer and enters the reconstruction process (reconstructing the convolutional layer structure, transferring the alignable weights, and handling the group incompatibility problem according to formula (10)). Finally, all scales are checked until the detection head repair is completed.
[0091] like Figure 3 As shown, the specific process is as follows:
[0092] Read and baseline fixation: Load the decomposed and pruned model, and set the number of defect categories. The number of levels in the detection head, i.e., the number of scales Z, and the actual number of upstream feature channels at each scale. Set the target channel for the detection head: the regression branch cv2 Cv3 is a classification branch. ,in, For the target channel of the regression branch, cv2 is the standard setting for the regression branch of the output channel. , indicating that there are 5 regressors for each category; For the target channel of the classification branch, cv3 is the standard setting for the output channel classification branch. One classification channel for each category;
[0093] Rapid inspection and problem localization: For each scale Z, cv2 and cv3 are inspected layer by layer, and the following three conditions must be met simultaneously:
[0094] Dimension matching correctness verification: verification Is it equal to the input channel dimension of the convolution weights? ,in, is the input channel dimension of the convolution weights;
[0095] Grouped convolution correctness verification:
[0096] and (9)
[0097] Wherein, "%" indicates "divisibility". The output channel dimension of the convolution weights. The number of upstream input channels must be divisible by the number of groups in order to divide the input into groups. The output channel dimension of this layer must also be divisible by the number of groups in order to distribute the output evenly among the groups;
[0098] Output constraint correctness verification: Verification Are they respectively equal to , ;
[0099] If any of the above three conditions is not met, the layer will be marked as a problem layer, and the problem type will be labeled as: input mismatch only / groups incompatibility only / both / output was mistakenly modified.
[0100] Strategy Selection: If a direct forward pass is possible, conservative repairs are performed, only checking and recording without modifying the structure; if a direct forward pass is not possible or a problematic layer is identified, a refactoring process is initiated. This refactoring process includes rebuilding the convolutional layer structure, migrating alignable weights, and handling incompatible grouping.
[0101] Reconstructing the convolutional layer structure: First, obtain the actual number of channels of the upstream features. Then reconstruct the convolutional layer parameters: number of input channels of the convolutional layer. Equal to the actual number of upstream feature channels at each scale Number of output channels of convolutional layer Equal to the target number of output channels In addition, the kernel size, stride, and padding pixel count of the convolutional layer remain the same as those of the original layer, and the output size remains the same as the input size.
[0102] The migration can align weights: First, align channels: the original convolutional layer weight tensors are transformed into reconstructed weight tensors, and their shapes are adjusted according to the new number of channels. Then, perform appropriate initialization for missing channels: the reconstructed weight tensors are initialized or zero-initialized. Finally, redundant channels are discarded directly.
[0103] Handling grouping incompatibility: First, calculate the greatest common divisor of the corrected grouping numbers. :
[0104] (10)
[0105] Where gcd is used to calculate the greatest common divisor;
[0106] Finally, if And if the integer is , then let groups equal to Conversely, set groups = 1.
[0107] Step S5: Fine-tune the model parameters, including the number of training epochs, learning rate, early stopping patience value, weight decay, and learning rate decay. Specifically, the number of training epochs is set to 250, the learning rate to 0.01, the early stopping patience value to 35, the weight decay to 0.001, and the learning rate decay to 0.05. After the main training is complete, the weight file path is automatically passed to the fine-tuning function.
[0108] Figure 4 The performance comparison of the proposed method with the original object detection networks YOLOv12 and YOLOv12-StarNet is shown under different parameter configurations. In the figure, mAP50(B) / % represents the average accuracy (mAP) based on the bounding box (B: bbox) when the IoU threshold is fixed at 0.5, expressed as a percentage. A higher value indicates more accurate detection. mAP50–95(B) / % represents the average mAP (also for bounding boxes) obtained by averaging across 10 IoU thresholds from 0.5 to 0.95 with a step size of 0.05; this is a more rigorous and comprehensive indicator.
[0109] The model of this invention introduces low-rank tensor decomposition and low-rank pruning in the backbone and neck, without modifying the decoupling head; the combinations of decomposition parameters decomposition=2 / 4 / 8 / 24 and pruning rank=1 / 2 / 4 / 8 were evaluated. Overall, while maintaining an inference latency of approximately 100ms (Speed(ms)), the number of parameters (Params(M, K)), where "K" represents thousands and "M" represents millions, can be significantly reduced from 2.57M to approximately 317K-147K, and the mAP remains around 90% in most settings (except for a significant decrease in accuracy when decomposition=4 and rank=2). In comparison, the comparative method is not superior in terms of accuracy and speed (for example, its mAP50 / 50-95 is only about 64.68% / 26.61%, and its inference is slower). The trends brought about by different hyperparameters are also quite clear: a lower rank or a smaller decomposition can achieve a higher compression ratio, but excessive compression will cause a decline in accuracy; under the current data, decomposition=4 combined with rank=1 can achieve a better trade-off between accuracy, speed and parameter size.
[0110] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A lightweight image object detection network based on low-rank tensor decomposition and structured pruning, characterized in that: Specifically, the following steps are performed: Step S1, replace Conv2d in all original Conv modules in the target detection network YOLOv12 with Conv2d_BN supporting low-rank decomposition; Step S2: Adjust the original weights According to formula (1), it can be decomposed into three low-rank matrices: (1) wherein "T" denotes a transpose representation of a matrix, "@" denotes a matrix multiplication operation, an output channel factor is represented as , rank], an intermediate connection factor is represented as [rank, rank], an input channel factor is represented as , rank], wherein is the number of output channels, is the number of input channels, and rank is a decomposition rank; Step S3, structural pruning is performed on the three decomposed low-rank matrices; and An absolute value sum is calculated as an importance index for each rank component of the factor, and the rank components are sorted in descending order to select the rank components with the highest importance indexes to form a set S, and then the three factors are pruned according to the set S 、 、 The three factors are pruned synchronously, 、 The importance is not calculated separately, and the pruned factors , , The model is updated back to realize compression of the model parameter quantity; Step S4, adaptive repair of the detection head in the detection network; first, read the compressed model and set the baseline parameters, then check the regression branch layer and the classification branch layer of each scale of the detection head layer by layer, verify the correctness of the dimension matching, the correctness of the grouped convolution and the correctness of the output constraint, if the above three conditions are met, perform conservative repair, if the conditions are not met, mark the problem layer and enter the reconstruction process, finally, review all scales until the detection head repair is completed; Step S5, fine-tuning of the training rounds, learning rate, early stopping patience value, weight decay and learning rate decay of the model parameters; wherein the training rounds are set to 250 epochs, the learning rate is set to 0.01, the early stopping patience value is set to 35, the weight decay is set to 0.001, and the learning rate decay is set to 0.05, and after the main training is completed, the weight file path is automatically passed to the fine-tuning function.
2. The lightweight object detection network based on low-rank tensor decomposition and structured pruning according to claim 1, characterized in that: The specific process of low-rank tensor decomposition in step S2 is as follows: Original convolution kernel tensor: (2) wherein K is a convolution weight tensor, with size , is the number of input channels of the convolution layer, is the number of output channels of the convolution layer, , is the size of the convolution kernel in the height and width directions; Let the number of rank components retained after decomposition be rank, and decompose the convolution kernel into three groups of factors: , , (3)。 3. The lightweight object detection network based on low-rank tensor decomposition and structured pruning of claim 2, wherein: The specific process of pruning in step S3 is as follows: Factor importance evaluation and structured pruning, importance score , pabs criterion, based on the column L1 norm of s, "L1 norm" is "sum of absolute values", commonly used to evaluate importance when pruning, screen out small weights, calculate importance score for each s , and prune the corresponding column from small to large according to the score, keep the one with large score: (4) wherein, importance score of the s-th rank component, denotes the s-th column vector of denotes the element in the o-th row, s-th column, is the number of output channels of the convolution layer, is the L1 norm of the s-th column, the right summation is its definition; Select the retained rank set S, and retain k<rank components; (5) Wherein, S is the retained rank component set, |S|=k, which is obtained by taking Top-k from the importance score of each component, k (k≤rank) is the rank after pruning, that is, the actual number of rank components retained finally; Synchronously crop the three factors and reduce the rank: (6) wherein, denotes the s-th column vector of denotes the s-th column vector of denotes the s-th column vector of denotes updating the left variable with the right matrix, i.e. performing a synchronized clipping, rank k denotes updating the rank parameter of the current layer to k; Parameter quantity after pruning: (7) where, is the approximation of the parameter quantity after pruning to k.
4. The lightweight object detection network based on low-rank tensor decomposition and structured pruning of claim 3, wherein: The specific process of step S4 is as follows: Read and baseline fixed: load the decomposed and pruned model, set the number of defect categories , the number of layers of the detection head, i.e. the number of scales Z, the actual number of channels of the upstream features at each scale , set the target channel of the detection head: the regression branch cv2 , the classification branch cv3 , wherein, is the target channel of the regression branch, cv2 is the standard setting of the output channel regression branch, , representing 5 regression quantities per category; is the target channel of the classification branch, cv3 is the standard setting of the output channel classification branch, , 1 classification channel per category; Quick check and problem positioning: check cv2, cv3 of each scale Z layer by layer, which needs to meet the following three conditions at the same time: dimensional correctness verification: verifying whether the input channel dimension of the convolutional weight is equal to wherein, the input channel dimension of the convolutional weight; Grouped convolution correctness verification: and (8) wherein "%" denotes "integer division", output channel dimension of the convolution weights, : the number of upstream input channels must be divisible by the number of groups in order to evenly divide the inputs into groups, : the output channel dimension of this layer must also be divisible by the number of groups in order to evenly divide the outputs into groups; Output constraint correctness verification: verifying whether are respectively equal to , ; The above three conditions, if the conditions are not met, mark the layer as a problem layer and note the problem type: only input mismatch / only groups incompatible / both / output is mischanged; Strategy selection: direct forward, perform conservative repair, only check and record, do not change the structure; cannot directly forward or find problem layer, enter the reconstruction process; wherein, the reconstruction process includes rebuilding the convolution layer structure, migrating the alignable weight, and handling the grouped incompatible; Reconstruct the convolutional layer structure: first get the actual channel number of the upstream feature Then reconstruct the convolutional layer parameters: the input channel number of the convolutional layer Equal to the actual channel number of the upstream feature at each scale The output channel number of the convolutional layer Equal to the target output channel number In addition, the convolution kernel size, convolution step, and the original layer are consistent, and the number of padding pixels and the input size are consistent; Migrate the alignable weight: first, align the channels: the original convolution layer weight tensor becomes the reconstructed weight tensor, the shape is adjusted according to the new number of channels, then initialize the missing channels reasonably: initialize or zero-initialize the reconstructed weight tensor, finally, redundant channels: directly discard; Processing packet incompatibility: first, compute the greatest common divisor of the modified packet numbers : (9) Wherein, gcd is the calculation of the greatest common divisor; Finally, if and is an integer, then let groups equal ; otherwise, let groups = 1.