Cotton cloth defect detection method based on improved YOLOv8s

By improving the YOLOv8s network model and introducing SPDConv, BRA-SPPF, small target detection layer and NWD-EIoU loss function, the problem of tiny weak and poor multi-scale defect detection in cotton defect detection is solved, achieving higher detection accuracy and efficiency to meet industrial production needs.

CN118587186AActive Publication Date: 2024-09-03JIANGNAN UNIV
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202410735450.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-07
Publication Date
2024-09-03
Estimated Expiration
2044-06-07

AI Technical Summary

Technical Problem

Existing cotton defect detection technology is prone to missed detections and false detections when detecting tiny, weak, multi-scale defects, and its detection efficiency and accuracy are insufficient, making it difficult to meet the needs of industrial production.

Method used

Improve the YOLOv8s network model by introducing the SPDConv module, BRA-SPPF module, small target detection layer and NWD-EIoU loss function to enhance the model's detection ability of small targets and multi-scale features, and improve detection accuracy and efficiency.

Benefits of technology

It effectively improves the detection accuracy of small and weak targets and the detection effect of multi-scale targets, reduces the missed detection and false detection rates, improves the overall performance of the cotton defect detection model, and meets the requirements of industrial real-time detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118587186A
    Figure CN118587186A
Patent Text Reader

Abstract

The invention discloses a cotton cloth defect detection method based on improved YOLOv8s, and belongs to the technical field of cotton cloth defect detection. The method comprises the following steps: dividing cotton cloth defects into broken warps, broken holes, stains, cotton grains and joints, and constructing a cotton cloth defect data set; the method comprises the following steps: improving an original YOLOv8 network model based on an SPDConv module, a BRA module, a small target detection head, an NWD loss function and an EIoU loss function, and constructing a cotton cloth defect detection model; training the data set by adopting the improved YOLOv8s to obtain a trained cotton cloth defect detection model; and inputting a to-be-detected image into the trained cotton cloth defect detection model, and carrying out defect detection on the target cotton cloth to obtain a final detection result. The method is particularly aimed at tiny, weak and multi-scale defects, the small target feature extraction capability of the model is enhanced, the cotton cloth defect detection precision is improved, and the method is of great significance to the cotton cloth production industry.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a cotton cloth defect detection method based on improved YOLOv8s, and belongs to the technical field of cotton cloth defect detection. Background Art

[0002] my country's cotton textile industry has maintained the top position in the world's cotton cloth exports for 18 consecutive years, occupying a prominent position in the global market, and is also an important part of my country's industrial economy. The quality of cotton cloth is a very important part of the cotton cloth textile industry chain, among which the defects on the surface of cotton cloth directly determine the quality of the cloth. Therefore, defect detection is a key step in cotton cloth production. At present, most companies use manual visual inspection, which has many disadvantages: 1. High experience requirements for inspectors; 2. Low detection efficiency, small defects are easily overlooked, and long-term work is prone to missed detection and false detection; 3. After working for a long time, the staff is prone to visual fatigue; 4. The labor resources that consume energy are becoming increasingly scarce. From this point of view, manual inspection is difficult to meet actual production requirements.

[0003] With the rapid development of artificial intelligence technology, many studies have applied target detection networks to cotton cloth defect detection. Target detection can achieve classification and positioning, and is mainly divided into two types of detection models: one is two-stage detection, which has the advantage of high detection accuracy; the other is single-stage detection, which has the advantage of faster detection speed. Although the current cotton cloth defect detection method based on deep learning has improved in speed, accuracy and adaptability, it is easy to miss detection and misdetection when targeting tiny, weak, and multi-scale defects, and does not achieve a good detection effect. Summary of the invention

[0004] In order to solve the problem that the existing cotton cloth defect detection technology has poor detection effect on tiny and weak defects with large target scale differences, the present invention provides a cotton cloth defect detection method based on improved YOLOv8s, and the technical solution is as follows:

[0005] The first object of the present invention is to provide a cotton cloth defect detection method, comprising:

[0006] Step 1: Obtain the cotton cloth image to be detected;

[0007] Step 2: Use the improved YOLOv8s network to perform defect detection on the cotton cloth image to be detected to obtain the final detection result;

[0008] The construction of the improved YOLOv8s network includes: replacing the last standard convolution in the backbone network of the YOLOv8s network model and all standard convolutions of the neck network with the SPDConv module.

