Fabric dyeing flaw lightweight detection method and system based on improved YOLO

By improving the YOLO model, replacing the backbone network and introducing the Coordinate attention mechanism, combining data enhancement and structured pruning, the problem of large amount of calculation and time-consuming in fabric dyeing defect detection is solved, efficient and real-time defect detection is achieved, and production is reduced cost.

CN119006370APending Publication Date: 2024-11-22ZHEJIANG SCI-TECH UNIV +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410962656.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-18
Publication Date
2024-11-22

AI Technical Summary

Technical Problem

The existing fabric dyeing defect detection methods have problems such as large calculation volume, long time, and relying on high computing power equipment. The traditional machine vision methods are insufficient in reliability and limited generalization capabilities.

Method used

Using the improved YOLO model, by replacing the Conv and C3 structures in the YOLOv5s model with PatchEmbed, FasterNet-block, and PatchMerge structures in FasterNet, and introducing the Coordinate attention mechanism, data enhancement and structured pruning are performed, and lightweight models are obtained and deployed to Test on mobile devices.

Benefits of technology

While ensuring detection accuracy, it speeds up model inference, improves real-time and accuracy of detection, reduces model parameters and production costs, and is suitable for deployment on mobile devices with less computing power.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119006370A_ABST
    Figure CN119006370A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of fabric dyeing flaw detection, in particular to a fabric dyeing flaw lightweight detection method and system based on improved YOLO. The method comprises the following steps: acquiring a fabric dyeing defect picture; marking the acquired fabric dyeing defect picture and dividing a data set to obtain sample image data; performing data enhancement on the sample image data; the method comprises the following steps: replacing a Conv structure and a C3 structure with a PatchEmbed structure, a Faster Net-block structure and a PatchMerge structure in a Faster Net; the method comprises the following steps: inserting a Coordinate attention into a C3 module in a Neck layer, and fusing the Coordinate attention into the C3 module in the Neck layer; training an improved YOLOv5s model by using the sample image data; performing structured pruning on the trained improved YOLO model to obtain a lightweight model; and deploying the lightweight model on a target mobile device, and performing fabric dyeing flaw 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 dyeing defect detection, and in particular to a lightweight fabric dyeing defect detection method and system based on improved YOLO. Background Art

[0002] In the textile printing and dyeing industry, various defects will appear on fabrics after dyeing, printing, and continuous flat processing. Among them, fabric defect detection after dyeing is a key link in the production process. The current detection methods are mainly divided into traditional machine vision technology and deep learning-based technology. Traditional machine vision methods rely on manual feature extraction and are usually only applicable to the detection of defects on some fabrics after dyeing. They have the disadvantages of insufficient reliability, limited generalization ability, and slow detection speed. In contrast, deep learning methods can self-learn and extract deep image features from a large amount of data, and achieve more efficient and accurate detection in complex environments. However, there are many fabric dyeing defect detection algorithms based on deep learning at present, all of which have the disadvantages of large amount of calculation, long time consumption, and dependence on high computing power devices such as graphics processing units (GPUs). In addition, a set of detection equipment needs to have multiple industrial cameras to complete the detection task, and the cost of industrial cameras is relatively high. Summary of the invention

[0003] The object of the present invention is to provide a lightweight detection method and system for fabric dyeing defects based on improved YOLO.

[0004] The technical solution adopted by the present invention is: a lightweight detection method for fabric dyeing defects based on improved YOLO, comprising the following steps:

[0005] Collect pictures of fabric dyeing defects;

[0006] The collected fabric dyeing defect images are marked according to the corresponding defect categories and the data sets are divided to obtain sample image data;

[0007] Perform data augmentation on sample image data;

[0008] The PatchEmbed, FasterNet-block, and PatchMerge structures in FasterNet are used to replace the Conv and C3 structures in the YOLOv5s model;

[0009] Insert and integrate Coordinate attention into the C3 module in the Neck layer of the YOLOv5s model to obtain an improved YOLOv5s model;

