An improved YOLOv5s cloth defect detection method

By improving the GCP-YOLOv5s network of YOLOv5s and utilizing the Ghost module and CBAM attention mechanism, the problems of slow speed and low accuracy of YOLOv5s in cloth defect detection are solved, and lightweight and high-precision defect detection is achieved.

CN116630269BActive Publication Date: 2025-09-26ZHEJIANG SCI-TECH UNIV +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310593376.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-25
Publication Date
2025-09-26
Estimated Expiration
2043-05-25

AI Technical Summary

Technical Problem

The existing YOLOv5s model has problems in cloth defect detection, such as slow detection speed, high missed detection rate, high false detection rate, and low detection accuracy. In addition, traditional machine learning and deep learning algorithms have poor application effects in actual production environments.

Method used

Using the GCP-YOLOv5s network, by improving the Backbone, Neck and Head parts of YOLOv5s, using the Ghost module to reconstruct the backbone network, adding the CBAM attention mechanism, replacing the CBS and C3 modules with GhostCBS and C3Ghost modules, and using PConv in the Neck part, a lightweight multi-scale feature fusion network was constructed.

Benefits of technology

It achieves the reduction of model parameters and calculation amount without affecting detection accuracy, improves detection speed and accuracy, reduces missed detection and false detection rates, and is suitable for cloth defect detection in actual production environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116630269B_ABST
    Figure CN116630269B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of fabric defect detection and discloses a cloth defect detection method that improves YOLOv5s. The specific process includes collecting surface images of cloth, cropping and amplifying the collected images, and then inputting them into a GCP-YOLOv5s network to output images with the location and type of defects. The GCP-YOLOv5s network is based on the Yolov5s network, and all CBS modules except the first one in Backbone are replaced with GhostCBS modules, and all C3 modules are replaced with C3Ghost modules. At the same time, a CBAM attention mechanism is added after the SPPF module. The CBS modules in Neck are replaced with GhostCBS, and all C3 modules are replaced with C3P modules. The present invention improves the Yolov5s network, reducing the number of model parameters and the amount of computation without affecting detection accuracy, making it more suitable for cloth defect detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] Fabric defects refer to imperfections that appear on the fabric surface during the weaving process. These defects are primarily caused by equipment failure, yarn problems, trapped debris, poor processing, and excessive stretching. Traditional manual inspection methods suffer from high costs and low efficiency. Furthermore, manual inspection methods are subject to subjective factors and are easily affected by factors such as fatigue and lack of concentration, resulting in reduced detection accuracy. Furthermore, standardization is difficult to achieve. Therefore, there is a growing trend toward automated detection of fabric surface defects using computer technology. Two main approaches are employed. One is based on traditional machine learning-based object detection algorithms, which detect fabric defects based on fabric texture and statistical features. Most of these methods require the pre-defined defect features. However, due to the complexity and diversity of fabric defects, methods that rely solely on shallow feature extraction for fabric texture analysis are easily affected by uneven lighting and noise, resulting in low defect detection accuracy. Furthermore, traditional machine learning algorithms perform poorly on massive datasets, making them unsuitable for widespread application in real-world production environments.

[0003] Another type of object detection algorithm is based on deep learning. While it performs well in some areas, it also has some drawbacks. The improved FasterRCNN algorithm improves detection of small objects and minor defects, but its large model size limits its application to specific problem contexts. YOLOv5s is the lightest model in the YOLOv5 series. However, when using YOLOv5s for fabric defect detection, it still suffers from slow detection speed, high missed detection rate, high false detection rate, and low detection accuracy. Summary of the Invention

[0004] The technical problem to be solved by the present invention is to provide a cloth defect detection method based on an improved YOLOv5s, which is used to detect fabric surface defects in a lightweight and high-precision manner.

[0005] In order to solve the above technical problems, the present invention provides a cloth defect detection method based on an improved YOLOv5s. The specific process includes collecting a surface image of the cloth, cropping and amplifying the collected image in a computer, and then inputting it into a GCP-YOLOv5s network to output a fabric defect detection image with the defect location and type;

[0006] The GCP-YOLOv5s network is based on the Yolov5s network. In the Backbone part, all CBS modules except the first one are replaced by GhostCBS modules, and all C3 modules are replaced by C3Ghost modules. At the same time, the CBAM attention mechanism is added after the SPPF module at the tail of the Backbone. In the Neck part, the CBS modules in the feature pyramid network and the path aggregation network are replaced by GhostCBS, and the C3 modules are replaced by C3P modules. The Head part maintains the original three detector structures.