[0009] Optionally, the construction of the improved YOLOv8s network also includes: introducing the SPPF module in the backbone network of the YOLOv8s network model into the double-layer routing attention mechanism BRA, and placing the BRA module after the first convolution in the SPPF module.

[0010] Optionally, the construction of the improved YOLOv8s network also includes: adding a small target dedicated detection head on the basis of the original three detection heads of the YOLOv8s network model, and the output feature map size is 160×120.

[0011] Optionally, the construction of the improved YOLOv8s network further includes: changing the original positioning regression loss function CIoU of the YOLOv8s network model to an NWD-EIoU loss function, wherein the NWD-EIoU loss function is a combination of the NWD loss function and the EIoU, and the combination method is shown in the following formula;

[0012] Loss = α·EIoU+(1-α)·NWD

[0013] Where α is the weight ratio of EIoU.

[0014] Optionally, the weight ratio α is 0.8.

[0015] Optionally, the cotton cloth defects include: broken warps, holes, stains, cotton particles and joints.

[0016] Optionally, the training process of the improved YOLOv8s network includes: using the Labelimg data labeling tool to classify and label the collected cotton cloth images, and after the labeling is completed, converting the label files from xml format to txt format, and dividing the data set into a training set and a validation set according to the ratio.

[0017] A second object of the present invention is to provide a cotton cloth defect detection system, comprising:

[0018] An image acquisition device, used for acquiring an image of cotton cloth to be detected;

[0019] A defect detection module, configured to perform defect detection on the cotton cloth image using the improved YOLOv8s network as described in any one of the above items;

[0020] The output display module is configured to output and display the defect detection result.

[0021] Optionally, the image acquisition device includes: a CCD camera and a lens.

[0022] The third object of the present invention is to provide a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the cotton cloth defect detection method as described in any one of the above items is implemented.

[0023] The beneficial effects of the present invention are:

[0024] The cotton cloth defect detection method of the present invention introduces the SPDConv module into the backbone network and the neck network, and weighs and analyzes the position and number of the SPDConv module settings. Experimental results show that the introduction of the SPDConv module in the present invention can effectively improve the feature extraction capability of low resolution and small targets, thereby improving the detection accuracy of tiny and weak targets and enhancing the overall detection performance of the cotton cloth defect detection model.

[0025] In one embodiment of the present invention, a BRA-SPPF module is further introduced into the backbone network of YOLOv8s. By integrating the BRA module into the SPPF module, better content perception capability is achieved, while also saving complex calculations. Therefore, the BRA-SPPF module effectively improves the detection effect of targets of different scales while avoiding high computational complexity.

[0026] In one embodiment of the present invention, further adding a small target detection layer can enhance the model's perception of small targets, thereby reducing the occurrence of missed detection and false detection of small targets.

[0027] In one embodiment of the present invention, the NWD loss function is further combined with EIoU to construct the NWD-EIoU loss function, which reduces the sensitivity to various scale features and effectively balances the differences between targets, thereby improving the detection accuracy of targets of different scales.

[0028] The present invention is based on the improvement of the YOLOv8s network model and constructs a model suitable for cotton cloth defect detection. It can improve the detection accuracy of tiny and weak defects with large scale differences and enhance the overall performance of the cotton cloth defect detection model. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0030] Figure 1 The present invention is a flow chart of a cotton cloth defect detection method based on improved YOLOv8s.

[0031] Figure 2 This is a structural diagram of a cotton cloth defect detection model based on improved YOLOv8s in the present invention.

[0032] Figure 3 It is a structural diagram of the SPDConv module in the present invention.

[0033] Figure 4 It is a schematic diagram of the structure of the BRA-SPPF module in the present invention.

[0034] Figure 5 Figure 2 is a schematic diagram of the structure of the BRA module.

[0035] Figure 6 This is a diagram of defect types in the present invention.

[0036] Figure 7 The detection results of cotton cloth defects are shown in the figure below:

[0037] Figure 8 The following are the detection results of cotton cloth defects by each network model. DETAILED DESCRIPTION

[0038] In order to make the objectives, technical solutions and advantages of the present invention more clear, the embodiments of the present invention will be further described in detail below with reference to the accompanying drawings.

[0039] Embodiment 1:

[0040] This embodiment provides a cotton cloth defect detection method, comprising:

