Cloth defect detection method based on YOLOV8s improvement

By introducing DCNv2 and Polarized Self-Attention modules and small object detection heads into the YOLOV8s model, the problem of insufficient recognition capabilities of small objects and complex backgrounds in cloth defect detection is solved, and the detection accuracy and efficiency are significantly improved.

CN119027780AInactive Publication Date: 2024-11-26ZHEJIANG IND POLYTECHNIC COLLEGE
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411077879.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-07
Publication Date
2024-11-26
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing cloth defect detection methods have limited recognition capabilities in small targets and complex backgrounds, making it difficult to achieve ideal detection results.

Method used

Introduce DCNv2 module and Polarized Self-Attention module in the YOLOV8s model, and add a small object detection head at the 1/4 resolution feature map position. The shape and position of the convolution kernel are adjusted adaptively by DCNv2, and Polarized Self-Attention optimizes attention calculation , combining channel and spatial attention, reduce information loss, and add detection heads in the shallow layer to improve the accuracy of small object detection.

Benefits of technology

It effectively improves the accuracy and robustness of cloth defect detection, improves the detection ability of small targets and complex backgrounds, and significantly improves the detection accuracy and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119027780A_ABST
    Figure CN119027780A_ABST
Patent Text Reader

Abstract

The invention discloses a cloth flaw detection method based on YOLOV8s improvement. The cloth flaw detection method comprises the following steps: S1, introducing a DCNv2 module into a YOLOV8s model; s2, a Polarized Self-Attention module is introduced into the YOLOV8s model, and the Polarized Self-Attention module is used for optimizing a calculation mode of self-attention by introducing a concept of polarization filtering; and S3, on the basis of three original detection heads of YOLOV8s, a detection head is introduced at the position of a 1 / 4 resolution characteristic pattern, in the step S2, Polarized Self-Attention uses matrix multiplication operation to reduce the dimension of the characteristic pattern, and in the step S2, Polarized Self-Attention reduces position pairs needing to be calculated through polarization filtering. According to the invention, DCNv2, a Polarized Self-Attention and a small target detection head are introduced on the basis of YOLOV8s. The DCNv2 can adaptively adjust the convolution shape to extract more effective flaw features, the Polarized Self-Attention enables the model to extract more important features, and the small target detection head can improve the detection precision of small-size flaws. Compared with the original YOLOV8s algorithm, the provided method has the advantages that the mAP50 index is improved by 4.2%, and the cloth defect detection accuracy is greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of cloth defect detection, and in particular to a cloth defect detection method improved based on YOLOV8s. Background Art

[0002] As a real-time target detection algorithm, YOLOV8s has demonstrated excellent performance in many fields. However, in the task of cloth defect detection, due to its limited recognition ability for small targets and complex backgrounds, it still needs further optimization.

[0003] In the existing cloth defect detection, due to the various types and shapes of cloth defects, and the small size and inconspicuous characteristics of cloth defects, traditional target detection methods often fail to achieve ideal detection results. In order to improve the accuracy and efficiency of cloth defect detection, the present invention makes important improvements based on YOLOV8s. Summary of the invention

[0004] The technical problem to be solved by the present invention is to overcome the above technical defects and provide a cloth defect detection method improved based on YOLOV8s.

[0005] In order to solve the above problems, the technical solution of the present invention comprises the following steps:

[0006] S1. The DCNv2 module is introduced into the YOLOV8s model;

[0007] S2. The Polarized Self-Attention module is introduced into the YOLOV8s model. The PolarizedSelf-Attention module optimizes the calculation method of self-attention by introducing the concept of polarization filtering;

[0008] S3. Based on the original three detection heads of YOLOV8s, a detection head is introduced at the position of the 1 / 4 resolution feature map.

[0009] Furthermore, in step S2, the Polarized Self-Attention reduces the position pairs that need to be calculated by polarization filtering. The Polarized Self-Attention does not calculate the attention between all position pairs, but selectively calculates the attention between some position pairs, thereby reducing the computational complexity.

[0010] Furthermore, in step S2, Polarized Self-Attention reduces the dimension of the feature map by matrix multiplication, which can perform attention calculation while maintaining high-resolution features, thereby reducing information loss.

[0011] Furthermore, the DCNv2 processes targets with complex deformation and scale changes by introducing an offset, which enables the convolution kernel to adaptively adjust its shape and position to better adapt to the deformation of the target object.

[0012] Furthermore, the Polarized Self-Attention in step S2 combines channel attention and spatial attention at the same time. The Polarized Self-Attention not only focuses on the relationship between different channels, but also focuses on the relationship between different pixels in spatial positions.

[0013] Furthermore, adding a detection head to the shallow layer of the model in step S3 can effectively improve the detection accuracy of small targets.

