A method for detecting surface defects in fabrics
By employing DCS and DCPAN technologies, the technical problems of multi-scale detection of fabric surfaces in existing technologies have been solved. The accuracy and efficiency of fabric surface defect detection have been improved by using DCS and DCPAN technologies.
Patent Information
- Application Number
- CN202310373080.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-10
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2043-04-10
AI Technical Summary
Existing technologies are ineffective at detecting multi-scale defects on fabric surfaces, especially small-target defects, resulting in low detection efficiency and impacting fabric quality and cost.
We employ DCSPPF and DCPANet modules to extract and fuse features from fabric defect images. Combining adaptive anchor box strategies and data augmentation, we use the CSP_Darknet53 network model for multi-scale feature extraction and detection. We remove duplicate boxes through non-maximum suppression and achieve high-precision defect detection.
It improves the accuracy of fabric surface defect detection, overcomes the loss of small target defect information, enhances the robustness of multi-scale detection, and reduces fabric production costs.
Smart Images

Figure CN116823716B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of industrial defect detection technology, and more specifically to a method for detecting surface defects in fabrics. Background Technology
[0002] Fabrics are indispensable materials for human life and industrial production, and are widely used in clothing, decoration, and other applications. However, during the fabric production process, various defects can form on the fabric surface due to factors such as improper manual operation and interference from the production environment.
[0003] Fabric defects in industrial production not only severely affect the appearance quality and grade of fabrics but also significantly impact their price. Therefore, the detection of fabric surface defects is an essential step in textile manufacturing quality control. Currently, most textile enterprises rely on manual visual inspection of fabric defects, which can only repair obvious defects, is time-consuming and inefficient, and severely limits production capacity. Therefore, developing automatic defect detection algorithms suitable for the textile industry has high academic and applied value.
[0004] Traditional object detection techniques, such as YOLO and Fast R-CNN, perform exceptionally well in detecting objects of conventional sizes. However, fabric defect data often suffers from several issues: significant scale differences between different defect types; and some defects are extremely small, containing much useless background information. Traditional methods still face challenges in detecting small targets like fabric defects.
[0005] In summary, this method, based on the classic network, uses DCSPPF to reduce the loss of defect information and reuse features, and then further uses DCPANet to achieve better multi-scale feature fusion, thereby improving the detection accuracy of multi-scale fabric defects. Summary of the Invention
[0006] To overcome the shortcomings of existing methods and improve the detection accuracy of multi-scale defects on fabric surfaces, this invention provides a method for detecting defects on fabric surfaces.
[0007] The technical solution of the present invention is as follows:
[0008] A method for detecting surface defects in fabrics includes the following steps:
[0009] Step 1: Preprocessing of the fabric defect image, as follows:
[0010] Step 1.1: Perform data augmentation on the fabric defect images;
[0011] Step 1.2: Adopt an adaptive anchor box strategy to re-cluster the targets in the dataset to generate the best anchor box templates as the initial anchor boxes;
[0012] Step 1.3: Normalize all fabric defect images to a uniform size;
[0013] Step 2: Use the CSP_Darknet53 network model to extract features from the fabric defect image to obtain feature map f0. Each time the CSP module processes the image, a feature map b is obtained. i , i represents the i-th time the CSP module processes the data, i = 1, 2, 3, 4;
[0014] Step 3: Feed feature map b4 into the DCSPPF module to obtain feature map f5. The DCSPPF module processes the feature map as follows: feature map b4 first passes through a convolutional layer to obtain feature map f1, then passes through three max pooling layers to obtain feature maps f2, f3, and f4 respectively. Feature maps f1 and f2 are concatenated to obtain feature map c1. Feature maps f1, f2, and f3 are concatenated with c1 to obtain feature map c2. Feature maps f1, f3, and f4 are concatenated with c2 to obtain feature map c3. Finally, feature maps c1, c2, and c3 are concatenated to obtain feature map c4, and then fed into a convolutional layer to obtain feature map f5.
[0015] Step 4: Feed feature map f5 into the DCPANet module for further feature fusion to obtain three feature maps f of different sizes. s f m f b The DCPANet module processes feature map f5 as follows: feature map f5 is passed through a convolutional layer to obtain feature map f6. Feature map f6 is upsampled to twice its original size, concatenated with feature map b3, and then fed into a CSP module. After passing through another convolutional layer, feature map f7 is obtained. Feature map f7 is upsampled to twice its original size, concatenated with feature map b2, and then fed into a CSP module. Finally, it is concatenated with feature map b2 to obtain the large-scale feature map f. b Feature map f b After passing through a convolutional layer, the concatenation is performed with feature maps f7 and b3, and then fed into a CSP module to obtain the medium-scale feature map f. m Feature map f m After passing through a convolutional layer, it is concatenated with feature maps f6 and b2, and then fed into a CSP module to obtain a small-scale feature map f. s ;
[0016] Step 5: Combine the three feature maps of different sizes. b f m f s Three detection heads d1, d2, and d3 are fed into the network to detect large, medium, and small targets, respectively, to obtain detection boxes of defects in the fabric image. The detection boxes contain category, confidence, and location information. Each of the three detection heads d1, d2, and d3 is composed of a single convolutional layer, and their loss functions are all as shown in Equation (1):
[0017] Loss=λ1L cls +λ2L obj +λ3L loc (1)
[0018] Where λ1, λ2, and λ3 are balance coefficients, and the classification loss L cls And confidence loss L obj Both use BCE loss, and the localization loss L of the detection box is... loc The CIoU loss is used, as shown in equation (2):
[0019]
[0020] Among them, c, c gt Let p and p represent the predicted class and the true class, respectively. iou Let b and b' represent the confidence score predicted by the detection box and the IoU value between the detection box and the ground truth box, respectively. gt Let represent the center points of the detection box and the ground truth box, respectively; ρ represent the Euclidean distance between the two center points; l represent the diagonal distance of the smallest closure region that can simultaneously contain both the detection box and the ground truth box; α is the weight coefficient; and v represents the aspect ratio similarity and is calculated according to equation (3).
[0021]
[0022] Among them, w, w gt H and h represent the widths of the detection bounding box and the ground truth bounding box, respectively. gt These represent the heights of the detection bounding box and the ground truth bounding box, respectively.
[0023] Step 6: Use non-maximum suppression to remove duplicate detection boxes for the same target.
[0024] The beneficial effects of this invention are as follows: This invention can detect various defects on the fabric surface, can overcome the loss of small target defect information to a certain extent, and has better robustness to multi-scale defect information, thereby improving the accuracy of fabric defect detection and reducing fabric cost losses, which is of great significance to fabric production. Attached Figure Description
[0025] Figure 1 This is the DCSPPF module of the present invention;
[0026] Figure 2 This is the DCPANet module of the present invention;
[0027] Figure 3 This invention provides the overall network architecture for fabric defect detection. Detailed Implementation
[0028] The present invention will be further described below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the invention.
[0029] A method for detecting fabric defects, comprising the following steps:
[0030] Step 1: Preprocessing of the fabric defect image, as follows:
[0031] Step 1.1: Perform data augmentation on the fabric defect images;
[0032] Step 1.2: Adopt an adaptive anchor box strategy to re-cluster the targets in the dataset to generate the best anchor box templates as the initial anchor boxes;
[0033] Step 1.3: Normalize all fabric defect images to a uniform size;
[0034] Step 2: Use the CSP_Darknet53 network model to extract features from the fabric defect image to obtain feature map f0. Each time the CSP module processes the image, a feature map b is obtained. i , i represents the i-th time the CSP module processes the data, i = 1, 2, 3, 4;
[0035] Step 3: Feed feature map b4 into the DCSPPF module to obtain feature map f5. The DCSPPF module processes the feature map as follows: feature map b4 first passes through a convolutional layer to obtain feature map f1, then passes through three max pooling layers to obtain feature maps f2, f3, and f4 respectively. Feature maps f1 and f2 are concatenated to obtain feature map c1. Feature maps f1, f2, and f3 are concatenated with c1 to obtain feature map c2. Feature maps f1, f3, and f4 are concatenated with c2 to obtain feature map c3. Finally, feature maps c1, c2, and c3 are concatenated to obtain feature map c4, and then fed into a convolutional layer to obtain feature map f5.
[0036] Step 4: Feed feature map f5 into the DCPANet module for further feature fusion to obtain three feature maps f of different sizes. s f m f b The DCPANet module processes feature map f5 as follows: feature map f5 is passed through a convolutional layer to obtain feature map f6. Feature map f6 is upsampled to twice its original size, concatenated with feature map b3, and then fed into a CSP module. After passing through another convolutional layer, feature map f7 is obtained. Feature map f7 is upsampled to twice its original size, concatenated with feature map b2, and then fed into a CSP module. Finally, it is concatenated with feature map b2 to obtain the large-scale feature map f. b Feature map f bAfter passing through a convolutional layer, the concatenation is performed with feature maps f7 and b3, and then fed into a CSP module to obtain the medium-scale feature map f. m Feature map f m After passing through a convolutional layer, it is concatenated with feature maps f6 and b2, and then fed into a CSP module to obtain a small-scale feature map f. s ;
[0037] Step 5: Combine the three feature maps of different sizes. b f m f s Three detection heads d1, d2, and d3 are fed into the network to detect large, medium, and small targets, respectively, to obtain detection boxes of defects in the fabric image. The detection boxes contain category, confidence, and location information. Each of the three detection heads d1, d2, and d3 is composed of a single convolutional layer, and their loss functions are all as shown in Equation (1):
[0038] Loss=λ1L cls +λ2L obj +λ3L loc (1)
[0039] Where λ1, λ2, and λ3 are balance coefficients, and the classification loss L cls And confidence loss L obj Both use BCE loss, and the localization loss L of the detection box is... loc The CIoU loss is used, as shown in equation (2):
[0040]
[0041] Among them, c, c gt Let p and p represent the predicted class and the true class, respectively. iou Let b and b' represent the confidence score predicted by the detection box and the IoU value between the detection box and the ground truth box, respectively. gt Let represent the center points of the detection box and the ground truth box, respectively; ρ represent the Euclidean distance between the two center points; l represent the diagonal distance of the smallest closure region that can simultaneously contain both the detection box and the ground truth box; α is the weight coefficient; and v represents the aspect ratio similarity and is calculated according to equation (3).
[0042]
[0043] Among them, w, w gt H and h represent the widths of the detection bounding box and the ground truth bounding box, respectively. gt These represent the heights of the detection bounding box and the ground truth bounding box, respectively.
[0044] Step 6: Use non-maximum suppression to remove duplicate detection boxes for the same target.
Claims
1. A method for detecting surface defects in fabrics, characterized in that, Includes the following steps: Step 1: Preprocessing of fabric defect images; Step 2: Use the CSP_Darknet53 network model to extract features from the fabric defect image to obtain feature map f0. Each time the CSP module processes the image, a feature map b is obtained. i , i represents the i-th time the CSP module processes the data, i = 1, 2, 3, 4; Step 3: Input feature map b4 into the DCSPPF module to obtain feature map f5; Step 4: Feed feature map f5 into the DCPANet module for further feature fusion to obtain three feature maps f of different sizes. s f m f b ; Step 5: Combine the three feature maps of different sizes. b f m f s Three detection heads d1, d2, and d3 are fed into the network to detect large, medium, and small targets, respectively, to obtain detection boxes of defects in the fabric image. The detection boxes contain category, confidence, and location information. Each of the three detection heads d1, d2, and d3 is composed of a single convolutional layer, and their loss functions are all as shown in Equation (1): Loss=λ1L cls +λ2L obj +λ3L loc (1) Where λ1, λ2, and λ3 are balance coefficients, and the classification loss L cls And confidence loss L obj Both use BCE loss, and the localization loss L of the detection box is... loc The CIoU loss is used, as shown in equation (2): Among them, c, c gt Let p and p' represent the predicted class and the true class, respectively. iou Let b and b' represent the confidence score predicted by the detection box and the IoU value between the detection box and the ground truth box, respectively. gt Let represent the center points of the detection box and the ground truth box, respectively; ρ represent the Euclidean distance between the two center points; l represent the diagonal distance of the smallest closure region that can simultaneously contain both the detection box and the ground truth box; α is the weight coefficient; and v represents the aspect ratio similarity and is calculated according to equation (3): Among them, w, w gt H and h represent the widths of the detection bounding box and the ground truth bounding box, respectively. gt These represent the heights of the detection bounding box and the ground truth bounding box, respectively. Step 6: Use non-maximum suppression to remove duplicate detection boxes for the same target.
2. The method for detecting surface defects in fabrics according to claim 1, characterized in that, Step 1 is as follows: Step 1.1: Perform data augmentation on the fabric defect images; Step 1.2: Adopt an adaptive anchor box strategy to re-cluster the targets in the dataset to generate the best anchor box templates as the initial anchor boxes; Step 1.3: Normalize all fabric defect images to a uniform size.
3. The method for detecting surface defects in fabrics according to claim 1, characterized in that, Step 3 is as follows: Feature map b4 first passes through a convolutional layer to obtain feature map f1, and then passes through three max pooling layers to obtain feature maps f2, f3, and f4 respectively. Feature maps f1 and f2 are concatenated to obtain feature map c1. Feature maps f1, f2, and f3 are concatenated with c1 to obtain feature map c2. Feature maps f1, f3, and f4 are concatenated with c2 to obtain feature map c3. Finally, feature maps c1, c2, and c3 are concatenated to obtain feature map c4, and then fed into a convolutional layer to obtain feature map f5.
4. The method for detecting surface defects in fabrics according to claim 1, characterized in that, Step 4 is as follows: Feature map f5 is passed through a convolutional layer to obtain feature map f6. Feature map f6 is upsampled to twice its original size, concatenated with feature map b3, and then fed into a CSP module. After passing through another convolutional layer, feature map f7 is obtained. Feature map f7 is upsampled to twice its original size, concatenated with feature map b2, and then fed into a CSP module. Finally, it is concatenated with feature map b2 to obtain the large-scale feature map f. b Feature map f b After passing through a convolutional layer, the concatenation is performed with feature maps f7 and b3, and then fed into a CSP module to obtain the medium-scale feature map f. m Feature map f m After passing through a convolutional layer, it is concatenated with feature maps f6 and b2, and then fed into a CSP module to obtain a small-scale feature map f. s .
Citation Information
Patent Citations
Electronic component surface defect detection method based on YOLOv5 convolutional neural network
CN114663382A
Tracheal intubation positioning method and device based on deep learning, and storage medium
US20220265360A1