Visual inspection method for workpiece surface groove machining defects

By optimizing the CSGE-DETR defect detection model for triangular grooves in large circular knitting machines, the problems of missed and false detections of minute defects and complex backgrounds in the detection process have been solved, achieving high-precision and efficient defect identification, which is suitable for real-time detection of triangular grooves in large circular knitting machines.

CN120852876APending Publication Date: 2025-10-28FUJIAN UNIV OF TECH
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202511004292.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-21
Publication Date
2025-10-28

AI Technical Summary

Technical Problem

In the detection of defects in triangular grooves of large circular knitting machines, the small size of the defects, the complex background, and the optical scattering effect lead to a decrease in imaging quality. Existing detection algorithms are prone to missed detections and false detections, making it difficult to maintain high accuracy and stability in complex environments.

Method used

A lightweight large circular knitting machine triangular groove defect detection model CSGE-DETR is adopted. By introducing the CGSE module, multi-scale feature fusion, frequency domain enhancement and lightweight adaptive extraction module, the image preprocessing and deep learning detection methods are optimized to improve the model's defect recognition accuracy and robustness.

Benefits of technology

Under complex background and optical scattering conditions, it significantly improves the accuracy and stability of defect detection, reduces computational complexity, and meets the requirements of real-time detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120852876A_ABST
    Figure CN120852876A_ABST
Patent Text Reader

Abstract

The invention provides a visual detection method for processing defects of a groove on the surface of a workpiece, which is used for detecting the defects of a slot of a triangle of a circular knitting machine, a lightweight slot defect detection model CSGE-DETR of the triangle of the circular knitting machine is used in the method, the trunk of the model comprises a CGSE module, and the model further comprises an SOEP trunk network and a RepC3 module introducing wavelet convolution WTConv; the detection method comprises the following steps. The method comprises the steps of 1, image acquisition; 2, preprocessing the image; step 3, defect identification; the computer machine vision detection method is optimized for solving the problems that the defect size of the triangle of the circular knitting machine is small, the background is complex, and the imaging quality is reduced due to the optical scattering effect when the defect is captured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of machine vision technology, and in particular to a visual inspection method for defects in the surface grooves of a workpiece. Background Technology

[0002] The textile and apparel industry exists independently as a traditional industry and is an important pillar of the national economy. The circular knitting machine is a piece of equipment used in the field of textile science and technology. The caliper of the circular knitting machine is one of its core components. [The physical object is shown...] Figure 10 As shown, defects in the triangular grooves of a large circular knitting machine directly negatively impact the textile thread, affecting the quality of the final product. Therefore, ensuring its quality is crucial. However, in actual inspection, machine vision inspection of groove defects often presents certain challenges. For example, their small size makes defect detection susceptible to optical diffuse reflection effects, and complex backgrounds and spatial shapes can affect defect detection performance. They are also easily affected by environmental interference, making them difficult to detect using conventional target detection algorithms. This is especially challenging for small, three-dimensional target detection tasks, as small targets typically have low resolution, low contrast, and complex backgrounds.

[0003] The cam on a circular knitting machine is a key component of the circular knitting machine, a core piece of equipment in the knitting industry. Its detection of yarn groove defects is crucial to the quality of knitted products. However, yarn groove defects are often poorly imaged due to factors such as their small size, complex background interference, and optical astigmatism during defect detection, frequently resulting in missed or false detections.

[0004] Surface defect detection technology focuses on locating defect positions and identifying their types using specific models. Before deep neural network-driven object detection algorithms became mainstream, traditional object detection methods played a crucial role. These methods are primarily based on algorithms and techniques, such as Viola-Jones, HOG (Histogram of Oriented Gradients) combined with SVM (Support Vector Machines), Non-Maximum Suppression (NMS), Deformable Parts Model (DPM), Selective Search (SS), and EdgeBoxes. Ding et al. proposed a textile defect detection algorithm based on HOG feature extraction and SVM feature classification. Experimental results show that this method is relatively simple to implement and suitable for online applications. Dou et al. designed a fast railway bolt detection algorithm based on template matching to determine whether bolts are in the correct position, demonstrating superior performance compared to previous methods. Furthermore, He et al. proposed a Gaussian Mixture Deformable Parts Model (GMDPM) based on HOG features for defect detection in railway fasteners. Additionally, Li Q et al. achieved rapid defect identification by applying fractal features. The features extracted by this method exhibit invariance to scale transformations, stability to rotation and translation, and effectively resist the influence of illumination intensity. However, traditional manual feature extraction methods have certain limitations. Therefore, Xie W et al. proposed a novel machine vision classification method for welding defects. This method, based on a Gaussian mixture model, employs an improved background subtraction algorithm to effectively extract the features of weld defects and achieve accurate classification.

[0005] While traditional defect detection methods perform well in certain applications, they are often limited by the selection and generalization capabilities of manually manipulated features when dealing with complex or highly variable image data. These limitations become particularly pronounced when faced with large-scale, diverse industrial image data.

[0006] With the widespread application of deep learning in object detection, the accuracy and speed of object detection technology have rapidly improved. The initial R-CNN series algorithms, such as R-CNN, Fast R-CNN, Faster R-CNN, and Mask R-CNN, were two-stage algorithms that first generated candidate bounding boxes and then identified objects within those boxes, prioritizing detection accuracy. However, their computational complexity resulted in slow execution speeds. Subsequently, single-stage algorithms like SSD and the YOLO series emerged, achieving a good balance between accuracy and speed and gaining widespread application. However, regardless of whether the algorithm is two-stage or single-stage, most rely on Non-Maximum Suppression (NMS) to handle redundant bounding boxes. This technique suffers from low efficiency, inability to be parallelized, reduced inference speed, and the need to select appropriate NMS thresholds in different scenarios to avoid missing targets.

[0007] Transformer models initially excelled in natural language processing and have been increasingly applied to computer vision in recent years. DETR was the first to apply Transformer to computer vision, directly performing ensemble prediction on images, eliminating the anchor mechanism and NMS processing, simplifying the object detection process, and demonstrating superior learning capabilities in object detection. However, DETR requires significant training time, limiting its use in real-time applications. Many researchers have improved DETR, but the attention mechanism itself introduces more parameters and computational complexity, hindering its real-time application. LV et al. proposed the real-time detection model RT-DETR, a highly practical end-to-end real-time object detection model that achieves real-time performance while maintaining high accuracy, outperforming comparable YOLO detection models in both speed and accuracy.

[0008] In order to improve the accuracy of small target detection, SUN et al. integrated the classic path aggregation network PAN

[28] with the aggregation and distribution GD (Gather-andDistribute) mechanism to form a new feature fusion architecture and applied it to RT-DETR. By taking advantage of the advantages of the two fusion methods, the detection of small targets was improved. MUZAMMUL et al. combined the RT-DETR model with the slice-aided hyper inference (SAHI) method, which effectively improved the target detection and recognition capabilities in long-distance images. Li et al. introduced the self-attention upsampling (SAU) module in RT-DETR and proposed an improved IDIoU loss function based on EIoU (Efficient-IoU) to reduce the instability in the small defect matching process and improve the detection capability of small targets. Dongbo Wu et al. introduced HS-FPN (Hybrid Feature Pyramid Network) to enhance the multi-scale defect detection capability and replaced the original GIoU loss function with Inner-GIoU to accelerate convergence and improve the small defect detection capability. WeiSong et al. introduced a super-resolution convolution module (SRConv) in the backbone network to enhance image details and clarity.

[0009] Adding a channel attention mechanism to the self-attention module improves feature extraction capabilities. LUO et al. used a lightweight network in the RT-DETR model to reduce the number of parameters, but the accuracy was not as good as the original model.

[0010] In summary, surface defects often lack fixed shapes, uniform sizes, stable aspect ratios, and consistent brightness. This high variability poses a significant challenge to the effectiveness of target detection algorithms. Especially in complex background environments, the presence of redundant information significantly increases the computational cost of deep networks with a large number of parameters. Furthermore, existing target detection algorithms exhibit poor generalization ability when handling uncommon scale targets, typically requiring multiple downsampling steps to obtain standard features, which further reduces the ability to detect small targets. When defect features are primarily characterized by high background complexity and small target features, efficiently extracting key features becomes a major challenge. Single-stage target detection algorithms achieve a good balance between speed and accuracy, making them particularly suitable for industrial inspection applications with high real-time requirements. These models complete the target detection task in a single stage, improving inference speed and making them more practical for engineering applications. However, in practical applications, single-stage detectors still face many challenges; different models perform differently in different application scenarios. Therefore, selecting a suitable target detection model for a specific industrial inspection task is crucial. Existing methods are prone to missed detections and false detections when the defect size is small, the background is complex, and the imaging quality is reduced due to optical scattering effects. This seriously affects the stability and reliability of the detection. Summary of the Invention

[0011] This invention proposes a visual inspection method for defects in the surface grooves of workpieces. It optimizes the computer machine vision inspection method to address the problems of small defect size, complex background, and decreased imaging quality caused by optical scattering effect when capturing defects in large circular knitting machines.