[0007] As an improvement of the cloth defect detection method of improving YOLOv5s of the present invention:

[0008] The cropping process is to crop the image into a group of images of 96x96 pixels, and then proportionally enlarge each 96x96 pixel image to 640x640 pixels.

[0009] As a further improvement of the cloth defect detection method of improving YOLOv5s of the present invention:

[0010] The GhostCBS module replaces the ordinary convolution in the CBS module of the Yolov5s network with Ghost convolution.

[0011] As a further improvement of the cloth defect detection method of improving YOLOv5s of the present invention:

[0012] The C3Ghost module is constructed by replacing the convolution in the Bottleneck structure of the C3 module in the backbone of the Yolov5s network with Ghost convolution to reconstruct the C3Ghost module.

[0013] As a further improvement of the cloth defect detection method of improving YOLOv5s of the present invention:

[0014] The C3P module is reconstructed into a C3P module by replacing the convolution in the Bottleneck structure of the C3 module in the neck part of the Yolov5s network with PConv convolution.

[0015] As a further improvement of the cloth defect detection method of improving YOLOv5s of the present invention:

[0016] The training and testing process of the GCP-YOLOv5s network is as follows:

[0017] Collect images of the finished cloth surfaces and cut them into 96*96 pixel images on a computer. After manually annotating the images with defects, divide them into training and test sets at a ratio of 0.8:0.2.

[0018] The images in the training set are fed into the GCP-YOLOv5s network. During the training process, the loss function value is calculated and the model parameters are iteratively optimized through backpropagation. Training ends after reaching the preset number of epochs. The test set is then fed into the GCP-YOLOv5s network, and the intersection-over-union ratio (IoU) of the candidate prediction boxes and the annotated boxes, as well as evaluation indicators, are calculated.

[0019] The beneficial effects of the present invention are mainly reflected in:

[0020] 1. The present invention uses the Ghost module to reconstruct the Backbone of the Yolov5s network, making the backbone network more lightweight and reducing the number of model parameters and computational complexity without affecting the detection accuracy.

[0021] 2. The present invention adds the CBAM attention mechanism module to the SPPF module of the backbone feature extraction network, and uses the attention mechanism to enhance the feature extraction capability of the backbone feature extraction network;

[0022] 3. This invention further reduces the number of model parameters and computational complexity by using PConv within the Bottleneck structure in the C3 module of the Neck portion. Because the Bottleneck structure is composed of multiple identical modules connected in series, channels that are not involved in convolution in PConv will participate in convolution in other identical modules, thereby alleviating the problem of insufficient feature fusion caused by using PConv alone. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] The specific embodiments of the present invention are further described in detail below with reference to the accompanying drawings.

[0024] Figure 1 Schematic diagram of the structure of the basic Yolov5s;

[0025] Figure 2 Schematic diagram of the structure of the improved Yolov5s of the present invention;

[0026] Figure 3 Schematic diagram of ordinary convolution and Ghost convolution structure;

[0027] Figure 4 Schematic diagram of the CBAM attention mechanism structure;

[0028] Figure 5 This is a structural comparison diagram of PConv, ordinary convolution, and depth-wise separable convolution;

[0029] Figure 6 The C3 module and the Bottleneck structure diagram before and after improvement;

[0030] Figure 7 Schematic diagram of warp and weft defects on the fabric surface;

[0031] Figure 8 Flowchart of the model training process of the GCP-YOLOv5s network of the present invention;

[0032] Figure 9 This is an example of the detection effect of fabric surface defects using YOLOv5s;

[0033] Figure 10 This is an example diagram of the detection effect of fabric surface defects using the GCP-YOLOv5s network of the present invention. DETAILED DESCRIPTION

[0034] The present invention is further described below with reference to specific embodiments, but the protection scope of the present invention is not limited thereto:

[0035] Example 1: A cloth defect detection method based on improved YOLOv5s. The specific process is as follows:

[0036] 1. Improve Yolov5s network

