Method and device for detecting small-size defects on surface of low-voltage sheath of cable
Through the improved YOLOv5 and ResNet18 models, combined with feature fusion and attention mechanism, the problems of high missed detection rate and low efficiency in small-size defect detection of cable sheaths are solved, and efficient and accurate detection results are achieved.
Patent Information
- Application Number
- CN202511046626.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-29
- Publication Date
- 2025-09-19
AI Technical Summary
Traditional manual quality inspection is insufficient in detecting small-sized defects in cable sheath production, and has problems such as high missed detection rate, low efficiency, and high risk, making it difficult to meet the needs of high-speed production scenarios.
An improved YOLOv5 target detection model is adopted, with the addition of a P2 high-resolution detection head, a BiFPN feature pyramid, a normalized Wasserstein distance loss function, and DIoU-NMS. This is combined with an improved ResNet18 classification model and the CBAM attention mechanism to enhance the small target feature detection and classification capabilities.
It improves the precision and accuracy of small-size defect detection, reduces the missed detection rate, improves detection efficiency and safety, and ensures the quality of low-voltage sheath products.
Smart Images

Figure CN120672745A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of computer vision and deep learning, and specifically provides a method and device for detecting small-size defects on the surface of a low-voltage cable sheath. Background Art
[0002] During cable sheath production, small defects (generally smaller than 32×32 pixels) such as particles, pits, and water droplets are easily generated due to equipment adjustments, raw material impurities, or cooling water erosion. Traditional manual quality inspection suffers from high missed detection rates, low efficiency, and high risk in high-speed production scenarios.
[0003] How to solve the problem of insufficient manual quality inspection ability for small-size defects, use machine vision to replace manual visual quality inspection, reduce missed detection rate and false detection rate, improve inspection efficiency and production safety, reduce production costs and dependence on external resources are problems that technical personnel in this field urgently need to solve. Summary of the Invention
[0004] The present invention aims to address the deficiencies of the above-mentioned prior art and provides a highly practical method for detecting small-size defects on the surface of a low-voltage cable sheath.
[0005] A further technical task of the present invention is to provide a device for detecting small-size defects on the surface of a low-voltage cable sheath that is rationally designed, safe and applicable.
[0006] The technical solution adopted by the present invention to solve its technical problem is:
[0007] A method for detecting small-scale defects on the surface of low-voltage cable sheaths. First, in the target detection stage, the original structure of the YOLOv5 algorithm consists of three detection heads: P3, P4, and P5. From top to bottom, they represent the detection capabilities of the detection heads for small, medium, and large scales.
[0008] Then, in the image classification stage, the small-sized particle images in the target detection data are cropped and input into the algorithm for training to enhance the defect features.
[0009] Furthermore, a P2 layer detection head is added to learn the feature information of small targets from the shallow feature map and then splice it with the deep feature map, so that the deep network can also learn the feature information of small targets;
[0010] On the basis of adding the P2 detection head, deleting the P5 detection head and removing redundant parameters, the parameter calculation formula is as follows:
[0011] H2=(H1-K+2P) / S+1;
[0012] Among them, H1 is the input width, K is the number of convolution kernels, P is zero padding, and S is the step size.
[0013] Furthermore, the traditional PANet is replaced by BiFPN, and features of different resolutions are weightedly fused through bidirectional cross-scale connections. The weighted fusion formula is expressed as follows:
[0014] p i t =Conv(∑w ij f j t-1 );
[0015] Among them, F is the input feature and W is the learnable weight. We use NWD as the loss function and adopt a new measurement method to calculate the similarity between boxes. The box is modeled as a Gaussian distribution, and the Wasserstein distance is used to measure the similarity between the two distributions.
[0016] When using Wasserstein distance, even if the two boxes do not overlap at all or overlap very little, the similarity can still be measured. In addition, NWD is insensitive to the target scale and is more stable for small targets.
[0017] Furthermore, assuming that the bounding box R = (cx, cy, w, h), for two bounding boxes, the second-order Wasserstein distance can be defined as:
[0018]
[0019] Distance metrics cannot be used directly for similarity. A new metric is obtained using the normalized exponential, called the normalized Wasserstein distance, which is expressed by the following formula:
[0020]
[0021] Based on NWD loss, the principle is as follows:
[0022]
[0023] DIoU-NMS is used to consider the center distance of the bounding box to avoid a large IOU between the two boxes. However, when the center distance is also large, the boxes may be judged as two objects and will not be filtered out.
[0024] Furthermore, the DIoU formula is as follows:
[0025]
[0026] Among them, b predicts the center of the box, b gt is the center of the ground-truth box, ρ 2 (b,b gt ) represents the square of the distance between the center of the real box and the predicted box d 2, c represents the diagonal length of the minimum enclosing area of the two boxes.
[0027] Furthermore, in the image classification stage, small-sized defects such as particles in the target detection data are cropped into 64*64 images and input into the algorithm for training to enhance the defect features;
[0028] The algorithm adopts an improved ResNet18 algorithm, adds a CBAM attention mechanism module, and inserts it into each residual block of ResNet18. After being applied to each residual block, the initial state of the CBAM module is close to "through", that is, in the early stage of training, the CBAM module has little impact on the feature map, will not destroy the weight of the pre-trained model, retains the original structure of ResNet18, and enhances the features of small targets.
[0029] Furthermore, the channel attention module CAM performs global average pooling GAP and global maximum pooling GMP on the input feature map to generate two 1×1×C channel descriptors, input the two descriptors into the shared multi-layer perceptron MLP, add them after nonlinear transformation, and then generate the channel attention weight Mc through Sigmoid activation.
[0030] Furthermore, the spatial attention module (SAM) performs average pooling and maximum pooling on the feature map output by CAM in the channel dimension to obtain two H×W×1 feature maps. The two are concatenated and compressed into a single channel through a 7×7 convolution layer. The spatial attention weight Ms is then generated through a Sigmoid filter. The input feature map is then element-wise multiplied with Mc and Ms to complete the recalibration of the channel and spatial dimensions.
[0031] The calculation formula is as follows:
[0032] M c (F)=σ(MLP(AvgPool(F))+MLP(MaxPool(F)));
[0033] Where σ is the Sigmoid function;
[0034] Output feature map:
[0035] is element-wise multiplication.
[0036] A device for detecting small-size defects on the surface of a low-voltage cable sheath, comprising: at least one memory and at least one processor;
[0037] The at least one memory is configured to store a machine-readable program;
[0038] The at least one processor is used to call the machine-readable program to execute a method for detecting small-size defects on the surface of a low-voltage cable sheath.
[0039] Compared with the prior art, the method and device for detecting small-size defects on the surface of a low-voltage cable sheath of the present invention have the following outstanding beneficial effects:
[0040] (1) This paper improves the accuracy of small-scale defect detection by optimizing the YOLOv5 object detection model, adding a P2 high-resolution detection head, a bidirectional feature pyramid (BiFPN), a normalized Wasserstein distance (NWD) loss function, and DIoU-NMS. This optimization method improves small target detection and is more suitable for small target detection tasks.
[0041] (2) The ResNet18 classification model is optimized, and the CBAM attention mechanism is added after the residual block. The small target features are enhanced while retaining the ResNet18 structure, thereby improving the accuracy of small target classification.
[0042] (3) The designed method for detecting small-scale defects on the surface of low-voltage cable sheaths can solve the problems of high missed detection rates, low quality inspection efficiency, and high difficulty in manually determining small-scale defects such as particles, pits, and water droplets in low-voltage sheath production. The present invention uses machine vision to replace manual visual quality inspection, improving quality inspection efficiency and accuracy, and better ensuring the quality of low-voltage sheath products. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0044] Figure 1 This is a schematic diagram of the structure of a P2 small target detection head added to a method for detecting small-size defects on the surface of a low-voltage cable sheath;
[0045] Figure 2 This is a schematic diagram of the BiFPN feature fusion structure in the method for detecting small-size defects on the surface of low-voltage cable sheath;
[0046] Figure 3 This is a schematic diagram of the CBAM attention mechanism module in the small-size defect detection method for the cable low-voltage sheath surface;
[0047] Figure 4 The present invention is a schematic diagram of the algorithm detection process in a method for detecting small-size defects on the surface of a low-voltage cable sheath. DETAILED DESCRIPTION
[0048] In order to enable those skilled in the art to better understand the solutions of the present invention, the present invention will be further described in detail below in conjunction with specific embodiments. Obviously, the embodiments described are only some embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0049] A best embodiment is given below:
[0050] like Figure 1-4 As shown in the embodiment, a method for detecting small-size defects on the surface of a low-voltage cable sheath is provided.
[0051] First, in the target detection stage, the original structure of the YOLOv5 algorithm consists of three detection heads: P3, P4, and P5. From top to bottom, they represent the detection capabilities of the detection heads for small, medium, and large scales.
[0052] Then, in the image classification stage, the small-sized particle images in the target detection data are cropped and input into the algorithm for training to enhance the defect features.
[0053] During the object detection phase, the YOLOv5 algorithm's original structure consists of three detection heads, P3, P4, and P5. From top to bottom, these heads represent their detection capabilities for small, medium, and large scales. However, small objects suffer from fewer features, unclear semantic features, and are easily overwhelmed by features due to continuous convolution. Objects with a size of [32,32] are considered small, and small defects on low-voltage jackets are generally smaller than [32,32]. For the P3 detection head, the feature layer size is [80,80], which is an 8x downsampling compared to the original input feature map size.
[0054] For small targets, the features at P3 are downsampled to feature maps smaller than [4,4] in size, resulting in a problem of too few features, which in turn leads to poor detection capabilities of the P3 detection head for small targets.
[0055] Therefore, to address the problem of easy loss of small target features, a P2 layer (1 / 4 downsampling) detection head (output size is 80×80) is added. After learning the feature information of small targets from the shallow feature map, it is spliced with the deep feature map, so that the deep network can also learn the feature information of small targets, allowing the network to pay more attention to the detection of small targets and improve the target detection effect. In addition, since the dataset mainly contains small targets, the P5 detection head is deleted on the basis of adding the P2 detection head, and redundant parameters are deleted to avoid the increase in calculation amount and the slowdown of detection inference speed.
[0056] The parameter calculation formula is as follows:
[0057] H2=(H1-K+2P) / S+1;
[0058] Among them, H1 is the input width, K is the number of convolution kernels, P is zero padding, and S is the step size.
[0059] The traditional PANet is replaced by BiFPN, which uses bidirectional cross-scale connections to weightedly fuse features of different resolutions and enhance the transmission efficiency of small target features.
[0060] The weighted fusion formula is expressed as follows:
[0061] p i t =Conv(∑w ij f j t-1 );
[0062] Among them, F is the input feature and W is the learnable weight; NWD is used as the loss function, a new measurement method is adopted to calculate the similarity between boxes, the box is modeled as a Gaussian distribution, and the Wasserstein distance is used to measure the similarity between the two distributions.
[0063] When using Wasserstein distance, even if two boxes do not overlap at all or overlap very little, similarity can still be measured. In addition, NWD is insensitive to object scale and is more stable for small objects.
[0064] Assuming the bounding box R = (cx, cy, w, h), for two bounding boxes, the second-order Wasserstein distance can be defined as:
[0065]
[0066] This distance metric cannot be used directly for similarity. Using the normalized exponential to get a new metric, called the normalized Wasserstein distance, is expressed by the following formula:
[0067]
[0068] Based on NWD loss, the principle is as follows:
[0069]
[0070] YOLOv5's original IoU structure only considers the overlap between the predicted and ground-truth boxes, without factoring in center-point distance and aspect ratio. DIoU-NMS considers the center-point distance of bounding boxes, preventing large IoU between two boxes. However, if the center-point distance is also large, the boxes may be considered as two objects and not be filtered out.
[0071] The DIoU formula is as follows:
[0072]
[0073] Among them, b predicts the center of the box, b gt is the center of the ground-truth box, ρ 2 (b,b gt ) represents the square of the distance between the center of the real box and the predicted box d 2 , c represents the diagonal length of the minimum enclosed area of the two boxes (the minimum rectangular box that contains both the predicted box and the real box).
[0074] In the image classification and target detection stages, the data size is large, small-size defects account for a small proportion of the image, and the features are not obvious.
[0075] Small defects such as particles in target detection data are cropped into 64*64 images and fed into the algorithm for training to enhance defect features. The algorithm uses a modified ResNet-18 algorithm. A CBAM (Channel-by-Channel Attention) attention mechanism module is added and inserted after each residual block (BasicBlock) of ResNet-18. The initial state of the CBAM module is close to "pass-through." That is, in the early stages of training, the CBAM module has a minimal impact on the feature map and does not disrupt the weights of the pre-trained model. This preserves the original ResNet-18 structure and enhances the features of small objects.
[0076] The channel attention module (CAM) performs global average pooling (GAP) and global maximum pooling (GMP) on the input feature map to generate two 1×1×C channel descriptors. The two descriptors are input into a shared multi-layer perceptron (MLP), added after nonlinear transformation, and then activated by Sigmoid to generate the channel attention weight Mc.
[0077] The spatial attention module (SAM) performs average pooling and maximum pooling on the feature map output by the CAM in the channel dimension to obtain two H×W×1 feature maps. After splicing the two, they are compressed into a single channel through a 7×7 convolution layer. The spatial attention weight Ms is then generated by Sigmoid. The input feature map is multiplied element-wise with Mc and Ms in turn to complete the recalibration of the channel and spatial dimensions.
[0078] The calculation formula is as follows:
[0079] M c (F)=σ(MLP(AvgPool(F))+MLP(MaxPool(F)));
[0080] Where σ is the Sigmoid function.
[0081] Output feature map:
[0082] is element-wise multiplication.
[0083] Based on the above method, a device for detecting small-size defects on the surface of a low-voltage cable sheath in this embodiment includes: at least one memory and at least one processor;
[0084] The at least one memory is configured to store a machine-readable program;
[0085] The at least one processor is used to call the machine-readable program to execute a method for detecting small-size defects on the surface of a low-voltage cable sheath.
[0086] The above-mentioned specific implementation methods are only specific cases of the present invention. The patent protection scope of the present invention includes but is not limited to the above-mentioned specific implementation methods. Any technical solutions that conform to the above-mentioned specific implementation methods of the present invention and any appropriate changes or substitutions made thereto by ordinary technicians in the relevant technical field shall fall within the patent protection scope of the present invention.
[0087] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to these embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the appended claims and their equivalents.
Claims
1. A method for detecting small-size defects on the surface of a low-voltage cable sheath, characterized in that: First, in the target detection stage, the original structure of the YOLOv5 algorithm consists of three detection heads: P3, P4, and P5. From top to bottom, they represent the detection capabilities of the detection heads for small, medium, and large scales. Then, in the image classification stage, the small-sized particle images in the target detection data are cropped and input into the algorithm for training to enhance the defect features.
2. A method for detecting small-size defects on the surface of a low-voltage cable sheath according to claim 1, characterized in that: Add a P2 layer detection head to learn the feature information of small targets from the shallow feature map and then splice it with the deep feature map, so that the deep network can also learn the feature information of small targets; On the basis of adding the P2 detection head, deleting the P5 detection head and removing redundant parameters, the parameter calculation formula is as follows: H2=(H1-K+2P) / S+1; Among them, H1 is the input width, K is the number of convolution kernels, P is zero padding, and S is the step size.
3. A method for detecting small-size defects on the surface of a low-voltage cable sheath according to claim 2, characterized in that: The traditional PANet is replaced by BiFPN, and features of different resolutions are weightedly fused through bidirectional cross-scale connections. The weighted fusion formula is expressed as follows: p i t =Conv(∑w ij f j t-1 ); Among them, F is the input feature and W is the learnable weight. We use NWD as the loss function and adopt a new measurement method to calculate the similarity between boxes. The box is modeled as a Gaussian distribution, and the Wasserstein distance is used to measure the similarity between the two distributions. When using Wasserstein distance, even if the two boxes do not overlap at all or overlap very little, the similarity can still be measured. In addition, NWD is insensitive to the target scale and is more stable for small targets.
4. A method for detecting small defects on the surface of a low-voltage cable sheath according to claim 3 The detection method is characterized in that Assuming the bounding box R = (cx, cy, w, h), for two bounding boxes, the second-order Wasserstein distance can be defined as: Distance metrics cannot be used directly for similarity. A new metric is obtained using the normalized exponential, called the normalized Wasserstein distance, which is expressed by the following formula: Based on NWD loss, the principle is as follows: DIoU-NMS is used to consider the center distance of the bounding box to avoid a large IOU between the two boxes. However, when the center distance is also large, the boxes may be judged as two objects and will not be filtered out.
5. A method for detecting small-size defects on the surface of a low-voltage cable sheath according to claim 4, characterized in that: The DIoU formula is as follows: -1≤DIoU≤1; Among them, b predicts the center of the box, b gt is the center of the ground-truth box, ρ 2 (b,b gt ) represents the square of the distance between the center of the real box and the predicted box d 2 , c represents the diagonal length of the minimum enclosing area of the two boxes.
6. A method for detecting small-size defects on the surface of a low-voltage cable sheath according to claim 5, characterized in that: In the image classification stage, small-sized defects such as particles in the target detection data are cropped into 64*64 images and input into the algorithm for training to enhance the defect features; The algorithm adopts an improved ResNet18 algorithm and adds a CBAM attention mechanism module, which is inserted into each residual block of ResNet18. After being applied to each residual block, the initial state of the CBAM module is close to "pass-through". That is, in the early stages of training, the CBAM module has little impact on the feature map and will not destroy the weights of the pre-trained model. It retains the original structure of ResNet18 and enhances the features of small objects.
7. A method for detecting small-size defects on the surface of a low-voltage cable sheath according to claim 6, characterized in that: The channel attention module CAM performs global average pooling GAP and global maximum pooling GMP on the input feature map to generate two 1×1×C channel descriptors. The two descriptors are input into the shared multi-layer perceptron MLP, added after nonlinear transformation, and then activated by Sigmoid to generate the channel attention weight Mc.
8. A method for detecting small-size defects on the surface of a low-voltage cable sheath according to claim 7, characterized in that: The spatial attention module (SAM) performs average pooling and maximum pooling on the feature map output by the CAM in the channel dimension to obtain two H×W×1 feature maps. The two maps are concatenated and compressed into a single channel through a 7×7 convolution layer. The spatial attention weight Ms is then generated through a Sigmoid filter. The input feature map is element-wise multiplied with Mc and Ms in turn to complete the recalibration of the channel and spatial dimensions. The calculation formula is as follows: M c (F)=σ(MLP(AvgPool(F))+MLP(MaxPool(F))); Where σ is the Sigmoid function; Output feature map: is element-wise multiplication.
9. A device for detecting small-size defects on the surface of a low-voltage cable sheath, characterized in that: include: at least one memory and at least one processor; The at least one memory is configured to store a machine-readable program; The at least one processor is configured to call the machine-readable program to execute the method according to any one of claims 1 to 8.
Citation Information
Cited By
Deep learning optimization method for transmission efficiency of super-copper low-voltage cable
CN122113633A
A deep learning optimization method for transmission efficiency of super copper low-voltage cable
CN122113633B