Knitted cotton fabric knot defect detection method based on improved third-order recursive gated convolution
By combining an improved third-order recursive gated convolutional network with multilayer perceptron branches, the problem of low accuracy in detecting knot defects in knitted cotton fabrics was solved, achieving efficient and accurate defect detection and improving fabric production quality.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG GONGSHANG UNIVERSITY
- Filing Date
- 2023-06-13
- Publication Date
- 2026-05-01
AI Technical Summary
Existing methods for detecting knot defects in knitted cotton fabrics are inefficient and lack precision, failing to meet the cost control and inspection needs of modern industry.
An improved third-order recursive gated convolutional network is adopted, combined with a multilayer perceptron branch, to increase cross-order feature interaction. The YOLOv7 network model is improved and trained using the CIou loss function and the binary cross-entropy loss function to improve the defect detection accuracy.
It improves the detection accuracy of knot defects in knitted cotton fabrics and the domain generalization performance of the model, thereby enhancing the quality of fabric production.
Smart Images

Figure CN116740016B_ABST
Abstract
Description
A Method for Detecting Knot Defects in Knitted Cotton Fabrics Based on Improved Third-Order Recursive Gated Convolution Technical Field
[0001] This invention belongs to the field of target detection and pattern recognition in computer vision, and relates to a method for detecting knot defects in knitted cotton fabrics based on deep learning. Background Technology
[0002] With the continuous improvement of socio-economic levels, people's requirements for the appearance of their daily clothing are constantly increasing. The appearance of fabric greatly influences people's judgment of product value and function. Knitted cotton fabric is the material used to make many garments in people's daily lives. If the fabric produced by the manufacturer has defects, the aesthetics of the clothing will be greatly reduced, significantly diminishing the company's competitiveness. However, in actual production, due to the influence of the production environment and technology, knitted cotton fabric often exhibits various defects. Among them, knot defects are small in size, vary in shape, and are difficult to detect, making them one of the pain points in fabric production. Currently, most methods for detecting knot defects in knitted cotton fabric rely on traditional image processing and manual inspection. Manual inspection is inefficient and costly, failing to meet the requirements of modern industry for cost control and inspection efficiency. Traditional image processing methods generally extract defect features by manually designing feature extraction algorithms, but this method has low accuracy and poor robustness, and is not ideal for detecting knot defects in knitted cotton fabric. Therefore, it is necessary to design a new algorithm for detecting knot defects in knitted cotton fabric for practical manufacturing applications.
[0003] In recent years, thanks to the rapid development of deep learning and the increasing availability of computing power, deep learning-based object detection methods have performed exceptionally well in the field of industrial product defect detection, significantly improving detection accuracy and speed compared to previous methods. Since knot defects in fabrics are small in size and vary in shape across different fabric styles, this invention proposes an improved third-order recursive gated convolution method using a multilayer perceptron for detecting knot defects in knitted cotton fabrics. This invention is plug-and-play, enhancing the model's domain generalization performance while improving the detection accuracy of defects in knitted cotton fabrics, thereby improving the production quality of the fabric. Summary of the Invention
[0004] This invention presents an improved method for detecting knot defects in knitted cotton fabrics based on third-order recursive gated convolution. By further integrating features from different orders through multilayer perceptron branches, the method retains the defect information at the lower levels while enriching the multi-scale information of the network, effectively improving the detection rate of knot defects in knitted cotton fabrics.
[0005] To achieve the above objectives, the specific steps of the present invention are as follows:
[0006] Step 1: Using a linear projection function Features output from the previous layer of the network Based on the channel division, a set of projection features is denoted as... in The segmented features are then sequentially input into gated convolutions for recursive computation, using the following formula: , where the symbol This represents the dot product between features. The feature mapping function f is a channel-wise convolutional layer with a kernel size of 7*7, a stride of 1, and padding of 3. To ensure the number of channels during spatial interaction, the dimension mapping function... Designed as follows:
[0007]
[0008] Where Identity is the identity mapping function, which means that the current feature is output directly without any processing; The channel augmentation function, implemented with a 1x1 convolution kernel, increases the number of feature channels from... Expanded to .
[0009] Step 2: Modify the structure of the above third-order recursive gated convolution: Since the interaction mode of features in the third-order recursive gated convolution is limited to adjacent features... and The interactions between them did not take into account cross-order interactions. Furthermore, given that multilayer perceptrons can better utilize global structural information compared to convolutional networks, the output feature map of the first-order gated convolution is considered. A separate multilayer perceptron branch is added after the initial convolution, and the channels of this branch are expanded to allow it to interact with the output feature map of the second-order gated convolution. By interacting with spatial features, more underlying information about defects is preserved, and the multi-scale details of the network are enriched to adapt to the characteristics of knot defects in different fabrics.
[0010] Step 3: Replace all convolutional modules in the neck network of YOLOv7 with improved third-order recurrent convolutions;
[0011] Step 4: Use an industrial area scan camera to capture images of the fabric, manually label fabric defects, and obtain a defect dataset;
[0012] Step 5: Load the collected and labeled fabric dataset into the improved YOLOv7 network model. The model localization loss uses the CIou loss function, denoted as... Both the classification loss and confidence loss of the model adopt the binary cross-entropy loss, denoted as ; , Then, weighting is performed by setting different weights. ,in for The loss weight has a value of 0.05. for The loss weight has a value of 0.3. for The loss weight is set to 0.7. The modified model is then retrained to obtain the target network model weights.
[0013] Step 6: Load the target network model weights into the real-time fabric detection system, perform inference analysis on the real-time images captured by the camera, and store the detection results of knot defects and other defects in the knitted cotton fabric into the system.
[0014] The innovation of this invention lies in changing the original three-order recursive gated convolution feature extraction method and adding a cross-order feature interaction method, which enhances the network's low-level feature extraction capability and makes the network more sensitive to the detailed features of small targets. It provides a good solution to the prominent problems of existing detection algorithms, such as poor detection effect and low accuracy in detecting knots and defects in knitted cotton fabrics. Attached Figure Description
[0015] Figure 1 is a schematic diagram of the fabric inspection system.
[0016] Figure 2 is a schematic diagram of the improved third-order recursive gated convolution of the present invention; Detailed Implementation
[0017] The present invention will be further described below with reference to specific implementation schemes and accompanying drawings.
[0018] The overall flowchart of the fabric defect detection system is shown in Figure 1, and the steps are as follows:
[0019] (S1) Industrial cameras acquire fabric images in real time at high speed;
[0020] (S2) The model reads the input image and performs real-time detection;
[0021] (S3) The model determines whether the fabric image has defects. If there are defects, proceed to step (S4); otherwise, proceed to step (S5).
[0022] (S4) The model marks the defects on the defective images and stores the defect category information in the system;
[0023] (S5) The system gives an instruction on whether to continue the detection. If yes, the detection continues and returns to step (S2); otherwise, the detection ends directly.
[0024] The model can be obtained through the following steps:
[0025] (1) First, the structure of the third-order recursive gated convolution needs to be modified, as shown in Figure 2. Linear projection function Features output from the previous layer of the network Based on the channel division, a set of projection features is denoted as... ,in , features According to the recursive calculation formula The data is sequentially input into a gated convolutional layer for recursive computation. First, the segmented features are processed... Based on the feature mapping function Calculations yielded ,feature Then through the dimension mapping function ,( )get ,but , where the symbol This represents the dot product between features, and then... Through dimension mapping function get Similarly , Because the interaction of features in a third-order recursive gated convolution is limited to adjacent features. and The interactions between them did not take into account cross-order interactions. Furthermore, given that multilayer perceptrons can better utilize global structural information compared to convolutional networks, the output feature map of the first-order gated convolution is considered. A separate multilayer perceptron branch is added after the first layer, and the channels are expanded to facilitate integration with the output feature map of the second layer. Interacting with spatial features, denoted as ,in ))), Indicates features Flatten the vectors into one-dimensional vectors along the dimensions of h and w to facilitate subsequent fully connected operations. This indicates a fully connected layer from the input layer to the hidden layer. ReLU indicates a fully connected layer from the hidden layer to the output layer, while ReLU indicates a non-linear processing of the merged feature map. This indicates that a one-dimensional vector Reconstruct the feature map into an h×w shape. Then, based on the features... achievable , This indicates that the features are added element by element. Finally, the features are... With features Dot product After the final projection layer Get the final output .
[0026] (3) Replace all convolutional modules of the neck network of yolov7 with improved third-order recurrent convolutions.
[0027] (4) The fabric images are acquired by an industrial area array camera, and the fabric defects are manually labeled to obtain a defect dataset;
[0028] (5) Load the collected and labeled fabric dataset into the improved YOLOv7 network model. The model localization loss adopts the CIou loss function, denoted as . Both the classification loss and confidence loss of the model adopt the binary cross-entropy loss, denoted as ; , Then, weighting is performed by setting different weights. ,in for The loss weight has a value of 0.05. for The loss weight has a value of 0.3. for The loss weight is set to 0.7. The modified model is then retrained to obtain the target network model weights.
[0029] The steps for the improved third-order recursive gated convolutional inference of images are as follows:
[0030] Step (1): The fabric image is input into the YOLOv7 network. First, the upper layer network extracts image features to obtain a set of feature maps, denoted as... Then, through the linear projection function A set of features was obtained .
[0031] ,in This indicates a convolutional layer with a kernel size of 1*1, which expands the input feature channels C to twice their original size.
[0032]
[0033] ,
[0034] Step (2), Features After being cut Both are input into the feature mapping function f(x) and calculated to obtain... ;feature Then through the dimension mapping function get .
[0035] , ,in This indicates a channel-wise convolutional layer with a kernel size of 7*7, a stride of 1, and padding of 3, where the input and output feature channels remain unchanged.
[0036] , in This indicates a convolutional layer with a kernel size of 1*1, where the input and output feature channels remain unchanged.
[0037] Step (3): The result obtained in step (2) The input is fed into a gated convolution and calculated recursively. , The first-order recursive operation is obtained. .
[0038] , Among the symbols This represents the dot product between features.
[0039] Step (4): Obtain the result from step (3) Input to dimension mapping function get Then The input is fed into a gated convolution and a second-order recursive operation is performed according to the recursive calculation formula to obtain the result. At the same time The input is fed into the multilayer perceptron branch to obtain... .
[0040] ,
[0041] , .
[0042] ))), Indicates features Flatten the vectors into one-dimensional vectors along the dimensions of h and w to facilitate subsequent fully connected operations. This indicates a fully connected layer from the input layer to the hidden layer. ReLU indicates a fully connected layer from the hidden layer to the output layer, while ReLU indicates a non-linear processing of the merged feature map.
[0043] , , This indicates that a one-dimensional vector The feature map is then converted back to h×w.
[0044] Step (5): The result obtained in step (4) Input to dimension mapping function get , and then with The Add operation yields .
[0045]
[0046] , Indicates features Add elements one by one.
[0047] Step (6): Obtain the result from step (5) Input into gated convolution and features Dot product yields After passing through the final projection layer Get the final output .
[0048]
[0049]
Claims
1. A method for detecting knot defects in knitted cotton fabrics based on improved third-order recursive gated convolution, characterized in that... The method includes the following steps: Step 1, in the YOLOv7 network model, through a linear projection function... Features output from the previous layer of the network Based on the channel division, a set of projection features is denoted as... ,in The segmented features are then processed according to the recursive formula. The inputs are sequentially fed into a gated convolutional layer for recursive computation, where the sign... This represents the dot product between features. The feature mapping function f is for a deep convolutional layer. To align the number of channels in the spatial interaction process, the dimension mapping function... Designed as follows: Where Identity is the identity mapping function, meaning that the current feature is output directly without any processing; For channel expansion functions, the number of feature channels is increased from... Expanded to Step 2: Modify the structure of the third-order recursive gated convolution in Step 1: linear projection function. Features output from the previous layer of the network Based on the channel division, a set of projection features is denoted as... ,in , features According to the recursive calculation formula The data is sequentially input into a gated convolutional layer for recursive computation; firstly, the segmented features are processed... Based on the feature mapping function Calculations yielded ,feature Then through the dimension mapping function get ,but ; among which symbols This represents the dot product between features, and then... Through dimension mapping function get Similarly , Because the interaction of features in a third-order recursive gated convolution is limited to adjacent features. and The interactions between them did not take into account cross-order interactions. Furthermore, given that multilayer perceptrons can better utilize global structural information compared to convolutional networks, the output feature map of the first-order gated convolution is considered. A separate multilayer perceptron branch is added after the first layer, and the channels are expanded to facilitate integration with the output feature map of the second layer. Interacting with spatial features, denoted as ,in ))), Indicates features Flatten the vectors into one-dimensional vectors along the dimensions of h and w to facilitate subsequent fully connected operations; This indicates a fully connected layer from the input layer to the hidden layer. ReLU indicates a fully connected layer from the hidden layer to the output layer, while ReLU indicates non-linear processing of the merged feature map. This indicates that a one-dimensional vector Reconstruct the feature map into an h×w shape; then, based on the features... achievable , This indicates that the features are added element by element; finally, the features are... With features Dot product After the final projection layer Get the final output Step 3: Replace all convolutional modules of the neck network of YOLOv7 with improved third-order recurrent convolutions; Step 4: Use an industrial area array camera to acquire fabric images, manually label fabric defects, and obtain a defect dataset; Step 5: Load the acquired and labeled fabric dataset into the improved YOLOv7 network model, retrain, and obtain the target network model weights; Step 6: Load the target network model weights into the real-time fabric detection system, perform inference analysis on the real-time images acquired by the camera, and store the detection results of knot defects and other defects in knitted cotton fabric into the system.
2. The method for detecting knot defects in knitted cotton fabrics based on improved third-order recursive gated convolution as described in claim 1, characterized in that: Linear projection function in step 1 and channel expansion functions All are implemented by a 1*1 convolutional layer to expand the channels of the feature map; in order to reduce the amount of computation, the feature mapping function f is implemented by a channel-wise convolutional layer with a kernel size of 7*7, a stride of 1, and padding of 3. Without changing the size of the feature map, the larger convolutional kernel is more suitable for the interaction of features between different positions in the feature map.
3. The method for detecting knot defects in knitted cotton fabrics based on improved third-order recursive gated convolution as described in claim 1, characterized in that: In step 5, the loss function used to evaluate the model training effect is obtained by weighted fusion of different loss functions, where the classification loss and confidence loss both adopt the binary cross-entropy loss, and the localization loss is the CIou loss function.
Citation Information
Patent Citations
Fabric defect detection method based on Swinin-Transform and NAS-FPN
CN114066820A
Monaural multi-talker speech recognition with attention mechanism and gated convolutional networks
US20200043467A1