Method, system, device and medium for detecting surface defects of cable low-voltage sheath
Patent Information
- Application Number
- CN202410852575.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2026-10-30
- Estimated Expiration
- 2044-06-28
AI Technical Summary
然而,深度学习方法也存在一些缺点,由于正负样本特征差异小、类别间的特征差异小,以及目标尺度小等原因,使得基于YOLO的目标检测模型存在一些误检和漏检的情况
[0057](一)本发明设计了一种基于边界框形状和尺度的损失函数,有效消除了边界框的形状和尺度等固有属性对边界框回归的影响,适用于基于交并比和锚框的检测器,提高了小目标缺陷的检测效果;
Smart Images

Figure CN118691897B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer recognition and image processing technology, specifically to a method, system, equipment, and medium for detecting surface defects in low-voltage cable sheaths. Background Technology
[0002] With continued investment in infrastructure construction, the cable industry is showing a steady growth trend. The safety and reliability of cable products are of paramount importance, relating to the stable operation of the power system and the safety of people's lives and property. For example, in the production of low-voltage sheaths, improper material selection and inaccurate processing techniques can lead to production quality problems such as delamination and particles on the surface of the low-voltage sheath, resulting in substandard final products.
[0003] Traditional manual inspection is inefficient, inconsistent, and easily influenced by individual subjectivity. Traditional image processing methods have limitations, primarily relying on predefined algorithms and rules to process and analyze image data. This approach has limited generalization ability when dealing with diverse cable and defect types, often requiring adjustments and optimizations for specific situations. Deep learning methods exhibit better generalization ability when handling diverse cable and defect types, while also meeting real-time detection requirements. However, deep learning methods also have some drawbacks. Due to the small differences in features between positive and negative samples, small differences in features between categories, and small target scale, YOLO-based target detection models experience some false positives and false negatives.
[0004] Therefore, how to improve the detection rate of small targets with surface defects in low-pressure sheaths, and thus improve the performance and flexibility of the model, is a technical problem that urgently needs to be solved. Summary of the Invention
[0005] The technical objective of this invention is to provide a method, system, device, and medium for detecting surface defects in low-voltage cable sheaths, in order to address the problem of how to improve the detection rate of small targets on the surface of low-voltage sheaths, thereby improving the performance and flexibility of the model.
[0006] The technical objective of this invention is achieved as follows: a method for detecting surface defects in low-voltage cable sheaths, the method being as follows:
[0007] S1. Based on the analysis of the small target defect detection task, a loss function based on the bounding box shape and scale is designed for training the low-voltage cable sheath defect detection model, thereby improving the sensitivity of anchor-based detectors to small target defects in bounding box regression.
[0008] S2. Based on the analysis of the structure and optimization path of the low-voltage cable sheath defect detection model, an adaptive feature fusion decoupling head module AFFD is designed to further decouple the defect localization and classification tasks, so that the defect detection model learns suitable feature representations in different sub-tasks, thereby improving the efficiency and accuracy of the defect detection model.
[0009] S3. Combining steps S1 and S2, design and train a modular cable low-voltage sheath defect detection model. Use the final obtained cable low-voltage sheath detection model to detect defects in the input image. Defect detection includes two sub-tasks: defect localization and defect classification.
[0010] As a preferred approach, the loss function based on the bounding box shape and scale is designed as follows:
[0011] To address the shape deviation between the ground truth (GT) bounding box and the predicted bounding box, weighting coefficients are set in the horizontal and vertical directions, respectively, as follows:
[0012]
[0013] Among them, w mbr and h mbr These represent the width and height of the smallest bounding rectangle of the truth box and the prediction box, respectively; and These are the coordinates of the top left and bottom right corners of the prediction box and the truth box, respectively.
[0014] The bounding boxes are modeled as two-dimensional Gaussian distributions, and the similarity of these distributions is measured using the normalized Wasserstein distance (NWD). The Wasserstein distance measures distribution similarity even without overlap or with negligible overlap. Furthermore, the Wasserstein distance (NWD) is insensitive to objects of different scales, making it suitable for measuring the similarity between small objects. Specifically:
[0015] Let the bounding box be B = (cx, cy, w, h). For two bounding boxes, the second-order Wasserstein distance is defined as:
[0016]
[0017] Similarity is measured using a normalized exponent:
[0018]
[0019] Where C is a constant determined by the dataset, and is set as the average absolute size of the targets in the dataset; the normalized Wasserstein distance with shape scale factor added is:
[0020]
[0021] The normalized Wasserstein distance loss function based on the shape scale factor is:
[0022] L NWD-shape =1-NWD(B a B b ).
[0023] As a preferred option, the adaptive feature fusion decoupling head module AFD is used to generate spatially coarse and semantically stronger feature codes for classification tasks, while providing high-resolution feature maps containing edge information for localization tasks, regressing object boundaries, further decoupling the feature codes for classification and localization tasks, and improving the overall network performance.
[0024] More preferably, the adaptive feature fusion decoupled head module AFD performs deep and shallow adaptive feature fusion in front of the detection head through a feature pyramid-like structure, and then sends them to the head for corresponding decoding output. The classification task fuses features from a deeper layer of the current layer to embed rich semantic features into the current layer; the regression task fuses features from two adjacent layers to obtain rich spatial detail information.
[0025] Even better, the adaptive feature fusion decoupling head module AFFD adds a fourth branch to the small target detection layer based on the YOLOv5 network structure, further improving the detection capability of small targets;
[0026] The network structure corresponding to the adaptive feature fusion decoupling head module AFFD includes Neck and AFFD Head; Neck adopts FPN, which includes p1, p2, p3 and p4; where p1-p4 represent features at different levels in the feature pyramid, and each feature has a different spatial resolution;
[0027] The AFFD Head includes AFFD-x-cls and AFFD-x-reg, which correspond one-to-one with p1, p2, p3 and p4 in FPN. AFFD-x-cls and AFFD-x-reg represent the feature map obtained after decoupling the classification and regression tasks of the features of the x-th layer and performing adaptive feature fusion.
[0028] Specifically, for the p2 layer features, AFFD-2-cls is used to receive feature maps from AFFD-3-cls and perform weighted fusion by learning weight coefficients α and β; AFFD-2-reg is used to receive feature maps from AFFD-1-reg and AFFD-3-reg and perform weighted fusion by learning weight coefficients α, β and γ.
[0029] As a preferred method, the input image is obtained as follows:
[0030] The cable is guided to the imaging unit via a transmission device. The imaging unit is equipped with a light source and a camera unit, designed for image acquisition and transmission.
[0031] After image acquisition, the images are transmitted to back-end processing equipment via a network solution. The back-end processing equipment is equipped with trained computer vision target detection algorithms to process and analyze the images, thereby identifying defects and displaying the analysis results.
[0032] A surface defect detection system for low-voltage cable sheaths, the system comprising:
[0033] The loss function design module is used to design loss functions based on the shape and scale of the bounding box according to the analysis of the small target defect detection task. These functions are used to train the cable low-voltage sheath defect detection model and improve the sensitivity of anchor-frame-based detectors to small target defects in bounding box regression.
[0034] The decoupling head design module is used to design an adaptive feature fusion decoupling head module AFFD based on the structure and optimization path of the low-voltage sheath defect detection model of the cable, further decoupling the defect localization and classification tasks, so that the defect detection model learns suitable feature representations in different sub-tasks, thereby improving the efficiency and accuracy of the defect detection model.
[0035] The modular processing module is used to design and train a modular cable low-voltage sheath defect detection model by combining the loss function design module and the decoupling head design module. The final obtained cable low-voltage sheath detection model is used to detect defects in the input image. The defect detection includes two sub-tasks: defect localization and defect classification.
[0036] Preferably, the loss function design module includes:
[0037] The weight coefficient setting submodule is used to set weight coefficients in the horizontal and vertical directions respectively for the shape deviation between the ground truth (GT) bounding box and the predicted bounding box, as shown in the following formula:
[0038]
[0039] Among them, w mbr and h mbr These represent the width and height of the smallest bounding rectangle of the truth box and the prediction box, respectively; and These are the coordinates of the top left and bottom right corners of the prediction box and the truth box, respectively.
[0040] The modeling submodule models the bounding boxes as two-dimensional Gaussian distributions and measures the similarity of these distributions using the normalized Wasserstein distance (NWD). The Wasserstein distance measures distribution similarity even without overlap or with negligible overlap. Furthermore, the NWD is insensitive to objects of different scales, making it suitable for measuring the similarity between small objects. Specifically:
[0041] Let the bounding box be B = (cx, cy, w, h). For two bounding boxes, the second-order Wasserstein distance is defined as:
[0042]
[0043] Similarity is measured using a normalized exponent:
[0044]
[0045] Where C is a constant determined by the dataset, and C is set as the average absolute size of the targets in the dataset; the normalized Wasserstein distance with the shape scale factor added is:
[0046]
[0047] The normalized Wasserstein distance loss function based on the shape scale factor is:
[0048] L NWD-shape =1-NWD(B a B b );
[0049] The Adaptive Feature Fusion Decoupling Head Module (AFFD) generates spatially coarse and semantically stronger feature codes for classification tasks, while providing high-resolution feature maps containing edge information for localization tasks to regress object boundaries. This further decomposes the feature codes for classification and localization tasks, improving the overall network performance. The AFD decoupling head module adds a fourth branch to the small target detection layer based on the YOLOv5 network structure, further improving the detection capability for small targets.
[0050] The network structure corresponding to the adaptive feature fusion decoupling head module AFFD includes Neck and AFFD Head; Neck adopts FPN, which includes p1, p2, p3 and p4; where p1-p4 represent features at different levels in the feature pyramid, and each feature has a different spatial resolution;
[0051] The AFFD Head includes AFFD-x-cls and AFFD-x-reg, which correspond one-to-one with p1, p2, p3, and p4 in FPN. AFFD-x-cls and AFFD-x-reg represent the feature map obtained after decoupling the classification and regression tasks of the features of the x-th layer and performing adaptive feature fusion.
[0052] An electronic device includes: a memory and at least one processor;
[0053] The memory contains computer programs;
[0054] The at least one processor executes the computer program stored in the memory, causing the at least one processor to perform the cable low-voltage sheath surface defect detection method as described above.
[0055] A computer-readable storage medium storing a computer program that can be executed by a processor to implement the method for detecting surface defects in low-voltage cable sheaths as described above.
[0056] The method, system, equipment, and medium for detecting surface defects in low-voltage cable sheaths of the present invention have the following advantages:
[0057] (i) This invention designs a loss function based on the shape and scale of the bounding box, which effectively eliminates the influence of the inherent properties of the bounding box such as shape and scale on the bounding box regression. It is suitable for detectors based on cross-union ratio and anchor boxes, and improves the detection effect of small target defects.
[0058] (II) This invention designs an adaptive feature fusion decoupled head module, which improves the feature representation of the defect detection subtask, optimizes the feature allocation and fusion of different subtasks, and improves the performance and flexibility of the model; at the same time, it effectively decouples the subtasks to address the problem of spatial misalignment in defect detection, so as to more accurately locate and classify defects.
[0059] (III) This invention employs modular design and model training to obtain a low-pressure sheath surface defect detection model. Through testing and experimentation, the accuracy of the optimized model is effectively improved, ultimately reaching 91.3%. Attached Figure Description
[0060] The invention will be further described below with reference to the accompanying drawings.
[0061] Appendix Figure 1 This is a schematic diagram of the adaptive feature fusion decoupling head module. Detailed Implementation
[0062] The following detailed description of the cable low-voltage sheath surface defect detection method, system, equipment, and medium of the present invention is based on the accompanying drawings and specific embodiments.
[0063] Example 1:
[0064] This embodiment provides a method for detecting surface defects in the low-voltage sheath of cables, as detailed below:
[0065] S1. Based on the analysis of the small target defect detection task, a loss function based on the bounding box shape and scale is designed for training the low-voltage cable sheath defect detection model, thereby improving the sensitivity of anchor-based detectors to small target defects in bounding box regression.
[0066] S2. Based on the analysis of the structure and optimization path of the low-voltage cable sheath defect detection model, an adaptive feature fusion decoupling head module AFFD is designed to further decouple the defect localization and classification tasks, so that the defect detection model learns suitable feature representations in different sub-tasks, thereby improving the efficiency and accuracy of the defect detection model.
[0067] S3. Combining steps S1 and S2, design and train a modular cable low-voltage sheath defect detection model. Use the final obtained cable low-voltage sheath detection model to detect defects in the input image. Defect detection includes two sub-tasks: defect localization and defect classification.
[0068] In this embodiment, the input image is obtained in the following specific way:
[0069] ① The cable is guided to the shooting unit via a transmission device. The shooting unit is equipped with a light source and a camera shooting unit, which is designed to acquire and transmit images.
[0070] ②After image acquisition, the images are transmitted to the back-end processing equipment via a network solution. The back-end processing equipment is equipped with a trained computer vision target detection algorithm to process and analyze the images, thereby identifying defects and displaying the analysis results.
[0071] Intersection over Union (IoU) based metrics are highly sensitive to positional deviations of small objects, significantly degrading detection performance when used in anchor-box-based detectors. Small objects typically exhibit extremely limited appearance information, increasing the difficulty of learning discriminative features and leading to detection failures. The small pixel count of small objects also increases the difficulty of selecting positive and negative samples during training. Since IoU's sensitivity varies greatly across different object scales, even small positional deviations can cause a significant decrease in IoU (from 0.53 to 0.06) for small objects (e.g., 6×6 pixels). The sensitivity of IoU to small objects and the inaccuracy of label assignment ultimately lead to convergence difficulties during network training; therefore, IoU is not a good metric for small objects. The loss function designed in step S1 of this embodiment, based on the bounding box shape and scale, is as follows:
[0072] S101. For the shape deviation between the ground truth (GT) bounding box and the predicted bounding box, weight coefficients are set in the horizontal and vertical directions respectively, as follows:
[0073]
[0074] Among them, w mbr and h mbr These represent the width and height of the smallest bounding rectangle of the truth box and the prediction box, respectively; and These are the coordinates of the top left and bottom right corners of the prediction box and the truth box, respectively.
[0075] S102. Model the bounding boxes as a two-dimensional Gaussian distribution, and measure the similarity of the Gaussian distributions using the normalized Wasserstein distance (NWD). The Wasserstein distance can measure distribution similarity even without overlap or with negligible overlap. Furthermore, the Wasserstein distance (NWD) is insensitive to objects of different scales, making it suitable for measuring the similarity between small objects. Specifically:
[0076] ① Let the bounding box be B = (cx, cy, w, h). For two bounding boxes, the second-order Wasserstein distance is defined as:
[0077]
[0078] ② Use the normalized exponent to measure similarity:
[0079]
[0080] Where C is a constant determined by the dataset, and C is set as the average absolute size of the targets in the dataset; the normalized Wasserstein distance with the shape scale factor added is:
[0081]
[0082] ③ The normalized Wasserstein distance loss function based on the shape scale factor is:
[0083] L NWD-shape =1-NWD(B a B b ).
[0084] Defect detection comprises two subtasks: defect localization and defect classification. However, these two subtasks have different preferences for defect features. Localization tends to require edge features, while classification requires semantic contextual information. Typical single-stage object detection methods have different receptive field branches, each a coupled head that receives the same feature map input and then performs predictions for both classification and localization. Some methods attempt to decouple the output heads, splitting them into independent branches for defect classification and bounding box regression tasks respectively. While this decoupling method allows the two different subtasks to converge better, it doesn't fundamentally solve the problem due to the inconsistent feature preferences of the two subtasks. To address this issue, the Adaptive Feature Fusion Decoupling Head Module (AFFD) in step S2 of this embodiment generates spatially coarse and semantically rich feature codes for the classification task, while providing high-resolution feature maps containing edge information for the localization task to better regress object boundaries. This further decouples the feature codes for classification and localization tasks, improving the overall network performance.
[0085] Secondly, the inconsistency between different feature scales is a limitation of single-stage object detectors based on feature pyramids. Although structures such as FPN (Feature Pyramid Network) fuse multi-scale features through top-down and bottom-up paths, this fusion is sometimes insufficient. Each layer of feature maps in the feature pyramid may not completely eliminate differences between different scales during the fusion process, resulting in insufficient feature representation. Unlike other feature fusion methods, such as element-wise summation or concatenation, this method adds weight parameters to the branches of feature maps at different scales, enabling the network to directly learn how to spatially filter features from other layers and fuse features from different layers together. In this way, the detection head can adaptively select the most useful features based on the spatial location and scale context of each feature, thereby improving detection accuracy. Furthermore, in step S2 of this embodiment, the adaptive feature fusion decoupling head module AFFD adds a fourth branch to the small target detection layer based on the YOLOv5 network structure, further improving the detection capability for small targets.
[0086] In step S2 of this embodiment, the adaptive feature fusion decoupling head module AFD performs deep and shallow adaptive feature fusion in front of the detection head through a feature pyramid-like structure, and then sends them to the head for corresponding decoding output. The classification task fuses features from a deeper layer of the current layer to embed rich semantic features into the current layer; the regression task fuses features from two adjacent layers to obtain rich spatial detail information.
[0087] As attached Figure 1 As shown, the network structure corresponding to the adaptive feature fusion decoupling head module AFFD includes a Neck and an AFFD Head; the Neck uses FPN, which includes p1, p2, p3 and p4; where p1-p4 represent features at different levels in the feature pyramid, and each feature has a different spatial resolution;
[0088] The AFFD Head includes AFFD-x-cls and AFFD-x-reg, which correspond one-to-one with p1, p2, p3 and p4 in FPN. AFFD-x-cls and AFFD-x-reg represent the feature map obtained after decoupling the classification and regression tasks of the features of the x-th layer and performing adaptive feature fusion.
[0089] Specifically, for the p2 layer features, AFFD-2-cls is used to receive feature maps from AFFD-3-cls and perform weighted fusion by learning weight coefficients α and β; AFFD-2-reg is used to receive feature maps from AFFD-1-reg and AFFD-3-reg and perform weighted fusion by learning weight coefficients α, β and γ.
[0090] Example 2:
[0091] This embodiment provides a surface defect detection system for low-voltage cable sheaths, the system comprising:
[0092] The loss function design module is used to design loss functions based on the shape and scale of the bounding box according to the analysis of the small target defect detection task. These functions are used to train the cable low-voltage sheath defect detection model and improve the sensitivity of anchor-frame-based detectors to small target defects in bounding box regression.
[0093] The decoupling head design module is used to design an adaptive feature fusion decoupling head module AFFD based on the structure and optimization path of the low-voltage sheath defect detection model of the cable, further decoupling the defect localization and classification tasks, so that the defect detection model learns suitable feature representations in different sub-tasks, thereby improving the efficiency and accuracy of the defect detection model.
[0094] The modular processing module is used to design and train a modular cable low-voltage sheath defect detection model by combining the loss function design module and the decoupling head design module. The final obtained cable low-voltage sheath detection model is used to detect defects in the input image. The defect detection includes two sub-tasks: defect localization and defect classification.
[0095] The loss function design module in this embodiment includes:
[0096] The weight coefficient setting submodule is used to set weight coefficients in the horizontal and vertical directions respectively for the shape deviation between the ground truth (GT) bounding box and the predicted bounding box, as shown in the following formula:
[0097]
[0098] Among them, w mbr and h mbr These represent the width and height of the smallest bounding rectangle of the truth box and the prediction box, respectively; and These are the coordinates of the top left and bottom right corners of the prediction box and the truth box, respectively.
[0099] The modeling submodule models the bounding boxes as two-dimensional Gaussian distributions and measures the similarity of these distributions using the normalized Wasserstein distance (NWD). The Wasserstein distance measures distribution similarity even without overlap or with negligible overlap. Furthermore, the NWD is insensitive to objects of different scales, making it suitable for measuring the similarity between small objects. Specifically:
[0100] Let the bounding box be B = (cx, cy, w, h). For two bounding boxes, the second-order Wasserstein distance is defined as:
[0101]
[0102] Similarity is measured using a normalized exponent:
[0103]
[0104] Where C is a constant determined by the dataset, and C is set as the average absolute size of the targets in the dataset; the normalized Wasserstein distance with the shape scale factor added is:
[0105]
[0106] The normalized Wasserstein distance loss function based on the shape scale factor is:
[0107] L NWD-shape =1-NWD(B a B b ).
[0108] In this embodiment, the adaptive feature fusion decoupling head module AFD is used to generate spatially coarse and semantically stronger feature codes for classification tasks, while providing high-resolution feature maps containing edge information for localization tasks, regressing object boundaries, further decoupling the feature codes for classification and localization tasks, and improving the overall network performance. The adaptive feature fusion decoupling head module AFD adds a fourth branch to the small target detection layer based on the YOLOv5 network structure, further improving the detection capability of small targets.
[0109] As attached Figure 1 As shown, the network structure corresponding to the adaptive feature fusion decoupling head module AFFD in this embodiment includes a Neck and an AFFD Head; the Neck adopts FPN, which includes p1, p2, p3 and p4; where p1-p4 represent features at different levels in the feature pyramid, and each feature has a different spatial resolution;
[0110] The AFFD Head includes AFFD-x-cls and AFFD-x-reg, which correspond one-to-one with p1, p2, p3, and p4 in FPN. AFFD-x-cls and AFFD-x-reg represent the feature map obtained after decoupling the classification and regression tasks of the features of the x-th layer and performing adaptive feature fusion.
[0111] Example 3:
[0112] This embodiment also provides an electronic device, including: a memory and a processor;
[0113] The memory stores the instructions executed by the computer.
[0114] The processor executes computer execution instructions stored in the memory, causing the processor to perform the cable low-voltage sheath surface defect detection method in any embodiment of the present invention.
[0115] The processor can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), off-the-shelf programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor can be a microprocessor or any conventional processor.
[0116] Memory is used to store computer programs and / or modules. The processor implements various functions of the electronic device by running or executing the computer programs and / or modules stored in the memory, and by accessing data stored in the memory. Memory can mainly include a program storage area and a data storage area. The program storage area can store the operating system, at least one application program required for a function, etc.; the data storage area can store data created based on the use of the terminal, etc. In addition, memory can also include high-speed random access memory, and can also include non-volatile memory, such as hard disks, RAM, plug-in hard disks, smart memory cards (SMC), secure digital storage (SD) cards, flash memory cards, at least one disk storage device, flash memory devices, or other volatile solid-state storage devices.
[0117] Example 4:
[0118] This embodiment also provides a computer-readable storage medium storing multiple instructions, which are loaded by a processor to cause the processor to execute the cable low-voltage sheath surface defect detection method according to any embodiment of the present invention. Specifically, a system or apparatus equipped with a storage medium may be provided, on which software program code implementing the functions of any of the above embodiments is stored, and the computer (or CPU or MPU) of the system or apparatus can read and execute the program code stored in the storage medium.
[0119] In this case, the program code read from the storage medium can itself implement the function of any of the above embodiments, and therefore the program code and the storage medium storing the program code constitute part of the present invention.
[0120] Storage media embodiments for providing program code include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RYM, DVD-RW, DVD+RW), magnetic tapes, non-volatile memory cards, and ROMs. Alternatively, program code can be downloaded from a server computer via a communication network.
[0121] Furthermore, it should be clear that not only can the program code read by the computer be executed, but also the operating system or other components operating on the computer can be instructed based on the program code to perform some or all of the actual operations, thereby realizing the function of any of the embodiments described above.
[0122] Furthermore, it is understood that the program code read from the storage medium is written to the memory set in the expansion board inserted into the computer or to the memory set in the expansion unit connected to the computer. Then, based on the instructions of the program code, the CPU or other components installed on the expansion board or expansion unit execute some and all of the actual operations, thereby realizing the function of any of the embodiments described above.
[0123] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for detecting surface defects in the low-voltage sheath of cables, characterized in that, The method is as follows: S1. Based on the analysis of the small target defect detection task, a loss function based on the bounding box shape and scale is designed for training the low-voltage cable sheath defect detection model, thereby improving the sensitivity of anchor-based detectors to small target defects in bounding box regression. S2. Based on the analysis of the structure and optimization path of the low-voltage cable sheath defect detection model, an adaptive feature fusion decoupling head module AFFD is designed to further decouple the defect localization and classification tasks, so that the defect detection model learns suitable feature representations in different sub-tasks, thereby improving the efficiency and accuracy of the defect detection model. S3. Combining steps S1 and S2, design and train a modular cable low-voltage sheath defect detection model. Use the final obtained cable low-voltage sheath detection model to perform defect detection on the input image. The defect detection includes two sub-tasks: defect localization and defect classification. The loss function designed based on the bounding box shape and scale is as follows: To account for the shape deviation between the ground truth bounding box and the predicted bounding box, weighting coefficients are set in the horizontal and vertical directions, respectively, as follows: ; ; in, and Let represent the width and height of the smallest bounding rectangle of the truth box and the prediction box, respectively; )and( , () represents the coordinates of the top left and bottom right corners of the prediction box and the truth box, respectively; The bounding boxes are modeled as two-dimensional Gaussian distributions, and the similarity of these distributions is measured using normalized Wasserstein distance. The Wasserstein distance measures distribution similarity even when there is no overlap or negligible overlap. Specifically: Let the bounding box be B = (cx, cy, w, h). For two bounding boxes, the second-order Wasserstein distance is defined as: ; Similarity is measured using a normalized exponent: ; Where C is a constant determined by the dataset, and is set as the average absolute size of the targets in the dataset; the normalized Wasserstein distance with shape scale factor added is: ; ; ; The normalized Wasserstein distance loss function based on the shape scale factor is: ; The decoupled head module AFD, which performs deep and shallow adaptive feature fusion in front of the detection head through a feature pyramid structure, and then sends them to the head for corresponding decoding output. The classification task fuses features from a deeper layer of the current layer to embed rich semantic features into the current layer; the regression task fuses features from two adjacent layers to obtain rich spatial detail information. The adaptive feature fusion decoupling head module AFD adds a fourth branch to the small target detection layer based on the YOLOv5 network structure, further improving the detection capability of small targets; The network structure corresponding to the adaptive feature fusion decoupling head module AFFD includes Neck and AFFD Head; Neck adopts FPN, which includes p1, p2, p3 and p4; where p1-p4 represent features at different levels in the feature pyramid, and each feature has a different spatial resolution.
2. The method for detecting surface defects in low-voltage cable sheaths according to claim 1, characterized in that, The Adaptive Feature Fusion Decoupling Head Module (AFFD) is used to generate spatially coarse and semantically stronger feature codes for classification tasks, while providing high-resolution feature maps containing edge information for localization tasks to regress object boundaries, further decoupling the feature codes for classification and localization tasks and improving the overall network performance.
3. The method for detecting surface defects in low-voltage cable sheaths according to claim 1, characterized in that, The AFFD Head includes AFFD-x-cls and AFFD-x-reg, which correspond one-to-one with p1, p2, p3 and p4 in FPN. AFFD-x-cls and AFFD-x-reg represent the feature map obtained after decoupling the classification and regression tasks of the features of the x-th layer and performing adaptive feature fusion. Specifically, for the p2 layer features, AFFD-2-cls is used to receive feature maps from AFFD-3-cls and perform weighted fusion by learning weight coefficients α and β; AFFD-2-reg is used to receive feature maps from AFFD-1-reg and AFFD-3-reg and perform weighted fusion by learning weight coefficients α, β and γ.
4. The method for detecting surface defects in low-voltage cable sheaths according to claim 1, characterized in that, The specific method for obtaining the input image is as follows: The cable is guided to the imaging unit via a transmission device. The imaging unit is equipped with a light source and a camera unit, designed for image acquisition and transmission. After image acquisition, the images are transmitted to the back-end processing equipment via a network solution. The back-end processing equipment is equipped with trained computer vision target detection algorithms to process and analyze the images, thereby identifying defects and displaying the analysis results.
5. A surface defect detection system for low-voltage cable sheaths, characterized in that, The system includes: The loss function design module is used to design loss functions based on the shape and scale of the bounding box according to the analysis of the small target defect detection task. These functions are used to train the cable low-voltage sheath defect detection model and improve the sensitivity of anchor-frame-based detectors to small target defects in bounding box regression. The decoupling head design module is used to design an adaptive feature fusion decoupling head module AFFD based on the structure and optimization path of the low-voltage sheath defect detection model of the cable, further decoupling the defect localization and classification tasks, so that the defect detection model learns suitable feature representations in different sub-tasks, thereby improving the efficiency and accuracy of the defect detection model. The modular processing module is used to design and train a modular cable low-voltage sheath defect detection model by combining the loss function design module and the decoupling head design module. The final obtained cable low-voltage sheath detection model is used to detect defects in the input image. The defect detection includes two sub-tasks: defect localization and defect classification. The loss function design module includes: The weight coefficient setting submodule is used to set weight coefficients in the horizontal and vertical directions respectively for the shape deviation between the ground truth bounding box and the predicted bounding box, as shown in the following formula: ; ; in, and Let represent the width and height of the smallest bounding rectangle of the truth box and the prediction box, respectively; )and( , () represents the coordinates of the top left and bottom right corners of the prediction box and the truth box, respectively; The modeling submodule models the bounding boxes as two-dimensional Gaussian distributions and measures the similarity of these distributions using normalized Wasserstein distance. Wasserstein distance measures distribution similarity even when there is no overlap or negligible overlap. Specifically: Let the bounding box be B = (cx, cy, w, h). For two bounding boxes, the second-order Wasserstein distance is defined as: ; Similarity is measured using a normalized exponent: ; Where C is a constant determined by the dataset, and is set as the average absolute size of the targets in the dataset; the normalized Wasserstein distance with shape scale factor added is: ; ; ; The normalized Wasserstein distance loss function based on the shape scale factor is: ; The Adaptive Feature Fusion Decoupling Head Module (AFFD) generates spatially coarse and semantically stronger feature codes for classification tasks, while providing high-resolution feature maps containing edge information for localization tasks to regress object boundaries. This further decomposes the feature codes for classification and localization tasks, improving the overall network performance. The AFD decoupling head module adds a fourth branch to the small target detection layer based on the YOLOv5 network structure, further improving the detection capability for small targets. The network structure corresponding to the adaptive feature fusion decoupling head module AFFD includes Neck and AFFD Head; Neck adopts FPN, which includes p1, p2, p3 and p4; where p1-p4 represent features at different levels in the feature pyramid, and each feature has a different spatial resolution.
6. The cable low-voltage sheath surface defect detection system according to claim 5, characterized in that, The AFFD Head includes AFFD-x-cls and AFFD-x-reg, which correspond one-to-one with p1, p2, p3, and p4 in FPN. AFFD-x-cls and AFFD-x-reg represent the feature map obtained after decoupling the classification and regression tasks of the features of the x-th layer and performing adaptive feature fusion.
7. An electronic device, characterized in that, include: Memory and at least one processor; The memory contains computer programs; The at least one processor executes the computer program stored in the memory, causing the at least one processor to perform the cable low-voltage sheath surface defect detection method as described in any one of claims 1 to 4.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that can be executed by a processor to implement the method for detecting surface defects in low-voltage cable sheaths as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Model training method and device
CN111797711A
Wasserstein distance and difference measurement-combined chest radiograph anomaly recognition domain self-adaptive method and Wasserstein distance and difference measurement-combined chest radiograph anomaly recognition domain self-adaptive system
CN115601535A