Intelligent detection method for appearance defects of data lines based on image processing

By adaptively adjusting the contribution weights of the bottom features of the feature pyramid network and combining spatial and channel attention maps, the detection of data line defects is optimized, solving the problems of insufficient detection accuracy and robustness, and achieving efficient detection of multi-scale defects on the surface of data lines.

CN122391139APending Publication Date: 2026-07-14CHENZHOU YIDEMI ELECTRONICS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHENZHOU YIDEMI ELECTRONICS CO LTD
Filing Date
2026-04-17
Publication Date
2026-07-14

AI Technical Summary

Technical Problem

Existing image processing-based data cable defect detection methods have shortcomings in terms of detection accuracy and robustness. In particular, when faced with large differences in the scale of surface defects on data cables, they cannot take into account both detailed information and background noise, leading to over-detection or under-detection.

Method used

By adaptively adjusting the feature contribution weights of the bottom layer of the feature pyramid network and combining spatial and channel attention maps, the feature contribution ratio of each pixel is dynamically adjusted to optimize the feature fusion process. Adaptive bottom layer feature contribution weights are generated by utilizing grayscale features, local textures, and channel activation modes.

Benefits of technology

It significantly improves the ability to detect multi-scale defects on the surface of complex data lines, achieving robust and accurate defect detection, and effectively preserving small defect details and suppressing background noise in complex environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122391139A_ABST
    Figure CN122391139A_ABST
Patent Text Reader

Abstract

The present application relates to a kind of data line appearance defect intelligent detection methods based on image processing, belong to image processing technical field.The method first determines the basic weight coefficient according to the global statistical characteristics of data line appearance image, provides the benchmark matched with overall scene for subsequent adjustment, subsequent to each pixel point, first from the spatial angle, utilize spatial attention to combine the local texture and gray feature of pixel point to determine the spatial adjustment factor of pixel point, then from the channel angle, utilize channel attention and the feature map used when obtaining channel attention to determine the channel feature of each channel of pixel point, determine the channel adjustment factor of pixel point, finally, the adaptive bottom feature contribution weight of three is obtained, the feature pyramid multi-feature fusion process is optimized to balance detail and semantics, while effectively retaining the details required for small defects, suppress background noise.The present application can significantly improve the detection ability of complex data line surface multi-scale defects, realize robust and accurate defect detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and in particular to an intelligent detection method for appearance defects in data cables based on image processing. Background Technology

[0002] In today's world of ubiquitous electronic products, the manufacturing quality of data cables directly impacts user experience and the safe and stable operation of devices. On one hand, cosmetic defects such as surface scratches, cracks, stains, and deformation not only reduce the product's aesthetics, affecting consumer purchasing decisions and damaging brand image, but also indicate potential problems with the internal structure of the data cable. For example, damaged insulation may lead to leakage risks, and deformation of connection points may affect data transmission stability and charging efficiency, thereby threatening user safety and the lifespan of the device. Therefore, the detection of cosmetic defects in data cables is of paramount importance.

[0003] To ensure efficient detection of surface defects in data cables, image processing-based methods are often employed for this purpose, aiming for high-efficiency and automated detection. Deep learning-based methods for detecting surface defects in data cables can retain the necessary detail information for small defects while using semantic information to suppress background noise. This effectively addresses the challenge of large differences in defect scale, significantly improving detection accuracy and robustness. However, during the detection process, traditional feature pyramids typically set fixed weights for the contribution of lower-level features during fusion. These weights control the degree to which detailed information (such as edges and textures) is retained in the final features. But given the large scale differences in defects on data cables, in surface defect detection scenarios, small scratches require high-resolution lower-level details to capture, while large stains or dents rely on high-level semantic information to understand the overall shape. Furthermore, factors such as lighting fluctuations and product color variations in the production environment can affect image quality, leading to varying degrees of reliability of lower-level details. Therefore, using fixed weights for the lower-level feature contributions in the feature pyramid cannot accommodate all scenarios: excessively high weights can introduce noise leading to over-detection, while excessively low weights can miss small defects, resulting in under-detection.

[0004] Therefore, current image processing-based data cable defect detection methods suffer from technical shortcomings, including insufficient detection accuracy and robustness. Summary of the Invention

[0005] In view of this, the present invention provides an intelligent detection method for data cable appearance defects based on image processing, so as to solve the technical problems of insufficient detection accuracy and robustness of current image processing-based data cable defect detection methods.

