Edge degradation defect detection method

By combining layer-adaptive amplitude pruning and channel-level feature distillation training with an edge information enhancement submodule, a lightweight target detection model is constructed. This solves the problem of insufficient perception of high-frequency edge detail information in existing models, and achieves efficient edge degradation defect detection and lightweight model deployment.

CN122089732APending Publication Date: 2026-05-26SOUTH CHINA UNIV OF TECH
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202610543798.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-04-23
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

Existing target detection models have limited ability to perceive high-frequency edge details, resulting in low recall and detection accuracy for edge degradation defects. Furthermore, model improvements are usually limited to structural or compression aspects, which is insufficient to meet the real-time detection requirements of UAV aerial inspection.

Method used

A lightweight target detection model is constructed by employing layer-adaptive amplitude pruning and channel-level feature distillation training methods, combined with an edge information enhancement submodule, and extracting high-frequency edge feature maps through self-supervised differential extraction, thereby enhancing the detection capability of edge degradation defects.

Benefits of technology

It improves the detection accuracy of edge degradation defects and enables lightweight deployment of the model, meeting the real-time inference requirements of the edge computing platform and enhancing the detection capability of defects such as rust and loosening.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122089732A_ABST
    Figure CN122089732A_ABST
Patent Text Reader

Abstract

This application discloses a method for detecting edge degradation defects, relating to the fields of computer vision and industrial intelligent inspection technology. The method includes: acquiring an image to be detected; inputting the image into a target detection model to obtain a defect detection result. The target detection model is obtained by training an improved model through channel-level feature distillation after layer-adaptive amplitude pruning. The improved model includes an edge information enhancement submodule, which performs self-supervised differencing based on the original feature map and low-frequency feature map extracted from the image to be detected, obtaining an enhanced high-frequency edge feature map. This application improves the accuracy of defect detection by adding an edge information enhancement submodule to the modified model structure, extracting high-frequency edge signals through self-supervised differencing, enhancing edge features, and performing defect detection. Furthermore, the target detection model obtained through pruning and distillation achieves lightweight deployment of the model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the fields of computer vision and industrial intelligent inspection technology, and in particular to a method for detecting edge degradation defects. Background Technology

[0002] In real-world scenarios such as industrial facility inspection and drone aerial photography, the targets to be inspected often exhibit defect features in the form of edge degradation. These defects include: irregular texture degradation caused by surface corrosion, changes in contour shape due to loose or missing fasteners, and anomalies in fine structures such as missing pins. A common characteristic of these defects is that the defect signal is mainly reflected in the local edges and high-frequency detail areas of the target, rather than overall semantic changes. Therefore, a high level of edge perception capability is required from the feature extraction module.

[0003] Current target detection models extract global semantic features sufficiently, but their ability to perceive high-frequency edge details is limited, resulting in low recall rates for edge degradation defects such as rust and loosening. Furthermore, current model improvements typically focus only on structural or compression aspects, leading to low detection accuracy for edge degradation defects using current methods. Summary of the Invention

[0004] The main objective of this application is to provide a method for detecting edge degradation defects, aiming to solve the technical problem that current methods have low detection accuracy for edge degradation defects.

[0005] To achieve the above objectives, this application proposes a method for detecting edge degradation defects, the method comprising: Obtain the image to be detected that contains the aforementioned edge degradation defects; The image to be detected is input into a preset target detection model to obtain defect detection results. The target detection model is obtained by training a preset improved model through channel-level feature distillation after performing layer adaptive amplitude pruning. The improved model includes an edge information enhancement submodule, which performs self-supervised difference based on the original feature map and low-frequency feature map extracted from the image to be detected to obtain an enhanced high-frequency edge feature map.

[0006] In one embodiment, before the step of inputting the image to be detected into a preset target detection model to obtain the defect detection result, the method further includes: Obtain a training dataset containing image samples to be detected, wherein the image samples to be detected contain the edge degradation class defects; The training dataset is input into a preset model to be trained, and the model to be trained is trained based on the image samples to be detected to obtain the improved model; The improved model is used as the base model to be pruned, and the layer adaptive amplitude pruning is performed on the base model to be pruned to obtain the pruned model. Using the improved model as the teacher model and the pruning model as the student model, the channel-level feature distillation training is performed based on the teacher model, the student model, and the training dataset to obtain the target detection model.

[0007] In one embodiment, the model to be trained includes a lightweight backbone network and an improved neck network. The step of inputting the training dataset into a preset model to be trained and training the model based on the image samples to be detected to obtain the improved model includes: The training dataset is input into the lightweight backbone network to extract features from the image samples to be detected, thereby obtaining an initial feature map. The initial feature map is input into the improved neck network, and feature extraction and fusion are performed on the initial feature map to obtain a fused and enhanced feature map; Based on the fused and enhanced feature map, the parameters of the model to be trained are adjusted to obtain the improved model.

[0008] In one embodiment, the step of extracting features from the image sample to be detected to obtain an initial feature map includes: Initial feature extraction is performed on the image sample to be detected to obtain an initial sample feature map; The initial sample feature map is subjected to two independent convolutions by a preset first convolutional layer to obtain a first feature map and a second feature map. The first feature map is activated by a preset first activation function to obtain a first activated feature map. The first activated feature map and the second feature map are then multiplied element by element to obtain a multiplied feature map. The dimension of the multiplicative feature map is adjusted by a preset linear function, and the adjusted multiplicative feature map is then subjected to feature extraction by a preset depthwise separable convolution to obtain a depth feature map. The depth feature map is subjected to random depth regularization, and the regularized depth feature map is added to the initial sample feature map to obtain the initial feature map.

[0009] In one embodiment, the step of performing feature extraction and fusion on the initial feature map to obtain a fused enhanced feature map includes: Local spatial features are extracted from the initial feature map by a preset second convolutional layer to obtain a local spatial feature map, wherein the kernel size of the second convolutional layer is smaller than the kernel size of the first convolutional layer; Based on multiple preset pooling target sizes of different sizes, feature extraction is performed on the local spatial feature map to obtain multiple pooling feature maps of different sizes corresponding to the pooling target size. The original number of channels in the pooling feature map is compressed through the first convolutional layer to obtain a compressed feature map with the target number of channels, wherein the target number of channels is the quotient of the original number of channels and the number of pooling target sizes; Local spatial enhancement is performed on each of the compressed feature maps by the depthwise separable convolution to obtain spatially enhanced feature maps; The edge information enhancement submodule performs edge enhancement on the spatial enhancement feature map, and then upsamples the edge-enhanced feature map to obtain the high-frequency edge feature map. Based on the first convolutional layer, the channel dimensions of each of the high-frequency edge feature maps are concatenated to obtain the fused enhanced feature map with the same number of channels as the original number of channels.

[0010] In one embodiment, the step of performing edge enhancement on the spatial enhancement feature map through the edge information enhancement submodule, and upsampling the edge-enhanced feature map to obtain the high-frequency edge feature map includes: The spatially enhanced feature map is subjected to mean pooling to obtain a low-frequency feature map; The difference between the spatially enhanced feature map and the low-frequency feature map is calculated to obtain the high-frequency feature map; The high-frequency feature map is convolved, and the convolved high-frequency feature map is activated by a preset second activation function to obtain adaptive gating weights; The adaptive gating weights are added to the spatially enhanced feature map to obtain the high-frequency edge feature map.

[0011] In one embodiment, the step of performing layer-adaptive magnitude pruning on the base model to be pruned to obtain a pruned model includes: Based on the training dataset, the base model to be pruned is subjected to sparse training to obtain a sparse model. The loss value of the sparse training is the sum of the training loss value and the regularization loss value during the training process. The regularization loss value is the sum of the absolute values ​​of the scaling factors of each batch normalization layer in the base model to be pruned. The scaling factor is normalized to obtain a normalized scaling factor, and the normalized scaling factor is sorted in descending order to obtain a scaling factor sort. Based on the scaling factor sorting and the preset compression ratio, the channels of the sparse model are pruned from high to low until the compression ratio is reached, thus obtaining the pruned model to be trained. The pruning model is fine-tuned based on the training dataset to obtain the pruning model.

[0012] In one embodiment, the step of performing channel-level feature distillation training based on the teacher model, the student model, and the training dataset to obtain the object detection model includes: The training dataset is input into the teacher model and the student model respectively to obtain the teacher feature map output by the improved neck network of the teacher model and the student feature map output by the improved neck network of the student model. Obtain the standard detection loss for training the channel-level feature distillation, and calculate the channel-level feature distillation loss based on the teacher feature map and the student feature map; Based on the teacher feature map and the student feature map, calculate the logic layer distillation loss; The feature distillation loss and the logic layer distillation loss are added together to obtain the total distillation loss. The total distillation loss is multiplied by the current batch of channel-level feature distillation training. The multiplication loss is then multiplied by a preset cosine decay coefficient to obtain the final distillation loss. The cosine decay coefficient decreases as the training rounds increase. The final distillation loss is added to the standard detection loss to obtain the total loss. The parameters of the student model are then adjusted based on the total loss to obtain the target detection model.

