Image processing model and strip steel surface defect detection method
By replacing modules in the backbone and neck networks of the YOLOv5 model and combining loss function optimization and pruning, the problems of real-time performance and excessive computational overhead in strip surface defect detection were solved, achieving efficient and accurate defect detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGDONG UNIV OF TECH
- Filing Date
- 2026-03-31
- Publication Date
- 2026-07-03
Smart Images

Figure CN122335720A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer data processing technology, and in particular to an image processing model and a method for detecting surface defects in strip steel. Background Technology
[0002] With the development of modern industry, steel is widely used in construction, transportation, machinery, and aerospace. As an important steel product, strip steel is susceptible to surface defects such as scratches, cracks, and blemishes during production and processing due to factors such as raw materials, processes, and the environment. These defects not only reduce the mechanical strength, performance, and lifespan of the strip steel, affecting subsequent processing, but may also cause equipment failures or even serious safety accidents. Therefore, efficient and accurate detection of surface defects in strip steel has become a crucial link in ensuring product quality and production safety, and is of great significance to promoting the high-quality development of the steel industry.
[0003] Early technologies for detecting surface defects in steel strips primarily relied on visual inspection and physical-based sensor methods, such as eddy current, infrared, magnetic flux leakage, and laser scanning. These methods generally suffer from poor versatility, weak environmental adaptability, and difficulty in achieving automated, high-precision detection.
[0004] With the development of computer technology, traditional machine vision methods have emerged, mainly including three categories: methods based on local anomalies detect defects by analyzing the statistical characteristics of textures or in the frequency domain, with performance highly dependent on pre-set models; template matching methods detect defects by comparing them with defect-free templates, but are sensitive to changes in lighting and viewing angle; and methods based on feature extraction and classifiers rely on manually designed features, and their effectiveness is limited by the quality of feature engineering. These methods either rely on expert experience and specific physical effects, or are constrained by handmade features and fixed models. When dealing with diverse defects and complex industrial environments, they generally suffer from insufficient generalization, poor robustness, and limited automation.
[0005] In recent years, deep learning-based object detection methods have gradually become the mainstream in defect detection due to their powerful end-to-end feature learning capabilities. Object detection methods are mainly divided into two categories: two-stage algorithms represented by the R-CNN series, and single-stage algorithms represented by the YOLO series. Two-stage algorithms require generating candidate regions before classification and localization, offering high accuracy but also being computationally complex and slow, making them unsuitable for real-time industrial applications. Single-stage algorithms, on the other hand, directly predict the category and bounding box on the image, maintaining high accuracy while offering faster speed, making them more suitable for real-time detection tasks. Summary of the Invention
[0006] To address the problems of insufficient real-time performance, limited detection accuracy, excessive computational overhead, and difficulty in balancing accuracy and speed in existing strip surface defect detection methods, this invention proposes an image processing model and a strip surface defect detection method.
[0007] To achieve the above-mentioned technical effects, the technical solution of the present invention is as follows: An image processing model is provided in which the C3 module of the backbone network in the YOLOv5 model is replaced with an adaptive lightweight C3 module, and several convolutional modules are replaced with adaptive lightweight convolutional modules; the C3 module in the neck network is replaced with an adaptive lightweight C3 module, and the convolutional modules in the neck network are replaced with adaptive lightweight convolutional modules.
[0008] The present invention also provides a method for detecting surface defects in steel strips, comprising the following steps: Obtain a dataset of images of the steel strip surface; Construct an image processing model; Construct a bounding box regression loss function; input the strip steel surface image dataset into the image processing model for training; when the bounding box regression loss function converges, the trained image processing model is obtained. The trained image processing model is pruned to obtain a pruned image processing model; the surface image of the strip to be detected is input into the pruned image processing model to obtain the surface defect detection result of the strip.
[0009] Compared with the prior art, the beneficial effects of the technical solution of the present invention are: This invention proposes an image processing model and a method for detecting surface defects in strip steel. By replacing the standard C3 module and convolutional module in the backbone and neck network of the YOLOv5 model with adaptive lightweight C3 modules and adaptive lightweight convolutional modules, respectively, the number of model parameters and computational cost are significantly reduced while maintaining the accuracy of strip steel surface defect detection. The training process is optimized by combining the bounding box regression loss function, which accelerates the model convergence speed and improves the defect localization accuracy. The trained model is pruned to further compress the model size and reduce the computational requirements for deployment, enabling the model to be efficiently deployed on edge devices with limited computing resources. Attached Figure Description
[0010] Figure 1 This is a structural diagram of the image processing model in this invention; Figure 2 This is a structural diagram of the first spatial pyramid pooling fast module in this invention; Figure 3 This is a structural diagram of the adaptive lightweight C3 module in this invention; Figure 4 This is a structural diagram of the first adaptive lightweight bottleneck module in this invention; Figure 5 This is a structural diagram of the adaptive lightweight convolution module in this invention; Figure 6 This is a graph illustrating depthwise convolution computation in this invention; Figure 7 This is a diagram of some convolution operations in this invention; Figure 8 This is an operational diagram of the adaptive lightweight convolution module in this invention; Figure 9 This is a schematic flowchart of the strip steel surface defect detection method in this invention; Figure 10 This is a schematic diagram of the channel pruning process based on the channel scaling factor in this invention; Figure 11 This is a schematic diagram of the pruning process of the adaptive lightweight convolution module in this invention; Figure 12 This is a schematic diagram of the pruning process of the first adaptive lightweight bottleneck module in this invention; Figure 13 This is a schematic diagram of the adaptive lightweight C3 module pruning process in this invention. Detailed Implementation
[0011] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples of apparatuses and methods consistent with some aspects of the invention as detailed in the appended claims.
[0012] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. The singular forms “a,” “the,” and “the” used in this invention and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.
[0013] It should be understood that although the terms first, second, third, etc., may be used in this invention to describe various information, this information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first information may also be referred to as second information without departing from the scope of this invention, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to a determination."
[0014] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments.
[0015] Example 1 This embodiment proposes an image processing model, the structure of which is shown in the figure below. Figure 1 As shown, the image processing model replaces the C3 module of the backbone network in the YOLOv5 model with an adaptive lightweight C3 module, and several convolutional modules with adaptive lightweight convolutional modules; the C3 module in the neck network is replaced with an adaptive lightweight C3 module, and the convolutional modules in the neck network are replaced with adaptive lightweight convolutional modules.
[0016] In this embodiment, an adaptive lightweight convolution module is systematically used to replace the standard convolutions widely present in the backbone and neck parts of the YOLOv5 network, especially the standard convolutions in the C3 structure used for feature reuse and enhancement, thereby realizing the reconstruction of the YOLOv5 model and finally constructing an image processing model Ada-YOLO that balances accuracy and efficiency.
[0017] In one alternative embodiment, the backbone network includes: The first convolutional module, the first adaptive lightweight convolutional module, the first adaptive lightweight C3 module, the second adaptive lightweight convolutional module, the second adaptive lightweight C3 module, the third adaptive lightweight convolutional module, the third adaptive lightweight C3 module, the fourth adaptive lightweight convolutional module, the fourth adaptive lightweight C3 module, and the first spatial pyramid pooling fast module are connected in sequence. Further, an initial feature map is obtained from the surface image of the strip to be detected. The initial feature map is input into the first convolution module to obtain the first convolution feature. The first convolution feature is input into the first adaptive lightweight convolution module to obtain the first adaptive lightweight convolution feature. The first adaptive lightweight convolution feature is input into the first adaptive lightweight C3 module to obtain the first adaptive lightweight C3 feature. The first adaptive lightweight C3 feature is input into the second adaptive lightweight convolution module to obtain the second adaptive lightweight convolution feature. The second adaptive lightweight convolution feature is input into the second adaptive lightweight C3 module to obtain the second adaptive lightweight C3 feature. The second adaptive lightweight C3 feature is input into the third adaptive lightweight convolution module to obtain the third adaptive lightweight convolution feature. The third adaptive lightweight C3 feature is input into the fourth adaptive lightweight convolution module to obtain the fourth adaptive lightweight convolution feature. The fourth adaptive lightweight convolution feature is input into the fourth adaptive lightweight C3 module to obtain the fourth adaptive lightweight C3 feature. The fourth adaptive lightweight C3 feature is input into the first spatial pyramid pooling fast module to obtain the aggregated feature. The first spatial pyramid pooling fast module structure diagram is as follows: Figure 2 As shown, it includes: The second convolution module, the first max pooling module, the third convolution module, the fourth convolution module, the first splicing module, and the fifth convolution module are connected in sequence; the output of the second convolution module is also connected to the input of the first splicing module, the output of the first max pooling module is also connected to the input of the first splicing module, the output of the third convolution module is also connected to the input of the first splicing module, and the output of the fourth convolution module is also connected to the input of the first splicing module. The second convolutional module convolves the features input from the first spatial pyramid pooling fast module to obtain the second convolutional feature. The second convolutional feature is input into the first max pooling module to obtain the first max pooling feature. The first max pooling feature is input into the third convolutional module to obtain the third convolutional feature. The third convolutional feature is input into the fourth convolutional module to obtain the fourth convolutional feature. The second convolutional feature, the first max pooling feature, the third convolutional feature, and the fourth convolutional feature are input into the first concatenation module to obtain the first concatenation feature. The first concatenation feature is input into the fifth convolutional module to obtain the fifth convolutional feature.
[0018] In an alternative embodiment, the neck network includes: The fifth adaptive lightweight convolution module, the first upsampling module, the second stitching module, the fifth adaptive lightweight C3 module, the sixth adaptive lightweight convolution module, the second upsampling module, the third stitching module, the sixth adaptive lightweight C3 module, the seventh adaptive lightweight convolution module, the fourth stitching module, the seventh adaptive lightweight C3 module, the eighth adaptive lightweight convolution module, the fifth stitching module, and the eighth adaptive lightweight C3 module are connected in sequence. The output of the second adaptive lightweight C3 module is also connected to the input of the third stitching module; the output of the third adaptive lightweight C3 module is also connected to the input of the second stitching module; the output of the first spatial pyramid pooling fast module is also connected to the input of the fifth adaptive lightweight convolution module; the output of the fifth adaptive lightweight convolution module is also connected to the input of the fifth stitching module; the output of the sixth adaptive lightweight convolution module is also connected to the input of the fourth stitching module. The features obtained from the first spatial pyramid pooling fast module are input into the fifth adaptive lightweight convolution module to obtain the fifth adaptive lightweight convolution features; the fifth adaptive lightweight convolution features are input into the first upsampling module to obtain the first upsampling features; The first upsampling feature and the third adaptive lightweight C3 feature are input into the second concatenation module to obtain the second concatenation feature. The second concatenation feature is input into the fifth adaptive lightweight C3 module to obtain the fifth adaptive lightweight C3 feature. The fifth adaptive lightweight C3 feature is input into the sixth adaptive lightweight convolution module to obtain the sixth adaptive lightweight convolution feature. The sixth adaptive lightweight convolution feature is input into the second upsampling module to obtain the second upsampling feature. The second adaptive lightweight C3 feature and the second upsampling feature are input into the third concatenation module to obtain the third concatenation feature. The third concatenation feature is input into the sixth adaptive lightweight C3 module to obtain the sixth adaptive lightweight C3 feature. The sixth adaptive lightweight C3 feature is input into the seventh adaptive lightweight convolution module to obtain the seventh adaptive lightweight convolution feature. The seventh adaptive lightweight convolution feature is input into the fourth concatenation module, and the sixth adaptive lightweight convolution feature is also input into the fourth concatenation module to obtain the fourth concatenation feature. The fourth concatenation feature is input into the seventh adaptive lightweight C3 module to obtain the seventh adaptive lightweight C3 feature. The seventh adaptive lightweight C3 feature is input into the eighth adaptive lightweight convolution module to obtain the eighth adaptive lightweight convolution feature. The eighth adaptive lightweight convolutional feature is input into the fifth concatenation module, and the fifth adaptive lightweight convolutional feature is also input into the fifth concatenation module to obtain the fifth concatenation feature. The fifth concatenation feature is input into the eighth adaptive lightweight C3 module to obtain the eighth adaptive lightweight C3 feature.
[0019] In an optional embodiment, the image processing model further includes a head network, the head network comprising: The first detection head module, the second detection head module, and the third detection head module; The input terminal of the first detection head module is connected to the output terminal of the sixth adaptive lightweight C3 module, the input terminal of the second detection head module is connected to the output terminal of the seventh adaptive lightweight C3 module, and the input terminal of the third detection head module is connected to the output terminal of the eighth adaptive lightweight C3 module. The sixth adaptive lightweight C3 feature input to the first detection head module yields the first detection result; the seventh adaptive lightweight C3 feature input to the second detection head module yields the second detection result; and the eighth adaptive lightweight C3 feature input to the third detection head module yields the third detection result.
[0020] In one optional embodiment, any one of the adaptive lightweight C3 modules, AdaC3, from the first, second, third, fourth, fifth, sixth, seventh, and eighth adaptive lightweight C3 modules, has the following module structure diagram: Figure 3 As shown, it includes: The first and second branches are connected in parallel; The first branch includes: a sixth convolutional module, a first adaptive lightweight bottleneck module, a sixth splicing module, and a seventh convolutional module connected in sequence; for example, there can be n adaptive lightweight bottleneck modules; The second branch includes: an eighth convolution module; the output of the eighth convolution module is connected to the input of the sixth splicing module; The eighth convolutional module convolves the features input to the adaptive lightweight C3 module to obtain the eighth convolutional feature; the sixth convolutional module convolves the features input to the adaptive lightweight C3 module to obtain the sixth convolutional feature, the sixth convolutional feature is input to the first adaptive lightweight bottleneck module to obtain the first adaptive lightweight bottleneck feature, the eighth convolutional feature and the first adaptive lightweight bottleneck feature are input to the sixth concatenation module to obtain the sixth concatenation feature, and the sixth concatenation feature is input to the seventh convolutional module to obtain the seventh convolutional feature; The first adaptive lightweight bottleneck module, AdaBottleneck, has the following structure diagram: Figure 4 As shown, it includes: The ninth adaptive lightweight convolution module, the tenth adaptive lightweight convolution module, and the first addition module Add are connected in sequence. The ninth adaptive lightweight convolution module convolves the features input to the first adaptive lightweight bottleneck module to obtain the ninth adaptive lightweight convolution feature. The ninth adaptive lightweight convolution feature is input to the tenth adaptive lightweight convolution module to obtain the tenth adaptive lightweight convolution feature. The features input to the first adaptive lightweight bottleneck module and the tenth adaptive lightweight convolution feature are input to the first summing module to obtain the first summed feature.
[0021] In one optional embodiment, any one of the adaptive lightweight convolution modules AdaConv from the first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, and tenth adaptive lightweight convolution modules is shown in the following module structure diagram. Figure 5 As shown, it includes: First dynamic feature extraction convolutional module, ninth convolutional module, seventh concatenation module; The first dynamic feature extraction convolutional module includes a first depthwise convolutional module DWConv and a first partial convolutional module PConv; The first dynamic feature extraction convolution module performs depthwise convolution or partial convolution on the feature map input to the adaptive lightweight convolution module to obtain the first output feature. The first output feature is input into the ninth convolution module to obtain the ninth convolution feature. The first output feature and the ninth convolution feature are input into the seventh concatenation module to obtain the seventh concatenation feature. Furthermore, the adaptive lightweight convolution module dynamically selects depthwise convolution or partial convolution paths through a dimension-aware mechanism and supplements feature information with inexpensive linear operations, effectively balancing lightweight design and representational capability while significantly reducing model computational overhead. Let the size of the input feature map be... The output feature map size is The kernel size is ;in, Indicates the number of input channels. Indicates the height of the output feature map. This indicates the width of the output feature map. This indicates the length of the output feature map.
[0022] If standard convolution is used for computation, the number of parameters and computational cost are:
[0023]
[0024] in, This indicates the number of parameters in a standard convolutional module. This indicates the computational cost of a standard convolutional module.
[0025] The first depthwise convolution module (DWConv) uses depthwise convolution, a highly efficient spatial feature extraction method. Each convolutional kernel is responsible for extracting spatial features from only one input channel, thus greatly reducing computation and the number of parameters. The computation process is as follows: Figure 6 As shown; The number of parameters and computational cost of the first depthwise convolutional module are:
[0026]
[0027] in, This indicates the number of parameters in the first depthwise convolutional module. This indicates the computational cost of the first depthwise convolutional module; The ratio of computational cost to parameter count between depthwise convolution and standard convolution is:
[0028] This demonstrates that depthwise convolution can significantly reduce the number of parameters and computational cost of the model while extracting spatial features. However, because each input channel is processed independently, there is a lack of cross-channel information interaction and fusion. When faced with high-dimensional features with a large number of channels and rich semantic information, depthwise convolution often struggles to effectively capture the correlation and complementarity between channels. This may lead to insufficient feature extraction, thereby affecting the model's representational ability.
[0029] The partial convolution (PConv) module uses partial convolution, which is an efficient and lightweight convolution operation. A diagram of the partial convolution operation is shown below. Figure 7 As shown, its core idea is to perform standard convolution operations only on a subset of the channels of the input feature map, while allowing the remaining channels to be directly and identically mapped.
[0030] The parameters and computational complexity of the first part of the convolution module are as follows:
[0031]
[0032] in, This indicates the number of parameters in the first part of the convolutional module. This indicates the computational cost of the first convolutional module. Indicates the proportion of channels participating in standard convolution; Therefore, when processing high-dimensional features with a large number of channels, PConv (the first part of the convolutional module) can significantly reduce the number of parameters and computational cost because it only performs calculations on a subset of channels. At the same time, the standard convolutional operation performed on the selected channels preserves the complete spatial and channel interaction capabilities, effectively alleviating the feature representation bottleneck that may result from the complete channel independence of depthwise convolutions. However, in scenarios with a small number of input channels, the computational cost and number of parameters of PConv may not be significantly different from standard convolutions, and it may even lose its efficiency advantage in practical deployments due to the additional overhead of channel selection and concatenation.
[0033] In summary, while depthwise convolution and partial convolution are both effective lightweight methods, their effectiveness is highly correlated with the channel dimension of the input features. This indicates that a single, fixed lightweight strategy is unlikely to maintain optimal efficiency across structures with different dimensions.
[0034] Therefore, this invention proposes a dimension-aware adaptive lightweight convolution module, AdaConv, whose operation diagram is as follows: Figure 8 As shown, this module dynamically selects the feature extraction method based on the input channel dimension: for high-dimensional features, based on the idea of partial convolution, standard convolution calculations are performed on some channels, while the remaining channels are simply passed through; for low-dimensional features, based on the idea of depthwise convolution, each convolution kernel focuses on a single input channel for spatial feature extraction. Simultaneously, a low-cost linear operation branch is introduced to perform nonlinear transformations and expansions on the extracted feature information, supplementing feature diversity. This mechanism not only ensures that the computational efficiency in the feature extraction stage remains close to the theoretical optimum, but also guarantees the effective extraction of core features with low computational overhead, thus achieving a better trade-off between model lightweighting and feature representation capabilities.
[0035] For example, the input features are processed by a dynamic selection mechanism, choosing either DWConv or PConv for feature extraction, and then the first output feature is obtained. The first output feature is processed by a cheap linear operation to obtain additional feature information. Finally, the first output feature and the additional feature information are concatenated and fused to obtain the final output feature.
[0036] In one alternative embodiment, a dimension-aware convolution selection mechanism is used in the first dynamic feature extraction convolution module to select one of the first depth convolution module and the first partial convolution module based on the number of input channels. The expression for the dimension-aware convolution selection mechanism is:
[0037]
[0038]
[0039] in, This indicates the main volume integration segment rules. Indicates the input feature map, Represents depthwise convolution, PConv Indicates partial convolution. Indicates the number of input channels. This indicates that the intermediate channel is selected dynamically. Indicates learnable parameters, This indicates standard sigmoid activation.
[0040] Furthermore, for example, in the feature pyramid architecture widely used in multi-scale feature extraction, feature maps exhibit significant dimensionality characteristics at different levels: high-dimensional features with 512 to 1024 channels typically contain rich semantic information, and there is strong correlation between channels; intermediate-dimensional features with 128 to 512 channels carry representations of medium abstraction levels, while also needing to balance spatial detail preservation and channel interaction; low-dimensional features with fewer than 128 channels mainly contain basic visual patterns such as edges and textures, and the channels are relatively independent. This invention, referencing the dimension prior of the feature pyramid, designs a dimension-aware convolution selection mechanism based on the number of channels. In this mechanism: when the input channel number... When using a fixed depthwise convolution path, computational efficiency is maximized; when... At that time, a portion of the convolutional path is fixed to ensure sufficient channel interaction; in In the intermediate dimension range, the network uses learnable parameters The convolution type is determined independently. Parameters During training, gradient descent is used to learn, enabling the network to dynamically adjust the dependence of each layer on channel interaction according to task requirements.
[0041] Example 2 This embodiment proposes a method for detecting surface defects in strip steel based on Embodiment 1, and its flowchart is as follows: Figure 9 As shown, it includes the following steps: Obtain a dataset of images of the steel strip surface; Construct an image processing model; Construct a bounding box regression loss function; input the strip steel surface image dataset into the image processing model for training; when the bounding box regression loss function converges, the trained image processing model is obtained. The trained image processing model is pruned to obtain a pruned image processing model; the surface image of the strip to be detected is input into the pruned image processing model to obtain the surface defect detection result of the strip.
[0042] In this embodiment, the adaptive lightweight convolution module AdaConv and structured pruning are used to significantly reduce the computational overhead of the model and significantly improve the inference speed, thus meeting the requirements of high-speed production lines for real-time defect detection. By employing the dimension awareness and feature enhancement mechanisms of the adaptive lightweight convolution module, the model maintains representational capability while reducing computational overhead. Furthermore, by combining EIoU loss to optimize localization accuracy, the model achieves high accuracy while being significantly lightweight, thus realizing the synergistic optimization of accuracy, speed, and lightweightness.
[0043] In one optional embodiment, pruning the trained image processing model to obtain a pruned image processing model includes the following steps: Extract the channel scaling factor from the trained image processing model; All modules in the image processing model are pruned according to a preset channel scaling factor threshold. Specifically, the first depthwise convolution module and the ninth convolution module in the adaptive lightweight convolution module, the tenth adaptive lightweight convolution module in the first adaptive lightweight bottleneck module, and the eighth convolution module in the adaptive lightweight C3 module are pruned according to a preset number of output channels, and finally the pruned image processing model is obtained.
[0044] Furthermore, to better adapt the model to resource-constrained industrial environments, this invention employs channel pruning (based on the BatchNorm (BN layer) scaling factor) after the Ada-YOLO model training converges, such as... Figure 10 As shown, redundant parameters in the network are identified and removed, reducing the storage and computational overhead of the model.
[0045] Compared to pruning methods that require complex iterative searches or manual sensitivity settings, this strategy directly utilizes the channel scaling factor γ learned by the network during normal training as a metric for channel importance. The absolute value of γ directly reflects the activation intensity of the corresponding channel; the smaller the value, the more redundant the channel. Furthermore, channel pruning based on the channel scaling factor has a unique advantage when pruning convolutional layers: in standard convolutional modules, Batch Normalization (BN) layers typically follow convolutional layers, and their scaling factor γ directly corresponds to and measures the activation contribution of each channel in the convolutional layer. Therefore, pruning channels with smaller γ values is equivalent to removing redundant convolutional filters, thereby directly achieving structured model compression while maintaining the model's representational capabilities.
[0046] When applied to heterogeneous networks constructed as described in this invention, traditional channel pruning methods face a series of key challenges: a uniform global γ threshold cannot fairly measure the importance of channels in heterogeneous paths such as depthwise convolution and partial convolution, leading to pruning decision bias; after multi-path pruning within composite modules, channels across branches and layers need to be precisely and synchronously adjusted, which is prone to errors and difficult to automate manually; the nested module structure makes traditional traversal methods prone to repetition or omission, threatening the integrity and security of the pruning operation. These challenges make it difficult to directly apply traditional methods to the lightweight detection model Ada-YOLO of this invention.
[0047] To address the aforementioned challenges, this invention designs an automated, structure-aware channel pruning system, which consists of three core components working in tandem, systematically solving the pruning problem of heterogeneous adaptive networks.
[0048] The topology parsing and scheduling engine based on the structure description is the control center of this system. This engine parses the network's structured description file (such as YAML) to generate a flat, non-repeating sequence of basic module execution, thus ensuring the integrity and accuracy of pruning. Based on this sequence, the engine automatically calls the corresponding modular pruning interfaces and dynamically manages the transfer and alignment of input / output channels at each layer, achieving automatic maintenance of the data flow topology during the pruning process.
[0049] The modular pruning interface library implements dedicated pruning functions for different types of convolution operations (such as standard convolution, depthwise convolution, and partial convolution). Each function encapsulates the weight arrangement and channel pruning logic of the corresponding convolution kernel, providing basic operators for subsequent differentiated processing.
[0050] The system offers flexible dual-mode pruning control: it supports both a fully automatic pruning mode based on global γ sorting and thresholds, and a customized mode that prunes according to a specified number of output channels, to adapt to the coordination needs between different channels.
[0051] This system integrates channel importance assessment, heterogeneous module differential pruning, and inter-layer topology automatic maintenance, realizing full-process automation from model parsing and policy execution to structural reorganization, and providing a complete solution for efficient and reliable compression of complex lightweight models.
[0052] In this embodiment, the pain point of traditional methods being unable to adapt to dynamic heterogeneous networks is solved by using a structure-aware modular pruning interface and an automated channel alignment mechanism. On the basis of inheriting the high efficiency and automation of BN pruning, it achieves differentiated and accurate compression of heterogeneous modules such as depthwise / partial convolution, ensuring the regularity and usability of the pruned model.
[0053] Existing models are difficult to deploy on resource-constrained devices due to their high computational and memory consumption. This invention significantly reduces the number of parameters and computational load through systematic lightweight design and channel pruning, thereby reducing dependence on computing hardware and storage resources and providing a feasible solution for efficient and low-cost deployment in industrial edge computing scenarios.
[0054] Example 3 Based on Example 2, this embodiment designs corresponding pruning methods for any one of the following adaptive lightweight convolution modules: AdaConv (first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, and tenth adaptive lightweight convolution modules), AdaBottleneck (first, sixth, seventh, eighth, and ninth adaptive lightweight convolution modules), and AdaC3 (first, second, third, fourth, fifth, sixth, seventh, and eighth adaptive lightweight C3 modules). These methods are then encapsulated into a modular pruning interface library.
[0055] To ensure the integrity of the module's functionality and the correctness of the channel topology after pruning, and considering the composite structure of the core module AdaConv (which includes a dynamically selected main convolution path and a fixed inexpensive operation supplementary path), the following dedicated pruning process was designed for the core module AdaConv of this invention: Figure 11 As shown: (1) Conditional pruning of the main path. Differentiated operations are performed on the dynamically selected main path (which may be a depthwise convolution or a partial convolution): If it is a depthwise convolution, since the characteristics of depthwise convolution require the input and output dimensions to be the same, the pruning process selects to prune the output channels according to the preset input channels; if it is a partial convolution, pruning is performed normally according to the preset channel scaling factor threshold (importance assessment and structured pruning based on BN scaling factor). This step determines the number of output channels C_cv1 retained in the main path.
[0056] For example, the main path is: input features → in the first dynamic feature extraction convolution module, the dimension-aware convolution selection mechanism is used to select one of the first depth convolution module and the first partial convolution module according to the number of input channels (i.e., dynamic selection) → obtain the first output feature from the first dynamic feature extraction convolution module → input the first output feature into the seventh concatenation module.
[0057] (2) Pruning of Cheap Linear Operation Branches. Pruning is performed on the branches of cheap linear operations. The pruning process is subject to two constraints: the input must be strictly aligned with the main path output, meaning its input channel index must correspond to C_cv1; if the entire AdaConv module is subject to a global constraint requiring a specified number of output channels C_target, then the target number of output channels for the cheap linear operation (called cv2) is dynamically calculated. Under this constraint, channel importance pruning is performed on cv2 to obtain its output channel number C_cv2.
[0058] For example, the inexpensive linear operation branch is as follows: Input features → In the first dynamic feature extraction convolution module, a dimension-aware convolution selection mechanism is used to select one of the first depth convolution module and the first partial convolution module according to the number of input channels (i.e., dynamic selection) → Obtain the first output feature from the first dynamic feature extraction convolution module → Input the first output feature into the ninth convolution module to obtain the ninth convolution feature → Input the ninth convolution feature into the seventh concatenation module.
[0059] (3) Channel fusion and global verification. Finally, the outputs of the two paths are concatenated along the channel dimension to obtain the final output channel number C_out = C_cv1 + C_cv2 of the AdaConv module. If there is a preset global output constraint C_target, the system will automatically verify whether C_out is equal to C_target, thereby ensuring that the pruning result of this composite module is seamlessly integrated into the overall structured pruning link.
[0060] This strategy achieves accurate and secure compression of adaptive modules with branching structures by serializing and differentiating internal heterogeneous paths and dynamically allocating resources.
[0061] For pruning the first adaptive lightweight bottleneck module, AdaBottleneck, this invention adheres to the structural constraint of residual connections, meaning the final number of output channels must be strictly equal to the number of input channels. Under this hard constraint, the pruning process must ensure channel alignment of the residual paths while compressing the main path. The specific steps are designed as follows: Figure 12 As shown: (1) The main path entry convolution (ninth adaptive lightweight convolution module) selects free pruning. No output channel constraints are imposed at this stage, allowing independent evaluation and removal of redundant channels based on the BN scaling factor (channel scaling factor) to obtain the number of intermediate feature channels C_mid.
[0062] (2) Constraint pruning of the main path exit convolution (tenth adaptive lightweight convolution module). This module is subject to two key constraints: the input channels must strictly correspond to the output channels C_mid of the previous step, and to meet the dimension requirement of residual addition, the number of its output channels is forcibly set to the original number of input channels C_in of the module. Under this strong constraint, the pruning of the main path exit convolution is actually mapping the dimension from C_mid back to C_in, and removing the least important connections in the process.
[0063] (3) Implicit alignment of residual paths. Since the output of the residual branch needs to be added to the output of the main path, its output channel number is fixed at C_in during module initialization. Therefore, as long as the final output of the main path is constrained to C_in, the channel alignment of the residual path will be automatically satisfied.
[0064] For pruning the Adaptive Lightweight C3 module (AdaC3), this invention follows its dual-path aggregation structure, systematically decomposing the pruning process into parallel / serial pruning and final fusion of two independent paths. This method flexibly handles branching and fusion constraints while ensuring channel alignment between paths. The specific process is as follows: Figure 13 As shown: (1) Serialized pruning of the main path (first branch). First, the entry convolution (sixth convolution module) of the main path is pruned based on importance, and its output is used as the basis for subsequent processing. Then, the AdaBottleneck sequence in the main path is traversed serially. The pruning of each bottleneck module depends on the output of its predecessor module, forming a chain-like channel dependency propagation. The final output channel number of this path is denoted as C_path1.
[0065] (2) Constraint pruning of secondary paths (secondary branches). The pruning of secondary paths is subject to strict output constraints. To ensure correct splicing in the channel dimension, the number of output channels must be strictly equal to the number of output channels C_path1 of the primary path.
[0066] (3) Dual-path feature fusion and final mapping. After completing the dual-path pruning, the outputs of the two paths are concatenated along the channel dimension to obtain the number of fused feature channels. Finally, the output is processed by a fusion convolution. Its input is the concatenated features, and the output is pruned according to global constraints to obtain the final output channel count of the entire AdaC3 module.
[0067] Example 4 This embodiment further explains the bounding box regression loss function.
[0068] In an optional embodiment, the bounding box regression loss function is calculated as follows:
[0069] in, and These are the center points of the predicted bounding box and the ground truth bounding box, respectively. and This represents the width and height of the actual bounding box, while w and h represent the width and height of the anchor box. This represents the diagonal distance between the two smallest bounding rectangles. This represents the width of the minimum bounding rectangle. This represents the height of the smallest bounding rectangle.
[0070] Furthermore, in object detection tasks, the bounding box regression loss function is crucial for localization accuracy. To further optimize the bounding box regression accuracy of the model and improve detection performance, this invention introduces the EIoU (Efficient Intersection over Union) loss function.
[0071] The EIoU loss decouples the regression objective into three independent parts: overlap area loss, center point distance loss, and width and height loss. This allows the model to adjust the size of the prediction box more directly and efficiently, resulting in faster convergence and higher final localization accuracy.
[0072] In this embodiment, EIoU loss is used instead of traditional IoU loss for bounding box regression, which improves the model's accuracy in locating defect targets and accelerates the convergence speed during training. Taking into account factors such as center point distance and aspect ratio, it provides more accurate gradient directions, accelerates the convergence speed of bounding box regression, and improves model training efficiency.
[0073] The various embodiments in this invention are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the device embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments. The device embodiments described above are merely exemplary. The modules described as separate components may or may not be physically separate. When implementing the present invention, the functions of each module can be implemented in one or more software and / or hardware. Alternatively, some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0074] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the implementation of the present invention. Those skilled in the art can make other variations or modifications based on the above description. It is neither necessary nor possible to exhaustively describe all embodiments here. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the claims of the present invention.
Claims
1. An image processing model, characterized in that, The image processing model replaces the C3 module of the backbone network in the YOLOv5 model with an adaptive lightweight C3 module, and several convolutional modules with adaptive lightweight convolutional modules; the C3 module in the neck network is replaced with an adaptive lightweight C3 module, and the convolutional modules in the neck network are replaced with adaptive lightweight convolutional modules.
2. The image processing model of claim 1, wherein, The backbone network includes: The first convolutional module, the first adaptive lightweight convolutional module, the first adaptive lightweight C3 module, the second adaptive lightweight convolutional module, the second adaptive lightweight C3 module, the third adaptive lightweight convolutional module, the third adaptive lightweight C3 module, the fourth adaptive lightweight convolutional module, the fourth adaptive lightweight C3 module, and the first spatial pyramid pooling fast module are connected in sequence. The first spatial pyramid pooling fast module includes: The second convolution module, the first max pooling module, the third convolution module, the fourth convolution module, the first splicing module, and the fifth convolution module are connected in sequence; the output of the second convolution module is also connected to the input of the first splicing module, the output of the first max pooling module is also connected to the input of the first splicing module, the output of the third convolution module is also connected to the input of the first splicing module, and the output of the fourth convolution module is also connected to the input of the first splicing module. The second convolutional module convolves the features input from the first spatial pyramid pooling fast module to obtain the second convolutional feature. The second convolutional feature is input into the first max pooling module to obtain the first max pooling feature. The first max pooling feature is input into the third convolutional module to obtain the third convolutional feature. The third convolutional feature is input into the fourth convolutional module to obtain the fourth convolutional feature. The second convolutional feature, the first max pooling feature, the third convolutional feature, and the fourth convolutional feature are input into the first concatenation module to obtain the first concatenation feature. The first concatenation feature is input into the fifth convolutional module to obtain the fifth convolutional feature.
3. The image processing model of claim 1, wherein, The neck network includes: The fifth adaptive lightweight convolution module, the first upsampling module, the second stitching module, the fifth adaptive lightweight C3 module, the sixth adaptive lightweight convolution module, the second upsampling module, the third stitching module, the sixth adaptive lightweight C3 module, the seventh adaptive lightweight convolution module, the fourth stitching module, the seventh adaptive lightweight C3 module, the eighth adaptive lightweight convolution module, the fifth stitching module, and the eighth adaptive lightweight C3 module are connected in sequence. The output of the second adaptive lightweight C3 module is also connected to the input of the third stitching module; the output of the third adaptive lightweight C3 module is also connected to the input of the second stitching module; the output of the first spatial pyramid pooling fast module is also connected to the input of the fifth adaptive lightweight convolution module; the output of the fifth adaptive lightweight convolution module is also connected to the input of the fifth stitching module; the output of the sixth adaptive lightweight convolution module is also connected to the input of the fourth stitching module. The features obtained from the first spatial pyramid pooling fast module are input into the fifth adaptive lightweight convolution module to obtain the fifth adaptive lightweight convolution features; the fifth adaptive lightweight convolution features are input into the first upsampling module to obtain the first upsampling features; The first upsampling feature and the third adaptive lightweight C3 feature are input into the second concatenation module to obtain the second concatenation feature. The second concatenation feature is input into the fifth adaptive lightweight C3 module to obtain the fifth adaptive lightweight C3 feature. The fifth adaptive lightweight C3 feature is input into the sixth adaptive lightweight convolution module to obtain the sixth adaptive lightweight convolution feature. The sixth adaptive lightweight convolution feature is input into the second upsampling module to obtain the second upsampling feature. The second adaptive lightweight C3 feature and the second upsampling feature are input into the third concatenation module to obtain the third concatenation feature. The third concatenation feature is input into the sixth adaptive lightweight C3 module to obtain the sixth adaptive lightweight C3 feature. The sixth adaptive lightweight C3 feature is input into the seventh adaptive lightweight convolution module to obtain the seventh adaptive lightweight convolution feature. The seventh adaptive lightweight convolution feature is input into the fourth concatenation module, and the sixth adaptive lightweight convolution feature is also input into the fourth concatenation module to obtain the fourth concatenation feature. The fourth concatenation feature is input into the seventh adaptive lightweight C3 module to obtain the seventh adaptive lightweight C3 feature. The seventh adaptive lightweight C3 feature is input into the eighth adaptive lightweight convolution module to obtain the eighth adaptive lightweight convolution feature. The eighth adaptive lightweight convolutional feature is input into the fifth concatenation module, and the fifth adaptive lightweight convolutional feature is also input into the fifth concatenation module to obtain the fifth concatenation feature. The fifth concatenation feature is input into the eighth adaptive lightweight C3 module to obtain the eighth adaptive lightweight C3 feature.
4. The image processing model of claim 1, wherein, The image processing model also includes a head network, which comprises: The first detection head module, the second detection head module, and the third detection head module; The input terminal of the first detection head module is connected to the output terminal of the sixth adaptive lightweight C3 module, the input terminal of the second detection head module is connected to the output terminal of the seventh adaptive lightweight C3 module, and the input terminal of the third detection head module is connected to the output terminal of the eighth adaptive lightweight C3 module. The sixth adaptive lightweight C3 feature input to the first detection head module yields the first detection result; the seventh adaptive lightweight C3 feature input to the second detection head module yields the second detection result; and the eighth adaptive lightweight C3 feature input to the third detection head module yields the third detection result.
5. The image processing model of claim 2, wherein, Any one of the following adaptive lightweight C3 modules: First Adaptive Lightweight C3 Module, Second Adaptive Lightweight C3 Module, Third Adaptive Lightweight C3 Module, Fourth Adaptive Lightweight C3 Module, Fifth Adaptive Lightweight C3 Module, Sixth Adaptive Lightweight C3 Module, Seventh Adaptive Lightweight C3 Module, and Eighth Adaptive Lightweight C3 Module, includes: The first and second branches are connected in parallel; The first branch includes: a sixth convolutional module, a first adaptive lightweight bottleneck module, a sixth splicing module, and a seventh convolutional module connected in sequence; The second branch includes: an eighth convolution module; the output of the eighth convolution module is connected to the input of the sixth splicing module; The eighth convolutional module convolves the features input to the adaptive lightweight C3 module to obtain the eighth convolutional feature; the sixth convolutional module convolves the features input to the adaptive lightweight C3 module to obtain the sixth convolutional feature, the sixth convolutional feature is input to the first adaptive lightweight bottleneck module to obtain the first adaptive lightweight bottleneck feature, the eighth convolutional feature and the first adaptive lightweight bottleneck feature are input to the sixth concatenation module to obtain the sixth concatenation feature, and the sixth concatenation feature is input to the seventh convolutional module to obtain the seventh convolutional feature; The first adaptive lightweight bottleneck module includes: The ninth adaptive lightweight convolution module, the tenth adaptive lightweight convolution module, and the first summing module are connected in sequence. The ninth adaptive lightweight convolution module convolves the features input to the first adaptive lightweight bottleneck module to obtain the ninth adaptive lightweight convolution feature. The ninth adaptive lightweight convolution feature is input to the tenth adaptive lightweight convolution module to obtain the tenth adaptive lightweight convolution feature. The features input to the first adaptive lightweight bottleneck module and the tenth adaptive lightweight convolution feature are input to the first summing module to obtain the first summed feature.
6. The image processing model of claim 3, wherein, Any one of the following adaptive lightweight convolution modules—first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, and tenth—includes: First dynamic feature extraction convolutional module, ninth convolutional module, seventh concatenation module; The first dynamic feature extraction convolution module includes a first depthwise convolution module and a first partial convolution module; The first dynamic feature extraction convolution module performs depthwise convolution or partial convolution on the feature map input to the adaptive lightweight convolution module to obtain the first output feature. The first output feature is input into the ninth convolution module to obtain the ninth convolution feature. The first output feature and the ninth convolution feature are input into the seventh concatenation module to obtain the seventh concatenation feature.
7. The image processing model of claim 6, wherein, In the first dynamic feature extraction convolution module, a dimension-aware convolution selection mechanism is used to select one of the first depth convolution module and the first partial convolution module based on the number of input channels. The expression for the dimension-aware convolution selection mechanism is: in, This indicates the main volume integration segment rules. Indicates the input feature map, Represents depthwise convolution, PConv Indicates partial convolution. Indicates the number of input channels. This indicates that the intermediate channel is selected dynamically. Indicates learnable parameters, This indicates standard sigmoid activation.
8. A method for detecting surface defects in strip steel based on the image processing model described in claims 1 to 7, characterized in that, Includes the following steps: Obtain a dataset of images of the strip surface; Construct an image processing model; Construct a bounding box regression loss function; input the strip steel surface image dataset into the image processing model for training; when the bounding box regression loss function converges, the trained image processing model is obtained. The trained image processing model is pruned to obtain a pruned image processing model; the surface image of the strip to be detected is input into the pruned image processing model to obtain the surface defect detection result of the strip.
9. The method for detecting surface defects in strip steel according to claim 8, characterized in that, The expression for the bounding box regression loss function is as follows: in, and These are the center points of the predicted bounding box and the ground truth bounding box, respectively. and This represents the width and height of the actual bounding box, while w and h represent the width and height of the anchor box. This represents the diagonal distance between the two smallest bounding rectangles. This represents the width of the minimum bounding rectangle. This represents the height of the smallest bounding rectangle.
10. A method for detecting surface defects in strip steel according to claim 8, characterized in that, The trained image processing model is pruned to obtain the pruned image processing model, including the following steps: Extract the channel scaling factor from the trained image processing model; All modules in the image processing model are pruned according to a preset channel scaling factor threshold. Specifically, the first depthwise convolution module and the ninth convolution module in the adaptive lightweight convolution module, the tenth adaptive lightweight convolution module in the first adaptive lightweight bottleneck module, and the eighth convolution module in the adaptive lightweight C3 module are pruned according to a preset number of output channels, and finally the pruned image processing model is obtained.