[0006] The present invention provides an intelligent detection method for appearance defects of data cables based on image processing, comprising: A grayscale image of the appearance of the data line is obtained and recorded as the image to be identified. The image to be identified is input into a trained feature pyramid network to generate multi-layer feature maps. The channel attention map and spatial attention map corresponding to the image to be identified are calculated using the lowest layer feature map in the multi-layer feature maps. The basic weight coefficients are determined based on the overall grayscale features of the image to be identified and the probability of historical defects in the data line. The spatial attention value of any pixel in the image to be identified is determined based on the spatial attention map. The spatial adjustment factor of any pixel is determined based on the spatial attention value, local texture features, and local grayscale features of any pixel. The channel attention value of any pixel in each channel is determined based on the channel attention map. After determining the activation intensity, number of activated channels, and activation intensity distribution features of each channel of any pixel based on the bottom-level feature map, the channel adjustment factor of any pixel is determined. Based on the basic weight coefficients, the spatial adjustment factor of any pixel, and the channel adjustment factor of any pixel, the adaptive low-level feature contribution weight of any pixel is determined. Based on the adaptive low-level feature contribution weight of each pixel in the image to be identified, feature fusion based on the trained feature pyramid network is completed, thereby completing the defect detection on the image to be identified.

[0007] Furthermore, the trained feature pyramid network is built on a residual network and includes a convolutional block attention module.

[0008] Furthermore, the channel attention map and spatial attention map corresponding to the image to be identified are calculated using the lowest-level feature map in the multi-layer feature map, including: The lowest-level feature map is input into the convolutional block attention module to calculate the channel attention map and the spatial attention map.

[0009] Furthermore, the basic weighting coefficients are determined based on the overall grayscale features of the image to be identified and the probability of historical defects in the data line, including: After normalizing the gray values ​​of each pixel in the image to be identified, the mean gray value and the standard deviation of the gray value of the image to be identified are calculated. The product of the mean gray value and the standard deviation of the gray value of the image to be identified is recorded as the first basic weight characterization term. The probability of historical defects occurring in the current production batch of the data line up to the present is statistically analyzed and recorded as the second basic weight characterization item. The basic weight coefficient is determined based on the first basic weight characterization item and the second basic weight characterization item, and the basic weight coefficient is proportional to both the first basic weight characterization item and the second basic weight characterization item.

[0010] Further, determining the spatial adjustment factor for any given pixel includes: A window of a preset size centered on any pixel is denoted as the target window. The local binary mode value of each pixel in the target window is calculated. The Simpson diversity index of all local binary mode values ​​in the target window is calculated and denoted as the local texture complexity of any pixel. The product of the spatial attention value of any pixel and the local texture complexity of any pixel is denoted as the first spatial adjustment characterization term. Calculate the average gradient magnitude and gradient direction entropy of each pixel within the target window. Record the ratio of the standard deviation of gray values ​​within the target window to the standard deviation of gray values ​​in the image to be identified as the local contrast prominence. Multiply the average gradient magnitude and gradient direction entropy and sum them with the local contrast prominence to obtain the second spatial adjustment characterization term. The spatial adjustment factor of any pixel is determined based on the first spatial adjustment characteristic and the second spatial adjustment characteristic, and the spatial adjustment factor of any pixel is proportional to both the first spatial adjustment characteristic and the second spatial adjustment characteristic.

[0011] Further, determining the channel adjustment factor for any given pixel includes: The absolute value of the activation value of any pixel in any channel at the corresponding position on the bottom feature map is recorded as the activation intensity of any pixel in any channel. The product of the activation intensity of any pixel in any channel and the channel attention value of any pixel in any channel is recorded as the weighted activation intensity of any pixel in any channel. The sum of the weighted activation intensities of any pixel in all channels is recorded as the first channel adjustment characterization term of any pixel. The ratio of the number of channels whose activation intensity exceeds a preset activation intensity threshold to the total number of channels at the corresponding position of any pixel in the bottom layer feature map is recorded as the activation channel ratio. The normalized value of the difference between the kurtosis and the standard kurtosis value of the activation intensity of any pixel at the corresponding position in the bottom layer feature map is recorded as the activation intensity clustering. The ratio of the maximum value to the mean value of the activation intensity of any pixel at the corresponding position in the bottom layer feature map is recorded as the activation intensity prominence. The sum of the normalized value of the reciprocal of the activation channel ratio, the activation intensity clustering, and the activation intensity prominence is recorded as the second channel adjustment characterization term of any pixel. The channel adjustment factor of any pixel is determined based on the first channel adjustment characteristic and the second channel adjustment characteristic, and the channel adjustment factor of any pixel is proportional to both the first channel adjustment characteristic and the second channel adjustment characteristic.

[0012] Further, determining the adaptive low-level feature contribution weight for any pixel includes: The importance of the underlying features of any pixel is determined based on the basic weight coefficient, the spatial adjustment factor of any pixel, and the channel adjustment factor of any pixel. The preset maximum underlying feature contribution weight is weighted according to the importance of the underlying features of any pixel to obtain the adaptive underlying feature contribution weight of any pixel.