[0010] Improve the YOLOv5s model using sample image data training;

[0011] Perform structured pruning on the trained improved YOLO model to obtain a lightweight model;

[0012] The lightweight model is deployed on a target mobile device to perform fabric dyeing defect detection.

[0013] Preferably, the method for collecting fabric dyeing defect pictures comprises:

[0014] Under the same production conditions, collect pictures of fabric dyeing defects of different types.

[0015] Preferably, the collected fabric dyeing defect images are marked according to corresponding defect categories and divided into data sets, and the method for obtaining sample image data includes:

[0016] The minimum bounding rectangle is used to mark the category and position of each fabric dyeing defect, wherein the target minimum bounding rectangle surrounds the defect, and the minimum bounding rectangle is marked as (class, xmin, ymin, xmax, ymax), where class represents the defect category, xmin and ymin represent the coordinates of the upper left corner vertex of the minimum bounding rectangle, and xmax and ymax represent the coordinates of the lower right corner vertex of the minimum bounding rectangle.

[0017] Preferably, the method for performing data enhancement on sample image data includes:

[0018] After performing one or more operations of random rotation, random scaling, random cropping, dynamic adjustment of brightness contrast, and Mosaic enhancement on the sample image data, the defect category of the sample image data is associated to obtain new sample image data.

[0019] Preferably, the method of using PatchEmbed, FasterNet-block, and PatchMerge structures in FasterNet to replace Conv and C3 structures in the YOLOv5s model includes:

[0020] Use PatchEmbed and PatchMerge modules to replace the CBS module of the pre-imported YOLOv5 model;

[0021] A FasterNet-block module is used to replace the C3 module of the YOLOv5 model, and the FasterNet-block module includes a Pconv module.

[0022] Preferably, the method of performing structured pruning on the trained improved YOLO model to obtain a lightweight model includes:

[0023] Performing sparse regularization on the trained improved YOLO model;

[0024] Set a Speed-up p parameter to control the model pruning rate

[0025]

[0026] Among them, the value of Speed-up controls the network weight loss ratio, FLOPs 1 is the floating point operation of the unpruned model, FLOPs 2 is the floating point operation amount of the pruned model.

[0027] As an advantage, it also includes the steps of:

[0028] The sample image data is used multiple times to train the improved YOLOv5s model to obtain multiple trained improved YOLO models, the performance of the multiple trained improved YOLO models is compared, and the optimal model is selected as the final trained improved YOLO model.

[0029] Preferably, the method for comparing the performance of multiple trained improved YOLO models includes:

[0030] The performance of multiple trained improved YOLO models is compared using one or more of the following performance indicators: precision (P), recall (R), mean average precision (mAP), floating point operations (FLOPs), parameters (Parameters), FPS, and latency.

[0031] Preferably, the method of deploying the lightweight model on a target mobile device to detect fabric dyeing defects comprises:

[0032] Use the corresponding file of the improved YOLO model to replace the pre-imported YOLO model file of the original detection software, check the model input and output data dimensions, modify the input and output dimensions and label files, set the APP name and icon, and export to obtain the installation package;

[0033] Import and install the installation package on the target mobile device, obtain the target APP, and open the target APP to perform fabric dyeing defect detection.

[0034] The lightweight detection system for fabric dyeing defects based on improved YOLO includes:

[0035] A collection module is used to collect pictures of fabric dyeing defects;

[0036] The sample module is used to mark the collected fabric dyeing defect images according to the corresponding defect categories and divide the data sets to obtain sample image data;

[0037] A sample enhancement module, used to perform data enhancement on sample image data;

[0038] Replacement module, used to use PatchEmbed, FasterNet-block, PatchMerge structures in FasterNet to replace Conv and C3 structures in YOLOv5s model;

[0039] The integration module is used to insert and integrate the Coordinate attention into the C3 module in the Neck layer of the YOLOv5s model to obtain an improved YOLOv5s model;

[0040] The training module is used to train and improve the YOLOv5s model using sample image data;