[0013] In one embodiment, the step of calculating the channel-level feature distillation loss based on the teacher feature map and the student feature map includes: Determine whether the number of teacher channels in the teacher feature map is the same as the number of student channels in the student feature map; If they are not the same, the student feature map is convolved through a preset third convolutional layer to obtain a student feature map with the same number of student channels as the teacher channel. The teacher feature map is normalized in the channel dimension to obtain a normalized teacher feature map, and the student feature map is normalized in the channel dimension to obtain a normalized student feature map. The relative entropy of the normalized teacher feature map and the normalized student feature map is calculated to obtain the channel-level feature distillation loss.

[0014] In one embodiment, the step of calculating the logic layer distillation loss based on the teacher feature map and the student feature map includes: Divide the teacher feature map by a preset temperature coefficient, and then activate the teacher feature map after dividing by the temperature coefficient using a preset third activation function to obtain the teacher probability value. Divide the student feature map by the temperature coefficient, and then activate the student feature map after dividing by the temperature coefficient using the third activation function to obtain the student probability value. The binary cross-entropy between the teacher probability value and the student probability value is calculated to obtain the logic layer distillation loss.

[0015] One or more technical solutions proposed in this application have at least the following technical effects: This application obtains a detection image containing the aforementioned edge degradation defects, inputs the detection image into a preset target detection model, and obtains a defect detection result. The target detection model is a preset improved model that is trained by channel-level feature distillation after performing layer adaptive amplitude pruning. The improved model includes an edge information enhancement submodule, which performs self-supervised difference based on the original feature map and low-frequency feature map extracted from the detection image to obtain an enhanced high-frequency edge feature map.

[0016] Compared to current models that have limited ability to perceive high-frequency edge details and only focus on structural or compression aspects, resulting in low accuracy in detecting edge degradation defects, this application improves the accuracy of edge degradation defect detection by adding an edge information enhancement submodule to the modified model structure and training it through pruning and distillation. This also enables lightweight deployment of the model. Specifically, the edge information enhancement submodule of the improved model uses an unlabeled self-supervised approach to extract high-frequency edge signals from the feature map through differential extraction of original features and low-frequency features, achieving precise enhancement of edge responses. This enhanced feature is then used for defect detection, improving accuracy. Furthermore, the target detection model is trained by pruning and distilling the improved model, allowing for lightweight deployment without compromising defect detection accuracy. Therefore, overall, this application improves the accuracy of edge degradation defect detection and achieves lightweight model deployment. Attached Figure Description

[0017] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0018] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1This is a flowchart illustrating an embodiment of the edge degradation defect detection method of this application. Figure 2 This is a schematic diagram of the overall model structure provided in Embodiment 1 of the edge degradation defect detection method of this application; Figure 3 This is a schematic diagram of the model feature fusion module structure provided in Embodiment 1 of the edge degradation defect detection method of this application; Figure 4 This is a schematic diagram of the remaining modules of the model provided in Embodiment 1 of the edge degradation defect detection method of this application; Figure 5 This is a schematic diagram of the model feature fusion module provided in Embodiment 1 of the edge degradation defect detection method of this application; Figure 6 This is a flowchart illustrating the edge information enhancement submodule provided in Embodiment 1 of the edge degradation defect detection method of this application; Figure 7 This is a flowchart illustrating Embodiment 2 of the edge degradation defect detection method of this application; Figure 8 This is a flowchart illustrating Embodiment 3 of the edge degradation defect detection method of this application; Figure 9 This is a schematic diagram of the cosine decay distillation loss scheduling curve provided in Embodiment 3 of the edge degradation defect detection method of this application; Figure 10 This is a schematic diagram illustrating the data acquisition consent process involved in the edge degradation defect detection method in this application embodiment.

[0020] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0021] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.

[0022] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.

[0023] It should be noted that the executing entity in this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or an electronic device capable of performing the above functions, such as an edge degradation defect detection device. The following description uses an edge degradation defect detection device as an example to illustrate this embodiment and the subsequent embodiments.

[0024] In real-world scenarios such as industrial facility inspection and drone aerial photography, the targets to be inspected (such as transmission tower fasteners, bridge nodes, and pipe joints) often exhibit defect features in the form of edge degradation. These defects include: irregular texture degradation caused by surface corrosion, changes in contour shape due to loose or missing fasteners, and anomalies in fine structures such as missing pins. A common characteristic of these defects is that the defect signals are mainly reflected in the local edges and high-frequency detail areas of the target, rather than overall semantic changes. Therefore, a high level of edge perception capability is required from the feature extraction module.

[0025] Taking drone inspection of transmission tower bolts and fasteners as an example: Transmission towers are the core load-bearing components of high-voltage transmission lines, and their structural safety depends on the integrity of a large number of bolts and fasteners. Due to long-term exposure to the elements, vibration fatigue, and environmental corrosion, bolts and fasteners are highly susceptible to typical defects such as missing bolts, corrosion, loose or missing nuts, and missing pins. If these defects are not detected in time, they may lead to major safety accidents such as transmission line collapses, large-scale power outages, and even casualties. Currently, manual tower climbing inspections are inefficient and risky, while drone aerial inspections have become the mainstream method. However, how to efficiently utilize aerial images to achieve automatic and intelligent identification of bolt defects is a key technological requirement in the field of intelligent power operation and maintenance.

[0026] Current target detection models extract global semantic features sufficiently, but their ability to perceive high-frequency edge details is limited, resulting in low recall rates for edge degradation defects such as rust and loosening. Furthermore, current model improvements typically focus only on structural or compression aspects, leading to low detection accuracy for edge degradation defects using current methods.

[0027] In addition, targets in drone inspection images are relatively small compared to the overall image, and different shooting distances cause similar targets to show significant scale variations, making it difficult for a single receptive field feature extraction module to capture them comprehensively. Furthermore, the computing power of the UAV's onboard computing platform is limited, and the standard detection model has a large number of parameters and computational load, making it difficult to meet the requirements of real-time inference on the edge side.

[0028] Based on this, embodiments of this application provide a method for detecting edge degradation defects, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the edge degradation defect detection method of this application.

[0029] In this embodiment, the edge degradation defect detection method includes steps S10 to S20: Step S10: Obtain the image to be detected containing the edge degradation defects; It should be noted that edge degradation defects refer to defect types where the defect signal is mainly reflected in the local edges and high-frequency detail areas of the target, rather than in the overall semantic changes. These include, but are not limited to, texture irregularities caused by corrosion, contour shape changes due to loose or missing fasteners, and fine structural anomalies such as missing pins. The image to be detected refers to the original image input into the target detection model for defect detection, such as drone aerial images or industrial quality inspection images.

[0030] Step S20: Input the image to be detected into a preset target detection model to obtain the defect detection result. The target detection model is obtained by training a preset improved model through channel-level feature distillation after performing layer adaptive amplitude pruning. The improved model includes an edge information enhancement submodule. The edge information enhancement submodule performs self-supervised difference based on the original feature map and low-frequency feature map extracted from the image to be detected to obtain an enhanced high-frequency edge feature map.

[0031] It should be noted that the object detection model refers to an artificial neural network model used to identify and locate defects of a specific category from an image, and its output is a detection result containing the defect category and bounding box coordinates.

[0032] The pre-defined improved model refers to a detection model with edge awareness capabilities that integrates a multi-scale edge information enhancement feature extraction module into the neck feature fusion node of the basic target detection network and is jointly constructed with a lightweight backbone network.

[0033] Layer-adaptive amplitude pruning refers to a structured pruning strategy that normalizes the scaling factor of batch normalized layers within each layer before performing global sorting, and then performs channel-level pruning based on the sorting results to reduce the floating-point computation of the model. Channel-level feature distillation is a knowledge distillation method that captures the output feature maps of the teacher and student models at a specified feature layer in the neck region, performs Softmax normalization (a normalization function) on each channel dimension, and calculates the KL divergence between their probability distributions as the feature alignment loss, thereby transferring knowledge from the teacher model to the student model. The edge information enhancement submodule extracts high-frequency edge signals from the feature map through mean pooling difference, and fuses them with the original feature residuals using Sigmoid (an activation function) gated weights to achieve unlabeled self-supervised adaptive enhancement of edge responses.

[0034] Self-supervised differencing refers to a computational method that extracts high-frequency edge signals directly from the feature map itself through differencing operations (subtracting low-frequency smoothed features from the original features) without additional edge annotation supervision. The original features refer to the feature map input to the edge enhancement submodule, i.e., the feature representation initially extracted from the image to be detected without edge enhancement. Low-frequency features refer to the low-frequency smoothed components obtained after performing mean pooling on the original features, representing global or smooth region information in the feature map. The high-frequency edge feature map refers to the feature map extracted through self-supervised differencing and enhanced with Sigmoid-gated weights; this feature map strengthens the edge and high-frequency detail responses in the original features.

[0035] It should also be noted that the improved model in this embodiment replaces the original backbone in a single-stage object detection network (such as the YOLO series, a single-stage object detection algorithm) with a lightweight backbone network based on element-wise multiplication (StarNet, a star-shaped operation network), and replaces all feature fusion nodes in the neck with C3k2-MSEIE (a cross-stage local feature fusion-multi-scale edge information enhancement module) in this embodiment. This jointly constructs an improved detection model that balances lightweight feature extraction and edge perception enhancement, and trains it to convergence on the target task dataset to obtain the improved model. Figure 2 This is a schematic diagram of the overall structure of the model in this embodiment. Figure 3 This is a schematic diagram of the C3k2-MSEIE module structure in this embodiment. Figure 4 To improve the schematic diagram of the remaining structures in the model.

