Spandex wrap yarn defect detection method based on dual-channel feature learning
Through a method based on dual-channel feature learning, a spandex coated yarn defect detection model is constructed, which includes a double-layer convolution module, a dual-channel feature alignment module and a low-light enhancement module. This solves the problems of low accuracy and efficiency in traditional detection methods and achieves high-precision yarn defect detection.
Patent Information
- Application Number
- CN202510942119.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-09
- Publication Date
- 2025-10-10
AI Technical Summary
Traditional spandex covered yarn defect detection methods have low detection accuracy, low detection efficiency, and insufficient detection accuracy, which cannot meet the needs of modern textile quality control.
A spandex covered yarn defect detection method based on dual-channel feature learning is adopted, including a self-built image dataset, a two-layer convolution module, a dual-channel feature alignment module and a low-light enhancement module. The spatial transformation matrix is calculated through a two-layer decoder structure and conditional convolution, combined with a dynamic mask guidance mechanism and low-light enhancement technology to improve detection accuracy and efficiency.
It achieves high-precision segmentation and classification of yarn defects under complex background conditions, improves the segmentation accuracy and recognition ability of detection, enhances the generalization ability of the model, and significantly improves the detection effect.
Smart Images

Figure CN120766038A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of spandex covered yarn defect detection, and in particular relates to a spandex covered yarn defect detection method based on dual-channel feature learning. Background Art
[0002] The "Action Plan for the Development of the Intelligent Inspection Equipment Industry (2023-2025)" has been issued. Column 3, focusing on key areas for enhancing supply capacity, addresses the following: Intelligent inspection of key processes such as spinning, yarn production, weaving, and non-woven fabrics, addressing the inspection needs arising from flexible, large-format, easily deformable, and three-dimensional processing, high-speed and dynamic processing, and a wide variety of defects. In this context, yarn quality, as the fundamental raw material for textiles, is directly impacted by the performance and market competitiveness of end products. Yarn surface defects not only affect the appearance of the fabric but can also negatively impact the physical properties of the product. Researching and applying intelligent inspection technologies to accurately identify and classify yarn defects will not only help improve quality management across the production process but also further facilitate the digital transformation of the textile industry.
[0003] With the rapid development of high-performance fibers and high-tech products, yarn uniformity, strength, abrasion resistance, and defect control have become key factors affecting textile quality. Spandex-coated yarn, a key material for modern elastic textiles, plays an irreplaceable role in sportswear, medical protective gear, and smart wearable devices. Traditional methods for detecting defects in spandex-coated yarn suffer from low precision, low efficiency, and insufficient accuracy. In recent years, the rapid development of machine vision and deep learning detection technologies has provided new solutions for spandex detection. Efficient image processing algorithms can accurately detect key indicators such as spandex-coated yarn diameter distribution, breakage patterns, and rebound properties, significantly improving detection efficiency and accuracy. Summary of the Invention
[0004] The purpose of the present invention is to provide a spandex covered yarn defect detection method based on dual-channel feature learning, which solves the problems of low detection precision, low detection efficiency and insufficient detection accuracy of traditional spandex covered yarn defect detection methods.
[0005] The technical solution adopted by the present invention is a spandex coated yarn defect detection method based on dual-channel feature learning, comprising the following steps: Step 1: Collect spandex covered yarn images and build a spandex covered yarn defect image dataset; Step 2: Divide the spandex covered yarn defect image dataset according to the ratio to obtain a training image dataset and a verification image dataset; Step 3: Build a defect detection network model including a double-layer convolution module, a dual-channel feature alignment module, and a low-light enhancement module; Step 4: Use the training image dataset to train the defect detection network model, and optimize the parameters of each module in the network model based on the training results; Step 5: Input the verification image dataset into the optimized network model, perform the test, and output the verification results.
[0006] The present invention is also characterized in that: The spandex covered yarn defect image dataset in step 1 includes black spandex covered yarn defect images and white spandex covered yarn defect images under different specifications, different backgrounds, and different noise conditions; The self-built spandex covered yarn defect image dataset is specifically as follows: spandex covered yarn defect images are collected through an industrial camera, and an image enhancement preprocessing module is added to perform sharpening, contrast enhancement, threshold segmentation and morphological processing on the images, thereby improving the clarity of the yarn structure in the input image and reducing the interference of blurred images and background noise on the segmentation results. In view of the difference in background grayscale distribution between white yarn and black yarn, an image enhancement strategy is designed, and the mask of the background segmentation result is used as black, and the mask of the yarn segmentation result is used as white. Linear stretching, edge filling and image inversion operations are also introduced in the black yarn preprocessing process to further ensure the consistency of the training data.
[0007] In step 3, the double-layer convolution module introduces a double-layer decoder structure and conditional convolution, so that the model can calculate the transformation matrix of the image through convolution operations, ensuring that the yarn structure remains consistent in different feature space positions. The features of the yarn defect area are extracted through conditional convolution, and the defects in the yarn are accurately identified, reducing background interference.
[0008] The first convolution layer of the double-layer convolution module is responsible for basic feature extraction. This layer uses a small-size 3×3 convolution kernel to extract local features to retain detail information, as shown in formula (1): (1); in, is the input feature map, is the first layer convolution kernel weight matrix, represents the convolution operation, is the bias term, is a nonlinear activation function; Normalization is used to reduce internal variable offset and enhance the generalization ability of the model, as shown in formula (2): (2); in, is the mean value within the mini-batch, Standard deviation within; The second convolution layer of the double-layer convolution module is responsible for high-level feature fusion. This layer will further optimize feature expression and enhance the perception of defect areas. By using skip connections, the model can retain low-level features while learning high-level features, thereby improving detection results, as shown in formula (3): (3).
[0009] The dual-channel feature alignment module extracts feature information from the original image and the preliminary segmentation mask through a dual-channel feature network. The original image is used to retain the overall texture structure of the yarn, and the mask segmentation result is used to focus on the position and shape of the defect area. On this basis, combined with the dynamic mask guidance mechanism and defect category information, the edges and details of the defect area are further highlighted, making the target contour clearer and the classification more accurate, thereby improving the model's defect recognition ability.
[0010] The dual-channel feature alignment module combines the generation capability of the diffusion model with the classification task, introduces dual-channel diffusion, and performs synchronous diffusion calculations on the image branch and the mask branch, as shown in Equation (4): (4); To ensure the synchronous diffusion of the two, a cross-branch feature alignment constraint is added at each step of the diffusion process, as shown in Equation (5); (5); In the diffusion denoising process, conditional attention is added to the feature extraction process of each layer and feature transformation is used to align the image features and mask features, so that the model can focus on the defect area while suppressing background noise interference, as shown in Equation (6): (6); in, are dynamic learning weights.
[0011] The low-light enhancement module combines multi-scale adaptive illumination enhancement and dynamic contrast adjustment to effectively improve the detection performance of yarn defects under large changes in lighting conditions, enhance the detailed features of the image, and improve the segmentation accuracy of the defective area.
[0012] Input image for low-light enhancement module Calculate according to formula (7)-(9): (7); (8); (9); in, represents the original input image, represents the true reflection characteristics of the object, Indicates changes in light intensity; Controls the scale of the Gaussian filter, larger A smoother lighting distribution is extracted, and smaller Preserve more local contrast information; is a small positive number used to prevent division by zero errors; Introducing learnable The transformation is dynamically adjusted to make the brightness distribution of different areas more uniform, as shown in formula (10): (10); in, It is a learnable parameter that can be adaptively adjusted through a 1×1 convolution and Sigmoid normalization; For the enhanced image Perform local brightness normalization to make the brightness range of different areas close, thereby reducing the impact of illumination differences, as shown in formula (11): (11); in, and are the local mean and standard deviation, respectively. This normalization can eliminate the influence of brightness changes and make the defect area more prominent; Calculate channel attention weights through global pooling and two-layer fully connected networks , as shown in formula (12): (12); Among them, GAP represents global average pooling; and are learnable fully connected layer parameters; is the Sigmoid activation function; calculated Acting on the input features, the model pays more attention to the defect area, reduces background interference, and improves segmentation accuracy.
[0013] The training specifically uses a stochastic gradient descent optimizer, combined with a cosine annealing strategy to dynamically adjust the learning rate. During the training process, the learning rate gradually decays with the increase in the number of iterations, making the gradient update more stable, thereby reducing the oscillation phenomenon that occurs during the model convergence process and improving the convergence stability. To suppress overfitting, L2 regularization is used. By limiting the size of the weight parameters, it can prevent gradient explosion and effectively suppress overfitting without excessively restricting the computing power of the model, thereby improving the generalization ability of the model.
[0014] The beneficial effects of the present invention are: The present invention provides a spandex-coated yarn defect detection method based on dual-channel feature learning. The method ensures that defects can be correctly classified by calculating the spatial transformation matrix through a dual decoder structure and conditional convolution. To enhance the detection capability of defective areas, a dual-channel feature alignment module is introduced to synchronously learn the original features and mask features. Combining image contrast enhancement and noise suppression, the low-light enhancement module is utilized to improve the defect detection capability of the model under different lighting conditions. Experimental results show that the proposed method has significant advantages in segmentation accuracy, defect recognition capability, and generalization. It achieves high-precision segmentation and classification of yarn defects under complex background conditions, effectively improving the overall detection effect of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 This is a model architecture diagram of the spandex covered yarn defect detection method based on dual-channel feature learning of the present invention; Figure 2 Schematic diagram of yarns of different specifications in the spandex covered yarn defect detection method based on dual-channel feature learning of the present invention; Figure 3 This is a double-layer convolution module structure diagram of the spandex covered yarn defect detection method based on dual-channel feature learning of the present invention; Figure 4 1. It is a structural diagram of a dual-channel feature alignment module of a spandex covered yarn defect detection method based on dual-channel feature learning according to the present invention; Figure 5 This is a structural diagram of a low-light enhancement module of the spandex covered yarn defect detection method based on dual-channel feature learning of the present invention; Figure 6 This is a visualization result diagram of the hairiness segmentation of the spandex covered yarn defect detection method based on dual-channel feature learning of the present invention. DETAILED DESCRIPTION
[0016] The present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0017] Example 1 The spandex covered yarn defect detection method based on dual-channel feature learning proposed in this embodiment includes the following steps: Step 1: Collect spandex covered yarn images and build a spandex covered yarn defect image dataset; Step 2: Divide the spandex covered yarn defect image dataset according to the ratio to obtain a training image dataset and a verification image dataset; Step 3: Build a defect detection network model including a double-layer convolution module, a dual-channel feature alignment module, and a low-light enhancement module; Step 4: Use the training image dataset to train the defect detection network model, and optimize the parameters of each module in the network model based on the training results; Step 5, input the verification image dataset into the optimized network model, test and output the verification result.
[0018] Embodiment 2 The spandex covered yarn defect detection method based on double-channel feature learning proposed in this embodiment includes the following steps: Step 1, collect spandex covered yarn images, and build a spandex covered yarn defect image dataset; The spandex covered yarn defect image dataset includes black and white spandex covered yarn defect images under different specifications, different backgrounds and different noise conditions; The self-built spandex covered yarn defect image dataset is as follows: spandex covered yarn defect images are collected by an industrial camera, and an image enhancement preprocessing module is added to sharpen the image, enhance the contrast, perform threshold segmentation and morphological processing, improve the clarity of the yarn structure in the input image, reduce the interference of blurred images and background noise on the segmentation result, and design an image enhancement strategy according to the difference in background gray distribution between white yarn and black yarn. The mask of the background segmentation result is black, and the mask of the yarn segmentation result is white. Linear stretching, edge filling and image inversion operations are also introduced in the preprocessing process of black yarn to further ensure the consistency of the training data; Step 2, divide the spandex covered yarn defect image dataset according to the proportion to obtain a training image dataset and a verification image dataset; Step 3, construct a defect detection network model containing a double-layer convolution module, a double-channel feature alignment module and a low-light enhancement module; Step 4, train the defect detection network model using the training image dataset, and optimize the parameters of each module in the network model according to the training result; Step 5, input the verification image dataset into the optimized network model, test and output the verification result.
[0019] Embodiment 3 The spandex covered yarn defect detection method based on double-channel feature learning proposed in this embodiment includes the following steps: Step 1, collect spandex covered yarn images, and build a spandex covered yarn defect image dataset; The spandex covered yarn defect image dataset includes black and white spandex covered yarn defect images under different specifications, different backgrounds and different noise conditions; The self-built spandex cover yarn defect image dataset specifically comprises: collecting spandex cover yarn defect images through an industrial camera, and adding an image enhancement preprocessing module to perform sharpening, contrast enhancement, threshold segmentation and morphological processing on the images, thereby improving the definition of yarn structures in the input images, reducing the interference of blurred images and background noise on the segmentation results, designing an image enhancement strategy according to the difference in background gray distribution between white yarns and black yarns, taking the mask of the background segmentation result as black and the mask of the yarn segmentation result as white, and further introducing linear stretching, edge filling and image inversion operations in the preprocessing process of the black yarns to further ensure the consistency of the training data; Step 2, dividing the spandex cover yarn defect image dataset according to a proportion to obtain a training image dataset and a verification image dataset; Step 3, constructing a defect detection network model comprising a double-layer convolution module, a double-channel feature alignment module and a low-light enhancement module; The double-layer convolution module introduces a double-layer decoder structure and conditional convolution, so that the model can calculate the transformation matrix of the image through convolution operation, ensure that the yarn structure still remains consistent in different feature space positions, extract the features of the yarn defect area through conditional convolution, accurately identify the defects in the yarn and reduce background interference; The first layer convolution of the double-layer convolution module is responsible for basic feature extraction. This layer uses a small size convolution kernel of 3x3 to extract local features to retain detailed information, as shown in formula (1): (1); Wherein, is the input feature map, is the first layer convolution kernel weight matrix, represents the convolution operation, is the bias term, is a nonlinear activation function; Normalization is used to reduce internal variable bias and enhance the generalization ability of the model, as shown in formula (2): (2); Wherein, is the mean value within the mini-batch, is the standard deviation within the mini-batch; The second layer convolution of the double-layer convolution module is responsible for high-level feature fusion. This layer will further optimize feature expression and enhance the perception ability of the defect area. A skip connection is used to enable the model to learn high-level features while retaining low-level features, thereby improving detection effect, as shown in formula (3): (3); Step 4, training the defect detection network model using the training image dataset, and optimizing the parameters of each module in the network model according to the training results; Step 5: Input the verification image dataset into the optimized network model, perform the test, and output the verification results.
[0020] Example 4 The spandex covered yarn defect detection method based on dual-channel feature learning proposed in this embodiment includes the following steps: Step 1: Collect spandex covered yarn images and build a spandex covered yarn defect image dataset; The spandex covered yarn defect image dataset includes black spandex covered yarn defect images and white spandex covered yarn defect images with different specifications, different backgrounds, and different noise conditions; The self-built spandex-coated yarn defect image dataset is specifically constructed as follows: spandex-coated yarn defect images are collected using an industrial camera, and an image enhancement preprocessing module is added to perform image sharpening, contrast enhancement, threshold segmentation, and morphological processing. This improves the clarity of the yarn structure in the input image and reduces the interference of blurred images and background noise on the segmentation results. Based on the difference in background grayscale distribution between white yarn and black yarn, an image enhancement strategy is designed. The mask of the background segmentation result is set as black, and the mask of the yarn segmentation result is set as white. Linear stretching, edge filling, and image inversion operations are also introduced in the black yarn preprocessing process to further ensure the consistency of the training data. Step 2: Divide the spandex covered yarn defect image dataset according to the ratio to obtain a training image dataset and a verification image dataset; Step 3: Build a defect detection network model including a double-layer convolution module, a dual-channel feature alignment module, and a low-light enhancement module; The double-layer convolution module introduces a double-layer decoder structure and conditional convolution, enabling the model to calculate the image transformation matrix through convolution operations, ensuring that the yarn structure remains consistent in different feature space positions. Conditional convolution is used to extract the features of yarn defect areas, accurately identifying yarn defects and reducing background interference. The first convolution layer of the double-layer convolution module is responsible for basic feature extraction. This layer uses a small-size 3×3 convolution kernel to extract local features to retain detail information, as shown in formula (1): (1); in, is the input feature map, is the first layer convolution kernel weight matrix, represents the convolution operation, is the bias term, is a nonlinear activation function; Normalization is used to reduce internal variable offset and enhance the generalization ability of the model, as shown in formula (2): (2); wherein, is the mean value within the mini-batch, is the standard deviation within the mini-batch; The second layer of convolution of the double-layer convolution module is responsible for high-level feature fusion, which further optimizes feature expression and enhances the perception ability of the defect area. The model retains the bottom layer features while learning high-level features through a skip connection, improving the detection effect, as shown in equation (3): (3); The double-channel feature alignment module extracts feature information from the original image and the preliminary segmented mask through a double-channel feature network. The original image is used to retain the overall texture structure of the yarn, and the mask segmentation result is used to focus on the position and shape of the defect area. On this basis, combined with the dynamic mask guiding mechanism and defect category information, the edges and details of the defect area are further highlighted, making the target contour more clear and the classification more accurate, and improving the defect recognition ability of the model. The double-channel feature alignment module combines the generation ability of the diffusion model with the classification task, introduces double-channel diffusion, and performs synchronous diffusion calculation on the image branch and the mask branch, as shown in equation (4): (4); To ensure synchronous diffusion, cross-branch feature alignment constraints are added at each step of the diffusion process, as shown in equation (5): (5); During the diffusion denoising process, conditional attention and feature transformation are added to the feature extraction process at each layer to align the image features and mask features, so that the model can focus on the defect area while suppressing background noise interference, as shown in equation (6): (6); wherein, is the dynamically learned weight; The low-light enhancement module can effectively improve the detection performance of yarn defects under large changes in lighting conditions by combining multi-scale light adaptive enhancement and dynamic contrast adjustment, enhancing the detailed features of the image and improving the segmentation accuracy of the defect area. The input image of the low-light enhancement module According to equations (7)-(9): (7); (8); (9); wherein, denotes the original input image, denotes the true reflectance characteristics of the object, Indicates changes in light intensity; Controls the scale of the Gaussian filter, larger A smoother lighting distribution is extracted, and smaller Preserve more local contrast information; is a small positive number used to prevent division by zero errors; Introducing learnable The transformation is dynamically adjusted to make the brightness distribution of different areas more uniform, as shown in formula (10): (10); in, It is a learnable parameter that can be adaptively adjusted through a 1×1 convolution and Sigmoid normalization; For the enhanced image Perform local brightness normalization to make the brightness range of different areas close, thereby reducing the impact of illumination differences, as shown in formula (11): (11); in, and are the local mean and standard deviation, respectively. This normalization can eliminate the influence of brightness changes and make the defect area more prominent; Calculate channel attention weights through global pooling and two-layer fully connected networks , as shown in formula (12): (12); Among them, GAP represents global average pooling; and are learnable fully connected layer parameters; is the Sigmoid activation function; calculated Acting on the input features, the model focuses more on the defect area, reduces background interference, and improves segmentation accuracy; Step 4: Use the training image dataset to train the defect detection network model, and optimize the parameters of each module in the network model based on the training results; Step 5: Input the verification image dataset into the optimized network model, perform the test, and output the verification results.
[0021] Example 5 The spandex covered yarn defect detection method based on dual-channel feature learning proposed in this embodiment includes the following steps: Step 1: Collect spandex covered yarn images and build a spandex covered yarn defect image dataset; The spandex covered yarn defect image dataset includes black spandex covered yarn defect images and white spandex covered yarn defect images with different specifications, different backgrounds, and different noise conditions; The self-built spandex-coated yarn defect image dataset is specifically constructed as follows: spandex-coated yarn defect images are collected using an industrial camera, and an image enhancement preprocessing module is added to perform image sharpening, contrast enhancement, threshold segmentation, and morphological processing. This improves the clarity of the yarn structure in the input image and reduces the interference of blurred images and background noise on the segmentation results. Based on the difference in background grayscale distribution between white yarn and black yarn, an image enhancement strategy is designed. The mask of the background segmentation result is set as black, and the mask of the yarn segmentation result is set as white. Linear stretching, edge filling, and image inversion operations are also introduced in the black yarn preprocessing process to further ensure the consistency of the training data. Step 2: Divide the spandex covered yarn defect image dataset according to the ratio to obtain a training image dataset and a verification image dataset; Step 3: Build a defect detection network model including a double-layer convolution module, a dual-channel feature alignment module, and a low-light enhancement module; The double-layer convolution module introduces a double-layer decoder structure and conditional convolution, enabling the model to calculate the image transformation matrix through convolution operations, ensuring that the yarn structure remains consistent in different feature space positions. Conditional convolution is used to extract the features of yarn defect areas, accurately identifying yarn defects and reducing background interference. The first convolution layer of the double-layer convolution module is responsible for basic feature extraction. This layer uses a small-size 3×3 convolution kernel to extract local features to retain detail information, as shown in formula (1): (1); in, is the input feature map, is the first layer convolution kernel weight matrix, represents the convolution operation, is the bias term, is a nonlinear activation function; Normalization is used to reduce internal variable offset and enhance the generalization ability of the model, as shown in formula (2): (2); in, is the mean value within the mini-batch, Standard deviation within; The second convolution layer of the double-layer convolution module is responsible for high-level feature fusion. This layer will further optimize feature expression and enhance the perception of defect areas. By using skip connections, the model can retain low-level features while learning high-level features, thereby improving detection results, as shown in formula (3): (3); The dual-channel feature alignment module uses a dual-channel feature network to extract feature information from the original image and the initial segmentation mask. The original image is used to preserve the overall texture structure of the yarn, while the mask segmentation result is used to focus on the location and shape of the defect area. On this basis, combined with the dynamic mask guidance mechanism and defect category information, the edges and details of the defect area are further highlighted, making the target outline clearer and the classification more accurate, thereby improving the model's defect recognition ability. The dual-channel feature alignment module combines the generation capability of the diffusion model with the classification task, introduces dual-channel diffusion, and performs synchronous diffusion calculations on the image branch and the mask branch, as shown in Equation (4): (4); To ensure the synchronous diffusion of the two, a cross-branch feature alignment constraint is added at each step of the diffusion process, as shown in Equation (5); (5); In the diffusion denoising process, conditional attention is added to the feature extraction process of each layer and feature transformation is used to align the image features and mask features, so that the model can focus on the defect area while suppressing background noise interference, as shown in Equation (6): (6); in, is the dynamic learning weight; The low-light enhancement module combines multi-scale adaptive illumination enhancement and dynamic contrast adjustment to effectively improve yarn defect detection performance under conditions of large changes in lighting conditions, enhance image details, and improve the segmentation accuracy of defect areas. Input image for low-light enhancement module Calculate according to formula (7)-(9): (7); (8); (9); in, represents the original input image, represents the true reflection characteristics of the object, Indicates changes in light intensity; Controls the scale of the Gaussian filter, larger A smoother lighting distribution is extracted, and smaller Preserve more local contrast information; is a small positive number used to prevent division by zero errors; Introducing learnable The transformation is dynamically adjusted to make the brightness distribution of different regions more uniform, as shown in equation (10): (10); wherein, is a learnable parameter, which can be adaptively adjusted through a 1x1 convolution and Sigmoid normalization; The enhanced image is subjected to local brightness normalization to make the brightness range of different regions close, thereby reducing the influence of light difference, as shown in equation (11): (11); wherein, and are the local mean and standard deviation, respectively, and the normalization can eliminate the influence of brightness change and make the defect region more prominent; The channel attention weight is calculated through global pooling and two layers of fully connected network , as shown in equation (12): (12); wherein, GAP represents global average pooling; and are learnable fully connected layer parameters; is a Sigmoid activation function; the calculated acts on the input features, making the model pay more attention to the defect region, reducing background interference, and improving the segmentation accuracy; Step 4, training the defect detection network model using the training image dataset, and optimizing the parameters of each module in the network model according to the training result; The training is performed using a stochastic gradient descent optimizer, combined with a cosine annealing strategy to dynamically adjust the learning rate. During the training process, the learning rate gradually decays with the increase of the number of iterations, making the gradient update more stable, thereby reducing the oscillation phenomenon in the model convergence process and improving the convergence stability. To suppress overfitting, L2 regularization is used. By limiting the size of the weight parameters, the model calculation ability is not excessively limited, which can prevent gradient explosion and effectively suppress overfitting, thereby improving the generalization ability of the model; Step 5, input the verification image dataset into the optimized network model, and output the verification result after testing.
[0022] Embodiment 6 The spandex covered yarn defect detection method based on dual-channel feature learning proposed in this embodiment includes the following steps: Step 1: A self-built spandex covered yarn dataset is used, which contains black and white spandex covered yarn defect images under different specifications, different backgrounds, and different noise conditions; The self-built dataset used for model training and testing contains black and white spandex covered yarn defect images of different specifications, different backgrounds, and different noise conditions to ensure that the model can learn diverse defect features; it contains spandex images of five different specifications and defect categories, namely white normal yarn, white stiff yarn, white spandex-free yarn, black double-sided mesh yarn, and black yarn with uneven dots. The image resolution is 640×640, and the size is 3-channel color images. Figure 2 As shown; The self-built spandex-coated yarn defect image dataset is specifically constructed as follows: spandex-coated yarn defect images are collected using an industrial camera, and an image enhancement preprocessing module is added to perform image sharpening, contrast enhancement, threshold segmentation, and morphological processing. This improves the clarity of the yarn structure in the input image and reduces the interference of blurred images and background noise on the segmentation results. In view of the difference in background grayscale distribution between white yarn and black yarn, an image enhancement strategy is designed. The mask of the background segmentation result is set as black, and the mask of the yarn segmentation result is set as white. Linear stretching, edge filling, and image inversion operations are also introduced in the black yarn preprocessing process to further ensure the consistency of the training data. Step 2: Divide the spandex image dataset containing different defect types into training and validation datasets according to a certain ratio; The dataset includes yarn samples under different background conditions, including black and white spandex-covered yarn. The dataset contains 1,000 spandex defect images, of which 800 (80%) are used for training and 200 (20%) are used for validation. Step 3: The overall network architecture consists of a two-layer convolution module, a dual-channel feature alignment module, and a low-light enhancement module, as shown in Figure 1 As shown; Traditional single-layer convolution, ordinary stacked convolution or other convolution layers have certain limitations when processing complex textures and subtle boundary features. Based on this, the double-layer convolution module cited in this application divides the convolution operation into two stages. The first stage focuses on extracting the main structure of the defect and quickly locates the defect area in the yarn. The second stage further refines the defect features on this basis and supplements the details such as edges and textures. The module structure is as follows: Figure 3 As shown; Given an input feature map The first convolution layer of the double-layer convolution task module is responsible for basic feature extraction. This layer uses a small-size 3×3 convolution kernel to extract local features to retain detail information. The formula is as follows: (1); in, is the first layer convolution kernel weight matrix, represents the convolution operation, is the bias term, is a nonlinear activation function. Batch Normalization (BN) is then used to reduce internal variable offset and enhance the generalization ability of the model. (2); in, is the mean value within the mini-batch, The second convolution layer is responsible for high-level feature fusion. This layer will further optimize feature expression and enhance the perception of defect areas; Then, skip connections are used to allow the model to retain low-level features while learning high-level features, thereby improving the detection effect. The formula is as follows: (3); The core purpose of using the double-layer convolution task module is to ensure efficient calculation while enhancing the feature expression ability of yarn defect areas.
[0023] In the task of classifying and identifying yarn defects, since defects have complex morphology, low contrast, and are easily affected by lighting conditions and background texture, this method combines the generation capability of the diffusion model with the classification task, introduces dual-channel diffusion, and performs synchronous diffusion calculation using the image branch and the mask branch. The formula is expressed as: (4); In order to ensure the synchronous diffusion of the two, this method adds cross-branch feature alignment constraints at each step of the diffusion process. The formula is as follows: (5); This operation ensures that the mask maintains semantic consistency with the image features at each diffusion step, thereby improving segmentation accuracy. At the same time, during the diffusion denoising process, conditional attention is added to the feature extraction process at each layer and feature transformation is used to align image features and mask features, enabling the model to focus on the defect area while suppressing background noise interference. The calculation formula is as follows: (6); in, is a dynamic learning weight. This mechanism controls the generation process of the defect mask to the actual defect area of the image, avoids the generation of erroneous background noise, and ensures that the semantic information of the defect area is not lost by adjusting the degree of fusion of image features and mask features. Figure 4 shown.
[0024] Yarn images contain a variety of yarn colors and categories, such as white and black yarns with varying shades. When collecting yarn data, different background colors must be selected to highlight the yarn's details. For example, white yarn requires a black background to highlight its shape, while black yarn requires a white background to highlight its details. Therefore, for yarn images with low background light, only by effectively distinguishing foreground and background information can yarn defects be accurately classified and identified.
[0025] The contrast enhancement module aims to improve the lighting effect of low-light images, making the yarn texture details in the image clearer and ensuring that the defective areas are not over-enhanced or blurred. It uses low-light enhancement theory to perform illumination compensation, making the illumination distribution in the image more uniform, improving the visibility of low-light areas, and enhancing the edge information of yarn defects. The module structure is as follows: Figure 5 shown.
[0026] Assuming that the image can be decomposed into reflection component (Reflectance) and illumination component (Illumination), the input image The expression is as shown in the formula: (7); in: represents the original input image, represents the true reflection characteristics of the object, In order to enhance the details of the yarn defect area while avoiding over-enhancement of the background area, it is necessary to first estimate the illumination component. , and then calculate the reflection component by normalization The illumination component is smoothed from the original image by Gaussian The estimation is done to remove local texture information and only retain the illumination changes. It is shown below: (8); in, Controls the scale of the Gaussian filter, larger A smoother lighting distribution is extracted, and smaller More local contrast information is retained. The following normalization formula is used to calculate the reflection component: (9); in, Is a small positive number used to prevent division by zero errors. Remove the influence of illumination changes, make the brightness of the yarn defect area more uniform, make the tiny defects on the yarn surface clearer, and improve the discriminability of the segmentation model. However, the image after low-light enhancement may still have the problem of uneven local brightness distribution, so the learnable The transformation is dynamically adjusted to make the brightness distribution of different areas more uniform. The transformation is defined as follows: (10); in, is a learnable parameter that can be adaptively adjusted through a 1×1 convolution and sigmoid normalization. After completing illumination enhancement, it is still necessary to ensure that the model focuses on the defective area rather than enhancing irrelevant background information. To this end, this method incorporates an illumination normalization mechanism, which guides the model to focus on the yarn defect area through brightness normalization and a channel attention mechanism. First, the enhanced image Perform local brightness normalization to make the brightness range of different areas close, thereby reducing the impact of lighting differences. The formula is as follows: (11); in, and The local mean and standard deviation are respectively. This normalization can eliminate the influence of brightness changes and make the defect area more prominent. Then the channel attention weight is calculated through global pooling and two-layer fully connected network , the formula is as follows: (12); Where: GAP stands for Global Average Pooling. and are the learnable fully connected layer parameters. is the Sigmoid activation function. Acting on the input features, the model focuses more on the defect area, reduces background interference, and improves segmentation accuracy; Step 4: Use the self-built dataset to train the model, adjust the parameters based on the training results, enhance the performance, and realize the defect detection of spandex covered yarn; The network model for this method was built using the PyTorch framework, and experiments were conducted on a standard workstation equipped with an Intel Xeon(R) Silver 4314 CPU (2.4 GHz) and an NVIDIA RTX 3090 GPU. During model optimization, the stochastic gradient descent (SGD) optimizer was used for training, with momentum set to 0.9. The learning rate was dynamically adjusted using a cosine annealing strategy, initially set to 1×10⁻4. This learning rate was gradually decayed with increasing iterations during training, resulting in smoother gradient updates, thus reducing oscillations during model convergence and improving convergence stability. In addition, in order to suppress overfitting, L2 regularization is used and the weight decay coefficient is set to 5×10⁻ 4 By limiting the size of weight parameters, without excessively limiting the model's computational power, we can prevent gradient explosion and effectively suppress overfitting, thereby improving the model's generalization ability. At the same time, we introduce an early stopping mechanism, which automatically terminates training when the validation set loss does not decrease significantly after several consecutive epochs of training, preventing overfitting and reducing unnecessary computational costs. This method experiment uses mixed precision training to reduce video memory usage and improve training efficiency. It also uses pre-trained model weights for parameter initialization to accelerate convergence and improve model stability. The batch size of the model training is set to 4, and the number of training epochs is set to 200. Step 5: Finally, test on multiple data sets and compare with other methods to verify the effectiveness of this method. Figure 6 As shown; This method was first compared with traditional methods in terms of segmentation accuracy. The results showed that this method outperformed traditional methods in terms of yarn backbone integrity, defect region differentiation, and noise immunity. In particular, under low-contrast and complex background conditions, this method significantly reduced problems such as yarn structural incompleteness and edge loss. The accuracy of this method in yarn image segmentation was evaluated, demonstrating its feasibility and applicability for yarn defect identification. Five traditional methods, including Otsu thresholding, Canny edge detection, K-means clustering, and Morph, were tested on a spandex-coated yarn defect dataset.
[0027] The effectiveness of this method for segmenting hairy intersections was verified by comparison with various deep learning-based methods, including UNet++, CS2Net, Att-UNet, and DeepLabV3+. The aim was to assess the adaptability of different network architectures to the yarn defect classification task. The experiments used the same training, validation, and test sets, and were trained with the same hyperparameter settings.
[0028] In order to comprehensively evaluate the performance of this method in the yarn defect classification task, quantitative comparative experiments were carried out with typical traditional Otsu threshold method, Canny edge detection, K-means clustering, Morph and UNet++, CS2Net, Att-UNet, DeepLabV3+ and other deep learning classification models.
Claims
1. A spandex covered yarn defect detection method based on dual-channel feature learning, characterized in that: The following steps are involved: Step 1: Collect spandex covered yarn images and build a spandex covered yarn defect image dataset; Step 2: Divide the spandex covered yarn defect image dataset according to the ratio to obtain a training image dataset and a verification image dataset; Step 3: Build a defect detection network model including a double-layer convolution module, a dual-channel feature alignment module, and a low-light enhancement module; Step 4: Use the training image dataset to train the defect detection network model, and optimize the parameters of each module in the network model based on the training results; Step 5: Input the verification image dataset into the optimized network model, perform the test, and output the verification results.
2. The spandex covered yarn defect detection method based on dual-channel feature learning according to claim 1, characterized in that: The spandex covered yarn defect image dataset in step 1 includes black spandex covered yarn defect images and white spandex covered yarn defect images under different specifications, different backgrounds, and different noise conditions; The self-built spandex coated yarn defect image dataset is specifically as follows: spandex coated yarn defect images are collected by an industrial camera, and an image enhancement preprocessing module is added to perform sharpening, contrast enhancement, threshold segmentation and morphological processing on the images, thereby improving the clarity of the yarn structure in the input image and reducing the interference of blurred images and background noise on the segmentation results. In view of the difference in background grayscale distribution between white yarn and black yarn, an image enhancement strategy is designed, in which the mask of the background segmentation result is set as black, and the mask of the yarn segmentation result is set as white. Linear stretching, edge filling and image inversion operations are also introduced in the black yarn preprocessing process to further ensure the consistency of the training data.
3. The spandex covered yarn defect detection method based on dual-channel feature learning according to claim 2, characterized in that: The double-layer convolution module described in step 3 introduces a double-layer decoder structure and conditional convolution, so that the model can calculate the transformation matrix of the image through convolution operation, ensuring that the yarn structure remains consistent in different feature space positions, extracting the features of the yarn defect area through conditional convolution, accurately identifying defects in the yarn, and reducing background interference.
4. The spandex covered yarn defect detection method based on dual-channel feature learning according to claim 3 is characterized in that: The first convolution layer of the double-layer convolution module is responsible for basic feature extraction. This layer uses a small-size 3×3 convolution kernel to extract local features to retain detail information, as shown in formula (1): (1); in, is the input feature map, is the first layer convolution kernel weight matrix, represents the convolution operation, is the bias term, is a nonlinear activation function; Normalization is used to reduce internal variable offset and enhance the generalization ability of the model, as shown in formula (2): (2); in, is the mean value within the mini-batch, Standard deviation within; The second convolution layer of the double-layer convolution module is responsible for high-level feature fusion. This layer will further optimize feature expression and enhance the perception of defect areas. By using skip connections, the model can retain low-level features while learning high-level features, thereby improving detection results, as shown in formula (3): (3)。 5. The spandex covered yarn defect detection method based on dual-channel feature learning according to claim 4, characterized in that: The dual-channel feature alignment module extracts feature information from the original image and the preliminary segmentation mask through a dual-channel feature network. The original image is used to retain the overall texture structure of the yarn, and the mask segmentation result is used to focus on the position and shape of the defect area. On this basis, combined with the dynamic mask guidance mechanism and defect category information, the edges and details of the defect area are further highlighted, making the target contour clearer and the classification more accurate, thereby improving the defect recognition ability of the model.
6. The spandex covered yarn defect detection method based on dual-channel feature learning according to claim 5, characterized in that: The dual-channel feature alignment module combines the generation capability of the diffusion model with the classification task, introduces dual-channel diffusion, and performs synchronous diffusion calculation on the image branch and the mask branch, as shown in Equation (4): (4); To ensure the synchronous diffusion of the two, a cross-branch feature alignment constraint is added at each step of the diffusion process, as shown in Equation (5); (5); In the diffusion denoising process, conditional attention is added to the feature extraction process of each layer and feature transformation is used to align the image features and mask features, so that the model can focus on the defect area while suppressing background noise interference, as shown in Equation (6): (6); in, are dynamic learning weights.
7. The spandex covered yarn defect detection method based on dual-channel feature learning according to claim 6, characterized in that: The low-light enhancement module combines multi-scale illumination adaptive enhancement and contrast dynamic adjustment to effectively improve the detection performance of yarn defects under conditions with large changes in lighting conditions, enhance the detailed features of the image, and improve the segmentation accuracy of the defective area.
8. The spandex covered yarn defect detection method based on dual-channel feature learning according to claim 7, characterized in that: The input image of the low light enhancement module Calculate according to formula (7)-(9): (7); (8); (9); in, represents the original input image, represents the true reflection characteristics of the object, Indicates changes in light intensity; Controls the scale of the Gaussian filter, larger A smoother lighting distribution is extracted, and smaller Preserve more local contrast information; is a small positive number used to prevent division by zero errors; Introducing learnable The transformation is dynamically adjusted to make the brightness distribution of different areas more uniform, as shown in formula (10): (10); in, It is a learnable parameter that can be adaptively adjusted through a 1×1 convolution and Sigmoid normalization; For the enhanced image Perform local brightness normalization to make the brightness range of different areas close, thereby reducing the impact of illumination differences, as shown in formula (11): (11); in, and are the local mean and standard deviation, respectively. This normalization can eliminate the influence of brightness changes and make the defect area more prominent; Calculate channel attention weights through global pooling and two-layer fully connected networks , as shown in formula (12): (12); Among them, GAP represents global average pooling; and are learnable fully connected layer parameters; is the Sigmoid activation function; calculated Acting on the input features, the model pays more attention to the defect area, reduces background interference, and improves segmentation accuracy.
9. The spandex covered yarn defect detection method based on dual-channel feature learning according to claim 8, characterized in that: The training specifically uses a stochastic gradient descent optimizer for training, combined with a cosine annealing strategy to dynamically adjust the learning rate. During the training process, the learning rate gradually decays as the number of iterations increases, making the gradient update more stable, thereby reducing the oscillation phenomenon that occurs during the model convergence process and improving the convergence stability; To suppress overfitting, L2 regularization is used. By limiting the size of weight parameters, it can prevent gradient explosion and effectively suppress overfitting without excessively restricting the computing power of the model, thereby improving the generalization ability of the model.