[0041] The pruning module is used to perform structured pruning on the trained improved YOLO model to obtain a lightweight model;

[0042] The deployment module is used to deploy the lightweight model to a target mobile device to perform fabric dyeing defect detection.

[0043] The substantial effects of the present invention are:

[0044] 1. The present invention uses the fast network FasterNet to replace the original YOLOv5 backbone network, which speeds up the reasoning speed of the model while ensuring the detection accuracy, and greatly improves the real-time performance of the detection;

[0045] 2. Considering that most fabric dyeing defects are small objects, the CA attention mechanism is introduced to fully obtain the location information of fabric dyeing defects, improve the accuracy of the model with less increase in the number of model parameters;

[0046] 3. In order to deploy on mobile devices with less computing power, the trained model is pruned structurally, reducing the number of model parameters to 1 / 4 of the original model, and the inference speed of the pruned model is nearly doubled;

[0047] 4. Deploy lightweight models on mobile devices to complete defect detection tasks, reducing industrial production costs.

[0048] The present invention innovatively proposes a lightweight detection method and system for fabric dyeing defects based on improved YOLO, which effectively solves the problems currently faced in the fabric dyeing defect industry and is expected to significantly improve the production efficiency and economic benefits of the fabric industry. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] Figure 1 The present invention is a flow chart of a lightweight detection method for fabric dyeing defects.

[0050] Figure 2 This is a schematic diagram of the overall structure of the YOLOv5s model improved by the present invention.

[0051] Figure 3 This is a schematic diagram of the structure of each module of the YOLOv5s model improved by the present invention.

[0052] Figure 4 Schematic diagram of the CA attention mechanism structure of the present invention.

[0053] Figure 5 It is a schematic diagram of the working principle of PConv of the present invention.

[0054] Figure 6 Schematic diagram of the structured pruning principle of the present invention.

[0055] Figure 7 The present invention is a schematic structural diagram of a lightweight detection system for fabric dyeing defects. DETAILED DESCRIPTION

[0056] The specific implementation of the present invention will be further described below through specific examples in conjunction with the accompanying drawings.

[0057] This manual proposes a lightweight detection method for fabric dyeing defects based on improved YOLO. Figure 1 , including the following steps:

[0058] S1. Collect pictures of fabric dyeing defects;

[0059] S2. Label the collected fabric dyeing defect images according to the corresponding defect categories and divide the data sets to obtain sample image data;

[0060] S3. Perform data enhancement on sample image data;

[0061] S4. Use PatchEmbed, FasterNet-block, and PatchMerge structures in FasterNet to replace the Conv and C3 structures in the YOLOv5s model;

[0062] S5. Insert and integrate Coordinate attention into the C3 module in the Neck layer of the YOLOv5s model to obtain an improved YOLOv5s model;

[0063] S6. Improve the YOLOv5s model using sample image data training;

[0064] S7. Perform structured pruning on the trained improved YOLO model to obtain a lightweight model;

[0065] S8. Deploy the lightweight model to a target mobile device to perform fabric dyeing defect detection.

[0066] In step S1, the method for collecting fabric dyeing defect pictures is as follows:

[0067] S1A: Under the same production conditions, including light source changes, angles, distances and other factors, different types of fabric defects are collected;

[0068] S1B: Get an image with a resolution of 1920 × 1080 and save it in png format.

[0069] In step S2, the collected fabric dyeing defect images are marked according to the corresponding defect categories and the data sets are divided. The method for obtaining sample image data is as follows:

[0070] S2A: Use the minimum bounding rectangle in LabelImg software to label the category and location of each defect, ensuring that the target ground truth box completely surrounds the defect. The target ground truth box is labeled as (class, xmin, ymin, xmax, ymax), where class represents the defect category, xmin and ymin represent the coordinates of the upper left corner vertex of the box, and xmax and ymax represent the coordinates of the lower right corner vertex of the box.