[0036] It is understood that the target detection model is obtained by first performing layer-adaptive amplitude pruning on a pre-defined improved model to reduce computational load, and then using channel-level feature distillation to compensate for accuracy loss. This model inherits the sensitivity of the edge information enhancement submodule in the improved model to high-frequency edge signals. Simultaneously, the joint optimization of pruning and distillation significantly reduces floating-point operations while maintaining high detection accuracy. When an image to be detected is input, the model can efficiently utilize the high-frequency edge feature map output by the edge information enhancement submodule to improve the detection capability of edge degradation defects such as rust and loosening, and output accurate defect detection results with lightweight computational overhead, meeting the real-time inference requirements of the edge computing platform.

[0037] In one feasible implementation, the specific implementation method before inputting the image to be detected into a preset target detection model to obtain the defect detection result can also be: Obtain a training dataset containing image samples to be detected, wherein the image samples to be detected contain the edge degradation class defects; The training dataset is input into a preset model to be trained, and the model to be trained is trained based on the image samples to be detected to obtain the improved model; The improved model is used as the base model to be pruned, and the layer adaptive amplitude pruning is performed on the base model to be pruned to obtain the pruned model. Using the improved model as the teacher model and the pruning model as the student model, the channel-level feature distillation training is performed based on the teacher model, the student model, and the training dataset to obtain the target detection model.

[0038] It should be noted that the image samples to be detected refer to image data containing edge degradation defects used for model training or validation, and are the basic building blocks of the training dataset. The training dataset refers to a collection of multiple image samples to be detected and their corresponding ground truth annotations (such as defect categories and bounding box coordinates), used for model training, validation, and testing. The model to be trained refers to a detection model that has not yet been trained, with parameters in an initial or pre-trained state, and its structure is a pre-defined improved model architecture. The base model to be pruned refers to the improved model after training, serving as the starting point for subsequent structured pruning operations. The pruned model refers to a structured sparse model where floating-point operations are compressed and some channels are pruned after performing layer-adaptive magnitude pruning on the base model to be pruned.

[0039] Understandably, this implementation first trains an improved model with high detection accuracy using a training dataset containing edge degradation defects. Then, it performs layer-adaptive amplitude pruning on this improved model to reduce its floating-point computation. Finally, channel-level feature distillation is performed using the original improved model as the teacher and the pruned model as the student. Feature alignment loss transfers the teacher model's edge perception capability for edge degradation defects to the student model. Through these steps, this implementation effectively compensates for the accuracy loss caused by pruning while significantly reducing model computation. The resulting target detection model retains the high recall of the improved model for defects such as rust and loosening, while also meeting the real-time inference requirements of the edge computing platform, avoiding the significant performance degradation caused by simple pruning.

[0040] In one feasible implementation, the model to be trained includes a lightweight backbone network and an improved neck network. The specific implementation of inputting the training dataset into the preset model to be trained and training the model based on the image samples to be detected to obtain the improved model can also be: The training dataset is input into the lightweight backbone network to extract features from the image samples to be detected, thereby obtaining an initial feature map. The initial feature map is input into the improved neck network, and feature extraction and fusion are performed on the initial feature map to obtain a fused and enhanced feature map; Based on the fused and enhanced feature map, the parameters of the model to be trained are adjusted to obtain the improved model.

[0041] It should be noted that the lightweight backbone network refers to a network structure that uses star-shaped operations based on element-wise multiplication to form the core computational units, combined with depthwise separable convolutions and residual connections. This significantly reduces floating-point computation while maintaining the ability to effectively extract target features in complex backgrounds, and is used to extract basic features from the input image. The improved neck network refers to a network structure formed by replacing the original feature extraction module with a multi-scale edge information enhancement feature extraction module (MSEIE) in the neck feature fusion node of the object detection network. This network structure is used to perform multi-scale fusion and edge information enhancement on the feature map output by the backbone network.

[0042] The initial feature map refers to the feature representation output after the image sample to be detected undergoes forward computation by a lightweight backbone network. It is an abstract expression of the original image at a deep semantic level. The fused and enhanced feature map refers to the feature map output after the initial feature map undergoes multi-scale parallel branches, edge enhancement submodules, and feature fusion operations in an improved neck network. This feature map takes into account both multi-granular semantics and edge detail information.

[0043] Understandably, in the training process of this implementation, the lightweight backbone network extracts the initial feature map with extremely low computational cost, while the improved neck network further enhances the initial feature map through multi-scale parallel branches and edge information enhancement submodules, performing edge enhancement and multi-granularity fusion to generate a fused and enhanced feature map rich in high-frequency details. This allows the model under training to simultaneously propagate the gradient of the loss function to both the backbone and the neck during parameter adjustment, enabling the model to converge to an optimal state that satisfies both computational lightweight requirements and high sensitivity to edge degradation defects such as rust and loosening. Compared to directly using the standard backbone and standard neck for joint training, this implementation can achieve a higher defect recall rate with the same computational resources.

[0044] In one feasible implementation, the specific implementation of extracting features from the image sample to be detected to obtain an initial feature map can also be: Initial feature extraction is performed on the image sample to be detected to obtain an initial sample feature map; The initial sample feature map is subjected to two independent convolutions by a preset first convolutional layer to obtain a first feature map and a second feature map. The first feature map is activated by a preset first activation function to obtain a first activated feature map. The first activated feature map and the second feature map are then multiplied element by element to obtain a multiplied feature map. The dimension of the multiplicative feature map is adjusted by a preset linear function, and the adjusted multiplicative feature map is then subjected to feature extraction by a preset depthwise separable convolution to obtain a depth feature map. The depth feature map is subjected to random depth regularization, and the regularized depth feature map is added to the initial sample feature map to obtain the initial feature map.

[0045] It should be noted that the initial sample feature map refers to the feature map obtained after the initial feature extraction (such as standard convolution or downsampling) of the image sample to be detected, serving as the basic input for subsequent star-shaped operations. The first convolutional layer refers to an independent neural network layer composed of a predefined convolutional kernel and convolutional operations, used to perform linear transformations on the input feature map. This layer contains learnable weight parameters (such as convolutional kernel weights and biases). The first feature map refers to the feature map output after the initial sample feature map undergoes its first independent convolution (using the first convolutional kernel). The second feature map refers to the feature map output after the initial sample feature map undergoes its second independent convolution (also using the first convolutional kernel, but in an independent convolutional layer).

[0046] The first activation function refers to a preset function that performs non-linear activation on the first feature map, such as ReLU6 (an activation function). The first activated feature map refers to the feature map obtained after the first feature map is activated by the first activation function. The multiplicative feature map refers to the feature map obtained after the first activated feature map and the second feature map are multiplied element-wise. The linear function refers to a linear transformation used to adjust the channel dimension of the multiplicative feature map, usually implemented by a 1×1 convolution. The depth feature map refers to the feature map obtained after the multiplicative feature map with adjusted dimensions is processed by a depthwise separable convolution to extract local spatial features. Stochastic depth regularization refers to a regularization technique that randomly discards the output of the current layer (or path) with a certain probability and sets it to zero during training to prevent overfitting.

[0047] It should also be noted that the feature extraction formula for the StarNet in this embodiment is: output = x + DropPath(dwconv2(g(act(f1(x)) ⊙ f2(x)))) Where x is the input feature map, f1(x) is the first feature map after convolution, f2(x) is the second feature map after convolution, act is the activation function, ⊙ is element-wise multiplication, g is a preset linear function, dwconv2 is depthwise separable convolution, and DropPath is random depth regularization during training.

[0048] Understandably, this embodiment employs a first convolutional layer to perform two independent convolutions on the initial sample feature map. The resulting first activation feature map and the second feature map achieve a high-order combination of features through element-wise multiplication, significantly enhancing the non-linear expressive power of single-layer computation. Simultaneously, depthwise separable convolution further reduces the number of parameters and floating-point operations. Random depth regularization and residual connections (adding the regularized depth feature map to the initial sample feature map) effectively alleviate overfitting and ensure smooth gradient propagation. Compared to traditional feature extraction methods that stack multiple ordinary convolutional blocks, this embodiment significantly reduces computational overhead while achieving equal or even stronger feature expressive power. This allows the lightweight backbone network to run efficiently on edge computing platforms while maintaining effective feature extraction capabilities for edge degradation defects such as rust and loosening.

[0049] In one feasible implementation, the specific implementation of performing feature extraction and fusion on the initial feature map to obtain the fused enhanced feature map can also be: Local spatial features are extracted from the initial feature map by a preset second convolutional layer to obtain a local spatial feature map, wherein the kernel size of the second convolutional layer is smaller than the kernel size of the first convolutional layer; Based on multiple preset pooling target sizes of different sizes, feature extraction is performed on the local spatial feature map to obtain multiple pooling feature maps of different sizes corresponding to the pooling target size. The original number of channels in the pooling feature map is compressed through the first convolutional layer to obtain a compressed feature map with the target number of channels, wherein the target number of channels is the quotient of the original number of channels and the number of pooling target sizes; Local spatial enhancement is performed on each of the compressed feature maps by the depthwise separable convolution to obtain spatially enhanced feature maps; The edge information enhancement submodule performs edge enhancement on the spatial enhancement feature map, and then upsamples the edge-enhanced feature map to obtain the high-frequency edge feature map. Based on the first convolutional layer, the channel dimensions of each of the high-frequency edge feature maps are concatenated to obtain the fused enhanced feature map with the same number of channels as the original number of channels.

