A robust fabric defect detection method based on elastic momentum snake convolution
Patent Information
- Application Number
- CN202611121306.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-27
- Publication Date
- 2026-10-16
AI Technical Summary
[0005]针对现有技术中存在复杂背景下细长缺陷、不连续缺陷、缺陷尺寸差别大,导致检测精度低的技术问题,本发明提出一种基于弹性动量蛇卷积的鲁棒织物缺陷检测方法,通过空间方向信息编码提供空间引导信息,通过弹性门控机制和动量传播机制增强对不连续缺陷特征的提取能力,通过多感受野提取并融合特征精准捕捉不同尺度缺陷,有效提高了织物缺陷检测的精度和鲁棒性
[0044] The beneficial effects of this invention are as follows: This invention is a fabric defect detection method based on elastic momentum snake convolution. It uses the YOLOv26 target detection network as the baseline model, and then introduces a spatially guided attention module to provide stable directional spatial priors, enhancing topology-aware feature tracking capabilities. The elastic momentum snake convolution module suppresses sampling offsets caused by background noise through an elastic gating mechanism and maintains structural continuity in discontinuous regions using a momentum propagation mechanism, effectively improving the model's feature extraction capabilities for slender and fractured defects. Based on this, a multi-scale cross-layer fusion module is constructed to improve the model's learning ability at various defect sizes. Finally, the final result is predicted using three detection heads at different scales. This not only enhances the feature representation capability of the target detection network but also effectively improves the accuracy and robustness of fabric defect detection.
Smart Images