[0071] S2B: Divide all data sets into training sets, test sets, and validation sets in a ratio of 7:2:1 and put them into the images folder, and put the corresponding txt files into the labels file.

[0072] In step S3, the method for performing data enhancement on the sample image data is as follows:

[0073] S3A: When processing images of fabric dyeing defects, we noticed that there were small defect targets in the images. To address this problem, we proposed a data augmentation strategy, including random rotation, random scaling, random cropping, dynamic adjustment of brightness contrast, and Mosaic enhancement. Through random rotation, we can handle fabric dyeing defects at various angles and increase the diversity of data; random scaling and cropping can make the model better adapt to defect targets of different scales; by dynamically adjusting the brightness contrast, the robustness of the model can be increased to adapt to changes in lighting conditions; at the same time, Mosaic enhancement can splice multiple different images into a large image to increase the diversity of training data. The improved YOLOv5 structure is as follows Figure 2 , Figure 3 As shown:

[0074] In step S4, the method of using the PatchEmbed, FasterNet-block, and PatchMerge structures in FasterNet to replace the Conv and C3 structures in the YOLOv5s model is as follows:

[0075] S4A: Use PatchEmbed and PatchMerge modules to replace the CBS module of the original YOLOv5 model to adjust the upper and lower modules to adjust the channel;

[0076] S4B: Use the FasterNet-block module to replace the C3 module of the original YOLOv5 model. This module first uses a partial convolution (PConv) to reduce computational redundancy and memory access times, and then uses an inverted residual block to change the feature channel. The principle is as follows Figure 5 As shown in the figure, PConv only performs regular spatial feature extraction on some input channels, and the other channels remain unchanged. For continuous or regular memory access, the first or last continuous c p The channel is calculated as a representative of the entire feature map. Therefore, the FLOPs of PConv is only

[0077]

[0078] The FLOPs of Conv in the original YOLOv5 is

[0079] h×w×k 2 ×c 2 (2) The FLOPs of PConv is only 1 / 16 of that of conventional Conv, and PConv has a smaller number of memory accesses, i.e.

[0080]

[0081] The number of visits in the original YOLOv5 is

[0082] h×w×2c+k 2 ×c 2 ≈h×w×2c(4)The FLOPS here is only 1 / 4 of the original.

[0083] S4C: In order to fully extract information from all channels, a point-wise convolution (PWConv) is added after PConv. This looks more like a T-shaped convolution, which pays more attention to the pixel center position than the regular Conv because the weight of the pixel center position is greater than the surrounding neighboring positions. For the same input and output, the FLOPs of the T-shaped convolution are

[0084] h×w×(k2 ×c p ×c+c×(cc p ))(5)The FLOPs of PConv and PWConv are

[0085] h×w×(k 2 ×c p +c×c p )(6) where c>c p and cc p >c p ,Therefore, it is implemented in two steps to exploit the redundancy in the filter and further save FLOPs;

[0086] S4C: The number of channels in the entire network is selected as FasterNet-t0 for training.

[0087] like Figure 4 This reflects the principle of CA attention mechanism.

[0088] In step S5, the Coordinate attention is inserted and integrated into the C3 module in the Neck layer of the YOLOv5s model. The method for obtaining the improved YOLOv5s model is as follows:

[0089] S5A: Coordinate Attention (CA) combines convolution and pooling operations to enable the network to better understand the correlation between different positions by modeling the importance of spatial coordinates of input features. Convolution operations are used to extract features, while pooling operations are used to focus on the importance of different positions. This combination can help the network learn spatial detail information more effectively and improve sensitivity to different positions.

[0090] S5B: Inserting CA into the C3 module in the Neck layer of the backbone network can make the network pay more attention to the importance of spatial coordinates in the feature extraction and fusion stages. In the C3 module, feature fusion is a key step, and by introducing the CA mechanism, the correlation of different positions can be better captured during the feature fusion process, thereby improving the representation and generalization capabilities of the model.