[0041] Step 1: Obtain the cotton cloth image to be detected;

[0042] Step 2: Use the improved YOLOv8s network to perform defect detection on the cotton cloth image to obtain the final detection result;

[0043] The construction of the improved YOLOv8s network includes replacing the last standard convolution in the backbone network of the YOLOv8s network model and all standard convolutions in the neck network with SPDConv modules.

[0044] Embodiment 2:

[0045] This embodiment provides a cotton cloth defect detection method based on improved YOLOv8s, see Figure 1 , the method comprising:

[0046] Step 1: Classify cotton cloth defects into broken warp, hole, stain, cotton particle and joint, collect cotton cloth defect images according to the defect classification, and complete annotation, format conversion and data set division;

[0047] Step 2: Improve the original YOLOv8 network model based on SPDConv, BRA module, small target detection head, NWD loss function and EIoU loss function to build a cotton cloth defect detection model;

[0048] Step 3: Use the improved YOLOv8s to train the data set to obtain a trained cotton cloth defect detection model;

[0049] Step 4: Input the image to be detected into the trained cotton cloth defect detection model, perform defect detection on the target cotton cloth, and obtain the final detection result.

[0050] Among them, the original YOLOv8 network model is improved to build a cotton cloth defect detection model. The improved network structure is as follows Figure 2 As shown in the figure, the improvements include: (1) replacing the last convolution of the backbone network and all convolutions of the neck network of the YOLOv8 network model with the SPDConv module; (2) introducing the BRA module into the SPPF module of the YOLOv8 network model, and adding BRA after the standard convolution of SPPF; (3) adding a detection layer to the YOLOv8 network model, which is a 160×120 small target layer for detecting cotton defects of 4×3 and above; (4) replacing the loss function of the YOLOv8 network model with the NWD-EIoU loss function, which is a combination of the NWD loss function and the EIoU.

[0051] Before the improvement, YOLOv8 was divided into five different-sized models of n, s, m, l and x according to specific needs. The network structure mainly consists of three parts, namely the backbone network, the neck network and the detection head. The basic building block of the backbone network is the C2f module, which can extract better feature information with less parameters. The neck network realizes multi-scale feature fusion through the PAN-FPN structure. The detection head uses a decoupled head structure to separate the target detection and classification tasks. The YOLOv8s network model adjusts the input image size to 640×480×3. After the detection is completed, the output image sizes are 80×60×128, 40×30×256, and 20×15×512. When the cotton cloth image is compressed to 20×15×512, the feature information of small target defects is easily lost, and most of the small target information after deep convolution is submerged, resulting in poor small target detection effect. In addition, YOLOv8s's positioning regression loss function uses CIoU, which is more sensitive to the position deviation of small targets. The scales of cotton defects vary greatly, so the CIoU loss function is not suitable for multi-scale target detection such as cotton defects.

[0052] Therefore, in order to improve the accuracy of small, weak, and multi-scale defect detection, this embodiment makes the above-mentioned improvements to the YOLOv8s network model. The improved network model is as follows: Figure 2 shown.

[0053] First, in order to solve the problem of poor detection of tiny and weak targets, the SPDConv module is introduced.

[0054] The CBS layer of the original YOLOv8s network is a strided convolution, which is easy to lose detail features during feature learning, and has poor detection effects on low-resolution and small objects. Some stains appear as weak defects with little difference from the texture background, and after image compression, they belong to low-resolution images. The joints, cotton particles, and holes of cotton cloth are mostly small defects. The original YOLOv8s network has poor detection effects on such defects. Therefore, the SPDConv module is introduced in the backbone network and the neck network, and the last convolution of the backbone network and all convolutions of the neck network are replaced with SPDConv. Compared with ordinary convolution, the SPDConv module can retain more feature information and can effectively improve the feature extraction ability of small targets.

[0055] Specifically, Figure 3 As shown in Figure 1, the SPDConv module consists of a space-to-depth layer (SPDlayer) and a convolutional layer (NS-Conv) with a stride of 1, which is more sensitive to small objects and low-resolution images. First, the input S×S×C1 original feature map is split according to the point sampling method to obtain scale×scale size The feature map is a downsampling of the original input feature map. Then, all sub-feature maps are concatenated along the dimension channel to obtain a size of Finally, 1×1 convolution is used to reduce the dimension and retain the discriminant information of the feature map as much as possible, resulting in a feature map of size In the embodiment of the present invention, scale is set to 2. From the above steps, it can be seen that the SPDConv module retains the small target features as much as possible, which can effectively improve the detection effect of low-resolution targets and small targets.