[0050] It should be noted that the second convolutional layer refers to a convolutional layer with a smaller kernel size than the first convolutional layer, used to extract local spatial features from the input feature map. The local spatial feature map refers to the feature map output after the second convolutional layer extracts local spatial features from the initial feature map, preserving the original spatial resolution. The pooling target size refers to preset spatial size parameters used for adaptive average pooling, such as 3, 6, 9, 12, etc., used to simulate multi-scale changes of the target at different shooting distances. The pooled feature map refers to the feature map obtained after adaptive average pooling of the local spatial feature map according to a certain pooling target size, its spatial size being compressed to that pooling target size.

[0051] The original number of channels refers to the number of channels in the input feature map (such as a local spatial feature map), denoted by inc. The target number of channels refers to the quotient of the original number of channels and the number of pooling target sizes, that is, the number of target channels after compression for each multi-scale parallel branch. For example, when the original number of channels is inc and the number of pooling target sizes is 4, the target number of channels is inc / 4. The number of pooling target sizes refers to the number of preset pooling target sizes. For example, when bins=[3, 6, 9, 12], this number is 4. The compressed feature map refers to the feature map obtained after compressing the original number of channels of the pooling feature map through the first convolutional layer, and its number of channels becomes the target number of channels. The spatially enhanced feature map refers to the feature map output after the compressed feature map is subjected to local spatial enhancement through depthwise separable convolution. In this embodiment, the upsampling operation is performed through bilinear interpolation. The overall processing flow of MSEIE in this embodiment can be referred to Figure 5 .

[0052] Understandably, this embodiment uses a second convolutional layer with a smaller kernel to extract local spatial feature maps, preserving the fine spatial structure. Then, adaptive average pooling is performed based on multiple pooling target sizes, enabling the same feature map to simultaneously obtain global contextual information at large, medium, and small scales, covering target size variations at different shooting distances. Next, this embodiment compresses the number of channels through the first convolutional layer, enhances the local space through depthwise separable convolution, and strengthens high-frequency edge response through an edge information enhancement submodule. Finally, the high-frequency edge feature maps of each branch are concatenated along the channel dimension and restored to the original number of channels. This results in an output fused and enhanced feature map that simultaneously possesses multi-scale semantic information and enhanced edge details, significantly improving the feature perception capability for edge degradation defects such as rust, loosening, and missing small pins. This provides richer discriminative features for subsequent detection heads, thereby improving defect recall and localization accuracy.

[0053] In one feasible implementation, the specific implementation of performing edge enhancement on the spatial enhanced feature map through the edge information enhancement submodule and upsampling the edge-enhanced feature map to obtain the high-frequency edge feature map can also be: The spatially enhanced feature map is subjected to mean pooling to obtain a low-frequency feature map; The difference between the spatially enhanced feature map and the low-frequency feature map is calculated to obtain the high-frequency feature map; The high-frequency feature map is convolved, and the convolved high-frequency feature map is activated by a preset second activation function to obtain adaptive gating weights; The adaptive gating weights are added to the spatially enhanced feature map to obtain the high-frequency edge feature map.

[0054] It should be noted that the low-frequency feature map refers to the low-frequency smooth component obtained after performing mean pooling on the input feature map (in this case, the spatially enhanced feature map), representing global or smooth region information in the feature map. The high-frequency feature map refers to the high-frequency signal response obtained by calculating the difference between the input feature map and the low-frequency feature map, reflecting details such as edges and textures in the feature map. The second activation function refers to the activation function used to map the convolutional high-frequency feature map to the range (0, 1), which is the Sigmoid function in this case.

[0055] Adaptive gating weights refer to the weight values ​​output after the high-frequency feature map is processed by the convolutional layer and the second activation function (Sigmoid). Their values ​​range from (0, 1) and are used to adaptively control the intensity of edge information enhancement.

[0056] It should also be noted that the formula for low-frequency extraction in this embodiment is: low_freq = AvgPool2d(x, kernel_size=3, stride=1, padding=1) Where low_freq represents low-frequency features, AvgPool2d represents mean pooling, x represents the original input feature map, kernel_size represents the convolution kernel, stride represents the stride, and padding represents padding.

[0057] The formula for differential edge extraction is: edge = x low_freq Here, edge is the high-frequency edge response.

[0058] The formula for calculating the gating weight is: edge_w = Conv(edge, activation=Sigmoid) Where edge_w is the adaptive gating weight, Conv is the convolutional layer, and activation=Sigmoid indicates that the activation function is the Sigmoid function (S-shaped function).

[0059] Finally, the formula for residual enhancement fusion is: output = x + edge_w Wherein, output is the output high-frequency edge feature map. The overall process of the edge information enhancement submodule in this embodiment can be referred to Figure 6 .

[0060] Understandably, this implementation uses mean pooling to extract low-frequency feature maps, and then obtains high-frequency feature maps by differencing the spatially augmented feature map with the low-frequency feature map. This difference operation directly amplifies the edge and high-frequency detail components in the original features. The high-frequency feature map is then convolved and activated with a sigmoid function to generate adaptive gating weights. These weights automatically adjust the enhancement amplitude based on the high-frequency response intensity of the current feature map, avoiding the excessive amplification of irrelevant high-frequency noise by fixed enhancement. Finally, this implementation adds the gating weights to the original spatially augmented feature map as a residual, preserving the integrity of the original features while specifically enhancing edge information. Therefore, it adaptively enhances the high-frequency edge response in the feature map without any additional edge annotation, significantly improving sensitivity to edge degradation defects such as rust textures and contour gaps, while maintaining computational efficiency.

[0061] In one embodiment, the invention is described in detail using the defect detection of transmission tower bolt fasteners as an example, combined with experimental data. The method of this embodiment is not limited to this specific scenario and is also applicable to edge degradation defect detection tasks such as bridge joint inspection, pipe joint inspection, and industrial product surface defect detection.

[0062] Based on images from UAV inspections of power transmission towers, a target detection dataset containing five types of bolt fastener defects was constructed. The dataset contents are shown in Table 1 below: Table 1: Defect Target Detection Dataset for Bolt Fasteners

[0063] The dataset contains a total of 2150 images, with 1712 images in the training set (approximately 80%) and 438 images in the validation set (approximately 20%). The annotation format is YOLO (normalized center coordinates + width and height); the input resolution is 640×640 pixels; data augmentation includes: stitching, random horizontal flipping, and color gamut dithering.

[0064] Based on the above dataset, the experimental data at different stages of this embodiment are shown in Table 2 below: Table 2: Experimental Data for Defect Target Detection

[0065] As shown in the table above, the baseline recall rate is low (59.4%), reflecting the standard model's failure to detect small bolt targets and rust edge defects, indicating significant room for improvement.

[0066] By replacing the YOLO neck feature fusion module with the cross-stage local feature fusion-multi-scale edge information enhancement module of this embodiment (keeping the original structure of the backbone), and training it for 300 rounds on the above dataset, the recall rate was improved by more than 3.5 percentage points, proving that the MSEIE module effectively enhances the feature perception ability of edge degradation defects such as rust and loosening.

[0067] The original YOLO backbone was completely replaced with the lightweight backbone of this embodiment, while the neck remained the original YOLO structure. After training for 300 epochs on the aforementioned dataset, the accuracy improved by 5.0 percentage points, indicating that the backbone of this embodiment has a stronger ability to distinguish complex background interference, while significantly reducing the amount of computation.

[0068] By jointly improving the main trunk and neck, and training on the aforementioned dataset for 300 rounds, the joint scheme achieved an average precision of 67.9%, which is 4.5% higher than the baseline and 5.6% higher in recall. This is of great significance for power safety inspection scenarios that are sensitive to missed detections.

[0069] Through pruning and fine-tuning in this embodiment, the accuracy is reduced by about 3.2% compared to the improved model, and the number of FLOPs (Floating Point Operations) is reduced to about 50%, with the accuracy loss being compensated by the subsequent distillation stage.

[0070] After final distillation training, the deployed model showed an average increase of 3.8% in precision, 4.6% in recall, and 1.6% in accuracy compared to the baseline, with only about 50% of the FLOPs improving the model, meeting the real-time inference requirements of drone-borne edge AI terminals.

[0071] In summary, this embodiment obtains a detection image containing the aforementioned edge degradation defects, inputs the detection image into a preset target detection model, and obtains the defect detection result. The target detection model is obtained by training a preset improved model through channel-level feature distillation after performing layer adaptive amplitude pruning. The improved model includes an edge information enhancement submodule, which performs self-supervised difference based on the original feature map and low-frequency feature map extracted from the detection image to obtain an enhanced high-frequency edge feature map.