[0091] S5C: Select the experimental environment configuration as shown in Table 1, set the training hyperparameters as shown in Table 2, and start training the improved model after setting the parameters.

[0092] Table 1 Experimental environment configuration

[0093] Environment configuration Parameter Operating system Windows 10 CPU AMD64 GPU RTX 4060(8G) RAM 16 GB Development environment PyCharm 2023.2.2 Languages Python 3.9 Framework PyTorch 2.2.0+cu118 Operating platform CUDA 11.8

[0094] Table 2 Experimental hyperparameter settings

[0095] Hyperparameters information Iterations 300 Batch size 16 Optimizer AdamW Initial learning rate 0.001 Number of GPUs 1 Weight decay coefficient 0.0005

[0096] In step S7, the trained improved YOLO model is subjected to structured pruning to obtain a lightweight model as follows:

[0097] S7A: Structured pruning is used to slim down the model. First, sparse regularization is performed on the trained model. L1 regularization is added to the scaling factor of the batch normalization (BN) layer in the model. This will make the value of the scaling factor in BN approach 0 so that the network can distinguish the importance of channels (or neurons), because each scaling factor has a corresponding specific convolution channel (or neuron). The specific principle is as follows: Figure 6 shown.

[0098] S7B: Set a Speed_up parameter to control the model pruning rate

[0099]

[0100] Among them, the value of Speed-up controls the network weight loss ratio, FLOPs 1 is the floating point operation of the unpruned model, FLOPs 2 is the floating point operation amount of the pruned model.

[0101] The lightweight detection method for fabric dyeing defects based on improved YOLO also includes the following steps:

[0102] S7': Use sample image data to train the improved YOLOv5s model multiple times to obtain multiple trained improved YOLO models, compare the performance of multiple trained improved YOLO models, and select the best model as the final trained improved YOLO model. The specific method is as follows:

[0103] S7'A: The model is evaluated by seven indicators: precision (P), recall (R), mean average precision (mAP), floating point operations (FLOPs), parameters (Parameters), FPS and latency.

[0104] S7'B: The P value represents the probability that the model detects an image with fabric dyeing defects in the test set images as positive; the R value represents the ratio of fabric dyeing defects detected by the model in the test set images to the real fabric dyeing defects; the mAP value represents the average accuracy of the model in all categories, as shown in formulas (8)-(11)

[0105]

[0106] Among them, TP (true positive) indicates the number of fabric defects that can be correctly identified; FP (false positive) indicates the number of fabric defects that are incorrectly identified; FN (false negative) indicates the number of fabric defects that are not detected. The average progress (AP) indicates the detection accuracy of each fabric defect category of the model, and N indicates the number of fabric defect types.

[0107] S7'C: This study also used FLOPs and Parameters values ​​to evaluate the model complexity; FPS and Latency values ​​to verify the inference speed of the model. The calculation formulas are shown in (12)-(16)

[0108] FLOPs = W × H × K × K × C in ×C out (12)

[0109] Parameters = C in ×C out ×K×K (13)

[0110]

[0111] Among them, K represents the size of the convolution kernel; W and H represent the width and height of the input fabric defect feature map; C in ×C out Represents the number of input and output channels respectively; T s Represents the total time of all test reasoning; N t represents the total number of tests; BS represents the number of test images in each batch; ITPI represents the inference time for each image.

[0112] S7'D: First, a comparative experiment is conducted on the selection of model backbone.

[0113] S7'E: Secondly, conduct comparative experiments on the choice of attention mechanism and select the one with the best effect.

[0114] S7'F: Finally, different pruning rates are set to select the optimal model.

[0115] In all the above experiments, the same experimental data needs to be controlled, such as the backbone network channel size, attention mechanism, and experimental environment.

[0116] In step S8, the lightweight model is deployed on the target mobile device to perform fabric dyeing defect detection as follows:

[0117] S8A: Use model quantization to reduce model size, speed up inference, reduce power consumption, and make the model more adaptable to mobile device hardware, improving the efficiency and performance of model deployment on mobile devices. Specific quantization methods include Float 16 quantization, dynamic quantization, and full integer quantization. Due to the limited computing power of the mobile terminal, the quantization parameter --imgsz is set to 320.