[0056] Secondly, in order to solve the problem that the original YOLOv8s network has poor effect on multi-scale target detection, the BRA module is introduced to construct a new module BRA-SPPF.

[0057] The YOLOv8s backbone network increases the receptive field and enriches feature information through the SPPF module. SPPF is a spatial pyramid pooling structure based on the improved SPP structure. It extracts features of different scales through traditional convolution and three maximum pooling layers. Although the SPPF module can achieve the fusion of global and local information, since it only realizes feature extraction through a simple maximum pooling operation, some feature information may be lost, resulting in false detection, missed detection, etc. In order to further extract feature information and alleviate the missed detection phenomenon caused by the large difference in the scale of cotton cloth defects, a bi-level routing attention module (BRA) is introduced in the SPPF module. The BRA module is added after the standard convolution to obtain a new module BRA-SPPF, such as Figure 4 The BRA-SPPF module enables the network to filter out irrelevant background information interference, while paying more attention to the effective cotton cloth defect feature information, saving the amount of parameters and calculations, thereby achieving better multi-scale feature extraction and improving the richness of the feature map.

[0058] Specifically, Figure 5 As shown in the figure, the BRA module is a dynamic, query-aware sparse attention mechanism. The core idea is to filter out most of the irrelevant key-value pairs at the coarse region level so that only a small number of routing regions are retained, and then apply fine-grained Token-token interactions in the union of these routing regions. The specific steps are as follows:

[0059] (1) First, the H×L input feature map is divided into S×S non-overlapping regions and linearly mapped to obtain the query tensor Q, key tensor K, and value tensor V:

[0060] Q=X r W q , K = X r W k , V = X r W v

[0061] (2) Then, the attention weight is calculated on the coarse-grained Token, and only the Topk regions are taken as relevant regions to participate in the fine-grained calculation:

[0062] A r =Q r (K r ) T , I r =topkIndex(A r )

[0063] (3) Finally, collect I through the gather algorithm rThe Topk coarse-grained regions in the network are used as keys and values ​​in the final operation. To enhance locality, a deep convolution is applied to the values:

[0064] K g =gather(K,I r ), V g =gather(V,I r )

[0065] O=Attention(Q,K g ,V g )+LCE(V)

[0066] The BRA module is responsible for capturing global context information and local information through the interaction between coarse-grained and fine-grained regions, improving the information extraction of different scales of feature maps. The BRA module directly filters out most of the irrelevant regions through sparsity operations, avoiding the problem of excessive calculation and parameters, and achieving higher performance at a lower computational cost.

[0067] Next, in order to further improve the detection capability of small targets, a small target detection layer is added in the neck feature fusion network stage.

[0068] In the neck network of the YOLOv8s network, a three-layer feature map design is adopted. For an input of 640×480×3, after feature fusion, three different feature maps are output, namely 80×60, 40×30, and 20×15, which are used to detect targets of 8×6, 16×12, and 32×24, respectively. The large-scale feature map has a smaller receptive field, contains more target locations and local feature details, and is suitable for detecting small targets. On the contrary, the smaller-scale feature map has a larger receptive field and rich semantic information, but the local details are not obvious, which is suitable for detecting medium and large targets. However, cotton defects vary in size, and tiny and weak defects similar to texture backgrounds often appear. The largest feature map of the original YOLOv8s network is 80×60, which cannot fully meet the requirements of cotton defect detection and is prone to problems such as missed detection and false detection of tiny defects. Therefore, it is necessary to add a small target detection layer in the neck feature fusion stage, and splice the 160×120 feature map output by the backbone network with the upsampling of the neck network to detect cotton defects of 4×3 and above. The construction of the 160×120 small target layer enables YOLOv8s to capture the detailed features of cotton cloth defects through a smaller perception, and uses four detection layers of different scales for feature fusion, effectively utilizing the semantic information and fine-grained details at each level, thereby reducing the risk of missing or misidentifying small target defects, and making the identification and positioning of tiny and weak defects more accurate.