[0012] The present invention adopts the following technical solution.

[0013] A visual detection method for surface groove machining defects on workpieces is used for detecting groove defects in the triangular part of a large circular knitting machine. The method uses a lightweight large circular knitting machine triangular groove defect detection model CSGE-DETR. The backbone of the model includes the CGSE module, and the model also includes the SOEP backbone network and the RepC3 module with wavelet convolution WTConv.

[0014] The detection method includes the following steps;

[0015] Step 1: Image Acquisition;

[0016] Step 2: Image preprocessing;

[0017] Step 3: Defect identification.

[0018] In step one, considering the characteristics of the small size, complex structure, and strong background interference of the defects in the triangular groove of the large circular kiln, Hikvision industrial cameras are used for image acquisition. These cameras have high resolution and high dynamic range and can capture subtle structural changes.

[0019] The camera is fixed at a suitable angle using a custom mounting bracket to ensure vertical or near-vertical shooting of the wire groove area, effectively reducing geometric distortion. To solve imaging interference caused by optical astigmatism, the image acquisition system is equipped with a high color rendering index ring LED light source or a multi-angle lighting system. By adjusting the brightness, angle, and light source type, the uniformity of illumination in the measured area is optimized, minimizing highlights and shadows. The image acquisition process is triggered and controlled by a host computer or PLC, and the image acquisition operation is synchronized with the operation of the large circular knitting machine to ensure the stability and repeatability of image acquisition.

[0020] In step two, to improve the accuracy of trough defect detection, the acquired images need to undergo the following preprocessing steps:

[0021] Grayscale conversion: Converting the original image into a grayscale image reduces information redundancy, highlights structural details, and facilitates subsequent analysis;

[0022] Illumination equalization processing: To address the issues of complex backgrounds and uneven illumination, the adaptive histogram equalization CLAHE algorithm is used to locally enhance the image brightness, highlighting the edges of grooves and defect areas.

[0023] Scattering interference suppression: Introduce image smoothing algorithms (such as guided filtering or bilateral filtering) to suppress high-frequency noise and false edges caused by optical scattering while preserving edge details;

[0024] Noise removal: Median filtering or nonlocal mean denoising is applied to the image to reduce the interference of random noise on defect identification;

[0025] ROI Extraction and Standardization: Based on the location of the groove in the image, the region of interest (ROI) is extracted and geometrically corrected or dimensionally standardized to ensure the consistency of defect localization.

[0026] Edge detection and contour enhancement: An improved Canny algorithm combined with morphological processing is used to extract the edges of the grooves and enhance the contrast of defects, providing high-quality input for subsequent recognition and classification.

[0027] In step three, when detecting defects in the triangular groove of the large circular kiln, the image of the normal groove is used as a comparison sample dataset. If the groove being detected is not as flat as the normal groove, it is judged as a defect. Defects are divided into protruding defects and groove defects. They are distributed in the edge contour area and the transition area of ​​the groove bottom. They are small in size, have low contrast, and blurred edges. They are easily affected by complex backgrounds and light reflections, which may lead to missed detection or false detection.

[0028] In step three, the deep learning detection method of the RT-DETR model is improved, and structural optimization and frequency domain enhancement strategies are combined to identify defects, thereby improving the model's accuracy and robustness in identifying defects.

[0029] Improvements to the RT-DETR model include backbone network improvement, multi-scale feature fusion optimization, design of a frequency domain enhancement mechanism, and design of a lightweight adaptive extraction module.

[0030] In step three, the backbone network improvement includes the introduction of the CGSE module, specifically: to improve the feature representation ability of the groove contour and the groove bottom region, the context-guided global semantic enhancement module CGSE is introduced to replace the BasicBlock in the original RT-DETR backbone network.

[0031] The CGSE module introduces multi-scale context and global perception mechanisms, enabling the model to accurately capture local structural anomalies such as protrusions or grooves under complex lighting and diffuse reflection conditions, and maintains clear discrimination ability even in areas with blurred edges.

[0032] The CGSE module combines the channel attention mechanism of SENet and the context interaction mechanism of CGNet, organically integrating the advantages of both. The core feature of the CG module lies in its ability to dynamically fuse local and global features, achieving comprehensive capture of both fine local information and global contextual information, significantly improving the model's ability to distinguish between targets and backgrounds. Simultaneously, context interaction allows small targets to better express their location and characteristics in the global feature space, better capturing 3D defect details and solving the problem of small target features being easily ignored in traditional convolutional operations. Furthermore, SENet's SE module, with its simple and efficient design, dynamically adjusts the weights of feature channels through the channel attention mechanism, further strengthening the model's ability to focus on important features, thereby significantly improving network performance. The channel adaptation feature of the SE module enhances the model's robustness, enabling it to better cope with complex backgrounds and lighting changes. By combining context guidance and channel attention mechanisms, the CGSE module not only inherits the respective advantages of the CG and SE modules but also achieves further performance improvements through their synergistic effect. Figure 2 As shown: When the CGSE module works, the input image X is first processed through a 1×1 convolution to reduce the number of channels in the input features, thereby reducing the computational complexity of subsequent 3×3 convolutions and dilated convolutions. Simultaneously, channel information is fused to capture cross-channel correlations, providing a more efficient input representation for subsequent local and global feature extraction, improving feature expressiveness and computational efficiency. Subsequently, it undergoes two 3×3 standard convolutions and dilated convolutions to learn local features and the surrounding context with a larger receptive field, respectively. Then, the outputs of local features and the surrounding context are fused through a connection layer, batch normalization (BN), and parameterized ReLU (PReLU) operations to obtain joint features, expressed by the formula:

[0033] X′=PReLU(BN(Concat(Conv 3×3 (X), DConv 3×3 (X)))) Formula 1;

[0034] Where PReLU is parameterization; ReLU is the activation function; BN is the batch normalization operation; Conv and Dconv represent two different convolutions; Concat represents the feature concatenation operation; X' represents the parameterized feature map after concatenation.

[0035] Next, X′ is modeled using both channel attention (as described above) and global context (as described below), leveraging channel weighting and global weighting to enhance feature selection and semantic representation. Within the channel attention path, global pooling is used to reduce the spatial dimensionality of the input features, extracting global statistical information for each channel and generating channel description vectors. These channel description vectors are then passed through two fully connected (FC) layers: the first layer uses ReLU activation, and the second layer uses Sigmoid activation. This generates attention weights for each channel. Finally, these channel weights are used to weight each channel of the original input features, resulting in the channel-enhanced feature X. channel This enhances the importance of the channels. This can be expressed by the formula:

[0036]

[0037] z′=ReLU(W1z+b1) Formula 3;

[0038] s=σ(W2z′+b2) Formula 4;

[0039] X channel =s·X′ Formula 5;

[0040] in This is the global description vector of the channels, summarizing the overall spatial importance of each channel; w1 and b1 are the weights and biases of the fully connected layer. The generated channel attention weights are used in the global context modeling below. Global average pooling is applied to the input features to extract global context information, generating a global vector. Then, two fully connected (FC) layers are used to generate global spatial weights, which are applied channel-wise to the input features to obtain globally enhanced features that emphasize the dependencies of the global context. Finally, the two features are fused to give them stronger feature representation capabilities. This can be expressed by the formula:

[0041]

[0042] w global =FC(g) Formula 7;

[0043] X global =w global Formula 8 for X′;

[0044] in It is the extracted global context information; w global It is the adjusted contextual feature; X global | is a global enhancement feature.

[0045] In step three, the multi-scale feature fusion optimization includes Neck structure improvement. Specifically, the triangular groove of the large circular kiln exhibits significant multi-scale feature differences in structure: the groove edge is a narrow, sharp-angled structure, while the groove bottom area is a smooth or arc-shaped transition region. To fully extract defect features at different scales, a backbone convolution layer 1 (S2 layer) structure enhancement strategy is introduced in the Neck part, enabling the model to simultaneously focus on the details of the sharp edges of the groove and the texture and shape changes of the groove bottom concave area, thereby improving the detection capability of small-sized protrusions and concave defects.

[0046] The strategy for enhancing the structure of the first layer of the backbone convolution is the strategy for enhancing the structure of the S2 layer of the backbone convolution.

[0047] The RT-DETR model, with its superior feature extraction capabilities and fine-grained target detection technology, demonstrates excellent detection accuracy, especially when handling large, prominent targets against simple backgrounds. However, the original model's performance deteriorates when faced with tiny defects and complex background interference. Specifically, the original model's feature extraction module may fail to fully capture these subtle changes when dealing with small surface defects, leading to a significant decrease in detection accuracy. Particularly in the detection of defects such as 3D facade grooves and large circular machine triangular grooves, the small size and complex background interference make the targets even more difficult to identify, and the model fails to effectively address these challenges. Furthermore, surface reflection often causes a severe deterioration in image quality, especially when capturing 3D facade groove defects, where reflection exacerbates the target's blurriness. This optical scattering and reflection effect significantly impacts target localization and recognition, further reducing the model's detection accuracy. To overcome these challenges, the model needs to be able to adapt to and handle more complex scenes, fully considering the detection capability for small targets and the interference caused by optical effects, thereby improving its robustness and accuracy in complex environments.