[0013] The advantages of this invention compared to the prior art are: This invention first obtains basic weight coefficients based on the global statistical characteristics of the data cable appearance image, providing a benchmark for subsequent adjustments that matches the overall scene. Then, for each pixel, it first determines the corresponding spatial adjustment factor from a spatial perspective by combining spatial attention with the local texture and grayscale features of the appearance image. Next, from a channel perspective, it determines the channel features of each pixel corresponding to each channel by using channel attention and the corresponding feature maps used in the channel attention acquisition process, thus determining the corresponding channel adjustment factor. Finally, based on the basic weight coefficients and the two pixel-level adjustment factors, it obtains an adaptive low-level feature contribution weight, optimizing the multi-feature fusion process of the feature pyramid to balance details and semantics, effectively preserving the details required for small defects while suppressing background noise. This invention can significantly improve the detection capability of multi-scale defects on complex data cable surfaces, achieving robust and accurate defect detection. Attached Figure Description

[0014] To more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0015] Figure 1 This is a flowchart illustrating an intelligent detection method for appearance defects of data cables based on image processing, provided in Embodiment 1 of the present invention. Detailed Implementation

[0016] The overall concept of this invention is as follows: This invention performs pixel-level adaptive adjustment of the contribution weights of the bottom-level features during feature pyramid fusion, enabling the deep learning network to dynamically and differentially adjust the contribution ratios of different levels of information in the feature pyramid based on the content of the input image, thereby improving the detection accuracy of multi-scale defects on the surface of data lines. First, basic weight coefficients are obtained based on the global statistical characteristics of the image, providing a benchmark for subsequent adjustments that matches the overall scene. Second, pixel-level adjustment factors are generated from both spatial and channel perspectives. From a spatial perspective, spatial attention is combined with local features of the original image to determine the probability that a target pixel belongs to an edge-type defect (such as a scratch). From a channel perspective, channel attention and feature maps are used to calculate channel features and obtain their local feature activation patterns. Finally, based on the basic weight coefficients and the two pixel-level adjustment factors, the final adaptive weights are obtained. By adaptively adjusting the contribution weights of the bottom-level features according to the actual situation of each image, the degree of preservation of detail information can be finely adjusted, balancing detail and semantics. This allows for the preservation of details required for small defects while suppressing background noise, significantly improving the detection capability for multi-scale defects on the surface of complex data lines, achieving robust and accurate defect detection.

[0017] To further illustrate the technical solution of the present invention, specific embodiments are described below.

[0018] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of the invention include a particular feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. Furthermore, a particular feature, structure, or characteristic in one or more embodiments may be combined in any suitable form, and the terms "comprising," "including," "having," and variations thereof mean "including, but not limited to," unless otherwise specifically emphasized.

[0019] It should be understood that the sequence number of each step in the following embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0020] Method Implementation Examples: See Figure 1 This is a flowchart illustrating an intelligent detection method for data cable appearance defects based on image processing, as provided in Embodiment 1 of the present invention. Figure 1 As shown, the method may include the following steps: S101, Obtain a grayscale image of the appearance of the data line and record it as the image to be identified. Input the image to be identified into the trained feature pyramid network to generate multi-layer feature maps. Calculate the channel attention map and spatial attention map corresponding to the image to be identified using the lowest-level feature map in the multi-layer feature maps.

[0021] To achieve intelligent detection of appearance defects in data cables, it is first necessary to acquire images of the data cable's appearance. This embodiment uses a high-resolution industrial camera. The data cable is placed stably on an adjustable stage, and ample, soft illumination is provided by multiple evenly distributed LED light sources to avoid shadow interference. The industrial camera captures images of the data cable under inspection, covering its overall appearance and key areas where defects may exist. High-quality images of the data cable's appearance are acquired and then processed into grayscale to obtain the image to be identified. This provides rich and reliable raw data for subsequent accurate detection of appearance defects in the data cable.

[0022] Because this embodiment aims to optimize and adjust the contribution weights of the bottom-level features during fusion from both spatial and channel perspectives, it is necessary to further obtain the corresponding spatial attention map and channel attention map after acquiring the image to be recognized. Specifically, this embodiment obtains the spatial attention map and channel attention map corresponding to the image to be recognized by inputting the image to be recognized into a pre-trained Feature Pyramid Network (FPN). The training of the Feature Pyramid Network is completed using a large-scale data line defect dataset. The Feature Pyramid Network is preferably constructed using a Residual Network (ResNet), and particularly preferably using ResNet-50 as the backbone to obtain an Attention-FPN type Feature Pyramid Network. A Convolutional Block Attention (CBAM) module is inserted into the P2 feature layer, which is the bottommost feature layer. The Convolutional Block Attention (CBAM) module adjusts the input size required by the network, such as 512×512, when the image to be recognized is input into the trained Attention-FPN network. The grayscale values ​​of each pixel are then normalized (e.g., divided by 255 or standardized according to the mean and standard deviation of the ImageNet image database) for easy input. After the image is input, the backbone network extracts feature maps of different scales, generating multi-layer feature maps. The lowest-level feature map generated by the specially selected P2 layer (the lowest-level feature layer), which has the highest spatial resolution, is then fed into the CBAM attention module. First, the channel attention map is calculated, obtained through global pooling, MLP (Multilayer Perceptron), and the Sigmoid activation function. Then, the spatial attention map is calculated, obtained through channel dimension merging (e.g., average / max pooling), concatenation, convolution, and the Sigmoid activation function. These two maps respectively reflect the importance of the channel and location.