[0069] Finally, in order to solve the problem that the original loss function of YOLOv8s has poor detection effect on multi-scale targets, the NWD-EIoU loss function is constructed.

[0070] The loss function of the YOLOv8s network consists of the bounding box regression loss CIoU+DFL and the classification loss VFL. Among them, CIoU calculates the loss of the predicted box and the real box of the label, taking into account the center distance, aspect ratio, and overlapping area. However, the aspect ratio cannot reflect the actual difference in side length, while EIoU can reflect the actual difference in side length. The calculation formula is as follows:

[0071]

[0072] Where IoU (Intersection over Union) represents the intersection ratio between the predicted box and the real box; b, w and h represent the center point coordinates, width and height of the predicted box respectively; ρ(·) represents the Euclidean distance between the predicted box and the real box; w c and h c Respectively represent the width and height of the smallest bounding box composed of the real box and the predicted box; b gt 、w gt and h gt Represent the center point coordinates, width and height of the real box respectively.

[0073] EIoU has a large difference in sensitivity to objects of different scales. The position offset of small objects is more sensitive, which will cause a significant decrease in IoU. However, for medium and large objects, the same position offset will cause a small change in IoU. In order to solve this problem, the NWD bounding box regression loss that is insensitive to the position offset of small objects is introduced. This loss function first models the bounding box as a two-dimensional Gaussian distribution, and then measures the boundary similarity through the normalized Wasserstein distance. The calculation formula is as follows:

[0074]

[0075] This method can measure the similarity whether the two boxes overlap or not, and is insensitive to objects of different scales. Therefore, NWD is very suitable for measuring the similarity between the predicted box and the labeled box of small objects.

[0076] The scales of cotton cloth defects vary. If NWD directly replaces EIoU, the detection effect of large targets will be impaired. Therefore, EIoU suitable for medium and large target detection and NWD suitable for small target detection are combined. The combination method is as follows:

[0077] Loss = α·EIoU+(1-α)·NWD

[0078]

[0079] In the formula, W2 2 (N a ,N b ) is the distance metric, and its value range is [0, +∞], A=(cx a ,cy a ,w a ,h a ) and B=(cx b ,cy b ,w b ,h b ) are Gaussian distribution N a and N b , D is the number of defect categories in the dataset, Loss is the regression loss function, and α is the weight ratio of EIoU.

[0080] The above is a detailed description of step 2. Next, steps 1, 3, and 4 will be described in detail.

[0081] like Figure 6 As shown, the defect objects of the embodiment of the present invention are broken warp, holes, stains, cotton particles and joints. These defects are the five most frequent defects selected based on actual factory surveys. The fabrics selected are all solid-color fabrics, and cotton fabrics with different textures and counts are selected. The textures include thin threads, thick threads, plain weaves, and twills. Among them, broken warp is a slender defect, cotton particles, joints and holes are mostly small defects that are difficult to detect with the naked eye, and a few stain defects are weak defects with little difference from the texture background.

[0082] In order to verify the effectiveness of the method of the present invention, this embodiment uses CCD cameras, lenses and other acquisition hardware devices to construct a cotton cloth defect dataset with a resolution of 1294×964 and a total of 2136 images. After acquisition, Label Img is used to annotate the defects and generate corresponding xml file information.

[0083] The training platform of this embodiment experiment is Ubuntu 20.04.4LTS, using NVIDIA GeForce RTX3090 GPU acceleration, based on PyTorch1.8.1, using CUDA11.1 for computational acceleration. The batch size of the experimental training is set to 16, the epoch is set to 300, the initial learning rate is 0.01, and the input image size is 640×480×3.

[0084] In order to verify the effectiveness of the improved model, this embodiment selects five common evaluation indicators for target detection, which are:

[0085] (1) Average Precision (AP), the average recognition accuracy of each category;

[0086] (2) Mean Average Precision (mAP), the mean of the average recognition accuracy of all categories;

[0087] (3) FPS (Frames per second), the number of frames transmitted by the model per second, that is, the number of images that can be detected per second;

[0088] (4) Precision P (Precision), calculated as follows:

[0089]

[0090] (5) Recall rate R (Recall), calculated as follows:

[0091]

[0092] Where TP is the number of positive samples that are correctly detected, FP is the number of negative samples that are mistakenly detected as positive samples, and FN is the number of positive samples that are mistakenly detected as negative samples.