Figure CN122928795A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the technical field of fabric defect detection, and more particularly to a robust fabric defect detection method based on the YOLOv26n model, which is especially suitable for detecting defects in fabrics with discontinuous features. Background Technology
[0002] In the textile industry, quality assurance is crucial for maintaining product standards and customer satisfaction. Defects are typically caused by accidental machine malfunctions and repetitive errors during production, leading to problems such as warp and weft misalignment and structural discontinuities. Due to the specific conditions under which defects occur, their internal features often exhibit elongated shapes, high aspect ratios, and discontinuous local features. Furthermore, collecting images of these defective samples is difficult, requiring extensive human visual inspection. Early defect detection relied primarily on manual visual inspection, a method that is labor-intensive, time-consuming, and sometimes causes secondary damage to products. With the rapid increase in production volume, this method can no longer meet the growing demands of industrial applications. The rapid development of machine vision has provided strong support for the automated detection of fabric defects, making quality control in the production process more efficient and precise.
[0003] Currently, widely used object detection methods are mainly divided into two categories: one-stage and two-stage. Two-stage methods are region-based algorithms that divide object detection into two stages: detection and recognition. First, the algorithm or network searches for regions of interest in the image, and then identifies the objects within those regions, such as R-CNN, Fast-RCNN, and Faster-RCNN. One-stage methods, on the other hand, are end-to-end algorithms that use regression to directly generate the object's class probability and location coordinates, achieving both detection and recognition, such as YOLO and SSD. One-stage methods are significantly faster than two-stage methods, but their accuracy is relatively lower.
[0004] Unlike natural scene images, fabric defects, under complex production environments and imaging interference, often exhibit elongated shapes, large aspect ratios, and local texture discontinuities, such as edge weft shrinkage, skipped warp yarns, thick weft, and sparse-density patterns. Their structures show obvious discontinuities and anisotropy. Directly applying natural scene object detection methods to fabric defect detection tasks does not yield satisfactory results. In recent years, many researchers have improved and applied these classic algorithms to the field of fabric defect detection. For example, researchers [Zhang L, Li X, Sun Y, et al. Triple-attentions based salient object detector for strip steel surface defects[J].Scientific Reports, 2025, 15(1): 2537.] proposed a single-stage network TADet based on ResNet, which performs defect texture recognition tasks and achieves a highly efficient detection network. Zhao [Zhao T, Liu B, Gao Y, et al. Rethinking multi-modal object detection from the perspective of mono-modality feature learning[C] / / Proceedings of the IEEE / CVF International Conference on Computer Vision. 2025: 6364-6373.] designed an attention-based multi-scale fusion method applied to Faster R-CNN, guiding the model to focus more on defects rather than background regions, thus enhancing the model's ability to identify defect regions. Guo [Guo Y, Kang X, Li J, et al. Automatic fabricdefect detection method using AC-YOLOv5[J]. Electronics, 2023, 12(13): 2950.] improved upon YOLOv5 by proposing dilated convolutional pooling and convolutional compression activation modules, and self-learned the weights of each feature channel to further improve defect detection and anti-interference capabilities.Zeng [Zeng Z, Liu B, Fu J, et al. Reference-based defect detection network[J]. IEEE Transactions on Image Processing, 2021, 30: 6637-6647.] proposed a reference-based defect detection network (RDDN) based on Faster R-CNN by introducing template references and context references. However, the above method does not fully consider the joint modeling of the topological continuity of fabric defects and local detail features when dealing with the problem of low accuracy caused by slender defects and discontinuous defects in complex backgrounds. Summary of the Invention
[0005] To address the technical problem of low detection accuracy caused by slender defects, discontinuous defects, and large differences in defect size under complex backgrounds in existing technologies, this invention proposes a robust fabric defect detection method based on elastic momentum snake convolution. This method provides spatial guidance information through spatial orientation information encoding, enhances the ability to extract features of discontinuous defects through elastic gating and momentum propagation mechanisms, and accurately captures defects of different scales by extracting and fusing features through multiple receptive fields, thereby effectively improving the accuracy and robustness of fabric defect detection.
[0006] To achieve the above objectives, the technical solution of the present invention is implemented as follows:
[0007] A robust fabric defect detection method based on elastic momentum serpentine convolution includes:
[0008] S1: Obtain a dataset of fabric defect images, preprocess the dataset, and divide it into a training set, a validation set, and a test set according to a preset ratio.
[0009] S2: Construct a fabric defect detection network model; the fabric defect detection network model includes a backbone network, a multi-scale fusion network, and a detection head connected in sequence; both the backbone network and the multi-scale fusion network introduce SGA and EMS-Conv modules. The SGA module is used to encode spatial orientation information of the input feature map and provide spatial guidance information; the EMS-Conv module is used to suppress sampling offset through elastic gating mechanism and enhance the structural continuity of discontinuous regions through momentum propagation mechanism; the multi-scale fusion network introduces an MCFM module for extracting and fusing multi-scale features based on multiple receptive fields;
[0010] S3: Use the training set and validation set to train and validate the fabric defect detection network model, and obtain the trained defect detection network model.
[0011] S4: Use the trained fabric defect detection network model to detect fabric images in the test set and output the fabric defect detection results.
[0012] Furthermore, the backbone network adopts the YOLOv26n backbone network as the baseline model, including a feature extraction layer and a feature output layer; a first EMS-Conv module is introduced in the 5th layer of the feature extraction layer; a first SGA module is introduced in the 8th layer of the feature extraction layer; and a second SGA module is introduced in the 13th layer of the feature extraction layer; the output of the first EMS-Conv module is used as the small-scale high-resolution output of the feature output layer; the output of the first SGA module is used as the medium-scale medium-resolution output of the feature output layer; and the output of the second SGA module is used as the large-scale low-resolution output of the feature output layer.
[0013] Furthermore, the multi-scale fusion network adopts the neck network of YOLOv26n as the baseline model. The multi-scale fusion network includes a top-down upsampling fusion path and a bottom-up downsampling fusion path. The top-down upsampling fusion path includes a first upsampling fusion stage and a second upsampling fusion stage in sequence. A second EMS-Conv module is introduced at layer 17 corresponding to the first upsampling fusion stage, and a first MCFM module is introduced at layer 21 corresponding to the second upsampling fusion stage. The bottom-up downsampling fusion path includes a first downsampling fusion stage and a second downsampling fusion stage in sequence. A second MCFM module is introduced at layer 25 corresponding to the first downsampling fusion stage, a third SGA module is introduced at layer 29 corresponding to the second downsampling fusion stage, and a third MCFM module is introduced at layer 30 corresponding to the second downsampling fusion stage.
[0014] Furthermore, in multi-scale fusion networks, including:
[0015] In the first upsampling fusion stage, the large-scale low-resolution output undergoes the first UpSample operation and then the medium-scale medium-resolution output undergoes the first Concat operation to output the first stitching feature. The first stitching feature then passes through the fifth C3k2 layer and the second EMS-Conv module in sequence to output the first upsampling fusion feature.
[0016] In the second upsampling fusion stage, the first upsampling fusion feature is subjected to the second UpSample operation and then the small-scale high-resolution output is subjected to the second Concat operation to output the second stitched feature. The second stitched feature is then passed through the sixth C3k2 layer and the first MCFM module in sequence to output the second upsampling fusion feature.
[0017] In the first downsampling fusion stage, the second upsampling fusion feature passes through the sixth Conv layer and then undergoes a third Concat operation with the first upsampling fusion feature to output the third concatenated feature. The third concatenated feature then passes through the seventh C3k2 layer and the second MCFM module in sequence to output the first downsampling fusion feature.
[0018] In the second downsampling fusion stage, the first downsampling fusion feature passes through the seventh Conv layer and then undergoes the fourth Concat operation with the large-scale low-resolution output to output the fourth stitched feature. The fourth stitched feature passes through the eighth C3k2 layer, the third SGA module, and the third MCFM module in sequence to output the second downsampling fusion feature.
[0019] The detection head includes a first Detect module, a second Detect module, and a third Detect module. The second upsampled fusion feature output by the first MCFM module is used as the input of the first Detect module to detect small fabric defects. The first downsampled fusion feature output by the second MCFM module is used as the input of the second Detect module to detect medium-sized fabric defects. The second downsampled fusion feature output by the third MCFM module is used as the input of the third Detect module to detect large fabric defects.
[0020] Furthermore, the SGA module includes: a horizontal information extraction branch, a vertical information extraction branch, and a feature fusion unit;
[0021] The horizontal information extraction branch is used to perform horizontal global information aggregation on the input feature map of the SGA module to obtain horizontal features;
[0022] The vertical information extraction branch is used to perform vertical global information aggregation on the input feature map of the SGA module to obtain vertical features;
[0023] The feature fusion unit is used to fuse horizontal and vertical features to generate orientation-aware spatial attention weights, and then use the orientation-aware spatial attention weight map to recalibrate the input feature map to obtain a spatially guided feature map.
[0024] Furthermore, the EMS-Conv module includes a basic feature extraction branch, an offset prediction branch, an elastic gating branch, and a momentum propagation branch;
[0025] The basic feature extraction branch is used to extract basic features from the input feature map of the EMS-Conv module;
[0026] The offset prediction branch is used to predict the dynamic sampling offset based on the input feature map of the EMS-Conv module through deformable sampling.
[0027] The elastic gating branch is used to generate elastic gating weights based on the input feature map of the EMS-Conv module, and to suppress dynamic sampling offsets and fuse them with basic features through the elastic gating mechanism to obtain a stable dynamic sampling feature map after elastic constraints.
[0028] The momentum propagation branch is used to transfer information from the historical feature map output by the EMS-Conv module in the previous training iteration to the stable dynamic sampling feature map after elastic constraints, based on the input feature map of the EMS-Conv module, to obtain the output feature map of the current EMS-Conv module.
[0029] Furthermore, the MCFM module includes: a multi-branch feature extraction structure and an adaptive weight fusion unit;
[0030] A multi-branch feature extraction structure is used to extract features through feature extraction branches with different receptive fields to obtain multi-scale feature representations.
[0031] The adaptive weighted fusion unit is used to adaptively weight and fuse multi-scale feature representations to obtain the output feature map of the MCFM module.
[0032] Furthermore, in the SGA module, the processing procedures for the horizontal information extraction branch and the vertical information extraction branch include:
[0033] Input feature map of the SGA module Global average pooling is performed along both the horizontal and vertical directions to aggregate global information, with the horizontal pooling output being the final result. and vertical pooling output B represents the batch size, C represents the number of feature channels, H represents the feature map height, and W represents the feature map width.
[0034] In the SGA module, the feature fusion unit's processing includes:
[0035] Pooling output in the spatial dimension in the horizontal direction and vertical pooling output Perform splicing to obtain splicing features Use convolutional layers with a kernel size of 1×1 to stitch together features. Perform channel compression to obtain compression characteristics. r is the compression ratio; for compression features BatchNorm batch normalization and H-Swish nonlinear activation are performed to obtain the encoded features. ; for coding features Slice the data and extract vertical branch features separately. and horizontal branching features ; for vertical branch features and horizontal branching features The input feature map is then subjected to 1×1 convolution to restore the dimensionality of the channels, and then mapped to the 0~1 interval using the Sigmoid activation function to obtain the vertical spatial attention weight map X and the horizontal spatial attention weight map Y. The vertical spatial attention weight map X and the horizontal spatial attention weight map Y are then used to adjust the input feature map. Weighting is performed to obtain spatially guided feature maps. , .
[0036] Furthermore, in the EMS-Conv module, the basic feature extraction branch uses a standard convolution with a 3×3 kernel to extract the basic texture features of the fabric. ;
[0037] The offset prediction branch predicts the dynamic sampling offset through an offset prediction convolutional layer consisting of 3×3 convolutions, and then uses deformable sampling operations to modify the input feature map based on the dynamic sampling offset. Sampling is performed to obtain adaptive deformation feature maps. ;
[0038] The elastically gated branch generates elastically gated weights through elastically gated convolution operations and the Sigmoid activation function. ,in This refers to the elastically gated convolution operation consisting of convolutional layers with 1×1 kernels. It is the Sigmoid activation function. The elastic coefficient is used; elastic gating weights and adaptive deformation feature maps are employed. Perform element-wise multiplication and compare with the basic texture features of the fabric. Adding them together yields the stable dynamic sampling feature map after elastic constraints. , This represents element-wise multiplication;
[0039] The momentum propagation branch generates momentum-gated operations through momentum-gated convolution operations and the Sigmoid activation function. , This refers to momentum-gated convolution operations consisting of convolutional layers with 1×1 kernels; through momentum gating... and preset momentum coefficient Historical feature maps output by the EMS-Conv module in the previous training iteration Weighting is performed and compared with the stable dynamic sampling feature map after elastic constraints. By performing additive fusion, the momentum fusion characteristics are obtained. The historical feature map Gradient separation is performed during the current round of computation; gradients are not included in gradient backpropagation. Momentum fusion features. The final output feature map of the EMS-Conv module is obtained after batch normalization and SiLU activation function processing. .
[0040] Furthermore, in the MCFM module, the processing steps in the multi-branch feature extraction structure include:
[0041] The input feature map of the MCFM module The input is fed into an initial 1×1 convolution to obtain a feature map. ; feature map The data are fed into three groups of dilated convolutions with different dilation rates to obtain feature maps. Feature map Feature map ;
[0042] In the MCFM module, the processing steps in the adaptive weight fusion unit include:
[0043] feature map Feature map Feature map The weights are fed into an adaptive weight generation network, where they are generated through global pooling and MLP, and then normalized using Softmax to obtain the corresponding adaptive weights. k=1, 2, 3, and the feature map is adjusted using adaptive weights. Feature map Feature map Weighted fusion yields fusion characteristics. , for fusion features After SiLU activation and feature map The residuals are summed to obtain the output feature map of the MCFM module. .
[0044] The beneficial effects of this invention are as follows: This invention is a fabric defect detection method based on elastic momentum snake convolution. It uses the YOLOv26 target detection network as the baseline model, and then introduces a spatially guided attention module to provide stable directional spatial priors, enhancing topology-aware feature tracking capabilities. The elastic momentum snake convolution module suppresses sampling offsets caused by background noise through an elastic gating mechanism and maintains structural continuity in discontinuous regions using a momentum propagation mechanism, effectively improving the model's feature extraction capabilities for slender and fractured defects. Based on this, a multi-scale cross-layer fusion module is constructed to improve the model's learning ability at various defect sizes. Finally, the final result is predicted using three detection heads at different scales. This not only enhances the feature representation capability of the target detection network but also effectively improves the accuracy and robustness of fabric defect detection. Attached Figure Description
[0045] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0046] Figure 1 This is a flowchart of the fabric defect detection method based on elastic momentum snake convolution of the present invention.
[0047] Figure 2 This is a diagram illustrating the overall framework of the defect detection network model of the present invention.
[0048] Figure 3 This is a schematic diagram of the elastic momentum snake convolution module structure of the present invention.
[0049] Figure 4 This is a schematic diagram of the spatial guidance attention module structure of the present invention.
[0050] Figure 5 This is a schematic diagram of the multi-scale cross-layer fusion module structure of the present invention.
[0051] Figure 6 This is a comparison chart of fabric defect detection results. Detailed Implementation
[0052] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0053] A robust fabric defect detection method based on elastic momentum serpentine convolution, such as Figure 1 As shown, it includes:
[0054] S1: Obtain the fabric defect image dataset, preprocess the fabric defect image dataset, and divide it into training set, validation set and test set according to a preset ratio.
[0055] In this embodiment, the Alibaba Tianchi public dataset and a self-built fiberglass fabric defect dataset were obtained. The Tianchi public dataset contains 34 defect types and a total of 5913 fabric defect images, each image being 640×640 pixels. The self-built fiberglass fabric defect dataset contains 16983 images, covering 17 defect categories, collected from real industrial production environments, exhibiting complex texture interference and lighting variations. The self-built dataset includes slender defects, discontinuous defects, and defects with large size differences. Among them, color defect types include seven categories: colored stains, black stains, light black, black threads, warp stains, weft stains, and insect stains; structural defect types include ten categories: red seam ends, fabric scraps, warp abnormalities, weft abnormalities, broken threads, fuzz, holes, loose threads, coarse yarns, and yellow seam ends. The structural dataset is characterized by a high proportion of discontinuous defects, a large number of slender defects, and a relatively large proportion of linear defects, while the stain dataset is characterized by strong texture interference, diverse defect categories, and complex morphological scale variations.
[0056] In this embodiment of the application, the preprocessing of the fabric defect image dataset includes:
[0057] Data augmentation methods are employed to increase the number and diversity of training samples. These methods include random cropping, random flipping, scaling, and Mosaic image augmentation. Specifically, Mosaic image augmentation randomly stitches four different images together to create a new image, increasing the diversity and complexity of the training data. This improves model performance and robustness, reduces the risk of overfitting, and enhances the model's generalization ability. The LabelImg annotation tool is used to provide detailed annotations for the augmented images in the dataset, including at least defect category information and defect bounding box location information.
[0058] In this embodiment of the application, the dataset after sample augmentation is divided into three parts according to a ratio of 7:2:1, that is, 70% of the fabric images are randomly selected as the training set, 20% of the fabric images are randomly selected as the validation set, and 10% of the fabric images are randomly selected as the test set.
[0059] S2: Construct a fabric defect detection network model; the fabric defect detection network model includes a backbone network, a multi-scale fusion network, and a detection head connected in sequence; both the backbone network and the multi-scale fusion network introduce a Spatial Guidance Attention (SGA) module and an Elastic Momentum Snake Convolution (EMS-Conv) module. The Spatial Guidance Attention (SGA) module is used to encode spatial orientation information of the input feature map and provide stable spatial guidance information; the Elastic Momentum Snake Convolution (EMS-Conv) module is used to suppress sampling offset through elastic gating mechanism and enhance the structural continuity of discontinuous regions through momentum propagation mechanism; a Multi-Scale Cross-layer Fusion Module (MCFM) module is introduced into the multi-scale fusion network to extract and fuse multi-scale features based on multiple receptive fields.
[0060] In this embodiment, the backbone network uses the YOLOv26n backbone network as the baseline model, such as... Figure 2 As shown, the backbone network of this invention includes a feature extraction layer and a feature output layer. A first EMS-Conv module is introduced in the 5th layer of the feature extraction layer to correct shallow convolution sampling offset, enhance the feature integrity of fine, discontinuous linear defects in the fabric, retain refined basic features of small-scale defects, and filter shallow texture noise. A first SGA module is introduced in the 8th layer of the feature extraction layer to encode spatial information and optimize weights for mid-level features, strengthen the feature response of mid-scale fabric defects, suppress background and illumination interference, and improve the localization and characterization accuracy of medium-sized defects. A second SGA module is introduced in the 13th layer of the feature extraction layer to filter and enhance deep global spatial features, focus on the overall structure of large-scale fabric defects, weaken fine texture interference, and improve the recognition accuracy of large-sized defects. The output of the first EMS-Conv module is used as the small-scale high-resolution output of the feature output layer; the output of the first SGA module is used as the mid-scale medium-resolution output of the feature output layer; and the output of the second SGA module is used as the large-scale low-resolution output of the feature output layer.
[0061] Specifically, such as Figure 2 As shown, the backbone network includes, in sequence: first Conv layer, second Conv layer, first C3k2 layer, third Conv layer, second C3k2 layer, first EMS-Conv module, fourth Conv layer, third C3k2 layer, first SGA module, fifth Conv layer, fourth C3k2 layer, SPPF module, C2PSA module, and second SGA module.
[0062] In this embodiment of the application, the multi-scale fusion network uses the neck network of YOLOv26n as the baseline model, such as... Figure 2 As shown, the multi-scale fusion network includes a top-down upsampling fusion path and a bottom-up downsampling fusion path. The top-down upsampling fusion path includes a first upsampling fusion stage and a second upsampling fusion stage. In the 17th layer corresponding to the first upsampling fusion stage, a second EMS-Conv module is introduced to correct upsampling feature sampling bias, compensate for the loss of small, discontinuous defect features, enhance the continuity of linear micro-defect features, and avoid distortion and blurring of small-scale defect features. In the 21st layer corresponding to the second upsampling fusion stage, a first MCFM module is introduced to fuse multi-scale spliced features across multiple receptive fields, resolve hierarchical semantic differences, ensure the integrity of small-to-medium-sized defect features, and improve the compatibility of shallow-layer fusion features. The bottom-up downsampling fusion path... The process, from top to bottom, includes a first downsampling fusion stage and a second downsampling fusion stage. At layer 25 of the first downsampling fusion stage, a second MCFM module is introduced to reconstruct and fuse bottom and middle layer features across layers, strengthening the correlation between medium and large-sized defect features, filtering out redundant downsampling noise, and retaining key features of various defects. At layer 29 of the second downsampling fusion stage, a third SGA module is introduced to spatially guide and calibrate the weights of deep fusion features, suppress interference from complex environments, and accurately focus on and locate large-scale fabric defect regions. At layer 30 of the second downsampling fusion stage, a third MCFM module is introduced to integrate multi-scale features across all layers, unify semantic representations at each level, adapt to complex fabric defect morphologies, and provide high-quality fusion feature input for the detection head.
[0063] Specifically, such as Figure 2 As shown, a multi-scale fusion network includes:
[0064] In the first upsampling fusion stage, the large-scale low-resolution output undergoes the first UpSample operation and then the medium-scale medium-resolution output undergoes the first Concat operation to output the first stitching feature. The first stitching feature then passes through the fifth C3k2 layer and the second EMS-Conv module in sequence to output the first upsampling fusion feature.
[0065] In the second upsampling fusion stage, the first upsampling fusion feature is subjected to the second UpSample operation and then the small-scale high-resolution output is subjected to the second Concat operation to output the second stitched feature. The second stitched feature is then passed through the sixth C3k2 layer and the first MCFM module in sequence to output the second upsampling fusion feature.
[0066] In the first downsampling fusion stage, the second upsampling fusion feature passes through the sixth Conv layer and then undergoes a third Concat operation with the first upsampling fusion feature to output the third concatenated feature. The third concatenated feature then passes through the seventh C3k2 layer and the second MCFM module in sequence to output the first downsampling fusion feature.
[0067] In the second downsampling fusion stage, the first downsampling fusion feature passes through the seventh Conv layer and then undergoes a fourth Concat operation with the large-scale low-resolution output to output a fourth stitched feature. The fourth stitched feature then passes through the eighth C3k2 layer, the third SGA module, and the third MCFM module in sequence to output the second downsampling fusion feature.
[0068] In this embodiment, the detection head includes a first Detect module, a second Detect module, and a third Detect module; the second upsampled fusion feature output by the first MCFM module is used as the input of the first Detect module to detect small fabric defects; the first downsampled fusion feature output by the second MCFM module is used as the input of the second Detect module to detect medium-sized fabric defects; and the second downsampled fusion feature output by the third MCFM module is used as the input of the third Detect module to detect large fabric defects.
[0069] In the embodiments of this application, such as Figure 4 As shown, the SGA module includes: a horizontal information extraction branch, a vertical information extraction branch, and a feature fusion unit;
[0070] The horizontal information extraction branch is used to aggregate global information in the width (horizontal) direction of the input feature map of the SGA module to obtain horizontal features;
[0071] The vertical information extraction branch is used to aggregate global information in the height (vertical) direction of the input feature map of the SGA module to obtain vertical features;
[0072] The feature fusion unit is used to fuse horizontal and vertical features to generate orientation-aware spatial attention weights. These weights are then used to recalibrate the input feature map, resulting in a spatially guided feature map. The SGA module encodes horizontal and vertical positional information, providing stable global spatial guidance for dynamic convolutional sampling and effectively mitigating the problem of offset prediction drift in complex texture backgrounds.
[0073] Specifically, such as Figure 4 As shown, the method for obtaining spatially guided feature maps in the SGA module includes: processing the input feature map of the SGA module... Global average pooling is performed along both the horizontal and vertical directions to aggregate global information, resulting in a direction-aware feature vector, i.e., the horizontal pooling output. and vertical pooling output B represents the batch size, C represents the number of feature channels, H represents the feature map height, and W represents the feature map width.
[0074] Pooling output in the spatial dimension in the horizontal direction and vertical pooling output Perform splicing to obtain splicing features ;
[0075] Use convolutional layers with a kernel size of 1×1 to stitch together features. Perform channel compression to obtain compression characteristics. r is the compression ratio;
[0076] For compression features BatchNorm batch normalization and H-Swish nonlinear activation are performed to obtain the encoded features. ;
[0077] Encoding features Slice the data and extract vertical branch features separately. and horizontal branching features ;
[0078] Vertical branch features and horizontal branching features The channels are restored to C by 1×1 convolution and mapped to the 0~1 interval by the Sigmoid activation function to obtain the vertical spatial attention weight map X and the horizontal spatial attention weight map Y.
[0079] The input feature map is processed using the vertical spatial attention weight map X and the horizontal spatial attention weight map Y. Weighting is performed to obtain spatially guided feature maps. , .
[0080] In the embodiments of this application, such as Figure 3 As shown, the EMS-Conv module includes a basic feature extraction branch, an offset prediction branch, an elastic gating branch, and a momentum propagation branch.
[0081] The basic feature extraction branch is used to extract basic features from the input feature map of the EMS-Conv module;
[0082] The offset prediction branch is used to predict the dynamic sampling offset based on the input feature map of the EMS-Conv module through deformable sampling.
[0083] The elastic gating branch is used to generate elastic gating weights based on the input feature map of the EMS-Conv module, and to suppress dynamic sampling offsets and fuse them with basic features through the elastic gating mechanism to obtain a stable dynamic sampling feature map after elastic constraints.
[0084] The momentum propagation branch is used to transfer information from the historical feature map output by the EMS-Conv module in the previous training iteration to the stable dynamic sampling feature map after elastic constraints, based on the input feature map of the EMS-Conv module, to obtain the output feature map of the current EMS-Conv module.
[0085] Specifically, such as Figure 3 As shown, the method for obtaining the output feature map of the EMS-Conv module is as follows:
[0086] The input feature map of the EMS-Conv module The inputs are respectively fed into the basic feature extraction branch, the offset prediction branch, the elastic gating branch, and the momentum propagation branch;
[0087] The basic feature extraction branch extracts the basic texture features of the fabric through a standard convolution with a 3×3 kernel. ;
[0088] The offset prediction branch predicts the dynamic sampling offset through the offset prediction convolutional layer (Offset Conv, with a standard 3×3 convolution kernel), and then uses deformable sampling operations to modify the input feature map based on the dynamic sampling offset. Sampling is performed to obtain adaptive deformation feature maps. The deformable sampling operation mentioned above refers to deformable sampling of deformable convolution, which is existing technology and will not be described in detail here.
[0089] The elastically gated branch generates elastically gated weights through elastically gated convolution operations and the Sigmoid activation function. ,in For flexible gated convolution operations, a convolutional layer with a 1×1 kernel is used. It is the Sigmoid activation function. The elastic modulus is 0.3, which is used to control the suppression strength of the elastic gating.
[0090] Using elastic gating weights and adaptive deformation feature maps Element-wise multiplication is performed to suppress sampling offsets caused by background noise, reduce interference from background noise, and integrate with the fabric's basic texture features. Adding them together yields the stable dynamic sampling feature map after elastic constraints. , This represents element-wise multiplication;
[0091] The momentum propagation branch generates momentum-gated operations through momentum-gated convolution operations and the Sigmoid activation function. , For momentum-gated convolution operations, a convolutional layer with a 1×1 kernel is used; momentum gating is applied. and momentum coefficient Historical feature maps output by the EMS-Conv module in the previous training iteration Weighting is applied to transfer information from historical feature maps to the current feature map, enhancing the feature continuity of discontinuous regions, and combining it with the stable dynamic sampling feature map after elastic constraints. By performing additive fusion, the momentum fusion characteristics are obtained. The historical feature map Gradient separation is performed during the current round of computation; gradients are not included in gradient backpropagation. Momentum fusion features. The final output feature map of the EMS-Conv module is obtained after batch normalization and SiLU activation function processing. .
[0092] It is particularly important to note that, to enhance the structural awareness of slender targets, Dynamic SnakeConvolution (DSConv) is introduced to improve topology awareness. However, its offset propagation is highly dependent on the continuity of local features. When features are discontinuous due to complex textures or local contamination, the offset prediction is prone to drifting into the background region, leading to topological instability and missed detections. The design of elastic momentum snake convolution differs from standard deformable convolution and dynamic snake convolution. Although standard deformable convolution can adaptively adjust the sampling position, its offset prediction is easily affected by discontinuous feature responses, resulting in drift. Dynamic snake convolution enhances topology awareness through recursive offset propagation, but offset errors tend to accumulate at feature discontinuities. This invention introduces an elastic gating mechanism to adaptively adjust the offset response, effectively suppressing the propagation of unstable offsets; simultaneously, it transmits historical feature information to the current moment through momentum propagation branches, maintaining structural continuity in feature break regions.
[0093] It should be noted that the Spatial Guided Attention (SGA) module and the Elastic Momentum Snake Convolution (EMS-Conv) module form a collaborative working mechanism: SGA provides stable spatial prior information in the backbone network, and EMS-Conv performs robust topology-aware feature extraction in the neck network based on this spatial prior. Together, they enhance the model's ability to represent and locate features of slender and discontinuous defects.
[0094] In the embodiments of this application, such as Figure 5 As shown, the MCFM module includes: a multi-branch feature extraction structure and an adaptive weight fusion unit;
[0095] A multi-branch feature extraction structure is used to extract features through feature extraction branches with different receptive fields to obtain multi-scale feature representations.
[0096] The adaptive weighted fusion unit is used to adaptively weight and fuse multi-scale feature representations to obtain the output feature map of the MCFM module.
[0097] Specifically, such as Figure 5 As shown, the methods for obtaining the output feature map of the MCFM module include:
[0098] In a multi-branch feature extraction structure:
[0099] The input feature map of the MCFM module The input is fed into an initial convolution (1×1 kernel), and the number of feature channels is unified through channel dimension transformation to obtain the feature map. As a multi-branch shared input; the feature map The data are fed into three groups of dilated convolutions with different dilation rates (1, 2, and 3), and feature maps are obtained for each group. Feature map Feature map .
[0100] In the adaptive weight fusion unit:
[0101] feature map Feature map Feature map The weights are fed into an adaptive weight generation network, where they are generated through global pooling and MLP, and then normalized using Softmax to obtain the feature maps. Feature map Feature map The corresponding adaptive weights are respectively k=1, 2, 3, and the feature map is adjusted using adaptive weights. Feature map Feature map Weighted fusion yields fusion characteristics. ,in, Representing dilated convolutions with different dilation rates; for fused features After SiLU activation and feature map The residuals are summed to obtain the output feature map of the MCFM module. .
[0102] S3: Use the training set and validation set to train and validate the fabric defect detection network model to obtain the trained defect detection network model.
[0103] In this embodiment, all experiments were conducted on a server running the Ubuntu operating system. Training was based on the PyTorch 2.4.1 framework, CUDA version 12.1, and Python version 3.8. The GPU was an NVIDIA GeForce RTX4090 with 24GB of VRAM. The SGD optimizer was used during training, with a weight decay of 0.003. The initial learning rate was set to 0.01, and the batch size was set to 16. The entire training process consisted of 300 epochs, with a training size of 640×640.
[0104] After the fabric image is input into the backbone network, multiple feature maps of different sizes are output. These feature maps are then fused by a multi-scale feature fusion module to integrate features at all levels and location information before being sent to the detection head to obtain the detection result. The defect detection network model uses DFL loss for bounding box regression and CioU loss to optimize the accuracy of the bounding box regression.
[0105] S4: Use the trained fabric defect detection network model to detect fabric images in the test set and output the fabric defect detection results, including defect category, location and confidence information.
[0106] Simulation verification:
[0107] To verify the effectiveness of the proposed elastic momentum snake convolution module, several representative benchmark models were selected for comparative experiments, including YOLOv8n, YOLOv8s, YOLOv11n, YOLOv11s, YOLOv26n, YOLOv26s, Faster R-CNN, and RT-DETR-R18. The mean precision (AP50, AP50:95), precision, and recall were used as evaluation metrics, and experimental verification was conducted on two datasets.
[0108] The experimental results on the Tianchi public dataset are shown in Table 1. The proposed ESGM-YOLO achieves 48.7% and 23.7% AP50 and AP50:95 respectively, both outperforming all comparable methods. In particular, the recall rate of this invention reaches 45.3%, which is 9.9 percentage points higher than the baseline YOLOv26s model (35.4%), fully demonstrating that this invention has a stronger detection capability for slender and discontinuous defects and can effectively reduce false negatives.
[0109] Table 1 Performance comparison on the Tianchi dataset (%)
[0110]
[0111] The experimental results on the self-built glass fiber fabric defect dataset are shown in Table 2. The present invention achieves AP50 and AP50:95 scores of 75.3% and 49.0%, respectively, both outperforming all comparable methods. Compared to the baseline YOLOv26s model, the present invention improves AP50 and AP50:95 by 2.0% and 3.8%, respectively. A recall rate of 69.5% is achieved, demonstrating the robustness of the present invention under complex texture interference and varying illumination conditions.
[0112] Table 2 Performance comparison on the glass fiber fabric dataset (%)
[0113]
[0114] To verify the effectiveness of each module in this invention, ablation experiments were conducted on the Tianchi dataset, and the results are shown in Table 3. After introducing the EMS-Conv module, the AP50 improved from 45.9% to 47.1%, demonstrating the effectiveness of elastic momentum snake convolution for topology-aware feature extraction of discontinuous defect structures. Introducing the SGA or MCFM modules individually also brought stable performance improvements, reaching 46.5% and 46.8% respectively, verifying the positive effects of spatial guided learning and multi-scale feature fusion. When all three modules were introduced together, ESGM-YOLO achieved the best performance of 48.7%, an improvement of 2.8 percentage points compared to the baseline model, fully validating the effectiveness of the synergistic effect of EMS-Conv, SGA, and MCFM.
[0115] Table 3 Ablation experiments (%) of each module on the Tianchi dataset
[0116]
[0117] In addition, the deployment efficiency of the model was evaluated, and the results are shown in Table 4. Although the introduction of EMS-Conv, SGA, and MCFM increased the model complexity compared to the baseline YOLOv26s, ESGM-YOLO still achieved an inference speed of 356 FPS on an RTX 4090 GPU (batch size=1, FP16 accuracy), maintaining good real-time detection performance and demonstrating good deployment efficiency.
[0118] Table 4 Comparison of Model Efficiency
[0119]
[0120] In addition, a visualization experiment of the test results was conducted, and the visualization results are as follows: Figure 6As shown in the figure. The test results show that the fabric defect detection method based on elastic momentum serpentine convolution has a good detection effect on slender defects and discontinuous defects. It can accurately detect targets with a very small area ratio relative to the background and locally broken defect areas, with high positioning accuracy and low false negative rate.
[0121] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A robust fabric defect detection method based on elastic momentum serpentine convolution, characterized in that, include: S1: Obtain a dataset of fabric defect images, preprocess the dataset, and divide it into a training set, a validation set, and a test set according to a preset ratio. S2: Construct a fabric defect detection network model; the fabric defect detection network model includes a backbone network, a multi-scale fusion network, and a detection head connected in sequence; both the backbone network and the multi-scale fusion network introduce SGA and EMS-Conv modules. The SGA module is used to encode spatial orientation information of the input feature map and provide spatial guidance information; the EMS-Conv module is used to suppress sampling offset through elastic gating mechanism and enhance the structural continuity of discontinuous regions through momentum propagation mechanism; the multi-scale fusion network introduces an MCFM module for extracting and fusing multi-scale features based on multiple receptive fields; S3: Use the training set and validation set to train and validate the fabric defect detection network model, and obtain the trained defect detection network model. S4: Use the trained fabric defect detection network model to detect fabric images in the test set and output the fabric defect detection results.
2. The robust fabric defect detection method based on elastic momentum serpentine convolution according to claim 1, characterized in that, The backbone network uses the YOLOv26n backbone network as the baseline model, including a feature extraction layer and a feature output layer. A first EMS-Conv module is introduced in the 5th layer of the feature extraction layer; a first SGA module is introduced in the 8th layer of the feature extraction layer; and a second SGA module is introduced in the 13th layer of the feature extraction layer. The output of the first EMS-Conv module is used as the small-scale high-resolution output of the feature output layer; the output of the first SGA module is used as the medium-scale medium-resolution output of the feature output layer; and the output of the second SGA module is used as the large-scale low-resolution output of the feature output layer.
3. The robust fabric defect detection method based on elastic momentum serpentine convolution according to claim 2, characterized in that, The multi-scale fusion network uses the neck network of YOLOv26n as the baseline model. The multi-scale fusion network includes a top-down upsampling fusion path and a bottom-up downsampling fusion path. The top-down upsampling fusion path includes a first upsampling fusion stage and a second upsampling fusion stage in sequence. A second EMS-Conv module is introduced at layer 17 corresponding to the first upsampling fusion stage, and a first MCFM module is introduced at layer 21 corresponding to the second upsampling fusion stage. The bottom-up downsampling fusion path includes a first downsampling fusion stage and a second downsampling fusion stage in sequence. A second MCFM module is introduced at layer 25 corresponding to the first downsampling fusion stage, a third SGA module is introduced at layer 29 corresponding to the second downsampling fusion stage, and a third MCFM module is introduced at layer 30 corresponding to the second downsampling fusion stage.
4. The robust fabric defect detection method based on elastic momentum serpentine convolution according to claim 3, characterized in that, In multi-scale fusion networks, including: In the first upsampling fusion stage, the large-scale low-resolution output undergoes the first UpSample operation and then the medium-scale medium-resolution output undergoes the first Concat operation to output the first stitching feature. The first stitching feature then passes through the fifth C3k2 layer and the second EMS-Conv module in sequence to output the first upsampling fusion feature. In the second upsampling fusion stage, the first upsampling fusion feature is subjected to the second UpSample operation and then the small-scale high-resolution output is subjected to the second Concat operation to output the second stitched feature. The second stitched feature is then passed through the sixth C3k2 layer and the first MCFM module in sequence to output the second upsampling fusion feature. In the first downsampling fusion stage, the second upsampling fusion feature passes through the sixth Conv layer and then undergoes a third Concat operation with the first upsampling fusion feature to output the third concatenated feature. The third concatenated feature then passes through the seventh C3k2 layer and the second MCFM module in sequence to output the first downsampling fusion feature. In the second downsampling fusion stage, the first downsampling fusion feature passes through the seventh Conv layer and then undergoes the fourth Concat operation with the large-scale low-resolution output to output the fourth stitched feature. The fourth stitched feature passes through the eighth C3k2 layer, the third SGA module, and the third MCFM module in sequence to output the second downsampling fusion feature. The detection head includes a first Detect module, a second Detect module, and a third Detect module. The second upsampled fusion feature output by the first MCFM module is used as the input of the first Detect module to detect small fabric defects. The first downsampled fusion feature output by the second MCFM module is used as the input of the second Detect module to detect medium-sized fabric defects. The second downsampled fusion feature output by the third MCFM module is used as the input of the third Detect module to detect large fabric defects.
5. The robust fabric defect detection method based on elastic momentum serpentine convolution according to any one of claims 1-4, characterized in that, The SGA module includes: a horizontal information extraction branch, a vertical information extraction branch, and a feature fusion unit; The horizontal information extraction branch is used to perform horizontal global information aggregation on the input feature map of the SGA module to obtain horizontal features; The vertical information extraction branch is used to perform vertical global information aggregation on the input feature map of the SGA module to obtain vertical features; The feature fusion unit is used to fuse horizontal and vertical features to generate orientation-aware spatial attention weights, and then use the orientation-aware spatial attention weight map to recalibrate the input feature map to obtain a spatially guided feature map.
6. The robust fabric defect detection method based on elastic momentum serpentine convolution according to claim 5, characterized in that, The EMS-Conv module includes a basic feature extraction branch, an offset prediction branch, an elastic gating branch, and a momentum propagation branch. The basic feature extraction branch is used to extract basic features from the input feature map of the EMS-Conv module; The offset prediction branch is used to predict the dynamic sampling offset based on the input feature map of the EMS-Conv module through deformable sampling. The elastic gating branch is used to generate elastic gating weights based on the input feature map of the EMS-Conv module, and to suppress dynamic sampling offsets and fuse them with basic features through the elastic gating mechanism to obtain a stable dynamic sampling feature map after elastic constraints. The momentum propagation branch is used to transfer information from the historical feature map output by the EMS-Conv module in the previous training iteration to the stable dynamic sampling feature map after elastic constraints, based on the input feature map of the EMS-Conv module, to obtain the output feature map of the current EMS-Conv module.
7. The robust fabric defect detection method based on elastic momentum serpentine convolution according to claim 6, characterized in that, The MCFM module includes: a multi-branch feature extraction structure and an adaptive weight fusion unit; A multi-branch feature extraction structure is used to extract features through feature extraction branches with different receptive fields to obtain multi-scale feature representations. The adaptive weighted fusion unit is used to adaptively weight and fuse multi-scale feature representations to obtain the output feature map of the MCFM module.
8. The robust fabric defect detection method based on elastic momentum serpentine convolution according to claim 7, characterized in that, In the SGA module, the processing procedures for horizontal and vertical information extraction branches include: Input feature map of the SGA module Global average pooling is performed along both the horizontal and vertical directions to aggregate global information, with the horizontal pooling output being the final result. and vertical pooling output B represents the batch size, C represents the number of feature channels, H represents the feature map height, and W represents the feature map width. In the SGA module, the feature fusion unit's processing includes: Pooling output in the spatial dimension in the horizontal direction and vertical pooling output Perform splicing to obtain splicing features Use convolutional layers with a kernel size of 1×1 to stitch together features. Perform channel compression to obtain compression characteristics. r is the compression ratio; for compression features BatchNorm batch normalization and H-Swish nonlinear activation are performed to obtain the encoded features. ; for coding features Slice the data and extract vertical branch features separately. and horizontal branching features ; for vertical branch features and horizontal branching features The input feature map is then subjected to 1×1 convolution to restore the dimensionality of the channels, and then mapped to the 0~1 interval using the Sigmoid activation function to obtain the vertical spatial attention weight map X and the horizontal spatial attention weight map Y. The vertical spatial attention weight map X and the horizontal spatial attention weight map Y are then used to adjust the input feature map. Weighting is performed to obtain spatially guided feature maps. , .
9. The robust fabric defect detection method based on elastic momentum serpentine convolution according to claim 8, characterized in that, In the EMS-Conv module, the basic feature extraction branch uses a standard convolution with a 3×3 kernel to extract the basic texture features of the fabric. ; The offset prediction branch predicts the dynamic sampling offset through an offset prediction convolutional layer consisting of 3×3 convolutions, and then uses deformable sampling operations to modify the input feature map based on the dynamic sampling offset. Sampling is performed to obtain adaptive deformation feature maps. ; The elastically gated branch generates elastically gated weights through elastically gated convolution operations and the Sigmoid activation function. ,in This refers to the elastically gated convolution operation consisting of convolutional layers with 1×1 kernels. It is the Sigmoid activation function. The elastic coefficient is used; elastic gating weights and adaptive deformation feature maps are employed. Perform element-wise multiplication and compare with the basic texture features of the fabric. Adding them together yields the stable dynamic sampling feature map after elastic constraints. , This represents element-wise multiplication; The momentum propagation branch generates momentum-gated operations through momentum-gated convolution operations and the Sigmoid activation function. , This refers to momentum-gated convolution operations consisting of convolutional layers with 1×1 kernels; through momentum gating... and preset momentum coefficient Historical feature maps output by the EMS-Conv module in the previous training iteration Weighting is performed and compared with the stable dynamic sampling feature map after elastic constraints. By performing additive fusion, the momentum fusion characteristics are obtained. The historical feature map Gradient separation is performed during the current round of calculation, and the gradients are not included in gradient backpropagation. Momentum fusion characteristics The final output feature map of the EMS-Conv module is obtained after batch normalization and SiLU activation function processing. .
10. The robust fabric defect detection method based on elastic momentum serpentine convolution according to claim 9, characterized in that, In the MCFM module, the processing steps in the multi-branch feature extraction structure include: The input feature map of the MCFM module The input is fed into an initial 1×1 convolution to obtain a feature map. ; feature map The data are fed into three groups of dilated convolutions with different dilation rates to obtain feature maps. Feature map Feature map ; In the MCFM module, the processing steps in the adaptive weight fusion unit include: feature map Feature map Feature map The weights are fed into an adaptive weight generation network, where they are generated through global pooling and MLP, and then normalized using Softmax to obtain the corresponding adaptive weights. k=1, 2, 3, and the feature map is adjusted using adaptive weights. Feature map Feature map Weighted fusion yields fusion characteristics. , for fusion features After SiLU activation and feature map The residuals are summed to obtain the output feature map of the MCFM module. .