[0118] S8B: Replace the corresponding YOLO model file, check the model input and output data dimensions, modify the input and output dimensions and label files, set the mobile APP name and icon, and package it into an installation package in APK format.

[0119] S8C: Download Android Stdio software, put the phone into developer mode and turn on USB debugging. After running, the set APP will be automatically installed. After opening it and agreeing to the permissions, real-time detection of fabric dyeing defects can be achieved on the mobile device.

[0120] Considering the actual requirements of multi-fabric dyeing defect detection tasks for high detection accuracy, high detection speed and real-time performance, this study proposes a lightweight detection method and system for fabric dyeing defects based on improved YOLO. In order to meet the high real-time requirements of fabric dyeing defect detection tasks, PatchEmbed, PatchMerge and FasterNet-block modules are designed to significantly improve the inference speed of the model. The CA attention mechanism is introduced in the backbone layer and the neck layer to improve the model's detection ability for fabric dyeing defects. Furthermore, the channel pruning method is used to further reduce the model complexity and accelerate inference. Experimental verification shows that the proposed pruned FCP-YOLOv5 model has a good detection effect and shows excellent performance in both detection accuracy and speed. It is also beneficial to implement the pruned FCP-YOLOv5 model on embedded systems and mobile devices. By using the existing research results, the rapid detection of fabric dyeing defects can be realized in practical application scenarios.

[0121] This specification also provides a lightweight detection system for fabric dyeing defects based on improved YOLO, please refer to the attached drawings, including:

[0122] A collection module 100 is used to collect pictures of fabric dyeing defects;

[0123] The sample module 200 is used to mark the collected fabric dyeing defect pictures according to the corresponding defect categories and divide the data sets to obtain sample image data;

[0124] The sample enhancement module 300 is used to perform data enhancement on sample image data;

[0125] A replacement module 400 is used to replace the Conv and C3 structures in the YOLOv5s model with the PatchEmbed, FasterNet-block, and PatchMerge structures in FasterNet;

[0126] Integrating module 500, for inserting and integrating Coordinate attention into the C3 module in the Neck layer of the YOLOv5s model to obtain an improved YOLOv5s model;

[0127] A training module 600 is used to train an improved YOLOv5s model using sample image data;

[0128] A pruning module 700 is used to perform structured pruning on the trained improved YOLO model to obtain a lightweight model;

[0129] The deployment module 800 is used to deploy the lightweight model to a target mobile device to perform fabric dyeing defect detection.

[0130] The above-described embodiment is only a preferred solution of the present invention and does not limit the present invention in any form. There are other variations and modifications without exceeding the technical solution described in the claims.

Claims

1. A lightweight detection method for fabric dyeing defects based on improved YOLO, characterized in that: The following steps are involved: Collect pictures of fabric dyeing defects; The collected fabric dyeing defect images are marked according to the corresponding defect categories and the data sets are divided to obtain sample image data; Perform data augmentation on sample image data; The PatchEmbed, FasterNet-block, and PatchMerge structures in FasterNet are used to replace the Conv and C3 structures in the YOLOv5s model; Insert and integrate Coordinate attention into the C3 module in the Neck layer of the YOLOv5s model to obtain an improved YOLOv5s model; Improve the YOLOv5s model using sample image data training; Perform structured pruning on the trained improved YOLO model to obtain a lightweight model; The lightweight model is deployed on a target mobile device to perform fabric dyeing defect detection.

2. The lightweight detection method for fabric dyeing defects based on improved YOLO according to claim 1 is characterized in that: Methods for collecting images of fabric dyeing defects include: Under the same production conditions, collect pictures of fabric dyeing defects of different types.