[0093] In order to verify the effectiveness of the NWD-EIoU loss function introduced in this embodiment and explore the impact on the cotton cloth defect detection performance, the impact on the detection performance is analyzed by changing the α value, and the optimal combination of NWD and EIoU is obtained. The experimental results corresponding to different α values ​​are shown in Table 1.

[0094] Table 1: Detection results of different α values

[0095]

[0096] As can be seen from Table 1, the value of weight α has a great influence on the final detection result. As the weight α increases, the mAP value also gradually increases, and when the weight α is 0.8, the data set with large scale differences in this embodiment reaches a balanced state, and the detection effect is optimal. When α is 1, it indicates that the loss function is only EIoU, and the detection performance is not optimal at this time. It can be obtained that the addition of the loss function NWD makes it possible to better measure the similarity between the predicted box and the marked box of small objects, which is helpful for the detection of multi-scale targets. Therefore, in this embodiment, the weight α is 0.8.

[0097] In order to verify that the current position and number of SPDConv modules are the best choice, the impact on detection performance is analyzed by replacing different convolutions, and the experimental results are shown in Table 2. It can be seen from Experiment 2 that when all convolutions of the neck network are replaced with SPDConv, the detection performance of each defect is greatly improved, and the mAP value is increased by 12.5%; Experiment 3 found that when only the convolution of the 7th layer of the backbone network is replaced, the detection performance of each defect is slightly improved, among which the broken warp has only a 0.3% improvement effect; when all convolutions of the backbone network are replaced with SPDConv, the detection effect of broken warp is greatly reduced, and the AP is only 35.8%; from the results of Experiments 5, 6 and 7, it is found that the deeper the number of replaced convolution layers, the higher the AP values ​​and mAP values, and when Experiment 7 replaces the last convolution layer of the backbone network and all convolutions of the neck network at the same time, all defect detection results are greatly improved, and the experimental results are the best. The above experimental results show that paying too much attention to faint small targets in shallow networks will damage the detection performance. The main reason is that the shallow network is easily disturbed by the background information of the cotton cloth texture, and the SPDConv module will ignore medium and large targets. Among them, the detection effect of broken warp defects, which are slender large targets, fluctuates the most.

[0098] Table 2: Detection results of different positions and numbers of SPDConv modules

[0099]

[0100] In order to more intuitively observe the impact of the position and number of SPDConv on the experimental results, some detection results of Experiments 4, 5, 6 and 7 are compared, as shown in Figure 7 As shown in the figure, it can be seen that in experiment 4, replacing all convolutions of the backbone with SPDConv will not only result in missed detection and false detection of weak small targets such as stains, cotton particles and joints, but also missed detection and incomplete detection of broken warps. From experiments 5, 6 and 7, it can be seen that the detection and positioning accuracy of each defect type is improved as the number of network layers of the replaced convolution increases.

[0101] In order to verify the effectiveness of the improved YOLOv8s network model of this embodiment, the effects of SPDConv, BRA module, small target detection head, and NWD-EIoU loss function on the accuracy and rate of the network model are analyzed. This embodiment performs ablation experiments under the same parameters, and the experimental results are shown in Table 3. Experiments 2, 4, and 6 verify that the SPDConv module and the small target detection layer are good at improving tiny and weak targets. Experiments 3 and 7 show that the BRA module can effectively solve the problem of large defect scale differences. While improving the small target detection capability, it also improves the ability to capture the features of broken and slender targets. After using NWD-EIoU, mAP@0.5 and FPS increased by 11.6% and 24.4, respectively, indicating that it has a good effect on balancing sample scale differences and detection speed. Due to the addition of the small target detection head, the model detection speed has decreased, but in general, the detection accuracy has increased by 16.5%, and the ability to capture tiny and weak objects has improved, effectively solving the detection problem of large target scale differences.

[0102] Table 3 Ablation experiment results

[0103]

[0104] In order to further verify the superiority and effectiveness of the improved YOLOv8s network model of this embodiment, under the same parameters, Faster-RCNN, RT-DETR-L, YOLOv3, YOLOv5s, YOLOv6s, YOLOv7, YOLOv8s and the algorithm of this embodiment are experimented on a homemade cotton cloth defect dataset, and the four indicators of precision (P), recall (R), mAP@0.5 and FPS are used for comparison. The comparison results are shown in Table 4.