[0037] Abstract: Fabric defect detection is a one-stop service, which has a great significance for the improvement of the quality of fabric defect detection. In this paper, a fabric defect detection method based on Yolov5s network is proposed. The original backbone network is reconstructed by introducing GhostConv in GhostNet, which greatly reduces the network parameters and accelerates the speed of fabric defect detection. Secondly, the CBAM spatial channel attention mechanism is introduced into the backbone feature extraction network to enhance the feature extraction capability of the network and improve the accuracy of fabric defect detection. Finally, an improved C3-P module based on partial convolution is proposed, which improves the detection accuracy while reducing the model parameters, and can accelerate the fabric defect detection speed when the detection accuracy is close.

[0038] 1.1. Build a basic Yolov5s network

[0039] YOLOv5s is mainly composed of three parts: Backbone, Neck, and Head. Its structure is as follows: Figure 1 As shown in the figure, the backbone consists of the CBS module and the C3 module, and its function is to perform comprehensive feature extraction. The neck consists of the Feature Pyramid Networks (FPN) and the Path Aggregation Network (PAN), and its function is to achieve multi-scale feature fusion. The FPN transmits the semantic information of the deep feature map from the top to the bottom, while the PAN transmits the position information of the shallow feature map from the bottom to the deep layer. The head consists of three detectors, and its function is to complete the detection of object position and category.

[0040] 1.2 Lightweight backbone network

[0041] In order to achieve the lightweight Backbone of the YOLOv5s network, the present invention uses the Ghost module to reconstruct the Backbone of the basic Yolov5s network. In the feature layer obtained by conventional convolution, the feature information of some feature maps is relatively similar. Therefore, not all feature maps need to be obtained through convolution operations. Ghost convolution uses simple operations to generate partial feature maps, reducing the number of parameters and calculations of the model without almost affecting the detection accuracy. The calculation process of its Ghost convolution is as follows: First, a general feature map is obtained through conventional convolution, and then a linear operation is performed on each channel in the general feature map to obtain a simple feature map with the same number of channels. The simple feature map is a similar redundant feature map in the conventional convolution. Then, the general feature map and the simple feature map are stacked in the channel dimension to obtain the final output feature map. The structures of ordinary convolution and Ghost convolution are as follows: Figure 3 shown.

[0042] Assume that the size of the input feature map is h·w·c, and a convolution block with a convolution kernel of k·k is used to generate an output feature map with h′·w′·n output channels. Where h and w are the height and width of the feature map, c is the number of input channels, and n is the number of output channels. The amount of computation required for a feature extraction using ordinary convolution is as follows:

[0043] cost=n·h′·w′·c·k·k (1)

[0044] Ghost convolution first uses ordinary convolution to generate a general feature map. The number of channels of the general feature map is Then perform simple linear operations on the channels in the general feature map to increase the number of channels:

[0045]

[0046] Among them, s represents the number of linear operations, y i ′ represents the i-th general feature map, Φ j represents the simple feature map obtained by performing the jth linear transformation on the general feature map. Theoretically, the number of similar feature maps that can be obtained is m·s. In order to make the output channel the same as the original output feature channel, the first n similar feature maps are taken as the final output result.

[0047] The amount of computation required to perform a feature extraction using Ghost convolution is as follows:

[0048]

[0049] The ratio of the number of parameters between ordinary convolution and Ghost convolution is shown in formula (4), and the ratio of the number of calculations is shown in formula (5).

[0050]