[0014] The advantages of the present invention compared with the prior art are:

[0015] 1. The present invention provides a cloth defect detection method based on an improved YOLO V8s. DCNv2 (Deformable Convolutional Networks v2) is a deformable convolutional network that introduces an offset in the convolution process so that the convolution kernel can adaptively adjust its shape and position, thereby better adapting to the deformation and scale changes of the target object. In cloth defect detection, DCNv2 can effectively cope with the diversity of defect morphology and scale changes, and improve the accuracy and robustness of detection;

[0016] 2. The present invention provides an improved cloth defect detection method based on YOLOV8s. Polarized Self-Attention is a new type of attention mechanism, which reduces the attention between position pairs that need to be calculated by introducing polarization factors, thereby improving the efficiency of the self-attention model. In cloth defect detection, Polarized Self-Attention can help the model focus more on the defect area and reduce the attention to the background area, thereby improving the detection accuracy;

[0017] 3. The present invention provides a cloth defect detection method based on an improvement of YOLOV8s, and the small target detection head is a detection module specially designed for small targets in cloth defects. Since cloth defects are often small in size and easily overlooked or misdetected, the present invention enhances the detection capability of small-sized defects by introducing a small target detection head. The detection head improves the detection sensitivity and accuracy of small targets by optimizing parameters such as the size and aspect ratio of the anchor point box and adopting a more sophisticated feature fusion strategy. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1It is a diagram of the original YOLOV8s network structure provided by an embodiment of the present invention.

[0019] Figure 2 It is a structural diagram of the C2f, SPPF, Conv and Detect modules in the YOLOV8s algorithm provided in an embodiment of the present invention.

[0020] Figure 3 It is a calculation principle diagram of DCNv2 provided by an embodiment of the present invention.

[0021] Figure 4 It is a network structure diagram in which DCNv2 is added to the YOLOV8s model provided by an embodiment of the present invention.

[0022] Figure 5 It is a network structure diagram of Polarized Self-Attention provided for an embodiment of the present invention.

[0023] Figure 6 It is a network structure diagram in which Polarized Self-Attention is added to the YOLOV8s model provided by an embodiment of the present invention.

[0024] Figure 7 This is a network structure diagram of an embodiment of the present invention in which a small target detection head is added to the YOLOV8s model.

[0025] Figure 8 It is a network structure diagram provided by an embodiment of the present invention, in which DCNv2, Polarized Self-Attention and a small target detection head are added to the YOLOV8s model.

[0026] Fig. 9 This is a flowchart of cloth defect detection based on improved YOLOV8s provided by an embodiment of the present invention.

[0027] Fig.10 It is a schematic diagram of cloth defects provided by an embodiment of the present invention.

[0028] Fig.11 This is the result of detecting cloth defects using the original YOLOV8s algorithm provided by an embodiment of the present invention.

[0029] Fig.12 This is the result of detecting cloth defects using the improved YOLOV8s algorithm provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0030] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices consistent with some aspects of the present disclosure as detailed in the appended claims.

[0031] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments; based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0032] This embodiment proposes a cloth defect detection method based on YOLOV8s improvement, including the following steps:

[0033] S1. The DCNv2 module is introduced into the YOLOV8s model;

[0034] S2. The Polarized Self-Attention module is introduced in the YOLOV8s model. The Polarized Self-Attention module optimizes the calculation method of self-attention by introducing the concept of polarization filtering;

[0035] S3. Based on the original three detection heads of YOLOV8s, a detection head is introduced at the position of the 1 / 4 resolution feature map.

[0036] Furthermore, DCNv2 introduces an offset to handle targets with complex deformation and scale changes, so that the convolution kernel can adaptively adjust its shape and position to better adapt to the deformation of the target object.

[0037] Furthermore, in step S2, Polarized Self-Attention reduces the position pairs that need to be calculated through polarization filtering. Polarized Self-Attention does not calculate the attention between all position pairs, but selectively calculates the attention between some position pairs, thereby reducing the computational complexity.

[0038] Furthermore, in step S2, Polarized Self-Attention combines channel attention and spatial attention. Polarized Self-Attention not only focuses on the relationship between different channels, but also focuses on the relationship between different pixels in spatial positions.

[0039] Furthermore, in step S2, Polarized Self-Attention uses matrix multiplication to reduce the dimension of the feature map, which can perform attention calculation while maintaining high-resolution features, thereby reducing information loss.

[0040] Furthermore, adding a detection head in the shallow layer of the model in step S3 can effectively improve the detection accuracy of small targets.