[0048] The feature extraction part of the original model, such as Figure 3 As shown, the feature fusion process in the original model is as follows:

[0049]

[0050] in The fused features are represented by f(.), which is the fusion operation, usually using convolution or weighted averaging. s3, s4, and s5 represent the high-level features extracted from different layers, respectively.

[0051] In step four, an additional feature extraction layer is added to the original RT-DETR model, introducing a deeper convolutional structure and incorporating a multi-scale feature enhancement mechanism. In this study, we specifically introduce the S2 layer features from the backbone network for fusion. As a low-level feature, the S2 feature carries more detailed information, significantly improving detection accuracy, especially when dealing with small defects. Low-level features are typically highly sensitive to subtle changes, allowing the S2 layer to effectively avoid details that higher-level features might miss when capturing small defects, thereby enhancing the model's local detection capabilities and improving its structure. Figure 4 As shown, the new feature fusion formula is:

[0052]

[0053] in This represents the feature after fusion with the addition of s2, where f(.) is the fusion operation, usually using convolution or weighted averaging, and s2, s3, s4, and s5 represent the high-level features extracted from different layers, respectively.

[0054] By introducing S2 features, the model becomes more robust in capturing small targets and handling complex background interference. When faced with minute defects such as triangular grooves in large circular knitting machines and three-dimensional vertical surface grooves, the introduction of S2 features can better capture these subtle surface variations. Furthermore, the detailed information in the S2 layer is well-adapted to effects such as optical scattering and surface reflection, helping the model reduce image blurring caused by optical reflection and improving the accuracy of target localization and recognition.

[0055] By comprehensively utilizing features at different levels, the network's sensitivity to defects at different scales and under complex backgrounds is enhanced, thereby improving overall detection performance. Especially in highly complex scenarios, the model can fully leverage the advantages of multi-scale features, improving its ability to identify small targets and minute defects, enabling it to better cope with the challenges of complex backgrounds and surface optical effects in practical industrial applications. Therefore, this improvement not only increases detection accuracy but also enhances the model's robustness, promoting its potential for application in real-world scenarios.

[0056] In step three, the frequency domain enhancement mechanism includes the introduction of the WTConv module. Specifically, protrusions and grooves often manifest as high-frequency information such as texture breaks and contour changes. To enhance the model's frequency domain perception capability, wavelet convolution WTConv is introduced into the RePc3 module to capture subtle texture perturbations and local discontinuities in the frequency domain, making the model more sensitive to the presence of minor defects, especially those tiny grooves or slight protrusions that are difficult to detect with traditional convolution.

[0057] In the traditional RT-DETR model, the feature fusion stage employs the RepC3 (Reparameterized Convolutional Block with 3 Convolutions) structure. This structure batch normalizes the input feature map and effectively extracts features using 3×3 and 1×1 convolutions. Then, it element-wise adds the batch-normalized input feature map to these extracted features, and finally uses the SiLU activation function to achieve a non-linear transformation to generate the output. Figure 5 and Figure 6 As shown:

[0058] The RepC3 structure can optimize feature fusion to a certain extent, especially performing well in handling relatively simple visual tasks. However, when faced with complex scenes, especially high-resolution images, RepC3 has high computational complexity and fails to fully utilize multi-scale information, resulting in a decrease in the model's real-time processing performance and consequently affecting the accuracy of triangular groove defect detection on large circular knitting machines.

[0059] When dealing with the problem of detecting defects in wire grooves, factors such as the small size of the defects, complex background interference, and surface reflection often cause existing detection algorithms to miss or falsely detect defects during the feature extraction stage. Therefore, improving the model's ability to detect small defects in complex backgrounds has become the key to improving accuracy.

[0060] To address the shortcomings of RepC3 in multi-scale feature fusion, wavelet convolution WTConv (WTConv) was introduced in the feature fusion stage. Figure 7 );

[0061] Given an image X, the first-order Haar WT in one spatial dimension (width or height) is determined by the kernel. and The depthwise convolution is given, followed by a standard downsampling operator with a factor of 2; to perform a 2D Haar WT, the operation is combined in two dimensions using the following four filters to produce a depthwise convolution with a stride of 2:

[0062]

[0063] Formula 11;

[0064] f LL It is a low-pass filter, and f LH f HL f HH It is a set of high-pass filters;

[0065] For each input channel, the output of the convolution is:

[0066] [X LL X LHX HL X HH ] = Conv([f LL f LH f HL f HH Formula 12;

[0067] That is, there are four channels, and the resolution of each channel (in each spatial dimension) is half of X; X LL It is the low-frequency component of X, X LH X HL X HH The horizontal, vertical, and diagonal high-frequency components are represented by _; since the convolution kernel forms an orthonormal basis, the inverse wavelet transform (IWT) is obtained through transpose convolution:

[0068] X = Conv-transposed([f LL f LH ,f HL ,f HH ], [X LL X LH X HL X HH ]). Formula 13;

[0069] Then, the cascaded wavelet decomposition is given by recursively decomposing the low-frequency components.

[0070]

[0071] in And i is the current level, which leads to an increase in frequency and a decrease in spatial resolution at lower frequencies; convolution in the wavelet domain yields a larger receptive field, in the second-order wavelet domain Performing a 3×3 convolution on the low-frequency band will produce a corresponding 9-parameter convolution, corresponding to the lower frequencies of the 12×12 receiving field in the input X;

[0072] Wavelet Convolution (WTConv) enhances a model's ability to extract and fuse features at multiple scales by introducing a learnable weighting mechanism. WTConv can dynamically adjust the weights of convolution operations to effectively extract key information at different scales. Especially when dealing with minute defects and complex backgrounds, it can effectively reduce noise interference and improve sensitivity to details.

[0073] After being introduced into the RepC3 structure, WTConv overcomes the shortcomings of traditional convolution, especially in the detection of triangular groove defects on large circular kilns, where it can handle the challenges of small defect size, complex background interference, and surface reflection. Its ability to dynamically adjust the convolution kernel weights allows the model to more accurately capture subtle changes in the image while effectively reducing the computational burden and ensuring high detection accuracy.

[0074] In summary, the introduction of WTConv enhances the model's ability to process multi-scale information, improves the detection accuracy of small targets, and significantly improves real-time processing efficiency while maintaining low computational cost, providing strong technical support for defect detection in complex scenarios.

[0075] In step three, the lightweight adaptive extraction module LAE is designed as follows: by introducing an attention mechanism, the feature weights of different channels are dynamically adjusted to enhance important features and suppress redundant features, thereby significantly reducing the number of model parameters and computational costs, which is suitable for real-time on-site detection needs.

[0076] In the task of detecting triangular groove defects on large circular knitting machines, although the 3×3 convolution in the traditional neck module can extract local features, its fixed receptive field and kernel size often make it difficult to capture subtle changes and long-range dependencies in defects. In particular, when the defect morphology is complex and the scale varies greatly, the limitations of 3×3 convolution may affect the accuracy and robustness of feature extraction, thereby reducing the detection effect.

[0077] To address this issue, the original 3×3 convolution was replaced by the Lightweight Adaptive Extraction (LAE) module in LSM-YOLO, aiming to perform multi-scale feature extraction while reducing computational costs. LAE achieves more efficient feature extraction through multi-scale and adaptive feature extraction. The LAE module can improve the model's detection performance in Regions of Interest (ROIs) without adding extra parameters, enabling more precise focusing on key areas where defects are located and enhancing the ability to capture detailed features. This makes it more robust and flexible in handling defects with complex shapes and varied locations, adapting to changes in deformation and scale. The results are as follows: Figure 8 As shown;

[0078] The LAE module contains two parallel branches for lightweight feature extraction and adaptive feature extraction, respectively. The input data is a tensor of shape h×w×c, where h represents the image height, w represents the image width, and c represents the number of channels. In the lightweight feature extraction process, computation is reduced by employing group convolution and smaller convolution kernels. Specifically, group convolution divides the input feature map into multiple groups and performs convolution operations independently on each group. This strategy significantly reduces computation and memory consumption while preserving sufficient feature information. The core advantage of group convolution lies in optimizing resource utilization by breaking down the convolution operation into multiple smaller computational units. This can be expressed as:

[0079]

[0080] Among them, X input For the input feature map, Indicates the number of groups;

[0081] Next, the feature map undergoes dimension mapping, which rearranges the data structure through a rearrange operation. This operation adjusts the shape of the tensors or reorganizes the data, making the feature map format more suitable for subsequent feature processing, especially the adaptive feature extraction stage.

[0082] The purpose of the Rearrange operation is to optimize the data flow so that subsequent operations can effectively extract multi-scale features and perform corresponding transformations; expressed by the formula:

[0083] X rearranged =R earrange (X grouped ) Formula 17;

[0084] Where X grouped The feature map X is the result of grouped convolution processing during the lightweight feature extraction stage. rearranged This is a new feature map obtained after rearranging, which changes in dimension or structure, aiming to optimize data flow and enhance the model's feature extraction capabilities. Then, the pooled feature map undergoes further feature extraction through a 1×1 convolution (Conv) operation. The purpose of the 1×1 convolution is to compress or expand the features by adjusting the number of channels per pixel, while retaining key information and improving expressive power; this operation helps extract high-dimensional features, expressed by the formula:

[0085] X conv =Conv(X adaptive W conv ) Formula 19;

[0086] Among them W conv It is the convolution kernel, X conv It is the feature map after the convolution operation;

[0087] The next step, rearranging the data structure through the Rearrange operation, readjusts the shape of the tensors to accommodate the subsequent Softmax normalization operation. This rearrangement adjusts the data into a structure suitable for further processing, facilitating efficient feature fusion, as expressed by the formula:

[0088] X rearranged =Rearrange(X conv ) Formula 20;

[0089] Where X convThis represents the feature map extracted through convolution operations. This feature map is the result of average pooling (AP) and convolution (Conv) operations in the adaptive feature extraction part. X rearranged It is the rearranged feature map, whose shape or dimensions have been reorganized to ensure it is suitable for subsequent processing stages, especially the final Softmax normalization;

[0090] The feature maps after rearrangement are normalized using a Softmax operation. Softmax normalization transforms the feature values ​​into a probability distribution, ensuring that each feature value falls within a suitable range. This helps improve the model's stability and generalization ability. Finally, the features from the two parallel branches are fused, as expressed by the formula:

[0091] X final =Sofmtax(X rearranged ) Formula 21;

[0092] X output =X mapped ×X final Formula 22;

[0093] Where X mapped It is the output of lightweight feature extraction, X final It is the output of adaptive feature extraction, X output These are the feature maps after they have been fused;

[0094] The feature maps fused through multiplication are then further integrated through summation. This summation process adds the fused feature map to other possible feature maps, thereby enhancing the model's feature representation ability and information transmission effect. This operation helps to effectively integrate feature information from different sources, improves the model's ability to capture complex patterns, and significantly enhances its accuracy and generalization ability. The LAE module optimizes the integration of multi-scale information by fusing feature maps from two parallel branches. This fusion process not only effectively improves the model's feature extraction ability but also enhances its adaptability to different types of features, thereby improving the overall detection accuracy and effect. Compared with traditional convolution operations, the LAE module can greatly improve the accuracy and efficiency of feature extraction without significantly increasing computational overhead. Through this optimization, the LAE module not only significantly improves the accuracy of detecting triangular groove defects in large circular knitting machines but also makes the overall detection process more efficient, demonstrating its advantages in practical applications.

[0095] The large circular knitting machine triangular groove defect detection model is trained based on the large circular knitting machine triangular groove defect dataset, which is a self-made dataset taken with a Hikvision camera.

[0096] The data acquisition method for the large circular knitting machine triangular groove defect dataset is as follows: the camera captures images along the groove path to ensure complete defect imaging. It includes two types of defect images: humps and grooves, totaling 600 images. Due to the small sample size of the original dataset, this paper employs data augmentation to increase the sample size, including blurring, brightness adjustment, random cropping, rotation, translation, and mirroring. Blurring reduces detail information in the image, producing a version that differs from the original but is highly relevant, increasing the diversity of images in the training set and helping the model learn richer features. Brightness adjustment involves changing the brightness of the image, simulating brightness deviations under different ambient lighting conditions, improving the model's adaptability to different brightness levels. Random cropping extracts a region of random size and location from the image to remove certain parts, improving the model's adaptability to image transformations. Image rotation rotates the image around its center point by a certain angle, obtaining several different angles of the same image defect. Translation and mirroring move and flip the image, respectively. The expanded dataset contains 1200 images, and is randomly divided into training and test sets in an 8:2 ratio.

[0097] The camcorder is a key component of the circular knitting machine, a core piece of equipment in the knitting industry, and its groove defect detection is of great significance to the quality of knitted products. However, groove defects are often poorly imaged due to factors such as their small size, complex background interference, and optical astigmatism during groove defect capture, frequently resulting in missed detections and false detections. To address this issue, this invention proposes a lightweight circular knitting machine cam groove defect detection algorithm—CGSE-DETR—based on RT-DETR. To cope with the challenges of complex geometric shapes and defect features in space, this invention redesigns the backbone network and proposes the CGSE module. This module replaces the BasicBlock module in the backbone network by fusing contextual information and global semantic features, significantly reducing the number of parameters while optimizing the model's performance under complex lighting and reflection conditions. This design effectively enhances the extraction and fusion strength of groove feature information, thereby improving the robustness of defect detection in complex environments. Furthermore, considering the multi-scale characteristics of circular knitting machine cam groove defects, this invention further enhances the efficiency of the Neck part by introducing features to improve the detection capability of small targets. To improve the detection performance for subtle texture defects, this invention introduces wavelet convolution (WTConv) into the RePc3 module. This method effectively captures detailed information in the frequency domain, thereby significantly improving the detection capability for subtle defects. Finally, the proposed Lightweight Adaptive Extraction (LAE) module further optimizes the model's parameter count and computational cost by adaptively adjusting the feature representation. This ensures that the model maintains high accuracy while possessing low computational complexity, adapting to the practical needs of detecting triangular groove defects in large circular knitting machines. The improved model improves detection accuracy while maintaining a small parameter count and computational cost, demonstrating its robustness and meeting the application requirements for detecting triangular groove defects in large circular knitting machines.

[0098] The proposed lightweight large circular knitting machine triangular groove defect detection algorithm, CGSE-DETR, based on RT-DETR, demonstrates significant advantages in addressing issues such as complex background interference, optical astigmatism, and multi-scale feature detection. Firstly, the innovatively designed CGSE module integrates contextual information and global semantic features, improving its handling of spatially complex defects and the large number of parameters in the original model. Secondly, the introduction of wavelet convolution (WTConv) combined with RePC3 and the inclusion of S2 features further optimizes the model structure, enhancing the detection accuracy of groove defects. Finally, a lightweight adaptive extraction (LAE) module adaptively adjusts the feature representation, further reducing model complexity and enhancing its feature representation capabilities. This invention successfully improves the accuracy and robustness of large circular knitting machine triangular groove defect detection, achieving excellent detection performance, particularly under complex three-dimensional spatial and illumination variations.

[0099] The improved algorithm proposed in this invention not only achieves a breakthrough in the detection accuracy of small targets, but also optimizes the number of parameters and computational efficiency, fully demonstrating its effectiveness and practicality in detecting defects in triangular grooves of large circular knitting machines. The detection method proposed in this invention can minimize the number of parameters and computational load, and improve the robustness of the model.

[0100] This invention proposes an improved model based on RT-DETR—CGSE-DETR—which optimizes the imaging quality by addressing issues such as small defect size, complex background, and optical scattering effects during defect capture. It offers the following advantages:

[0101] (1) In the backbone network, this invention proposes and introduces the CGSE (Channel-Guided Spatial Enhancement) structure to replace the BasicBlock module in the original RT-DETR. This module works in synergy with the channel-guided mechanism and the spatial context enhancement strategy to reduce the number of model parameters while retaining efficient feature extraction capabilities, thereby improving the computational efficiency and detection accuracy of the model.

[0102] (2) Improving the accuracy of small target detection through multi-scale feature fusion: Since small target features are easily affected by the loss of multi-scale information, this invention introduces an additional information fusion path on the S2 layer features of the backbone network and integrates it into NECK to form a more robust feature extraction structure. The improved fusion strategy effectively improves the target feature representation ability in the small target detection task, provides richer detailed information for small target detection, and thus enhances the detection performance of the model in complex backgrounds.

[0103] (3) In order to integrate local and global information more efficiently, the present invention introduces wavelet convolution WTConv in the RepC3 module of the NECK part. By performing multi-frequency band processing on the input features, the convolution operation can adaptively capture target information at different scales.

[0104] (4) To address the issues of high computational cost and redundant feature extraction in traditional NECK architectures, this invention employs a lightweight adaptive feature extraction (LAE) module to replace some convolutional layers in NECK. This module dynamically adjusts the feature extraction strategy, resulting in more accurate feature representation within the ROI and improving detection performance without introducing additional parameters. Experiments show that the LAE module effectively enhances the model's adaptability to complex backgrounds in small object detection tasks and significantly reduces false positives and false negatives. Attached Figure Description

[0105] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments:

[0106] Appendix Figure 1 This is a schematic diagram of the network structure of the large circular kiln triangular groove defect detection model CSGE-DETR of the present invention;

[0107] Appendix Figure 2 This is a schematic diagram of the architecture of the CGSE module of the present invention;

[0108] Appendix Figure 3 This is a schematic diagram of the feature extraction part of the original RT-DETR model under traditional technology;

[0109] Appendix Figure 4 This is a schematic diagram of the CGSE-DETR feature extraction part of the present invention;

[0110] Appendix Figure 5 This is a schematic diagram of the traditional RT-DETR model, which uses the SiLU activation function to perform a nonlinear transformation to generate the output.

[0111] Appendix Figure 6 This is another schematic diagram of the traditional RT-DETR model, which uses the SiLU activation function to perform a nonlinear transformation to generate the output.

[0112] Appendix Figure 7 This is a schematic diagram illustrating the introduction of wavelet convolution WTConv in the feature fusion stage of this invention;

[0113] Appendix Figure 8 This is a schematic diagram illustrating how the LAE of this invention achieves more effective feature extraction through multi-scale feature extraction and adaptive feature extraction methods;

[0114] Appendix Figure 9 This is a comparative diagram of normal and defective samples of wire grooves (A in the diagram is a normal sample, and B and C are defective samples, namely groove defects and convex defects, respectively, and labeled as groove and hump).

[0115] Appendix Figure 10 This is a schematic diagram of the actual triangle of the large circular knitting machine. Detailed Implementation

[0116] As shown in the figure, a visual detection method for surface groove machining defects of workpieces is used for the detection of groove defects in the triangular part of a large circular knitting machine. The method uses a lightweight large circular knitting machine triangular groove defect detection model CSGE-DETR. The backbone of the model includes the CGSE module, and the model also includes the SOEP backbone network and the RepC3 module which introduces wavelet convolution WTConv.

[0117] The detection method includes the following steps;

[0118] Step 1: Image Acquisition;

[0119] Step 2: Image preprocessing;

[0120] Step 3: Defect identification.

[0121] In step one, considering the characteristics of the small size, complex structure, and strong background interference of the defects in the triangular groove of the large circular kiln, Hikvision industrial cameras are used for image acquisition. These cameras have high resolution and high dynamic range and can capture subtle structural changes.

[0122] The camera is fixed at a suitable angle using a custom mounting bracket to ensure vertical or near-vertical shooting of the wire groove area, effectively reducing geometric distortion. To solve imaging interference caused by optical astigmatism, the image acquisition system is equipped with a high color rendering index ring LED light source or a multi-angle lighting system. By adjusting the brightness, angle, and light source type, the uniformity of illumination in the measured area is optimized, minimizing highlights and shadows. The image acquisition process is triggered and controlled by a host computer or PLC, and the image acquisition operation is synchronized with the operation of the large circular knitting machine to ensure the stability and repeatability of image acquisition.

[0123] In step two, to improve the accuracy of trough defect detection, the acquired images need to undergo the following preprocessing steps:

[0124] Grayscale conversion: Converting the original image into a grayscale image reduces information redundancy, highlights structural details, and facilitates subsequent analysis;

[0125] Illumination equalization processing: To address the issues of complex backgrounds and uneven illumination, the adaptive histogram equalization CLAHE algorithm is used to locally enhance the image brightness, highlighting the edges of grooves and defect areas.

[0126] Scattering interference suppression: Introduce image smoothing algorithms (such as guided filtering or bilateral filtering) to suppress high-frequency noise and false edges caused by optical scattering while preserving edge details;

[0127] Noise removal: Median filtering or nonlocal mean denoising is applied to the image to reduce the interference of random noise on defect identification;

[0128] ROI Extraction and Standardization: Based on the location of the groove in the image, the region of interest (ROI) is extracted and geometrically corrected or dimensionally standardized to ensure the consistency of defect localization.

[0129] Edge detection and contour enhancement: An improved Canny algorithm combined with morphological processing is used to extract the edges of the grooves and enhance the contrast of defects, providing high-quality input for subsequent recognition and classification.

[0130] In step three, when detecting defects in the triangular groove of the large circular kiln, the image of the normal groove is used as a comparison sample dataset. If the groove being detected is not as flat as the normal groove, it is judged as a defect. Defects are divided into protruding defects and groove defects. They are distributed in the edge contour area and the transition area of ​​the groove bottom. They are small in size, have low contrast, and blurred edges. They are easily affected by complex backgrounds and light reflections, which may lead to missed detection or false detection.

[0131] In step three, the deep learning detection method of the RT-DETR model is improved, and structural optimization and frequency domain enhancement strategies are combined to identify defects, thereby improving the model's accuracy and robustness in identifying defects.

[0132] Improvements to the RT-DETR model include backbone network improvement, multi-scale feature fusion optimization, design of a frequency domain enhancement mechanism, and design of a lightweight adaptive extraction module.

[0133] In step three, the backbone network improvement includes the introduction of the CGSE module, specifically: to improve the feature representation ability of the groove contour and the groove bottom region, the context-guided global semantic enhancement module CGSE is introduced to replace the BasicBlock in the original RT-DETR backbone network.

[0134] The CGSE module introduces multi-scale context and global perception mechanisms, enabling the model to accurately capture local structural anomalies such as protrusions or grooves under complex lighting and diffuse reflection conditions, and maintains clear discrimination ability even in areas with blurred edges.

[0135] The CGSE module combines the channel attention mechanism of SENet and the context interaction mechanism of CGNet, organically integrating the advantages of both. The core feature of the CG module lies in its ability to dynamically fuse local and global features, achieving comprehensive capture of both fine local information and global contextual information, significantly improving the model's ability to distinguish between targets and backgrounds. Simultaneously, context interaction allows small targets to better express their location and characteristics in the global feature space, better capturing 3D defect details and solving the problem of small target features being easily ignored in traditional convolutional operations. Furthermore, SENet's SE module, with its simple and efficient design, dynamically adjusts the weights of feature channels through the channel attention mechanism, further strengthening the model's ability to focus on important features, thereby significantly improving network performance. The channel adaptation feature of the SE module enhances the model's robustness, enabling it to better cope with complex backgrounds and lighting changes. By combining context guidance and channel attention mechanisms, the CGSE module not only inherits the respective advantages of the CG and SE modules but also achieves further performance improvements through their synergistic effect. Figure 2As shown: When the CGSE module works, the input image X is first processed through a 1×1 convolution to reduce the number of channels in the input features, thereby reducing the computational complexity of subsequent 3×3 convolutions and dilated convolutions. Simultaneously, channel information is fused to capture cross-channel correlations, providing a more efficient input representation for subsequent local and global feature extraction, improving feature expressiveness and computational efficiency. Subsequently, it undergoes two 3×3 standard convolutions and dilated convolutions to learn local features and the surrounding context with a larger receptive field, respectively. Then, the outputs of local features and the surrounding context are fused through a connection layer, batch normalization (BN), and parameterized ReLU (PReLU) operations to obtain joint features, expressed by the formula:

[0136] X′=PReLU(BN(Concat(Conv 3×3 (X), DConv 3×3 (X)))) Formula 1; Where PReLU is parameterization; ReLU is the activation function; BN is the batch normalization operation; Conv and Dconv represent two different convolutions; Concat represents the feature concatenation operation; X' represents the parameterized feature map after concatenation.

[0137] Next, X′ is modeled using both channel attention (as described above) and global context (as described below), leveraging channel weighting and global weighting to enhance feature selection and semantic representation. Within the channel attention path, global pooling is used to reduce the spatial dimensionality of the input features, extracting global statistical information for each channel and generating channel description vectors. These channel description vectors are then passed through two fully connected (FC) layers: the first layer uses ReLU activation, and the second layer uses Sigmoid activation. This generates attention weights for each channel. Finally, these channel weights are used to weight each channel of the original input features, resulting in the channel-enhanced feature X. channel This enhances the importance of the channels. This can be expressed by the formula:

[0138]

[0139] z′=ReLU(W1z+b1) Formula 3;

[0140] s=σ(W2z′+b2) Formula 4;

[0141] X channel =s·X′ Formula 5;

[0142] in This is the global description vector of the channels, summarizing the overall spatial importance of each channel; w1 and b1 are the weights and biases of the fully connected layer. The generated channel attention weights are used in the global context modeling below. Global average pooling is applied to the input features to extract global context information, generating a global vector. Then, two fully connected (FC) layers are used to generate global spatial weights, which are applied channel-wise to the input features to obtain globally enhanced features that emphasize the dependencies of the global context. Finally, the two features are fused to give them stronger feature representation capabilities. This can be expressed by the formula:

[0143]

[0144] w global =FC(g) Formula 7;

[0145] X global =w global Formula 8 for X′;

[0146] in It is the extracted global context information; w global It is the adjusted contextual feature; X global | is a global enhancement feature.

[0147] In step three, the multi-scale feature fusion optimization includes Neck structure improvement. Specifically, the triangular groove of the large circular kiln exhibits significant multi-scale feature differences in structure: the groove edge is a narrow, sharp-angled structure, while the groove bottom area is a smooth or arc-shaped transition region. To fully extract defect features at different scales, a backbone convolution layer 1 (S2 layer) structure enhancement strategy is introduced in the Neck part, enabling the model to simultaneously focus on the details of the sharp edges of the groove and the texture and shape changes of the groove bottom concave area, thereby improving the detection capability of small-sized protrusions and concave defects.

[0148] The strategy for enhancing the structure of the first layer of the backbone convolution is the strategy for enhancing the structure of the S2 layer of the backbone convolution.

[0149] The RT-DETR model, with its superior feature extraction capabilities and fine-grained target detection technology, demonstrates excellent detection accuracy, especially when handling large, prominent targets against simple backgrounds. However, the original model's performance deteriorates when faced with tiny defects and complex background interference. Specifically, the original model's feature extraction module may fail to fully capture these subtle changes when dealing with small surface defects, leading to a significant decrease in detection accuracy. Particularly in the detection of defects such as 3D facade grooves and large circular machine triangular grooves, the small size and complex background interference make the targets even more difficult to identify, and the model fails to effectively address these challenges. Furthermore, surface reflection often causes a severe deterioration in image quality, especially when capturing 3D facade groove defects, where reflection exacerbates the target's blurriness. This optical scattering and reflection effect significantly impacts target localization and recognition, further reducing the model's detection accuracy. To overcome these challenges, the model needs to be able to adapt to and handle more complex scenes, fully considering the detection capability for small targets and the interference caused by optical effects, thereby improving its robustness and accuracy in complex environments.

[0150] The feature extraction part of the original model, such as Figure 3 As shown, the feature fusion process in the original model is as follows:

[0151]

[0152] in The fused features are represented by f(.), which is the fusion operation, usually using convolution or weighted averaging. s3, s4, and s5 represent the high-level features extracted from different layers, respectively.

[0153] In step four, an additional feature extraction layer is added to the original RT-DETR model, introducing a deeper convolutional structure and incorporating a multi-scale feature enhancement mechanism. In this study, we specifically introduce the S2 layer features from the backbone network for fusion. As a low-level feature, the S2 feature carries more detailed information, significantly improving detection accuracy, especially when dealing with small defects. Low-level features are typically highly sensitive to subtle changes, allowing the S2 layer to effectively avoid details that higher-level features might miss when capturing small defects, thereby enhancing the model's local detection capabilities and improving its structure. Figure 4 As shown, the new feature fusion formula is:

[0154]

[0155] in This represents the feature after fusion with the addition of s2, where f(.) is the fusion operation, usually using convolution or weighted averaging, and s2, s3, s4, and s5 represent the high-level features extracted from different layers, respectively.

[0156] By introducing S2 features, the model becomes more robust in capturing small targets and handling complex background interference. When faced with minute defects such as triangular grooves in large circular knitting machines and three-dimensional vertical surface grooves, the introduction of S2 features can better capture these subtle surface variations. Furthermore, the detailed information in the S2 layer is well-adapted to effects such as optical scattering and surface reflection, helping the model reduce image blurring caused by optical reflection and improving the accuracy of target localization and recognition.

[0157] By comprehensively utilizing features at different levels, the network's sensitivity to defects at different scales and under complex backgrounds is enhanced, thereby improving overall detection performance. Especially in highly complex scenarios, the model can fully leverage the advantages of multi-scale features, improving its ability to identify small targets and minute defects, enabling it to better cope with the challenges of complex backgrounds and surface optical effects in practical industrial applications. Therefore, this improvement not only increases detection accuracy but also enhances the model's robustness, promoting its potential for application in real-world scenarios.

[0158] In step three, the frequency domain enhancement mechanism includes the introduction of the WTConv module. Specifically, protrusions and grooves often manifest as high-frequency information such as texture breaks and contour changes. To enhance the model's frequency domain perception capability, wavelet convolution WTConv is introduced into the RePc3 module to capture subtle texture perturbations and local discontinuities in the frequency domain, making the model more sensitive to the presence of minor defects, especially those tiny grooves or slight protrusions that are difficult to detect with traditional convolution.

[0159] In the traditional RT-DETR model, the feature fusion stage employs the RepC3 (Reparameterized Convolutional Block with 3 Convolutions) structure. This structure batch normalizes the input feature map and effectively extracts features using 3×3 and 1×1 convolutions. Then, it element-wise adds the batch-normalized input feature map to these extracted features, and finally uses the SiLU activation function to achieve a non-linear transformation to generate the output. Figure 5 and Figure 6 As shown:

[0160] The RepC3 structure can optimize feature fusion to a certain extent, especially performing well in handling relatively simple visual tasks. However, when faced with complex scenes, especially high-resolution images, RepC3 has high computational complexity and fails to fully utilize multi-scale information, resulting in a decrease in the model's real-time processing performance and consequently affecting the accuracy of triangular groove defect detection on large circular knitting machines.

[0161] When dealing with the problem of detecting defects in wire grooves, factors such as the small size of the defects, complex background interference, and surface reflection often cause existing detection algorithms to miss or falsely detect defects during the feature extraction stage. Therefore, improving the model's ability to detect small defects in complex backgrounds has become the key to improving accuracy.

[0162] To address the shortcomings of RepC3 in multi-scale feature fusion, wavelet convolution WTConv (WTConv) was introduced in the feature fusion stage. Figure 7 );

[0163] Given an image X, the first-order Haar WT in one spatial dimension (width or height) is determined by the kernel. and The depthwise convolution is given, followed by a standard downsampling operator with a factor of 2; to perform a 2D Haar WT, the operation is combined in two dimensions using the following four filters to produce a depthwise convolution with a stride of 2:

[0164]

[0165] Formula 11;

[0166] f LL It is a low-pass filter, and f LH f HL f HH It is a set of high-pass filters;

[0167] For each input channel, the output of the convolution is:

[0168] [X LL X LH X HL X HH ] = Conv([f LL f LH f HL f HH Formula 12;

[0169] That is, there are four channels, and the resolution of each channel (in each spatial dimension) is half of X; X LL It is the low-frequency component of X, X LH X HL X HH The horizontal, vertical, and diagonal high-frequency components are represented by _; since the convolution kernel forms an orthonormal basis, the inverse wavelet transform (IWT) is obtained through transpose convolution:

[0170] X = Conv-transposed([f LL f LH f HL f HH ], [XLL X LH X HL X HH ]). Formula 13;

[0171] Then, the cascaded wavelet decomposition is given by recursively decomposing the low-frequency components.

[0172]

[0173] in And i is the current level, which leads to an increase in frequency and a decrease in spatial resolution at lower frequencies; convolution in the wavelet domain yields a larger receptive field, in the second-order wavelet domain Performing a 3×3 convolution on the low-frequency band will produce a corresponding 9-parameter convolution, corresponding to the lower frequencies of the 12×12 receiving field in the input X;

[0174] Wavelet Convolution (WTConv) enhances a model's ability to extract and fuse features at multiple scales by introducing a learnable weighting mechanism. WTConv can dynamically adjust the weights of convolution operations to effectively extract key information at different scales. Especially when dealing with minute defects and complex backgrounds, it can effectively reduce noise interference and improve sensitivity to details.

[0175] After being introduced into the RepC3 structure, WTConv overcomes the shortcomings of traditional convolution, especially in the detection of triangular groove defects on large circular kilns, where it can handle the challenges of small defect size, complex background interference, and surface reflection. Its ability to dynamically adjust the convolution kernel weights allows the model to more accurately capture subtle changes in the image while effectively reducing the computational burden and ensuring high detection accuracy.

[0176] In summary, the introduction of WTConv enhances the model's ability to process multi-scale information, improves the detection accuracy of small targets, and significantly improves real-time processing efficiency while maintaining low computational cost, providing strong technical support for defect detection in complex scenarios.

[0177] In step three, the lightweight adaptive extraction module LAE is designed as follows: by introducing an attention mechanism, the feature weights of different channels are dynamically adjusted to enhance important features and suppress redundant features, thereby significantly reducing the number of model parameters and computational costs, which is suitable for real-time on-site detection needs.

[0178] In the task of detecting triangular groove defects on large circular knitting machines, although the 3×3 convolution in the traditional neck module can extract local features, its fixed receptive field and kernel size often make it difficult to capture subtle changes and long-range dependencies in defects. In particular, when the defect morphology is complex and the scale varies greatly, the limitations of 3×3 convolution may affect the accuracy and robustness of feature extraction, thereby reducing the detection effect.

[0179] To address this issue, the original 3×3 convolution was replaced by the Lightweight Adaptive Extraction (LAE) module in LSM-YOLO, aiming to perform multi-scale feature extraction while reducing computational costs. LAE achieves more efficient feature extraction through multi-scale and adaptive feature extraction. The LAE module can improve the model's detection performance in Regions of Interest (ROIs) without adding extra parameters, enabling more precise focusing on key areas where defects are located and enhancing the ability to capture detailed features. This makes it more robust and flexible in handling defects with complex shapes and varied locations, adapting to changes in deformation and scale. The results are as follows: Figure 8 As shown;

[0180] The LAE module contains two parallel branches for lightweight feature extraction and adaptive feature extraction, respectively. The input data is a tensor of shape h×w×c, where h represents the image height, w represents the image width, and c represents the number of channels. In the lightweight feature extraction process, computation is reduced by employing group convolution and smaller convolution kernels. Specifically, group convolution divides the input feature map into multiple groups and performs convolution operations independently on each group. This strategy significantly reduces computation and memory consumption while preserving sufficient feature information. The core advantage of group convolution lies in optimizing resource utilization by breaking down the convolution operation into multiple smaller computational units. This can be expressed as:

[0181]

[0182] Among them, X input For the input feature map, Indicates the number of groups;

[0183] Next, the feature map undergoes dimension mapping, which rearranges the data structure through a rearrange operation. This operation adjusts the shape of the tensors or reorganizes the data, making the feature map format more suitable for subsequent feature processing, especially the adaptive feature extraction stage.

[0184] The purpose of the Rearrange operation is to optimize the data flow so that subsequent operations can effectively extract multi-scale features and perform corresponding transformations; expressed by the formula:

[0185] X rearranged =Rearrange(X grouped ) Formula 17;

[0186] Where X grouped The feature map X is the result of grouped convolution processing during the lightweight feature extraction stage. rearranged This is a new feature map obtained after rearranging, which changes in dimension or structure, aiming to optimize data flow and enhance the model's feature extraction capabilities. Then, the pooled feature map undergoes further feature extraction through a 1×1 convolution (Conv) operation. The purpose of the 1×1 convolution is to compress or expand the features by adjusting the number of channels per pixel, while retaining key information and improving expressive power; this operation helps extract high-dimensional features, expressed by the formula:

[0187] X conv =Conv(X adaptive W conv ) Formula 19;

[0188] Among them W conv It is the convolution kernel, X conv It is the feature map after the convolution operation;

[0189] The next step, rearranging the data structure through the Rearrange operation, readjusts the shape of the tensors to accommodate the subsequent Softmax normalization operation. This rearrangement adjusts the data into a structure suitable for further processing, facilitating efficient feature fusion, as expressed by the formula:

[0190] X rearranged =Rearrange(X conv ) Formula 20;

[0191] Where X conv This represents the feature map extracted through convolution operations. This feature map is the result of average pooling (AP) and convolution (Conv) operations in the adaptive feature extraction part. X rearranged It is the rearranged feature map, whose shape or dimensions have been reorganized to ensure it is suitable for subsequent processing stages, especially the final Softmax normalization;

[0192] The feature maps after rearrangement are normalized using a Softmax operation. Softmax normalization transforms the feature values ​​into a probability distribution, ensuring that each feature value falls within a suitable range. This helps improve the model's stability and generalization ability. Finally, the features from the two parallel branches are fused, as expressed by the formula:

[0193] X final =Softmax(X rearranged ) Formula 21;

[0194] X output =X mapped ×X final Formula 22;

[0195] Where X mapped It is the output of lightweight feature extraction, X final It is the output of adaptive feature extraction, X output These are the feature maps after they have been fused;

[0196] The feature maps fused through multiplication are then further integrated through summation. This summation process adds the fused feature map to other possible feature maps, thereby enhancing the model's feature representation ability and information transmission effect. This operation helps to effectively integrate feature information from different sources, improves the model's ability to capture complex patterns, and significantly enhances its accuracy and generalization ability. The LAE module optimizes the integration of multi-scale information by fusing feature maps from two parallel branches. This fusion process not only effectively improves the model's feature extraction ability but also enhances its adaptability to different types of features, thereby improving the overall detection accuracy and effect. Compared with traditional convolution operations, the LAE module can greatly improve the accuracy and efficiency of feature extraction without significantly increasing computational overhead. Through this optimization, the LAE module not only significantly improves the accuracy of detecting triangular groove defects in large circular knitting machines but also makes the overall detection process more efficient, demonstrating its advantages in practical applications.

[0197] The large circular knitting machine triangular groove defect detection model is trained based on the large circular knitting machine triangular groove defect dataset, which is a self-made dataset taken with a Hikvision camera.

[0198] The data acquisition method for the large circular knitting machine triangular groove defect dataset is as follows: the camera captures images along the groove path to ensure complete defect imaging. It includes two types of defect images: humps and grooves, totaling 600 images. Due to the small sample size of the original dataset, this paper employs data augmentation to increase the sample size, including blurring, brightness adjustment, random cropping, rotation, translation, and mirroring. Blurring reduces detail information in the image, producing a version that differs from the original but is highly relevant, increasing the diversity of images in the training set and helping the model learn richer features. Brightness adjustment involves changing the brightness of the image, simulating brightness deviations under different ambient lighting conditions, improving the model's adaptability to different brightness levels. Random cropping extracts a region of random size and location from the image to remove certain parts, improving the model's adaptability to image transformations. Image rotation rotates the image around its center point by a certain angle, obtaining several different angles of the same image defect. Translation and mirroring move and flip the image, respectively. The expanded dataset contains 1200 images, and is randomly divided into training and test sets in an 8:2 ratio.

Claims

1. A visual inspection method for surface groove machining defects on a workpiece, used for detecting groove defects in the triangular section of a large circular knitting machine, characterized in that: The method uses a lightweight large circular machine triangular groove defect detection model CSGE-DETR. The backbone of the model includes the CGSE module, and the model also includes the SOEP backbone network and the RepC3 module that introduces wavelet convolution WTConv. The detection method includes the following steps; Step 1: Image Acquisition; Step 2: Image preprocessing; Step 3: Defect identification.

2. The visual inspection method for surface groove machining defects of a workpiece according to claim 1, characterized in that: In step one, Hikvision industrial cameras are used for image acquisition. The cameras are fixed at a suitable angle using custom mounting brackets to ensure vertical or near-vertical shooting of the wire groove area. The image acquisition system is equipped with a high color rendering index ring LED light source or a multi-angle lighting system. By adjusting the brightness, angle, and light source type, the uniformity of illumination in the measured area is optimized. The image acquisition process is triggered and controlled by a host computer or PLC. The image acquisition operation is synchronized with the operation of the large circular knitting machine to ensure the stability and repeatability of image acquisition.

3. The visual inspection method for surface groove machining defects of a workpiece according to claim 1, characterized in that: In step two, to improve the accuracy of trough defect detection, the acquired images need to undergo the following preprocessing steps: Grayscale conversion: Converting the original image into a grayscale image reduces information redundancy, highlights structural details, and facilitates subsequent analysis; Illumination equalization processing: To address the issues of complex backgrounds and uneven illumination, the adaptive histogram equalization CLAHE algorithm is used to locally enhance the image brightness, highlighting the edges of grooves and defect areas. Scattering interference suppression: An image smoothing algorithm is introduced to suppress high-frequency noise and false edges caused by optical scattering; Noise removal: Median filtering or non-local mean denoising is applied to the image to reduce the interference of random noise on defect identification; ROI Extraction and Standardization: Based on the location of the groove in the image, the region of interest (ROI) is extracted and geometrically corrected or dimensionally standardized to ensure the consistency of defect localization. Edge detection and contour enhancement: An improved Canny algorithm combined with morphological processing is used to extract the edges of the grooves and enhance the contrast of defects.

4. The visual inspection method for surface groove machining defects of a workpiece according to claim 1, characterized in that: In step three, when inspecting the defects of the triangular groove of the large circular knitting machine, the image of the normal groove is used as the comparison sample dataset. If the groove being inspected is not as flat as the normal groove, it is judged as a defect. Defects are divided into protruding defects and groove defects; they are distributed in the edge contour area and the transition area of ​​the groove bottom. In step three, the deep learning detection method of the improved RT-DETR model is combined with structural optimization and frequency domain enhancement strategies to identify defects. Improvements to the RT-DETR model include backbone network improvement, multi-scale feature fusion optimization, design of a frequency domain enhancement mechanism, and design of a lightweight adaptive extraction module.

5. The visual inspection method for surface groove machining defects of a workpiece according to claim 4, characterized in that: In step three, the backbone network improvement includes the introduction of the CGSE module, specifically: the introduction of the Context-Guided Global Semantic Enhancement (CGSE) module, which is used to improve the RT-DETR model's ability to represent features of the groove contour and groove bottom region. The CGSE module introduces multi-scale context and global awareness mechanisms, enabling the model to accurately capture local structural anomalies of protrusions or grooves under complex lighting and diffuse reflection conditions. The CGSE module combines SENet's channel attention mechanism with CGNet's context interaction mechanism. When the CGSE module works, the input image X is first processed through a 1×1 convolution to reduce the number of channels in the input features, thus reducing the computational complexity of subsequent 3×3 and dilated convolutions. Simultaneously, channel information is fused to capture cross-channel correlations, providing a more efficient input representation for subsequent local and global feature extraction, improving feature expressiveness and computational efficiency. Subsequently, it passes through two standard 3×3 convolutions and a dilated convolution to learn local features and the surrounding context with a larger receptive field, respectively. Then, the outputs of the local features and the surrounding context are fused through a connection layer, batch normalization (BN), and parameterized ReLU operations to obtain joint features, expressed as a formula: X′=PReLU(BN(Concat(Conv 3×3 (X), DConv 3×3 (X)))) Formula 1; Where PReLU is parameterization; ReLU is the activation function; BN is the batch normalization operation; Conv and Dconv represent two different convolutions; Concat represents the feature concatenation operation; X' represents the parameterized feature map after concatenation. Next, X′ is modeled using both channel attention (as described above) and global context (as described below), leveraging channel weighting and global weighting to enhance feature selection and semantic representation. Within the channel attention path, global pooling is used to reduce the spatial dimensionality of the input features, extracting global statistical information for each channel and generating channel description vectors. These channel description vectors are then passed through two fully connected (FC) layers: the first layer uses ReLU activation, and the second layer uses Sigmoid activation. This generates attention weights for each channel. Finally, these channel weights are used to weight each channel of the original input features, resulting in the channel-enhanced feature X. channel This enhances the importance of the channels; expressed by the formula: z′=ReLU(W1z+b1) Formula 3; s=σ(W2z′+b2) Formula 4; X channel =s·X′ Formula 5; in This is the global description vector of the channels, summarizing the overall spatial importance of each channel; w1 and b1 are the weights and biases of the fully connected layer. These are the generated channel attention weights; In global context modeling, global average pooling is used to extract global context information from the input features, generating a global vector. Then, two fully connected layers (FC) are used to generate global spatial weights to weight the input features channel by channel, resulting in a globally enhanced feature that emphasizes the dependencies of the global context. Finally, the two features are fused to give it a stronger feature representation capability. Expressed as a formula: w global =FC(g) Formula 7; X global =w global Formula 8 for X′; in It is the extracted global context information; w global These are adjusted contextual features; X global It is a global enhancement feature.

6. The visual inspection method for surface groove machining defects of a workpiece according to claim 4, characterized in that: In step three, the multi-scale feature fusion optimization includes Neck structure improvement, specifically: the edge of the triangular groove of the large circular lobe is a narrow, sharp-angled structure, and the bottom area of ​​the groove is a smooth or arc-shaped transition area; in order to fully extract the defect features at different scales, a backbone convolution first layer structure enhancement strategy is introduced in the Neck part, so that the model can simultaneously focus on the details of the sharp edge of the groove and the texture and shape changes of the concave area at the bottom of the groove, thereby improving the detection capability of small-sized protrusions and concave defects; The strategy for enhancing the structure of the first layer of the backbone convolution is the strategy for enhancing the structure of the S2 layer of the backbone convolution. Suppose the feature fusion process in the original RT-DETR model is as follows: in The fused features are represented by f(.), which is the fusion operation. s3, s4, and s5 represent the high-level features extracted from different layers, respectively. In step four, an additional feature extraction layer is added to the original RT-DETR model, introducing a deeper convolutional structure and combining it with a multi-scale feature enhancement mechanism. Specifically, features from the S2 layer of the backbone network are introduced for fusion. S2 features are low-level features that carry more detailed information, enhancing the model's local detection capabilities. The feature fusion formula is as follows: in This indicates the feature after fusion with the addition of s2, f(.) is the fusion operation, and s2, s3, s4, and s5 represent the high-level features extracted from different layers, respectively. By introducing S2 features, the model becomes more robust in capturing small targets and handling complex background interference, thereby improving the accuracy of target localization and recognition.

7. The visual inspection method for surface groove machining defects of a workpiece according to claim 4, characterized in that: In step three, the frequency domain enhancement mechanism includes the introduction of the WTConv module. Specifically, protrusions and grooves are manifested as high-frequency information of texture breaks and contour changes. To enhance the frequency domain perception capability of the model, wavelet convolution WTConv is introduced in the RePc3 module to capture subtle texture perturbations and local discontinuities in the frequency domain, making the model more sensitive to the presence of minor defects. Specifically: Wavelet convolution WTConv is introduced in the feature fusion stage; given an image X, a first-level Haar WT in one spatial dimension is formed by the kernel. and The depthwise convolution is given, followed by a standard downsampling operator with a factor of 2; to perform a 2D Haar WT, the operation is combined in two dimensions using the following four filters to produce a depthwise convolution with a stride of 2: f LL It is a low-pass filter, and f LH f HL f HH It is a set of high-pass filters; For each input channel, the output of the convolution is: [X LL X LH X HL X HH ] = Conv([f LL f LH f HL f HH Formula 12; That is, there are four channels, and the resolution of each channel in each spatial dimension is half of X; X LL It is the low-frequency component of X, X LH X HL X HH _ represents its horizontal, vertical, and diagonal high-frequency components; The convolution kernels form an orthonormal basis, and the inverse wavelet transform (IWT) is obtained by transposing the convolution kernels. X=Conv-transposed([f LL ,f LH ,f HL ,f HH ], [X LL ,X LH ,X HL X HH ]). Formula 13; Then, the cascaded wavelet decomposition is given by recursively decomposing the low-frequency components. in And i is the current level, leading to an increase in frequency and a decrease in spatial resolution at lower frequencies; convolution in the wavelet domain yields a larger receptive field, in the second-order wavelet domain. Performing a 3×3 convolution on the low-frequency band produces a corresponding 9-parameter convolution, corresponding to the lower frequencies of the 12×12 receiving field in the input X; Wavelet convolution WTConv enhances the model's ability to extract and fuse features at multiple scales by introducing a learnable weighting mechanism; WTConv dynamically adjusts the weights of the convolution operation to extract key information at different scales.

8. The visual inspection method for surface groove machining defects of a workpiece according to claim 4, characterized in that: In step three, the lightweight adaptive extraction module (LAE) is designed by dynamically adjusting the feature weights of different channels through the introduction of an attention mechanism, thereby enhancing important features, suppressing redundant features, and reducing the number of model parameters and computational cost. Specifically, the LAE module contains two parallel branches, one for lightweight feature extraction and the other for adaptive feature extraction. The input data is a tensor of shape h×w×c, where h represents the image height, w represents the image width, and c represents the number of image channels. In the lightweight feature extraction process, grouped convolution and small convolution kernels are used to reduce computation. Specifically, grouped convolution divides the input feature map into multiple groups and performs convolution operations independently on each group. By breaking down the convolution operation into multiple small computational units, resource utilization is optimized. This can be expressed by the formula: Among them, X input For the input feature map, Indicates the number of groups; Next, the feature map undergoes dimension mapping, and the data structure is rearranged through the Rearrange operation; by adjusting the shape of the tensor or reorganizing the data, the format of the feature map is adapted to the adaptive feature extraction stage of the feature processing. The purpose of the Rearrange operation is to optimize the data flow, which can be expressed by the formula: X rearranged =Rearrange(X grouped ) Formula 17; Where X grouped The feature map X is the result of grouped convolution processing during the lightweight feature extraction stage. rearranged This is a new feature map obtained after rearranging, with changes in dimension or structure. The pooled feature map undergoes further feature extraction through a 1×1 convolution (Conv) operation. The role of the 1×1 convolution is to compress or expand the features by adjusting the number of channels in each pixel, while retaining key information and improving expressive power. This can be expressed by the formula: X conv =Conv(X adaptive W conv ) Formula 19; Among them W conv It is the convolution kernel, X conv It is the feature map after the convolution operation; The next step, rearranging the data structure through the Rearrange operation, readjusts the shape of the tensors to accommodate the subsequent Softmax normalization operation. This rearrangement adjusts the data into a structure suitable for further processing, facilitating efficient feature fusion. This can be expressed by the formula: X rearranged =Rearrange(X conv ) Formula 20; Where X conv This represents the feature map extracted through convolution operations. This feature map is the result of average pooling (AP) and convolution (Conv) operations in the adaptive feature extraction part. X rearranged It is the rearranged feature map, whose shape or dimensions have been reorganized to ensure it is suitable for subsequent processing stages, especially the final Softmax normalization; The feature maps after rearrangement are normalized using a Softmax operation. Softmax normalization transforms the feature values ​​into a probability distribution, ensuring that each feature value falls within a suitable range, thus improving the model's stability and generalization ability. Finally, the features from the two parallel branches are fused, as expressed by the formula: X final =Softmax(X rearranged ) Formula 21; X output =X mapped ×X final Formula 22; Where X mapped It is the output of lightweight feature extraction, X final It is the output of adaptive feature extraction, X output These are the feature maps after they have been fused; The feature maps fused by multiplication are then further integrated by summation, which adds the fused feature maps to other possible feature maps to enhance the model's feature representation ability and information transmission effect.

9. The visual inspection method for surface groove machining defects of a workpiece according to claim 1, characterized in that: The large circular knitting machine triangular groove defect detection model is trained based on the large circular knitting machine triangular groove defect dataset, which is a self-made dataset taken with a Hikvision camera.

10. A visual inspection method for surface groove machining defects on a workpiece according to claim 1, characterized in that: The data acquisition method for the large circular knitting machine's triangular groove defect dataset is as follows: the camera captures images along the groove path, ensuring complete defect imaging. This dataset includes two types of defect images: protrusions and grooves. Data augmentation was used to increase the sample size of the dataset, including image operations such as blurring, brightness adjustment, random cropping, rotation, translation, and mirroring. The augmented dataset was then randomly divided into training and test sets according to a set ratio.

Citation Information

Cited By

  • Water conservancy and hydropower engineering underwater multi-mode imaging detection method and sensing equipment

    CN122223021A