[0051] The CBS module of the YOLOv5s network consists of ordinary convolution, batch normalization operation, and Silu activation function. The ordinary convolution in the BS module ( Figure 1 The Conv2d in the CBS module is replaced with Ghost convolution, thereby reconstructing the CBS module into a GhostCBS module.

[0052] 1.3. Add CBAM attention mechanism module

[0053] The CBAM attention mechanism module includes channel attention and spatial attention: channel attention is used to enhance the network's ability to extract image features, and spatial attention is used to enhance the network's ability to focus on the target. The combination of the two can effectively dilute useless information, enhance robustness and detection accuracy. The present invention adopts a CBAM module in series. Figure 3 As shown. The channel attention module focuses on the important information in the feature map. The calculation process is as follows:

[0054]

[0055] Where: F is the original feature map; M C (F) is the output channel attention value; σ is the Sigmoid function; W0 and W1 are weight parameters; is the average pooling feature; is the maximum pooling feature.

[0056] The output value of the channel attention module is input into the spatial attention module. The calculation process of the spatial attention module is as follows:

[0057]

[0058] Where: M S (F) is the output spatial attention value; f 7×7 It is a convolution operation with a convolution kernel size of 7x7; is the average pooling feature, is the maximum pooling feature.

[0059] The present invention chooses to place the CBAM attention mechanism module after the SPPF module of the backbone feature extraction network, and uses the attention mechanism to enhance the feature extraction capability of the backbone feature extraction network.

[0060] 1.4 Improved Bottleneck Structure Based on Partial Convolution

[0061] GhostConv abandons some conventional convolution operations, uses simple operations to obtain redundant feature maps, and takes advantage of the correlation and redundancy between features. Inspired by GhostConv, the present invention uses a lightweight convolution module Partial Convolution (PConv) with less redundant calculations. PConv only applies filters to a few channels, and the rest of the channels remain unchanged. It has lower floating-point operations (FLOPs) than conventional convolution and higher floating-point operations per second (FLOPS) than depthwise separable convolution. The comparison between PConv and ordinary convolution and depthwise separable convolution is as follows: Figure 5 shown.

[0062] The C3 module consists of three convolution modules and a Bottleneck structure. Its main function is to increase the depth and receptive field of the network. The residual structure is introduced through Bottleneck, which reduces the optimization difficulty of the model. The core idea of ​​the Bottleneck structure is to use multiple small convolutions to replace large convolutions, so as to achieve the purpose of reducing the number of parameters. In the C3 module of the original YOLOv5s network constructed in step 1.1, Bottleneck is composed of 1x1 convolution and 3x3 convolution. The number of channels is reduced by 1x1 convolution, and then 3x3 convolution is used for downsampling. At the same time, the input and output are connected using the Shortcut operation. The present invention replaces all convolutions in the Bottleneck structure with Ghost convolution to obtain G-Bottleneck, and further replaces the Bottleneck in the C3 module of the original YOLOv5s network backbone in step 1.1 with G-Bottleneck to form a C3Ghost module;

[0063] Replace the Conv in the Bottleneck structure with PConv to obtain P-Bottleneck. Further, replace the Bottleneck in the C3 module of the original YOLOv5s network neck part in step 1.1 with P-Bottleneck to form the C3P module. The C3 module and the Bottleneck structures before and after the improvement are shown in the figure. Figure 6 shown.

[0064] By using PConv in the C3 module, the number of model parameters and computational complexity is further reduced. At the same time, because the Bottleneck structure is composed of multiple identical modules connected in series, channels that do not participate in convolution in PConv will participate in convolution in other identical modules, thus alleviating the problem of insufficient feature extraction caused by using PConv alone.

[0065] In combination with steps 1.1-1.4, the present invention uses the improved Yolov5s network as the cloth defect detection network (hereinafter referred to as GCP-YOLOv5s network), such as Figure 2 As shown in the figure, in the Backbone part of the Yolov5s network, all CBS modules except the first one are replaced by GhostCBS, and all C3 modules are replaced by C3Ghost modules. At the same time, the CBAM attention mechanism is added after the SPPF module at the tail of the Backbone, which can increase the feature extraction ability of the backbone network; in the Neck part, the CBS modules in the Feature Pyramid Networks (FPN) and the Path Aggregation Network (PAN) are replaced by GhostCBS, and the C3 modules are replaced by C3P modules, realizing a lighter multi-scale feature fusion; the Head maintains the original three detector structures, and its function is to complete the detection of object position and category.

[0066] 2. Model training

[0067] 2.1、Dataset establishment

[0068] The dataset was collected from a textile production enterprise. The dataset images were taken by an area array CCD camera. In order to realize the real-time monitoring of cloth defects, the camera was set at the cloth outlet, and the image acquisition pixel was set to 3072*96. In the computer, the collected defect images were cut into 96 pixel*96 pixel images, and the dataset was produced by LabelImg annotation. The weft defects were labeled as 'wei' and the warp defects were labeled as 'jing'. There are a total of 1356 images, of which 1220 are for training and 136 for testing. The warp and weft defect images are as follows: Figure 7 shown.

[0069] 2.2 Training and Testing Process

[0070] Input the labeled images in the training set into the GCP-YOLOv5s network for training, such as Figure 8As shown in the figure, the backbone network reconstructed by the Ghost module and the CBAM attention mechanism first performs feature extraction. Then, the Neck (including the C3P module) is used to fuse multi-scale features. Finally, the Head (head) generates defect candidate prediction boxes. The candidate prediction boxes are continuously optimized according to the loss function, and the training model obtains weights that are closer to the label. The loss function used is:

[0071] L=L box +L cls +L obj (8)

[0072] Among them, L box is the loss of the prediction box, L cls is the loss of defect category, L obj is the confidence loss.

[0073] The training parameters are preset with a learning rate of 0.01, num_work set to 8, batch_size set to 16, and epoch set to 300. During the training process, the loss function value is calculated and backpropagation is iteratively optimized to optimize the model parameters. The training ends after the 300th epoch is completed.

[0074] The testing process is to put the labeled test set images into the trained model, generate candidate prediction boxes, and calculate the intersection of the candidate prediction boxes and the labeled boxes. When the intersection of the candidate prediction boxes is greater than 0.5, it is a positive sample, and when it is less than 0.5, it is a negative sample. The mean average precision (mAP) is used as the evaluation indicator, where mAp0.5 = 97.1, thus obtaining a GCP-YOLOv5s network that can be used online.

[0075] 3. Use the improved yolov5s network after training online

[0076] Use a CCD camera to capture an image of a fabric defect, crop it to 96x96 pixels, and scale it up to 640x640 pixels. This image is then fed into the online GCP-YOLOv5s network obtained in step 2 to generate defect prediction candidate boxes. This outputs a fabric defect detection image with the defect location and type.

[0077] experiment

[0078] 1. The experiment uses the data set of Example 1

[0079] 2. Evaluation indicators

[0080] The experimental evaluation indicators include the number of parameters, floating-point operations (FLOPs), precision, recall, average precision (AP), mean average precision (mAP), and frames per second (FPS). The formula is shown in Equation (9-12):

[0081]

[0082] Among them, TP is the number of correctly predicted positive samples; FP is the number of positive samples incorrectly predicted as negative samples; TN is the number of correctly predicted negative samples; FN is the number of negative samples incorrectly predicted as positive samples.

[0083] 3. Input image size comparison experiment

[0084] Because the defect area in the dataset is small, distortion is easily caused during the convolution process. Therefore, we considered scaling the image up proportionally before inputting it. To explore the impact of different image input sizes on defect detection, we designed a comparative experiment on the detection effect of different input image sizes. Each image in the dataset in Example 1 was scaled up proportionally. FPS, precision, recall, mAp0.5, and mAp0.5-9.5 were selected as evaluation metrics. The results are shown in Table 1.

[0085] Table 1 Experimental results of different input sizes

[0086]

[0087] The experimental results in Table 1 show that when the input image size is within 640 pixels, detection performance improves as the size increases. When the input size is larger than 640 pixels, the improvement in detection performance is less noticeable, but the model's inference time increases, resulting in a decrease in the number of detection frames per second. To balance accuracy and computational cost, we chose to scale the images in the dataset to 640x640 pixels for input.

[0088] 4. Analysis of experimental results based on different attention mechanisms

[0089] In order to measure the improvement of the CBAM attention mechanism on the feature extraction ability of the backbone network, the number of parameters, precision, recall, mAp0.5, and mAp0.5-9.5 were selected as evaluation indicators, and different attention mechanisms were combined with the lightweight YOLOv5s replaced by GhostConv. The test results are shown in Table 2.

[0090] Table 2 Results of combining different attention mechanisms with lightweight backbone

[0091]

[0092] Table 2 shows that adding an attention mechanism to the backbone feature extraction network is effective. Although the CBAM and SE attention mechanisms slightly increase the number of model parameters, they improve the backbone network's feature extraction capabilities. While maintaining precision and recall close to those of the original model, they achieve higher mAp0.5 and mAp0.5-9.5. This paper chooses to use the CBAM attention mechanism in the backbone network due to its better performance.

[0093] 5. Comparative experiment

[0094] Table 3 shows the comparative test results of the present invention and four mainstream object detection algorithms under the same test set. Analysis of Table 3 shows that the improved YOLOv5s network proposed in the present invention reduces the number of model parameters and floating-point calculations while ensuring detection accuracy, thereby increasing the number of frames per second (FPS).

[0095] Table 3 Performance comparison of mainstream target detection algorithms

[0096]

[0097] 6. Ablation Experiment

[0098] Under the same test set, the comparative results of the ablation experiment of the present invention are shown in Table 4, where:

[0099] G-YOLOv5s is a YOLOv5s model after reconstructing the backbone network using the Ghost module, in which the CBS module and C3 module in the backbone network are replaced by the GhostCBS module and the C3Ghost module respectively.

[0100] GC-YOLOv5s uses the Ghost module to reconstruct the backbone network of the YOLOv5s model and adds the CBAM attention mechanism at the end. The CBS module and C3 module of the backbone network are replaced with the GhostCBS module and the C3Ghost module respectively. The CBAM attention mechanism module is added after the SPPF module.

[0101] GCP-YOLOv5s is the cloth defect detection network of the present invention.

[0102] Comparing YOLOv5s and G-YOLOv5s shows that after replacing the backbone network, the model's parameter count decreased, and mAp also decreased. Comparing G-YOLOv5s and GC-YOLOv5s shows that after using the attention mechanism, the model's parameter count increased slightly, and mAp@0.5-0.95 increased by 1.5%. With a small increase in parameters, the backbone network's feature extraction capabilities were improved. Comparing GC-YOLOv5s and GCP-YOLOv5s shows that after replacing the Bottleneck in C3 with PConv, the model's parameter count decreased by 19.9%, mAp@0.5 increased by 0.3%, and mAp@0.5-0.95 increased by 0.1%. The Neck portion achieved stronger feature fusion capabilities with fewer parameters. Comparing YOLOv5s and GCP-YOLOv5s, we see that compared to the baseline model, our proposed algorithm reduces parameters by 41.6% and computation by 43.1%, while increasing detection speed by 12 FPS. While maintaining the same mAp@0.5 result, mAp@0.5-0.95 improved by 1.7%. This demonstrates that our improved algorithm achieves higher detection accuracy and faster detection speed with fewer parameters and computation.

[0103] Table 4 GCP-YOLOv5s ablation experiment results

[0104]

[0105]

[0106] In order to illustrate the superiority of this algorithm, Figure 9 and Figure 10 The following table shows the detection results of YOLOv5s and GCP-YOLOv5s for the experimental dataset. Figure 9 and Figure 10 It can be seen that the improved algorithm proposed in this paper reduces the occurrence of missed detection and false detection, and has a stronger ability to locate cloth defects.

[0107] Finally, it should be noted that the above examples are merely specific embodiments of the present invention. Obviously, the present invention is not limited to the above examples and is subject to numerous variations. All variations that can be directly derived or conceived by a person of ordinary skill in the art from the disclosure of the present invention are considered to be within the scope of protection of the present invention.

Claims

1. A cloth defect detection method based on improved YOLOv5s, characterized in that The specific process includes collecting surface images of the cloth, cropping and amplifying the collected images on a computer, and then inputting them into the GCP-YOLOv5s network to output a fabric defect detection image with the location and type of the defect; The GCP-YOLOv5s network is based on the Yolov5s network. In the Backbone part, all CBS modules except the first one are replaced with GhostCBS modules, and all C3 modules are replaced with C3Ghost modules. At the same time, the CBAM attention mechanism is added after the SPPF module at the end of the Backbone. In the Neck part, the CBS modules in the feature pyramid network and the path aggregation network are replaced with GhostCBS, and the C3 modules are replaced with C3P modules. The Head part maintains the original three detector structures. The GhostCBS module is: replacing the ordinary convolution in the CBS module of the Yolov5s network with Ghost convolution; The C3Ghost module is constructed by replacing the convolution in the Bottleneck structure of the C3 module in the backbone of the Yolov5s network with Ghost convolution to reconstruct the C3Ghost module. The C3P module is constructed by replacing the convolution in the Bottleneck structure of the C3 module in the neck part of the Yolov5s network with PConv convolution to reconstruct the C3P module.

2. The cloth defect detection method based on improved YOLOv5s according to claim 1, characterized in that: The cropping and enlarging process is to crop the image into a group of images of 96x96 pixels, and then enlarge each 96x96 pixel image to 640x640 pixels in equal proportion.

3. The cloth defect detection method based on improved YOLOv5s according to claim 2, characterized in that: The training and testing process of the GCP-YOLOv5s network is as follows: Collect images of the surface of finished cloth produced by the company. In the computer, the collected images are cut into 96x96 pixel images. The images with defects are manually annotated and divided into training and test sets with a ratio of 0.8:0.

2. The images in the training set are fed into the GCP-YOLOv5s network. During the training process, the loss function value is calculated and the model parameters are iteratively optimized through backpropagation. Training ends after reaching the preset number of epochs. The test set is then fed into the GCP-YOLOv5s network, and the intersection-over-union ratio (IoU) of the candidate prediction boxes and the annotated boxes, as well as evaluation indicators, are calculated.