[0023] Thus, we have obtained the grayscale image corresponding to the current data line appearance image, which is also the image to be identified, as well as the spatial attention map and channel attention map corresponding to the image to be identified, in order to carry out subsequent analysis.

[0024] S102, determine the basic weight coefficients based on the overall grayscale features of the image to be identified and the probability of historical defects in the data line; determine the spatial attention value of any pixel in the image to be identified based on the spatial attention map; determine the spatial adjustment factor of any pixel based on the spatial attention value, local texture features, and local grayscale features of any pixel; determine the channel attention value of any pixel in each channel based on the channel attention map; and determine the activation intensity, number of activated channels, and activation intensity distribution characteristics of each channel of any pixel based on the bottom-level feature map; and then determine the channel adjustment factor of any pixel.

[0025] In the intelligent detection of defects in data cable appearance, accurate and efficient defect identification requires assigning appropriate weights to different pixels in the image. This embodiment first examines the global statistical characteristics of the image. These characteristics reflect fundamental information such as overall brightness, contrast, and the probability of defect occurrence, and can be used to construct basic weight coefficients, providing macroscopic guidance for detection. However, these basic weight coefficients, constructed from the global statistical characteristics, struggle to capture subtle local differences in the image. This is because the features of different locations and channels in the image are complex and diverse. Local characteristics such as the probability of defects from a spatial perspective, edge intensity, and pixel activation intensity from a channel perspective play a crucial role in accurate defect detection. Therefore, relying solely on basic weight coefficients is insufficient for accurate and efficient detection. It is also necessary to obtain adjustment factors corresponding to each pixel from both spatial and channel dimensions. Then, the basic weight coefficients are fused with these spatial and channel adjustment factors to generate the final adaptive weights for each pixel. This approach balances overall and local image features, improving the accuracy and reliability of detection.

[0026] Therefore, the basic weight coefficients are first obtained based on the global statistical characteristics of the image: The grayscale mean of the image to be identified reflects the overall brightness. Different data line colors (such as black / white) will change the overall brightness of the image to be identified, thus affecting the visibility of underlying details. The grayscale standard deviation serves as the global contrast; when the contrast is low, defects may be blurred, requiring the weakening of underlying details to prevent noise. The prior probability of defects is based on historical batch statistics; when defects are frequent, more refined detection is needed, increasing the weight of the underlying layers. Based on the above principles, by combining these three representations reflecting different global characteristics through preset coefficients, a basic weight coefficient applicable to each pixel in the image to be identified can be calculated, including: After normalizing the gray values ​​of each pixel in the image to be identified, the mean gray value and the standard deviation of the gray value of the image to be identified are calculated. The product of the mean gray value and the standard deviation of the gray value of the image to be identified is recorded as the first basic weight characterization term. The probability of historical defects occurring in the current production batch of the data line up to the present is statistically analyzed and recorded as the second basic weight characterization item. The basic weight coefficient is determined based on the first basic weight characterization item and the second basic weight characterization item, and the basic weight coefficient is proportional to both the first basic weight characterization item and the second basic weight characterization item.

[0027] The process of normalizing the gray values ​​of each pixel in the image to be identified before calculating the corresponding gray mean and gray standard deviation is to unify the magnitudes of the first and second basic weight representation terms, thereby preventing one of the two representation terms from becoming dominant and causing the other to lose its representational function.

[0028] The basic weighting coefficient takes into account the overall brightness, contrast, and probability of defects in the image to be identified, providing a unified and global reference standard for subsequent finer adjustments at the pixel level, ensuring that subsequent adjustments do not deviate from the basic condition of the image as a whole.

[0029] Furthermore, as a preferred embodiment, the basic weighting coefficient is:

[0030] in, This represents the basic weight coefficient of the i-th pixel. It is important to emphasize that in this embodiment, the basic weight coefficients of each pixel in the image to be identified are equal. as well as These represent the mean gray value and the standard deviation of the gray values ​​calculated after normalization of the gray values ​​of each pixel in the image to be recognized, respectively. When the image is dark, the mean gray value is... When the grayscale value is relatively small, the underlying details are easily overwhelmed by noise. Therefore, it is necessary to reduce the fusion weight of the underlying details to avoid introducing noise. Conversely, when the image is brighter, the average grayscale value should be reduced. When the overall contrast of the image to be recognized is relatively large, the underlying details are clear, and the contribution of the underlying layers can be appropriately enhanced to capture minor defects; when the overall contrast of the image to be recognized is low, the corresponding standard deviation of the grayscale value is [missing information]. When the contrast is small, the grayscale of the defect is close to that of the background. If we rely on the low-level details, it is easy to generate a lot of false defects. Therefore, we should rely more on high-level semantic information (global context) to identify the defect area. Thus, we need to reduce the fusion weight of the low-level details. When the contrast is high, the opposite is true. We need to increase the fusion weight of the low-level details. This indicates the probability of defects occurring in the current batch of data lines up to the current moment. If the current batch has a high incidence of defects, more refined detection is required. The weight of the underlying detail fusion should be increased to prevent missed detections. The probability of defects occurring in the current batch can be obtained by using the detection results of appearance defects of data lines in the current batch before the current moment using a traditional or defect detection deep learning network that has not been improved by the scheme in this embodiment. This indicates normalization. Since normalization requires a certain amount of data, it is necessary to ensure a certain amount of data reserves, such as 100 images of the appearance of the data cable. Data can be obtained from the current batch or the most recent batch. This embodiment does not specifically limit the data.