[0105] Table 4: Comparison results of different algorithms

[0106]

[0107] Compared with Faster-RCNN, RT-DETR-L, YOLOv3 and YOLOv7, the improved YOLOv8s has significantly improved all indicators; compared with YOLOv5s, YOLOv6s and YOLOv8s, although the FPS has decreased, the other indicators have been greatly improved; among them, compared with the original network YOLOv8s, mAP@0.5 has increased by 16.5%, the precision has increased by 11.9%, and the recall has increased by 8.8%. Although the FPS of the algorithm in this embodiment has decreased slightly, it still meets the real-time detection requirements. The results show that the improved YOLOv8s has better detection performance than other models, and has significant advantages in the detection of targets with large scale differences and small and weak targets. While meeting the real-time detection requirements of the factory, the detection performance of the model has been greatly improved, which is conducive to the detection of cotton cloth defects.

[0108] In order to intuitively describe the detection effect of the improved YOLOv8s network model, some detection result graphs before and after the improvement are intuitively compared, such as Figure 8 As shown. By comparing the figures, we can see that the hole in (b1) is similar to the stain, (b2) misdetects the hole as a stain, and (b3) detects the hole correctly; (d2) misses the weak cotton particle defect, and (d3) detects it accurately; (a3), (c3) and (e3) have greatly improved the detection accuracy compared with the original YOLOv8s. The results show that the improved network of the present invention enhances the feature extraction capability of different scales and improves the discrimination capability of various categories.

[0109] Some steps in the embodiments of the present invention may be implemented using software, and the corresponding software program may be stored in a readable storage medium, such as a CD or a hard disk.

[0110] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A cotton cloth defect detection method, characterized in that: The method comprises: Step 1: Obtain the cotton cloth image to be detected; Step 2: Use the improved YOLOv8s network to perform defect detection on the cotton cloth image to be detected to obtain the final detection result; The construction of the improved YOLOv8s network includes: replacing the last standard convolution in the backbone network of the YOLOv8s network model and all standard convolutions of the neck network with the SPDConv module.

2. The cotton cloth defect detection method according to claim 1, characterized in that: The construction of the improved YOLOv8s network also includes: introducing the double-layer routing attention mechanism BRA into the SPPF module in the backbone network of the YOLOv8s network model, and placing the BRA module after the first convolution in the SPPF module.

3. The cotton cloth defect detection method according to claim 1, characterized in that: The construction of the improved YOLOv8s network also includes: adding a small target dedicated detection head on the basis of the original three detection heads of the YOLOv8s network model, and the output feature map size is 160×120.

4. The cotton cloth defect detection method according to claim 1, characterized in that: The construction of the improved YOLOv8s network also includes: changing the original positioning regression loss function CIoU of the YOLOv8s network model to the NWD-EIoU loss function, wherein the NWD-EIoU loss function combines the NWD loss function and the EIoU, and the combination method is shown in the following formula; Loss = α·EIoU+(1-α)·NWD Where α is the weight ratio of EIoU.

5. The cotton cloth defect detection method according to claim 4, characterized in that: The weight ratio α is set to 0.

8.

6. The cotton cloth defect detection method according to claim 1, characterized in that: The cotton cloth defects include: broken warps, holes, stains, cotton particles and joints.

7. The cotton cloth defect detection method according to claim 1, characterized in that: The training process of the improved YOLOv8s network includes: using the Labelimg data labeling tool to classify and label the collected cotton cloth images, converting the label files from xml format to txt format after labeling, and dividing the data set into a training set and a validation set according to the ratio.

8. A cotton cloth defect detection system, characterized in that: The system comprises: An image acquisition device, used for acquiring an image of cotton cloth to be detected; A defect detection module, configured to perform defect detection on the cotton cloth image using the improved YOLOv8s network as described in any one of claims 1 to 7; The output display module is configured to output and display the defect detection result.

9. The cotton cloth defect detection system according to claim 8, characterized in that: The image acquisition device comprises: a CCD camera and a lens.

10. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by the processor, the cotton cloth defect detection method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Classroom learning behavior identification method based on improved YOLOv8

    CN117671781A

  • Road garbage detection method fusing two-dimensional attention and residual network

    CN117710935A

  • Multi-hop attention and depth model, method, storage medium and terminal for classification of target sentiments

    US20200356724A1