[0072] Compared to current models that have limited ability to perceive high-frequency edge details and only focus on structural or compression aspects, resulting in low accuracy in detecting edge degradation defects, this embodiment improves the accuracy of edge degradation defect detection by adding an edge information enhancement submodule to the modified model structure and training it through pruning and distillation. This also enables lightweight deployment of the model. Specifically, the improved model's edge information enhancement submodule uses an unlabeled, self-supervised approach to extract high-frequency edge signals from the feature map through differential extraction of original and low-frequency features, achieving precise enhancement of edge responses. This enhanced feature is then used for defect detection, improving accuracy. Furthermore, the target detection model in this embodiment is trained by pruning and distilling the improved model, allowing for lightweight deployment without compromising defect detection accuracy. Therefore, overall, this embodiment improves the accuracy of edge degradation defect detection and achieves lightweight model deployment.

[0073] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to that in Embodiment 1 above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 7 The step of performing layer-adaptive amplitude pruning on the base model to be pruned to obtain the pruned model further includes steps A10 to A40: Step A10: Based on the training dataset, perform sparse training on the base model to be pruned to obtain a sparse model. The loss value of the sparse training is the sum of the training loss value and the regularization loss value during the training process. The regularization loss value is the sum of the absolute values ​​of the scaling factors of each batch normalization layer in the base model to be pruned. It should be noted that sparse training refers to a training method in which additional regularization penalties are applied to the scaling factor of the batch normalization layer during model training, guiding the scaling factor of unimportant channels to approach zero. The purpose is to sparse the distribution of channel importance in the model, providing a basis for subsequent pruning. A sparse model refers to a model obtained after sparse training, in which the values ​​of unimportant channels in the scaling factor of the batch normalization layer have been compressed to near zero by the regularization penalty.

[0074] The training loss value refers to the standard loss function value calculated by the model after forward computation on the training dataset, based on the detection task (such as classification and regression). It reflects the model's fit to the current batch of data. The regularization loss value is the regularization term obtained by summing the absolute values ​​of the scaling factors of each batch normalization layer in the unpruned base model. It is usually an L1 norm and is used to penalize non-zero scaling factors. A batch normalization layer is a layer in a deep neural network used to standardize feature maps. It contains learnable scaling factors (gamma) and offset factors (beta), where the magnitude of the scaling factor reflects the importance of the corresponding channel. The scaling factor is a learnable parameter in the batch normalization layer used to scale the standardized features, usually represented by γ (gamma), and its absolute value measures the importance of the corresponding channel.

[0075] Understandably, this embodiment introduces a regularization loss value into the total loss function, which is the sum of the absolute values ​​of the scaling factors of each batch normalization layer as a penalty term. This L1 regularization has the sparsity property of compressing the scaling factors of unimportant channels to zero. In the sparse model obtained after sparse training, the importance of each channel (characterized by the absolute value of the scaling factor) shows a clear polarization, with important channels maintaining large scaling factors and redundant channels having scaling factors close to zero. This sparse distribution of channel importance allows subsequent layer adaptive amplitude pruning to prune channels based on clear numerical thresholds, avoiding the problem of blindly pruning important channels when the scaling factor distribution is relatively uniform, thus compressing the model's computational load while preserving the original model's key feature extraction capabilities to the greatest extent.

[0076] Step A20: Normalize the scaling factor to obtain a normalized scaling factor, and sort the normalized scaling factors in descending order to obtain a scaling factor sort. It should be noted that normalization refers to a mathematical operation that transforms a set of data according to certain rules so that its numerical range falls within a specific interval or meets specific distribution characteristics. Here, it refers to intra-layer normalization of the scaling factor. The normalized scaling factor refers to the new value obtained by performing intra-layer normalization (e.g., L1 norm normalization) on the scaling factor of each batch normalization layer, used to eliminate the influence of differences in the dimensions of the scaling factor between different layers. Scaling factor sorting refers to the sequence obtained by arranging the normalized scaling factors in descending order, where the channels at the beginning of the sequence correspond to more important features, and the channels at the end of the sequence correspond to less important features.

[0077] Understandably, this embodiment first performs intra-layer normalization on the scaling factors of each batch normalization layer, eliminating the differences in the absolute value range of scaling factors between different layers, so that the channel importance of each layer can be compared fairly globally. Then, the scaling factors are sorted in descending order to obtain the scaling factor ranking, and the least important channels are clearly marked. This avoids the problem that shallow channels may be over-pruned and deep channels under-pruned when using a uniform absolute value threshold for pruning. It realizes layer-adaptive channel importance assessment, providing a reasonable and balanced pruning order for subsequent global channel structured pruning, and ensuring the balance of capacity of each layer of the model after pruning.

[0078] Step A30: Based on the scaling factor sorting and the preset compression ratio, prune the channels of the sparse model from high to low until the compression ratio is reached to obtain the pruned model to be trained. It should be noted that the compression ratio refers to the preset model pruning target, used to control the proportion or degree of compression of the floating-point operation of the pruned model relative to the remaining operation of the unpruned model. For example, a compression ratio of 2.0 means that the floating-point operation is compressed to about 50% of the original model. The pruned model to be trained refers to the structured sparse model obtained after the channel pruning operation. Some of its channels have been pruned and have not yet been fine-tuned and restored to training. It will be used as the student model initialization weight in the knowledge distillation stage.

[0079] Understandably, this embodiment sorts channels based on a global normalized scaling factor, pruning sequentially starting with the least important channels and terminating at a preset compression ratio. This provides a clear and quantifiable basis for channel importance and a target for controlling computational load. Furthermore, since the normalized scaling factor eliminates dimensional differences between layers, this pruning strategy can fairly remove relatively unimportant channels from each layer, avoiding the problem of some layers being over-pruned while others are under-pruned due to single-threshold pruning. Thus, while compressing the model's floating-point computation to the target ratio, it maximizes the preservation of feature extraction capabilities for important channels in the original model, providing a compact initial model with controllable performance loss for subsequent fine-tuning and knowledge distillation stages.

[0080] Step A40: Fine-tune the pruning model to be trained based on the training dataset to obtain the pruning model.

[0081] It should be noted that fine-tuning training refers to using the pruned model weights as the initial state and continuing training on the target task dataset for a small number of rounds. The model parameters are updated through backpropagation to partially recover the detection accuracy loss caused by the pruning operation.

[0082] Understandably, this embodiment starts with the pruned weights of the model to be trained and performs fine-tuning training on the same training dataset. The model can readjust the weight distribution of the remaining channels through gradient descent to adapt to the feature representation space changed due to channel removal. Meanwhile, since the pruning operation only removes unimportant channels, the remaining channels retain most of the original model's feature extraction capabilities. Fine-tuning training can bring the model to a better state in fewer iterations, thereby restoring some detection accuracy while maintaining the low computational cost of the pruned model.

[0083] In one embodiment, the step of performing sparse training on the base model to be pruned based on the training dataset to obtain a sparse model further includes: During each forward propagation, the sum of the absolute values ​​of the feature maps of each channel in the spatial dimension is calculated using the high-frequency edge feature map output by the edge information enhancement submodule, and the total edge response intensity of each channel is obtained as the channel-level edge contribution. The channel-level edge contribution is normalized using Softmax to obtain the edge importance weight of each channel, where the channel with the higher edge contribution corresponds to a larger weight. When calculating the regularization loss value, the edge importance weighted L1 regularization is applied to the scaling factor of each batch normalization layer. That is, the regularization penalty term for each channel is the sum of the products of the edge importance weight and the absolute value of the scaling factor. The weighted L1 regularization loss is added to the training loss value and used as the total loss for gradient update. This results in channels with high edge contribution being subject to smaller regularization penalties and channels with low edge contribution being subject to larger regularization penalties. After iterative training, an edge-aware sparse model is obtained.

[0084] It should be noted that the channel-level edge contribution refers to the sum of the absolute values ​​(i.e., L1 norm) of the feature maps of each channel in the high-frequency edge feature map output by the edge information enhancement submodule, used to quantify the contribution of that channel to the total edge response. The edge importance weight refers to the probability distribution obtained after Softmax normalization of the channel-level edge contribution, with values ​​between 0 and 1 and a sum of 1 for all channel weights, used to characterize the relative importance of each channel in edge perception. Edge importance-weighted L1 regularization refers to multiplying the absolute value of the scaling factor for each channel by its edge importance weight, based on standard L1 regularization, thus suppressing the regularization penalty for channels with high edge contributions and enhancing the regularization penalty for channels with low edge contributions.

[0085] It is understood that in this embodiment, the channel-level edge contribution calculated from the high-frequency edge feature map output by the edge information enhancement submodule can accurately identify the channel most sensitive to edge degradation defects. Then, the edge importance weight obtained by Softmax normalization makes it possible to suppress the channel regularization penalty with high edge contribution when L1 regularization is applied, while the background or smooth channel regularization penalty with low edge contribution is enhanced.

[0086] This embodiment avoids mistakenly compressing the scaling factor of channels crucial to defect edge responses to zero during sparsification training through the above steps, thus preventing these critical channels from being incorrectly pruned in subsequent pruning stages. Furthermore, since defects in transmission tower bolt fasteners typically occupy a small area in the image and have sparse edge signals, traditional uniform regularization often uniformly sparsifies all channels, significantly reducing the model's ability to perceive weak edge signals. This step, however, uses weighted protection to ensure that the pruned model retains high sensitivity to rust textures and minute gaps.