[0031] After obtaining the basic weight coefficients, the spatial adjustment factor and channel adjustment factor are then analyzed and obtained. It should be noted that the analysis of the spatial adjustment factor and channel adjustment factor is performed on a single pixel. Therefore, each pixel in the image to be recognized will obtain a different spatial adjustment factor and channel adjustment factor.

[0032] From a spatial perspective, features such as spatial attention maps and normalized gradient magnitudes can be used to describe the local spatial characteristics of each pixel in terms of edge strength, local contrast, and local texture details, thereby generating spatial adjustment factors to determine the degree to which the contribution of underlying details needs to be adjusted at each location. From a channel perspective, channel attention is used to weight channel activation energy, and the activation intensity, activation sparsity, and activation intensity distribution characteristics of pixels in the channels are examined to characterize the local features of each pixel in the channel dimension, thus obtaining channel adjustment factors.

[0033] Specifically, regarding the spatial adjustment factor, it aims to determine the degree of adjustment of underlying details for each pixel location in a spatial dimension: First, the spatial attention value directly reflects the feature pyramid network's judgment on the probability of a defect at that location. Areas with high attention are likely to have defects and require enhanced low-level details for accurate segmentation, while areas with low attention may be background and can weaken the contribution of the low-level layers. Second, data line scratches exhibit strong edge features, and scratched pixels usually have a consistent direction. Therefore, locations with large grayscale gradient magnitudes and high directional consistency are likely scratches and require enhanced low-level details to preserve edge information, while flat areas do not require enhancement. At the same time, high local contrast indicates that the pixel may be a defect or an edge, requiring enhanced low-level details, while low-contrast areas may be a uniform background. Finally, the complexity of the LBP (Local Binary Patterns) values ​​in a local region reflects local texture changes. The texture of defective areas often differs from that of normal surfaces. Locations with high texture complexity require enhanced low-level details for differentiation, while areas with uniform texture do not require much detail.

[0034] By combining the above feature analysis, the spatial adjustment factor of any pixel can be determined, including: A window of a preset size centered on any pixel is denoted as the target window. The local binary mode value of each pixel in the target window is calculated. The Simpson diversity index of all local binary mode values ​​in the target window is calculated and denoted as the local texture complexity of any pixel. The product of the spatial attention value of any pixel and the local texture complexity of any pixel is denoted as the first spatial adjustment characterization term. After normalizing the gray values ​​of each pixel in the target window, calculate the average gradient magnitude and gradient direction entropy of each pixel. Calculate the ratio of the standard deviation of gray values ​​in the target window to the standard deviation of gray values ​​in the image to be identified, and record it as the local contrast salience. Multiply the average gradient magnitude and gradient direction entropy and sum them with the local contrast salience to obtain the second spatial adjustment characterization term. The spatial adjustment factor of any pixel is determined based on the first spatial adjustment characteristic and the second spatial adjustment characteristic, and the spatial adjustment factor of any pixel is proportional to both the first spatial adjustment characteristic and the second spatial adjustment characteristic.

[0035] To maintain the same magnitude as the basic weight coefficients, when the basic weight coefficients obtained in the further optimized acquisition method described above are normalized parameters, the spatial adjustment factor for any pixel in a preferred embodiment is:

[0036] in, This represents the spatial adjustment factor for the i-th pixel in the image to be identified. Indicates normalization, This represents the spatial attention value corresponding to the i-th pixel. To further ensure that this value has the same magnitude as other parts multiplied with it, it is preferable to use a normalized spatial attention value here. This normalization is based on the spatial attention values ​​of all pixels in the current image to be recognized. This represents the probability of the k-th LBP value occurring among the LBP values ​​of all pixels within the target window of the i-th pixel. The target window is an n*n (e.g., n=5) window centered on the i-th pixel. Simpson diversity index represents the sum of all LBP values ​​within the target window for the i-th pixel. The larger the index, the more diverse the patterns of LBP values ​​within the window, corresponding to a more complex local texture and a higher likelihood of a defect area. This represents the gradient magnitude of the j-th pixel within the target window corresponding to the i-th pixel. This represents the total number of pixels within the target window corresponding to the i-th pixel. This represents the gradient direction entropy value within the target window corresponding to the i-th pixel. This indicates that the larger the mean gradient value and the more consistent the gradient direction within the target window, the greater the likelihood of scratches or defects appearing within the target window. This represents the standard deviation of the grayscale values ​​of the target window corresponding to the i-th pixel. This represents the standard deviation of the grayscale values ​​in the image to be identified. The greater the difference between the local contrast of the i-th pixel and the global contrast level, the greater the possibility of defects or edges appearing in that local area.