3. The lightweight detection method for fabric dyeing defects based on improved YOLO according to claim 1, characterized in that: The collected fabric dyeing defect images are marked according to the corresponding defect categories and the data sets are divided. The method for obtaining sample image data includes: The minimum bounding rectangle is used to mark the category and position of each fabric dyeing defect, wherein the target minimum bounding rectangle surrounds the defect, and the minimum bounding rectangle is marked as (class, xmin, ymin, xmax, ymax), where class represents the defect category, xmin and ymin represent the coordinates of the upper left corner vertex of the minimum bounding rectangle, and xmax and ymax represent the coordinates of the lower right corner vertex of the minimum bounding rectangle.

4. The lightweight detection method for fabric dyeing defects based on improved YOLO according to claim 1, characterized in that: Methods for data augmentation of sample image data include: After performing one or more operations of random rotation, random scaling, random cropping, dynamic adjustment of brightness contrast, and Mosaic enhancement on the sample image data, the defect category of the sample image data is associated to obtain new sample image data.

5. The lightweight detection method for fabric dyeing defects based on improved YOLO according to claim 1, characterized in that: Methods for using PatchEmbed, FasterNet-block, and PatchMerge structures in FasterNet to replace the Conv and C3 structures in the YOLOv5s model include: Use PatchEmbed and PatchMerge modules to replace the CBS module of the pre-imported YOLOv5 model; A FasterNet-block module is used to replace the C3 module of the YOLOv5 model, and the FasterNet-block module includes a Pconv module.

6. The lightweight detection method for fabric dyeing defects based on improved YOLO according to claim 1, characterized in that: The method of performing structured pruning on the trained improved YOLO model to obtain a lightweight model includes: Performing sparse regularization on the trained improved YOLO model; Set a Speed_up parameter to control the model pruning rate The Speed-up value controls the network slimming ratio, FLOPs1 is the floating-point computing amount of the unpruned model, and FLOPs2 is the floating-point computing amount of the pruned model.

7. The lightweight detection method for fabric dyeing defects based on improved YOLO according to claim 1, characterized in that: Also includes the steps: The sample image data is used multiple times to train the improved YOLOv5s model to obtain multiple trained improved YOLO models, the performance of the multiple trained improved YOLO models is compared, and the optimal model is selected as the final trained improved YOLO model.

8. The method for lightweight detection of fabric dyeing defects based on improved YOLO according to claim 7, characterized in that: Methods for comparing the performance of multiple trained improved YOLO models include: The performance of multiple trained improved YOLO models is compared using one or more of the following performance indicators: precision (P), recall (R), mean average precision (mAP), floating point operations (FLOPs), parameters (Parameters), FPS, and latency.

9. The lightweight detection method for fabric dyeing defects based on improved YOLO according to claim 1, characterized in that: The method of deploying the lightweight model on a target mobile device to detect fabric dyeing defects includes: Use the corresponding file of the improved YOLO model to replace the pre-imported YOLO model file of the original detection software, check the model input and output data dimensions, modify the input and output dimensions and label files, set the APP name and icon, and export to obtain the installation package; Import and install the installation package on the target mobile device, obtain the target APP, and open the target APP to perform fabric dyeing defect detection.

10. A lightweight fabric dyeing defect detection system based on improved YOLO, characterized in that: include: A collection module is used to collect pictures of fabric dyeing defects; The sample module is used to mark the collected fabric dyeing defect images according to the corresponding defect categories and divide the data sets to obtain sample image data; A sample enhancement module, used to perform data enhancement on sample image data; Replacement module, used to replace the Conv and C3 structures in the YOLOv5s model with the PatchEmbed, FasterNet-block, and PatchMerge structures in FasterNet; The integration module is used to insert and integrate the Coordinate attention into the C3 module in the Neck layer of the YOLOv5s model to obtain an improved YOLOv5s model; The training module is used to train and improve the YOLOv5s model using sample image data; The pruning module is used to perform structured pruning on the trained improved YOLO model to obtain a lightweight model; The deployment module is used to deploy the lightweight model to a target mobile device to perform fabric dyeing defect detection.