[0087] In one embodiment, the step of applying the edge importance-weighted L1 regularization to the scaling factor of each batch normalization layer when calculating the regularization loss value further includes: Obtain the batch normalized layer groups corresponding to multiple feature pyramid levels of the improved neck network in the current base model to be pruned, wherein the target size detected by different feature pyramid levels is different; Based on the recall rate baseline of each defect category at different scales in the defect dataset of transmission tower bolt fasteners, a hierarchical importance factor is preset for each of the multiple feature pyramid levels to enhance the protection of sensitive channels at the edges of small targets. For each channel, its edge importance weight is multiplied by the hierarchy importance factor of its level to obtain the hierarchy-aware weighting coefficient. The regularization loss is calculated as the sum of the products of the hierarchical perceptual weighting coefficients and the absolute values ​​of the scaling factors for all channels, multiplied by the global sparsity regularization coefficient, and added to the total loss as the final regularization loss term.

[0088] It should be noted that the feature pyramid hierarchy refers to the three different scale feature map levels (including the first to third levels) of the improved neck network output. The first level is a high-resolution feature map used to detect small targets (such as missing pins), and the third level is a low-resolution feature map used to detect large targets (such as loose nuts). The hierarchy importance factor refers to the pre-set weight coefficient based on the contribution of each feature pyramid level in detecting specific edge degradation defects. A value greater than 1 indicates that the channel of that level should receive stronger regularization protection, while a value less than 1 indicates that more aggressive sparsity is allowed. The hierarchy-aware weighting coefficient is the coefficient obtained by multiplying the edge importance weight of the channel by the hierarchy importance factor of the level to which the channel belongs. It is used to apply differentiated penalty strength to channels of different levels in the regularization loss.

[0089] Understandably, this embodiment sets a higher layer importance factor for the first layer (small target detection layer), which provides stronger protection for channels with higher edge importance weights in this layer, making it less likely for their scaling factors to be compressed to zero. Conversely, a lower factor is set for the third layer (large target layer), allowing for more aggressive sparsification in exchange for computational compression.

[0090] Conventional pruning methods treat all feature layers uniformly, while this embodiment provides differentiated protection based on defect scale distribution, avoiding the waste of valuable model capacity in large background areas. Furthermore, since missing pins in transmission tower inspection images typically occupy a very small pixel area, their edge signals are weak in the first level and easily misinterpreted by regularization. By protecting the layer importance factor, the pruned model retains a higher rate of sensitive channels for missing pins, improving the accuracy of small target monitoring.

[0091] In summary, this embodiment performs sparsity training before pruning, using L1 regularization to compress the scaling factors of unimportant channels to near zero, thus sparsening the distribution of channel importance and providing a clear quantitative basis for subsequent pruning. Then, intra-layer normalization eliminates the dimensional differences in scaling factors between different layers, followed by descending sorting to obtain a globally fair channel importance ranking, thereby avoiding the problem of over-pruning of shallow channels caused by uniform threshold pruning. This embodiment then prunes from the least important channels based on this ranking and a preset compression ratio, ensuring that while achieving the target floating-point operation reduction ratio, the feature extraction capability of important channels is preserved to the greatest extent. Finally, fine-tuning training readjusts the weights of the remaining channels, partially recovering the accuracy loss caused by pruning.

[0092] Based on the first and second embodiments of this application, in the third embodiment of this application, the content that is the same as or similar to that in embodiments one and two above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 8The step of performing layer-adaptive amplitude pruning on the base model to be pruned to obtain the pruned model further includes steps B10 to B50: Step B10: Input the training dataset into the teacher model and the student model respectively, and obtain the teacher feature map output by the improved neck network of the teacher model and the student feature map output by the improved neck network of the student model. It should be noted that the teacher model refers to the improved model with high detection accuracy after full training, which serves as a knowledge source in the knowledge distillation process to guide the learning of the student model. The student model refers to the pruned model obtained after layer adaptive amplitude pruning and fine-tuning, which serves as a learning target in the knowledge distillation process, improving its own accuracy by imitating the behavior of the teacher model.

[0093] Teacher feature maps refer to the feature maps output by the improved neck network of the teacher model at a specified layer after image samples from the training dataset are input into the teacher model. These maps serve as the supervised targets during the distillation process. Student feature maps refer to the feature maps output by the improved neck network of the student model at the same specified layer after image samples from the training dataset are input into the student model. These maps serve as the objects to be aligned during the distillation process.

[0094] Understandably, this embodiment inputs the same training dataset into both the teacher and student models simultaneously, and captures feature maps of both models from the same layer of their improved neck networks. This ensures a one-to-one correspondence between the student model's feature maps and the teacher model's feature maps in both spatial dimension and semantic level. Furthermore, as a high-precision improved model, the teacher model's neck network output feature maps are rich in highly responsive information to edge degradation defects. While the student model, although computationally reduced through pruning, retains the same neck network structure, it provides direct, effective, and semantically aligned feature-level supervision signals for subsequent channel-level feature distillation. This allows the student model to compensate for the loss of edge perception capabilities caused by pruning by mimicking the feature distribution of the teacher model.

[0095] Step B20: Obtain the standard detection loss for the channel-level feature distillation training, and calculate the channel-level feature distillation loss based on the teacher feature map and the student feature map; It should be noted that channel-level feature distillation training refers to a training method in which, during the knowledge distillation process, the difference in channel-level probability distributions (such as KL divergence) between the teacher model and the student model's output feature maps at a specified feature layer is calculated as a loss function to guide the student model in learning the teacher model's feature representation capabilities. Standard detection loss refers to the standard loss function value calculated during the training of the object detection model based on the difference between the predicted results and the ground truth labels. It typically includes classification loss or regression loss, reflecting the model's accuracy in classifying and locating objects. Channel-level feature distillation loss refers to the loss value obtained by calculating the KL divergence (Kullback-Leibler divergence) between the probability distributions of the teacher's feature map and the student's feature map after performing Softmax normalization on each channel dimension. It is used to measure the difference in feature channel distributions between the teacher and student models.

[0096] In one feasible implementation, the specific implementation of calculating the channel-level feature distillation loss based on the teacher feature map and the student feature map can also be: Determine whether the number of teacher channels in the teacher feature map is the same as the number of student channels in the student feature map; If they are not the same, the student feature map is convolved through a preset third convolutional layer to obtain a student feature map with the same number of student channels as the teacher channel. The teacher feature map is normalized in the channel dimension to obtain a normalized teacher feature map, and the student feature map is normalized in the channel dimension to obtain a normalized student feature map. The relative entropy of the normalized teacher feature map and the normalized student feature map is calculated to obtain the channel-level feature distillation loss.

[0097] It should be noted that the number of teacher channels refers to the number of channels in the teacher feature map, i.e., the channel dimension of the output feature map of the improved neck network of the teacher model. The number of student channels refers to the number of channels in the student feature map, i.e., the channel dimension of the output feature map of the improved neck network of the student model. The third convolutional layer is used to adjust the number of channels in the student feature map, usually a 1×1 convolution. When the number of student channels is inconsistent with the number of teacher channels, this convolutional layer projects the student feature map into the same channel space as the teacher feature map.

[0098] The normalized teacher feature map refers to the probability distribution obtained by performing Softmax normalization on the teacher feature map along the channel dimension. The value corresponding to each channel is converted into a probability value between 0 and 1, with a sum of 1. The normalized student feature map refers to the probability distribution obtained by performing Softmax normalization on the student feature map along the channel dimension. The value corresponding to each channel is converted into a probability value between 0 and 1, with a sum of 1. Relative entropy, also known as Kullback-Leibler divergence, measures the degree of difference between two probability distributions; here, it is used to calculate the distribution distance between the normalized teacher feature map and the normalized student feature map.

[0099] Understandably, this embodiment first determines whether the number of channels in the teacher and student feature maps is consistent. If they are inconsistent, the student feature map is projected onto the teacher channel space through a third convolutional layer. This ensures that even if the number of channels in the student model changes after pruning, it can still achieve channel-level feature alignment with the teacher model. Furthermore, by performing Softmax normalization in the channel dimension, the feature response is converted into a probability distribution, eliminating the influence of differences in the absolute numerical range of the feature maps. This allows the distillation loss to focus on the relative importance distribution pattern between channels. Finally, using relative entropy (KL divergence) as the loss metric effectively drives the student model to learn the feature response distribution of the teacher model at the channel level, especially the high-response channel distribution for edge degradation defects generated by the multi-scale edge information enhancement feature extraction module in the teacher model. This ensures that the student model, even after the channel number changes following pruning, can still accurately inherit the key edge perception capabilities of the teacher model, avoiding the problem of feature distillation failure due to channel number mismatch. This further improves the detection accuracy of the student model for defects such as rust and loosening after distillation.

[0100] Step B30: Calculate the logic layer distillation loss based on the teacher feature map and the student feature map; It should be noted that the logic layer distillation loss refers to the loss function that performs soft label alignment on the classification confidence distribution output by the detection heads of the teacher model and the student model. It usually adopts KL divergence or cross-entropy loss to make the prediction behavior of the student model approach the soft prediction distribution of the teacher model.