[0037] After obtaining the spatial adjustment factor for each pixel from the above, it is necessary to further determine the degree of adjustment of the underlying details of each pixel from the channel dimension, thereby obtaining the channel adjustment factor for each pixel. This channel adjustment factor is related to the spatial adjustment factor, and the two work together to more accurately obtain the local features of each pixel in the image to be recognized. First, the sum of channel attention energies represents the total activation intensity of the pixel across important channels. Strong activation may indicate defects, thus requiring enhancement of underlying details. Second, channel activation sparsity measures the proportion of activated channels. Sparse activation means only a few channels respond, potentially corresponding to specific defect patterns, requiring enhancement of underlying details for accurate extraction. Dense activation, on the other hand, may indicate background clutter. Simultaneously, channel response kurtosis measures the distribution of activation intensity across channels for a pixel. High kurtosis may correspond to small but strong defects (such as dotted scratches), requiring detail enhancement. Low kurtosis corresponds to large areas of weak response, requiring reliance on higher-level semantics. Finally, the ratio of the maximum to the mean activation intensity across all channels for a pixel reflects the degree to which a single channel dominates the pixel. A large ratio indicates that the pixel's features are very prominent, potentially corresponding to significant defects, requiring detail enhancement. A small ratio indicates average features, requiring no detail enhancement.

[0038] Based on the above feature analysis, the channel adjustment factor for any pixel can be determined, including: The absolute value of the activation value of any pixel in any channel at the corresponding position on the bottom layer feature map is recorded as the activation intensity of any pixel in any channel. The product of the activation intensity of any pixel in any channel and the channel attention value of any pixel in any channel is recorded as the weighted activation intensity of any pixel in any channel. The sum of the weighted activation intensities of any pixel in all channels is recorded as the first channel adjustment characteristic of any pixel. The ratio of the number of channels in which the activation intensity of any pixel in all channels at the corresponding position on the bottom layer feature map exceeds a preset activation intensity threshold to the total number of channels is recorded as the activation channel proportion. The normalized value of the difference between the kurtosis and the standard kurtosis value of the activation intensity of any pixel in all channels at the corresponding position on the bottom layer feature map is recorded as the activation intensity clustering. The ratio of the maximum value to the mean value of the activation intensity of any pixel in all channels at the corresponding position on the bottom layer feature map is recorded as the activation intensity prominence. The sum of the reciprocal of the activation channel proportion, the activation intensity clustering, and the activation intensity prominence is recorded as the second channel adjustment characteristic of any pixel. The channel adjustment factor of any pixel is determined based on the first channel adjustment characteristic and the second channel adjustment characteristic, and the channel adjustment factor of any pixel is proportional to both the first channel adjustment characteristic and the second channel adjustment characteristic.

[0039] Similarly, to maintain the same magnitude as the basic weighting coefficient and the spatial adjustment factor, the corresponding channel adjustment factor for any pixel in a preferred embodiment is:

[0040] in, This represents the channel adjustment factor for the i-th pixel. Indicates normalization, This represents the channel attention value of the i-th pixel in the a-th channel. This represents the activation value of the i-th pixel in the a-th channel at the corresponding position in the bottom-most feature map (i.e., the P2 feature map). Since activation values ​​can be positive or negative, their absolute values ​​are taken to represent the activation intensity. This represents the sum of weighted activation intensities of the i-th pixel across all channels, also known as the first channel adjustment term. It reflects the total response intensity in important channels; a higher response intensity indicates a greater likelihood of local defects. To ensure that the magnitude of the final first channel adjustment term is the same as the overall result of the parameters involved in the subsequent calculation (which is actually the second channel adjustment term), the channel attention value here is... and activation value All are selected after normalization processing. This represents the number of channels where the activation intensity of the i-th pixel at its corresponding position in the bottom-level feature map exceeds a preset activation intensity threshold. The preset activation intensity threshold is preferably 1.5 times the average activation intensity of all channels, i.e., 1.5 times the average activation intensity of each pixel across all channels. Indicates the total number of channels. This represents the proportion of channels with activation intensity exceeding a threshold at that pixel out of the total number of channels, measuring the sparsity of activation. This indicates that the smaller the sparsity of activation, the greater the probability that a local area represents a specific defect pattern, requiring detailed extraction for precise analysis. Similarly, to ensure that the magnitude of this part is the same as that of other parts, the following... The optimal value has undergone normalization processing, representing the kurtosis of the curve plotted by taking all channels at the corresponding position of the i-th pixel in the bottom-level feature map as the horizontal axis and the activation intensity of each channel as the vertical axis. In other words, it represents the kurtosis of the activation intensity of the i-th pixel at the corresponding position in the bottom-level feature map across all channels. This represents the difference between the kurtosis value and the standard kurtosis value (i.e., subtraction term 3). The standard kurtosis value is the kurtosis value of a normally distributed system. To ensure the same magnitude and avoid negative results after subtraction, the difference is preferably a normalized result. This kurtosis difference characterizes the concentration of activation intensity at that pixel. A larger kurtosis difference indicates a higher likelihood of small but strong defects (such as dot-like scratches), requiring detail enhancement. It represents the maximum absolute value of the activation value of the i-th pixel at the corresponding position on the bottom feature map across all channels, which is also the maximum value of the activation intensity across all channels. This represents the average absolute value of the activation values ​​across all channels at the corresponding position of the i-th pixel in the bottom-level feature map, which is also the average activation intensity of all channels. This represents a preset minimum value, which is preferably 0.01 in this embodiment. Its purpose is to prevent the denominator from being 0. The larger the ratio of maximum activation intensity to average activation intensity, the stronger the dominance of a single channel, the more significant the defect, and the more attention needs to be paid to details.