[0041] In specific use, the network structure diagram of the YOLOV8s algorithm is as follows Figure 1 As shown in the figure, the input image passes through BackBone to obtain feature maps of different scales. After passing through Neck, the feature maps are integrated with feature information of other scales. Finally, the feature maps of different scales are sent to the detection head to obtain the prediction results of the model. The YOLOV8s network consists of Conv, C2f, SPPF and Detect modules. Backbone contains 5 Conv modules, 4 C2f modules and 1 SPPF module. Neck contains 2 Upsample modules, 4 C2f modules, 4 Concat modules and 2 Conv modules. Head contains 3 Detect modules. The structures of C2f, SPPF, Conv and Detect modules are shown in the figure. Figure 2 As shown in the figure. The Conv module consists of a convolutional layer, a BatchNorm2d layer and a SiLU layer; the Bottleneck is composed of two Conv modules with a residual connection structure; the C2f module divides the input feature map into multiple non-overlapping feature maps, and then combines different features after passing through different Bottlenecks to extract network features of different depths; the Detect module extracts features from multiple Conv modules and obtains the prediction results of the model through the convolution layer.

[0042] The calculation principle of the DCNv2 module introduced in the present invention is as follows: Figure 3 As shown in the figure. The input features are predicted by the convolution layer to obtain the feature map offset. When the convolution operation is performed on the feature map, the position of the convolution kernel parameters is first adjusted according to the calculated feature offset. The shape of the convolution kernel is adaptively adjusted according to the offset, which improves the adaptability of the convolution kernel to the input.

[0043] The overall network structure diagram of DCNv2 introduced in YOLOV8s is as follows Figure 4 As shown in the figure, the DCNv2 module is introduced into the BackBone of the YOLOV8s model, so that BackBone can better extract target features and thus improve detection accuracy.

[0044] The Polarized Self-Attention module structure introduced in this invention is as follows Figure 5As shown in the figure. Polarized Self-Attention includes two attention mechanisms: Channel Attention and Spatial Attention. Channel Attention performs weighted processing on the feature maps of different channels in the neural network to enhance the model's attention to key features; Spatial Attention performs weighted processing on the feature vectors at different positions in the neural network and focuses on these areas to help the model accurately locate and identify key targets in the image. The overall network structure diagram of the Polarized Self-Attention module introduced in YOLOV8s is shown in the figure. Figure 6 As shown in the figure. The input of Channel Attention passes through two 1x1 convolutional layers to obtain two feature maps of size C / 2xHxW and 1xHxW. After dimension conversion, the feature maps become C / 2xHxW and HWx1x1. The feature map of HWx1x1 is subjected to softmax to obtain the weight of HWx1x1. The feature map of C / 2xHxW and the weight feature map of HWx1x1 are subjected to matrix multiplication to obtain a feature map of size C / 2x1x1. The feature map of C / 2x1x1 passes through the convolution layer Conv, the normalization layer LayerNorm and the Sigmoid layer to become the weight feature map of Cx1x1. The output of Channel Attention can be obtained by multiplying the weight feature map of Cx1x1 with the input of Channel Attention. The input of Spatial Attention passes through two 1x1 convolutional layers to obtain two feature maps of size C / 2xHxW and C / 2xHxW. The first C / 2xHxW feature map becomes a C / 2x1x1 feature map after passing through the global pooling layer. The second C / 2xHxW feature map and the C / 2x1x1 feature map become 1xC / 2 and C / 2xHxW after dimension conversion. The 1xC / 2 feature map obtains a 1xC / 2 weight after softmax. The C / 2xHxW feature map and the 1xC / 2 weight feature map obtain a 1xHW feature map after matrix multiplication. The 1xHW feature map is converted into a 1xHxW weight feature map after dimension transformation Reshape and Sigmoid layer. The 1xHW weight feature map is multiplied with the input of Spatial Attention to obtain the output of Spatial Attention. The output of ChannelAttention and Spatial Attention is added to obtain the output of PSA.

[0045] The small target detection head structure introduced by the present invention is as follows Figure 7As shown in the figure, the original YOLOV8s model reduces the feature map resolution to 1 / 8, 1 / 16, and 1 / 32 for prediction. The information loss during the downsampling process causes the model to have poor detection effect on small targets. The introduction of an additional small target detection head at the 1 / 4 resolution position can effectively reduce the problem of poor small target detection effect caused by the loss of downsampling information.

[0046] The cloth defect detection algorithm based on YOLOV8s improved by the present invention is as follows Figure 8 In the BackBone part, the DCNv2 module is used to replace the original C2f module to enhance the feature extraction capability of BackBone. The PSA module is introduced in the Neck part so that the model can focus on the key target area. The small target detection head is introduced in the Head part to improve the detection effect of small targets.