[0101] In one feasible implementation, the specific implementation of calculating the logic layer distillation loss based on the teacher feature map and the student feature map can also be: Divide the teacher feature map by a preset temperature coefficient, and then activate the teacher feature map after dividing by the temperature coefficient using a preset third activation function to obtain the teacher probability value. Divide the student feature map by the temperature coefficient, and then activate the student feature map after dividing by the temperature coefficient using the third activation function to obtain the student probability value. The binary cross-entropy between the teacher probability value and the student probability value is calculated to obtain the logic layer distillation loss.

[0102] It's important to note that the temperature coefficient is a parameter used to soften the classification probability distribution, typically greater than 1. Dividing the logistic value by the temperature coefficient and then applying the activation function results in a smoother probability distribution, revealing similarity information between categories. The third activation function is the activation function used to convert the logistic value into a probability distribution, usually the Softmax function, used in the output layer of multi-class tasks. The teacher probability value refers to the softened probability distribution obtained by dividing the teacher feature map by the temperature coefficient and then activating it with the third activation function, representing the prediction confidence of the teacher model for each category under high temperatures. The student probability value refers to the softened probability distribution obtained by dividing the student feature map by the temperature coefficient and then activating it with the third activation function, representing the prediction confidence of the student model for each category under high temperatures. Binary cross-entropy is a loss function used to measure the difference between two probability distributions; here, it's used to calculate the distribution difference between the teacher and student probability values, serving as the distillation loss for the logistic layer.

[0103] Understandably, this embodiment introduces a temperature coefficient to soften the logical output of the teacher-student model. A higher temperature coefficient smooths out the originally sharp predicted probability distribution, thereby amplifying the teacher model's predicted probability for secondary categories (such as negative classes similar to the true categories). The relative magnitudes of these secondary categories reflect the teacher model's understanding of semantic similarity between categories (e.g., the ambiguity of the boundary between rust and corrosion). The student model fits the teacher's probability values ​​using a binary cross-entropy loss function. This loss function is more direct than KL divergence in gradient optimization and can effectively drive the student model's output distribution to approach the softened distribution of the teacher model.

[0104] Furthermore, the logic layer distillation loss and the channel-level feature distillation loss in this embodiment complement each other. The former constrains the prediction distribution of the output layer, while the latter constrains the channel response of the intermediate feature layer. This allows the student model, which has reduced computational cost after pruning, to more comprehensively inherit the teacher model's detailed classification knowledge of edge degradation defects, effectively making up for the accuracy loss caused by pruning and further improving the detection accuracy of multiple types of defects such as rust, loosening, and missing parts.

[0105] Step B40: Add the feature distillation loss and the logic layer distillation loss to obtain the total distillation loss. Multiply the total distillation loss by the current batch of channel-level feature distillation training. Multiply the multiplied loss by a preset cosine decay coefficient to obtain the final distillation loss. The cosine decay coefficient decreases as the training rounds increase. It should be noted that the total distillation loss refers to the sum of the feature distillation loss and the logic layer distillation loss, representing the complete distillation supervision signal. The current batch refers to the batch size (batch_size) used in the current iteration step during training, i.e., the number of image samples input into the model during each forward propagation. The cosine decay coefficient is a weighting coefficient that gradually decreases with increasing training rounds (iteration steps) according to the cosine function, used to dynamically adjust the contribution of the distillation loss to the total loss.

[0106] Understandably, this embodiment adds the feature distillation loss to the logic layer distillation loss to obtain the total distillation loss, allowing the student model to be supervised by both the intermediate feature layer and the output prediction layer, thus fully inheriting the knowledge of the teacher model. Furthermore, a cosine decay coefficient that decreases with each training epoch is introduced, making the distillation coefficient close to 1.0 in the early stages of training, rapidly aligning the feature distributions of the teacher and student models. In the later stages of training, the coefficient approaches 0.01, resulting in extremely weak distillation constraints. The model focuses on the detection task loss, effectively avoiding the overfitting of the student model to the teacher model that might result from excessively strong distillation constraints throughout the training process. This allows the final student model to achieve detection accuracy exceeding that of a simple pruning and fine-tuning model, and even surpassing the original baseline model, with low computational cost.

[0107] Step B50: Add the final distillation loss to the standard detection loss to obtain the total loss. Adjust the parameters of the student model based on the total loss to obtain the target detection model.

[0108] It should be noted that the formula for calculating the total loss function in this embodiment is as follows: L_total = L_det + (L_feature + L_logical) × batch_size × decay(i) Where L_det is the standard detection loss, decay(i) is the cosine decay coefficient of the i-th iteration, and batch_size is the current batch.

[0109] The formula for calculating the cosine attenuation coefficient is: decay(i) = α + β × [1 + cos(π × i / N)] / 2 Where N is the maximum number of iterations, α is the base value, and β is the difference coefficient. The schematic diagram of the cosine decay distillation loss scheduling curve in this embodiment can be found by referring to... Figure 9 .

[0110] Understandably, this embodiment adds the final distillation loss to the standard detection loss as the total loss, allowing the student model's parameter updates to be driven by two objectives simultaneously. The standard detection loss ensures the model doesn't deviate from the core tasks of defect classification and localization, while the final distillation loss guides the student model to mimic the high-quality feature representation and prediction behavior of the teacher model. The two work synergistically during training. Towards the end of training, when the cosine decay coefficient approaches zero, the total loss is primarily dominated by the standard detection loss, avoiding overfitting of the teacher model by the student model due to excessive distillation constraints. This results in a student model with significantly reduced computational cost after pruning, whose detection accuracy, after complete distillation training, not only recovers the pruning loss but can even surpass the original baseline model. Ultimately, this yields a high-precision, lightweight target detection model that meets the real-time inference requirements of edge computing platforms.

[0111] In one embodiment, the step of calculating the channel-level feature distillation loss based on the teacher feature map and the student feature map further includes: Laplacian edge detection is performed on the teacher feature map in the spatial dimension to generate an edge response map; The edge response map is thresholded to obtain a binary edge attention mask, wherein the edge region has a value of 1 and the non-edge region has a value of 0. The binary edge attention mask is multiplied element-wise with the teacher feature map and the student feature map in the spatial dimension to obtain the weighted teacher feature map and the weighted student feature map; Based on the weighted teacher feature map and the weighted student feature map, KL divergence is calculated after performing Softmax normalization in the channel dimension to obtain the channel-level feature distillation loss for edge enhancement.

[0112] It should be noted that Laplacian edge detection refers to using the Laplacian operator to perform spatial second derivative operations on the feature map to extract edges and high-frequency abrupt change regions, generating a response map that reflects drastic changes in local intensity. The edge response map refers to the response value map output after the feature map has undergone Laplacian edge detection, where high response values ​​correspond to strong edges or texture abrupt change regions in the feature map, and low response values ​​correspond to smooth regions.

[0113] Thresholding refers to the binarization operation of comparing pixel values ​​in the edge response map with a preset threshold, setting pixels greater than the threshold to 1 and pixels less than or equal to the threshold to 0. The binary edge attention mask refers to the binary matrix obtained after thresholding, whose spatial dimensions are the same as the teacher feature map. Edge regions (including rust texture boundaries, bolt outline gaps, loose nut gaps, etc.) are set to 1, while other smooth regions are set to 0.

[0114] The weighted teacher feature map is obtained by element-wise multiplying the binary edge attention mask with the teacher feature map in the spatial dimension, retaining only the responses in the edge regions of the teacher feature map, while the responses in non-edge regions are set to zero. The weighted student feature map is obtained by element-wise multiplying the same binary edge attention mask with the student feature map in the spatial dimension, retaining only the responses in the same spatial edge regions of the student feature map. The edge-enhanced channel-level feature distillation loss refers to the KL divergence loss calculated by aligning the channel response distributions in the edge regions of the teacher and student feature maps under the constraint of the edge attention mask, thus strengthening the distillation process's focus on defective edge features.

[0115] Understandably, this embodiment uses Laplacian edge detection to adaptively extract edge response maps from the teacher feature map and generates a binary edge attention mask through thresholding. This mask can accurately locate the edge positions of defects such as rust, loose nuts, and missing pins. The mask is then applied to both the teacher and student feature maps, forcing the distillation loss to calculate only the channel probability distribution differences within the edge region, rather than the global alignment of the entire feature map.

[0116] This embodiment avoids the student model overfitting the teacher model's noisy response over a large number of non-edge background regions by using the above steps, focusing the limited model capacity on the key areas for defect detection. Furthermore, since the pruned student model's feature representation ability in non-edge regions is naturally weakened, forcibly aligning the entire feature map may introduce unnecessary constraints, while aligning only edge regions reduces the distillation difficulty, allowing the student model to converge faster. Finally, the edge attention mask in this embodiment is generated online by the teacher model without additional annotation. It enhances the edge response during the feature extraction stage and strengthens the alignment weight of edge regions during the distillation stage. The synergistic effect of these two methods allows the pruned student model to further improve the recall rate of edge degradation defects such as rust and loosening while maintaining low computational cost.