[0041] At this point, the basic weight coefficients common to all pixels in the image to be recognized, as well as the spatial adjustment factor and channel adjustment factor corresponding to each pixel, have been obtained.

[0042] S103, based on the basic weight coefficient, the spatial adjustment factor of any pixel, and the channel adjustment factor of any pixel, determine the adaptive low-level feature contribution weight of any pixel, and complete the feature fusion based on the trained feature pyramid network according to the adaptive low-level feature contribution weight of each pixel in the image to be identified, thereby completing the defect detection on the image to be identified.

[0043] By fusing the global base weight coefficients with the spatial adjustment factors and channel adjustment factors corresponding to each pixel, global and local information can be organically combined. The resulting adaptive low-level feature contribution weights take into account both the overall image situation and the unique spatial and channel features of each pixel.

[0044] Specifically, the importance of the underlying features of any pixel is determined by fusing the basic weight coefficient, spatial adjustment factor, and channel adjustment factor. Then, the weight of the preset maximum underlying feature contribution weight is weighted according to the importance of the underlying features to obtain the adaptive underlying feature contribution weight corresponding to any pixel.

[0045] Furthermore, the adaptive low-level feature contribution weight for any pixel is:

[0046] in, This represents the adaptive low-level feature contribution weight of the i-th pixel. This represents the basic weight coefficient of the i-th pixel. This represents the spatial adjustment factor for the i-th pixel. This represents the channel adjustment factor for the i-th pixel. This indicates the importance of the underlying features corresponding to the current pixel. The greater the importance of the underlying features, the greater the corresponding final weight should be. This represents the preset maximum contribution weight of the underlying features. In this embodiment, it is preferably set to 0.6. This parameter can be set according to the environment of the acquired image. The higher the environmental noise, the lower this parameter should be to prevent the introduction of noise.

[0047] After obtaining the pixel-level adaptive low-level feature contribution weights, they are applied to the fusion process of the feature pyramid network: in the top-down path, when the high-level semantic feature map is upsampled and added pixel-by-pixel to the low-level detail feature map, the corresponding adaptive low-level feature contribution weight is multiplied at each pixel position of the low-level feature map to achieve a dynamic balance between detail information and semantic information; the fused multi-scale feature map is then fed into the detection head (such as RetinaNet or FCOS), which predicts whether there is a defect and its category at each position through the classification branch, and predicts the coordinates of the defect bounding box through the regression branch; the adaptive low-level feature contribution weights dynamically adjust the low-level contribution according to the spatial characteristics (edge ​​strength, texture complexity, scale preference) and channel characteristics (activation sparsity, defect prototype matching degree) of each pixel, so that the network retains more details in small scratch areas for accurate segmentation, while relying on high-level semantics to suppress noise in large areas of stains or background areas. The entire network is trained end-to-end, and the loss function combines classification loss (Focal Loss to handle imbalance between easy and difficult samples) and regression loss (GIoU Loss to optimize localization accuracy), so that the weight generation module and the detection target are co-optimized. Ultimately, the technology achieves the goal of robustly detecting various defects on the surface of data cables under complex lighting and background interference, thereby significantly improving detection accuracy.

[0048] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. 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 of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.

Claims