[0047] The flowchart of the cloth defect detection algorithm based on improved YOLOV8s proposed in the present invention is as follows Fig. 9 As shown in the figure, it mainly includes three parts: data collection, data processing, model training and model deployment. The specific steps are as follows:

[0048] Step 1: Collect a cloth defect data set, and use the cloth defect detection data set of the Tianchi platform 2019 Guangdong Industrial Intelligent Manufacturing Innovation Competition as the training and verification data of the present invention.

[0049] Step 2: There are 20 categories of cloth inspection data. Convert the data set into a YOLO format data set and divide the data set into a training set and a validation set. The training set has 3819 data and the validation set has 955 data.

[0050] Step 3: Perform model training and model verification on the divided data set. During the training process, the initial learning rate is 0.01, the batch training size of the model is 16, the training rounds are 100 times, and the resolution of the image during training is 1024x1024.

[0051] Step 3.1: Build the experimental environment required for model training and verification. The configured experimental environment is shown in Table 2.

[0052]

[0053] Table 2 Experimental configuration information

[0054] Step 3.2: Train the improved models on the constructed data sets respectively, and verify the effects of each model on the validation set. The experimental results are shown in Table 3. It can be seen that the modules introduced by the present invention have significantly improved the detection effect of the YOLOV8s model in the field of cloth defect detection. After adding the DCNv2 module to the YOLOV8s model, the mAP50 index increased by 2.3%, after adding the PSA module to the YOLOV8s model, the mAP50 index increased by 1.1%, after adding the small target detection head to the YOLOV8s model, the mAP50 index increased by 0.7%, after adding the DCNv2 and PSA modules to the YOLOV8s model, the mAP50 index increased by 3%, after adding the DCNv2 and small target detection head to the YOLOV8s model, the mAP50 index increased by 2.8%, and after adding the PSA and small target detection head to the YOLOV8s model, the mAP50 index increased by 1.7%. Compared with the original YOLOV8s model, the mAP50 of the improved YOLOV8s model is improved by 4.2%. It can be seen that the improved YOLOV8s model has better cloth defect detection performance.

[0055]

[0056] Table 3 Comparison of improved model performance

[0057] Step 3.3: Fig.10 For example, a piece of cloth has defects. Fig.11 is the detection result of the original YOLOV8s algorithm. Fig.12 This is the detection result of the method proposed in the present invention. It can be seen that the original YOLOV8s algorithm incorrectly classifies knots as holes, while the method proposed in the present invention can correctly identify this category. From the experimental results, it can be seen that the algorithm proposed in the present invention can effectively improve the detection accuracy of cloth defects and meet the needs of industrial production.

[0058] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.

[0059] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.

[0060] The present invention and its embodiments are described above, and such description is not restrictive. The drawings show only one embodiment of the present invention, and the actual structure is not limited thereto. In short, if ordinary technicians in the field are inspired by it, without departing from the purpose of the invention, they can design a structure and embodiment similar to the technical solution without creativity, which should belong to the protection scope of the present invention.

Claims

1. A cloth defect detection method based on YOLOV8s improvement, characterized in that: The following steps are involved: S1. The DCNv2 module is introduced into the YOLOV8s model; S2. A Polarized Self-Attention module is introduced into the YOLOV8s model. The Polarized Self-Attention module optimizes the calculation method of self-attention by introducing the concept of polarization filtering. S3. Based on the original three detection heads of YOLOV8s, a detection head is introduced at the position of the 1 / 4 resolution feature map.

2. The cloth defect detection method based on YOLOV8s improvement according to claim 1, characterized in that: The DCNv2 processes targets with complex deformation and scale changes by introducing an offset, which enables the convolution kernel to adaptively adjust its shape and position to better adapt to the deformation of the target object.

3. The cloth defect detection method based on YOLOV8s improvement according to claim 1, characterized in that: In step S2, the Polarized Self-Attention reduces the position pairs that need to be calculated by polarization filtering. The Polarized Self-Attention does not calculate the attention between all position pairs, but selectively calculates the attention between some position pairs, thereby reducing the computational complexity.

4. The cloth defect detection method based on YOLOV8s improvement according to claim 1, characterized in that: The Polarized Self-Attention in step S2 combines channel attention and spatial attention at the same time. The Polarized Self-Attention not only focuses on the relationship between different channels, but also focuses on the relationship between different pixels in spatial positions.

5. The cloth defect detection method based on YOLOV8s improvement according to claim 1 is characterized in that: In step S2, Polarized Self-Attention reduces the dimension of the feature map by matrix multiplication, which can perform attention calculation while maintaining high-resolution features, thereby reducing information loss.

6. The cloth defect detection method based on YOLOV8s improvement according to claim 1, characterized in that: In step S3, adding a detection head to the shallow layer of the model can effectively improve the detection accuracy of small targets.