[0117] In summary, this embodiment first captures feature maps from the same layer of the improved neck network of the teacher and student models, ensuring semantic alignment at the feature level; then, it simultaneously calculates channel-level feature distillation loss and logic-level distillation loss, enabling the student model to fully inherit the knowledge of the teacher model from both feature representation and decision-making behavior levels, especially the high sensitivity of the multi-scale edge information enhancement feature extraction module in the teacher model to edge degradation defects such as rust and loosening.

[0118] Furthermore, this embodiment introduces a cosine decay coefficient that decreases with each training epoch to dynamically schedule the total distillation loss. Strong distillation in the early training phase quickly aligns the feature distributions of teachers and students, while weak distillation in the later training phase allows the model to focus on the detection task loss, effectively avoiding overfitting of the teacher model to the student model caused by excessive distillation. Finally, the distillation loss is jointly optimized with the standard detection loss, enabling the student model to balance task fitting and knowledge imitation during parameter updates. Ultimately, this embodiment enables the student model, with significantly reduced computational cost after pruning, to not only recover the pruning loss after complete distillation training but also surpass the original baseline model in detection accuracy, ultimately obtaining a high-precision, lightweight object detection model that meets the real-time inference requirements of edge computing platforms.

[0119] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the edge degradation defect detection method of this application. Any simple modifications based on this technical concept are within the protection scope of this application.

[0120] All user-related data involved in this application was obtained with the user's permission or consent, as per [reference]. Figure 10 In other words, when this application is applied to a specific product or technology, user permission is required to acquire and process the relevant data, and the processing of the relevant data must comply with the relevant laws, regulations and regulatory standards of the relevant countries and regions.

[0121] The above description is only a part of the embodiments of this application and does not limit the scope of protection of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.

Claims

1. A method for detecting edge degradation defects, characterized in that, The method includes: Obtain the image to be detected that contains the aforementioned edge degradation defects; The image to be detected is input into a preset target detection model to obtain defect detection results. The target detection model is obtained by training a preset improved model through channel-level feature distillation after performing layer adaptive amplitude pruning. The improved model includes an edge information enhancement submodule, which performs self-supervised difference based on the original feature map and low-frequency feature map extracted from the image to be detected to obtain an enhanced high-frequency edge feature map.

2. The method as described in claim 1, characterized in that, Before the step of inputting the image to be detected into a preset target detection model to obtain the defect detection result, the method further includes: Obtain a training dataset containing image samples to be detected, wherein the image samples to be detected contain the edge degradation class defects; The training dataset is input into a preset model to be trained, and the model to be trained is trained based on the image samples to be detected to obtain the improved model; The improved model is used as the base model to be pruned, and the layer adaptive amplitude pruning is performed on the base model to be pruned to obtain the pruned model. Using the improved model as the teacher model and the pruning model as the student model, the channel-level feature distillation training is performed based on the teacher model, the student model, and the training dataset to obtain the target detection model.

3. The method as described in claim 2, characterized in that, The model to be trained includes a lightweight backbone network and an improved neck network. The steps of inputting the training dataset into the preset model to be trained and training the model based on the image samples to be detected to obtain the improved model include: The training dataset is input into the lightweight backbone network to extract features from the image samples to be detected, thereby obtaining an initial feature map. The initial feature map is input into the improved neck network, and feature extraction and fusion are performed on the initial feature map to obtain a fused and enhanced feature map; Based on the fused and enhanced feature map, the parameters of the model to be trained are adjusted to obtain the improved model.

4. The method as described in claim 3, characterized in that, The step of extracting features from the image sample to be detected to obtain an initial feature map includes: Initial feature extraction is performed on the image sample to be detected to obtain an initial sample feature map; The initial sample feature map is subjected to two independent convolutions by a preset first convolutional layer to obtain a first feature map and a second feature map. The first feature map is activated by a preset first activation function to obtain a first activated feature map. The first activated feature map and the second feature map are then multiplied element by element to obtain a multiplied feature map. The dimension of the multiplicative feature map is adjusted by a preset linear function, and the adjusted multiplicative feature map is then subjected to feature extraction by a preset depthwise separable convolution to obtain a depth feature map. The depth feature map is subjected to random depth regularization, and the regularized depth feature map is added to the initial sample feature map to obtain the initial feature map.

5. The method as described in claim 4, characterized in that, The step of extracting and fusing features from the initial feature map to obtain a fused and enhanced feature map includes: Local spatial features are extracted from the initial feature map by a preset second convolutional layer to obtain a local spatial feature map, wherein the kernel size of the second convolutional layer is smaller than the kernel size of the first convolutional layer; Based on multiple preset pooling target sizes of different sizes, feature extraction is performed on the local spatial feature map to obtain multiple pooling feature maps of different sizes corresponding to the pooling target size. The original number of channels in the pooling feature map is compressed through the first convolutional layer to obtain a compressed feature map with the target number of channels, wherein the target number of channels is the quotient of the original number of channels and the number of pooling target sizes; Local spatial enhancement is performed on each of the compressed feature maps by the depthwise separable convolution to obtain spatially enhanced feature maps; The edge information enhancement submodule performs edge enhancement on the spatial enhancement feature map, and then upsamples the edge-enhanced feature map to obtain the high-frequency edge feature map. Based on the first convolutional layer, the channel dimensions of each of the high-frequency edge feature maps are concatenated to obtain the fused enhanced feature map with the same number of channels as the original number of channels.

6. The method as described in claim 5, characterized in that, The steps of performing edge enhancement on the spatial enhanced feature map through the edge information enhancement submodule, and upsampling the edge-enhanced feature map to obtain the high-frequency edge feature map include: The spatially enhanced feature map is subjected to mean pooling to obtain a low-frequency feature map; The difference between the spatially enhanced feature map and the low-frequency feature map is calculated to obtain the high-frequency feature map; The high-frequency feature map is convolved, and the convolved high-frequency feature map is activated by a preset second activation function to obtain adaptive gating weights; The adaptive gating weights are added to the spatially enhanced feature map to obtain the high-frequency edge feature map.

7. The method as described in claim 2, characterized in that, The step of performing layer-adaptive amplitude pruning on the base model to be pruned to obtain the pruned model includes: Based on the training dataset, the base model to be pruned is subjected to sparse training to obtain a sparse model. The loss value of the sparse training is the sum of the training loss value and the regularization loss value during the training process. The regularization loss value is the sum of the absolute values ​​of the scaling factors of each batch normalization layer in the base model to be pruned. The scaling factor is normalized to obtain a normalized scaling factor, and the normalized scaling factor is sorted in descending order to obtain a scaling factor sort. Based on the scaling factor sorting and the preset compression ratio, the channels of the sparse model are pruned from high to low until the compression ratio is reached, thus obtaining the pruned model to be trained. The pruning model is fine-tuned based on the training dataset to obtain the pruning model.

8. The method as described in claim 2, characterized in that, The step of training the target detection model by channel-level feature distillation based on the teacher model, the student model, and the training dataset includes: The training dataset is input into the teacher model and the student model respectively to obtain the teacher feature map output by the improved neck network of the teacher model and the student feature map output by the improved neck network of the student model. Obtain the standard detection loss for training the channel-level feature distillation, and calculate the channel-level feature distillation loss based on the teacher feature map and the student feature map; Based on the teacher feature map and the student feature map, calculate the logic layer distillation loss; The feature distillation loss and the logic layer distillation loss are added together to obtain the total distillation loss. The total distillation loss is multiplied by the current batch of channel-level feature distillation training. The multiplication loss is then multiplied by a preset cosine decay coefficient to obtain the final distillation loss. The cosine decay coefficient decreases as the training rounds increase. The final distillation loss is added to the standard detection loss to obtain the total loss. The parameters of the student model are then adjusted based on the total loss to obtain the target detection model.

9. The method as described in claim 8, characterized in that, The step of calculating the channel-level feature distillation loss based on the teacher feature map and the student feature map includes: Determine whether the number of teacher channels in the teacher feature map is the same as the number of student channels in the student feature map; If they are not the same, the student feature map is convolved through a preset third convolutional layer to obtain a student feature map with the same number of student channels as the teacher channel. The teacher feature map is normalized in the channel dimension to obtain a normalized teacher feature map, and the student feature map is normalized in the channel dimension to obtain a normalized student feature map. The relative entropy of the normalized teacher feature map and the normalized student feature map is calculated to obtain the channel-level feature distillation loss.

10. The method as described in claim 8, characterized in that, The step of calculating the logic layer distillation loss based on the teacher feature map and the student feature map includes: Divide the teacher feature map by a preset temperature coefficient, and then activate the teacher feature map after dividing by the temperature coefficient using a preset third activation function to obtain the teacher probability value. Divide the student feature map by the temperature coefficient, and then activate the student feature map after dividing by the temperature coefficient using the third activation function to obtain the student probability value. The binary cross-entropy between the teacher probability value and the student probability value is calculated to obtain the logic layer distillation loss.

Citation Information

Patent Citations

  • Defect prediction method based on model pruning

    CN116342533A

  • Lightweight steel surface defect detection method based on improved YOLOv8n

    CN118196529A

  • Steel surface defect detection method based on improved model

    CN119048503A

  • Lightweight power transmission line insulator defect detection algorithm based on SGA and SE-F

    CN119228777A