1. A method for intelligent detection of appearance defects in data cables based on image processing, characterized in that, The method includes: A grayscale image of the appearance of the data line is obtained and recorded as the image to be identified. The image to be identified is input into a trained feature pyramid network to generate multi-layer feature maps. The channel attention map and spatial attention map corresponding to the image to be identified are calculated using the lowest layer feature map in the multi-layer feature maps. The basic weight coefficients are determined based on the overall grayscale features of the image to be identified and the probability of historical defects in the data line. The spatial attention value of any pixel in the image to be identified is determined based on the spatial attention map. The spatial adjustment factor of any pixel is determined based on the spatial attention value, local texture features, and local grayscale features of any pixel. The channel attention value of any pixel in each channel is determined based on the channel attention map. After determining the activation intensity, number of activated channels, and activation intensity distribution features of each channel of any pixel based on the bottom-level feature map, the channel adjustment factor of any pixel is determined. Based on the basic weight coefficients, the spatial adjustment factor of any pixel, and the channel adjustment factor of any pixel, the adaptive low-level feature contribution weight of any pixel is determined. Based on the adaptive low-level feature contribution weight of each pixel in the image to be identified, feature fusion based on the trained feature pyramid network is completed, thereby completing the defect detection on the image to be identified.

2. The intelligent detection method for appearance defects of data cables based on image processing according to claim 1, characterized in that, The trained feature pyramid network is built on a residual network and includes a convolutional block attention module.

3. The intelligent detection method for appearance defects of data cables based on image processing according to claim 2, characterized in that, Calculate the channel attention map and spatial attention map corresponding to the image to be identified using the lowest-level feature map in the multi-layer feature map, including: The lowest-level feature map is input into the convolutional block attention module to calculate the channel attention map and the spatial attention map.

4. The intelligent detection method for appearance defects of data cables based on image processing according to claim 1, characterized in that, The basic weighting coefficients are determined based on the overall grayscale features of the image to be identified and the probability of historical defects in the data lines, including: After normalizing the gray values ​​of each pixel in the image to be identified, the mean gray value and the standard deviation of the gray value of the image to be identified are calculated. The product of the mean gray value and the standard deviation of the gray value of the image to be identified is recorded as the first basic weight characterization term. The probability of historical defects occurring in the current production batch of the data line up to the present is statistically analyzed and recorded as the second basic weight characterization item. The basic weight coefficient is determined based on the first basic weight characterization item and the second basic weight characterization item, and the basic weight coefficient is proportional to both the first basic weight characterization item and the second basic weight characterization item.

5. The intelligent detection method for appearance defects of data cables based on image processing according to claim 1, characterized in that, Determining the spatial adjustment factor for any given pixel includes: A window of a preset size centered on any pixel is denoted as the target window. The local binary mode value of each pixel in the target window is calculated. The Simpson diversity index of all local binary mode values ​​in the target window is calculated and denoted as the local texture complexity of any pixel. The product of the spatial attention value of any pixel and the local texture complexity of any pixel is denoted as the first spatial adjustment characterization term. Calculate the average gradient magnitude and gradient direction entropy of each pixel within the target window. Record the ratio of the standard deviation of gray values ​​within the target window to the standard deviation of gray values ​​in the image to be identified as the local contrast prominence. Multiply the average gradient magnitude and gradient direction entropy and sum them with the local contrast prominence to obtain the second spatial adjustment characterization term. The spatial adjustment factor of any pixel is determined based on the first spatial adjustment characteristic and the second spatial adjustment characteristic, and the spatial adjustment factor of any pixel is proportional to both the first spatial adjustment characteristic and the second spatial adjustment characteristic.

6. The intelligent detection method for appearance defects of data cables based on image processing according to claim 1, characterized in that, Determining the channel adjustment factor for any given pixel includes: The absolute value of the activation value of any pixel in any channel at the corresponding position on the bottom feature map is recorded as the activation intensity of any pixel in any channel. The product of the activation intensity of any pixel in any channel and the channel attention value of any pixel in any channel is recorded as the weighted activation intensity of any pixel in any channel. The sum of the weighted activation intensities of any pixel in all channels is recorded as the first channel adjustment characterization term of any pixel. The ratio of the number of channels whose activation intensity exceeds a preset activation intensity threshold to the total number of channels at the corresponding position of any pixel in the bottom layer feature map is recorded as the activation channel ratio. The normalized value of the difference between the kurtosis and the standard kurtosis value of the activation intensity of any pixel at the corresponding position in the bottom layer feature map is recorded as the activation intensity clustering. The ratio of the maximum value to the mean value of the activation intensity of any pixel at the corresponding position in the bottom layer feature map is recorded as the activation intensity prominence. The sum of the normalized value of the reciprocal of the activation channel ratio, the activation intensity clustering, and the activation intensity prominence is recorded as the second channel adjustment characterization term of any pixel. The channel adjustment factor of any pixel is determined based on the first channel adjustment characteristic and the second channel adjustment characteristic, and the channel adjustment factor of any pixel is proportional to both the first channel adjustment characteristic and the second channel adjustment characteristic.

7. The intelligent detection method for appearance defects of data cables based on image processing according to any one of claims 1 to 6, characterized in that, Determining the adaptive low-level feature contribution weight for any pixel includes: The importance of the underlying features of any pixel is determined based on the basic weight coefficient, the spatial adjustment factor of any pixel, and the channel adjustment factor of any pixel. The preset maximum underlying feature contribution weight is weighted according to the importance of the underlying features of any pixel to obtain the adaptive underlying feature contribution weight of any pixel.