YOLOV8-based silk fabric defect detection method and system
By employing GhostHGNetv2 and Slim-Neck feature fusion networks in the YOLOv8 algorithm, combined with a shared detail enhancement detection head, the problems of large parameter count and high memory consumption of the YOLOv8 algorithm in industrial applications are solved, achieving efficient defect detection of silk fabrics.
Patent Information
- Application Number
- CN202510957711.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-11
- Publication Date
- 2025-11-04
AI Technical Summary
The YOLOv8 algorithm employs a complex feature extraction and fusion structure, resulting in high network depth and computational complexity. In practical industrial applications, it faces problems such as a large number of model parameters and high memory consumption, which limits its widespread application in industrial inspection scenarios.
A YOLOv8-based method for detecting defects in silk fabrics is designed by replacing the traditional backbone network with GhostHGNetv2, using a lightweight convolution method to reduce the number of parameters and computation, introducing a Slim-Neck optimized feature fusion network, and reducing the convolution computation by sharing details to enhance the detection head.
It reduces memory consumption, improves inference speed and computing efficiency, adapts to the real-time and resource efficiency requirements of industrial sites, and maintains high-precision detection capabilities.
Smart Images

Figure CN120894293A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to a method and system for detecting defects in silk fabrics based on YOLOv8. Background Technology
[0002] With the continuous improvement of production efficiency and quality standards in the textile industry, traditional manual inspection methods are insufficient to meet the demands of modern production. Intelligent textile defect detection can reduce errors and costs associated with manual inspection, thereby improving the safety and stability of production lines. The core of intelligent fabric defect detection lies in the robustness and efficiency of the algorithm. Target detection algorithms can be divided into two-stage (high accuracy but computationally intensive) and single-stage (fast speed but slightly lower accuracy). In recent years, the YOLO series of algorithms, through continuous optimization, has significantly improved accuracy while maintaining high-speed detection, making it more advantageous in fabric defect detection and a key research focus.
[0003] Against this research backdrop, researchers have progressively optimized the YOLO series algorithms. YOLOv1 introduced depthwise separable convolution and multi-scale feature extraction, achieving a detection speed of 50 FPS and an mAP of 66.8%. YOLOv2 optimized training parameters to meet the real-time detection requirements of fabric defects. YOLOv3 employed deformable convolution and focal loss, improving accuracy by 8.3%. YOLOv4 combined CBAM and CIOU losses, improving accuracy by 8.49% and speed by 37 FPS. YOLOv5 introduced a dense feature pyramid for high-precision real-time detection. The YOLOX algorithm embedded an SE module, improving accuracy by 2.7% while maintaining real-time performance. YOLOv7 optimized the multi-scale attention mechanism, enhancing the detection capability of complex defects. Addressing the need for high hardware efficiency, a RepGhost module based on the YOLOv8 model was constructed, introducing a new information distribution mechanism. By incorporating Wasserstein distance loss, the handling of small target positional deviations was optimized, resulting in an 18.9% improvement in accuracy on the AITEX dataset.
[0004] However, the YOLOv8 algorithm, due to its complex feature extraction and fusion structure, results in high network depth and computational complexity. In practical industrial applications, its large number of model parameters and high memory consumption limit its widespread use in industrial inspection scenarios. Summary of the Invention
[0005] In view of the shortcomings of the prior art, the purpose of this invention is to provide a YOLOv8-based method for detecting defects in silk fabrics. This method addresses the high network depth and computational complexity resulting from the complex feature extraction and fusion structure of the YOLOv8 algorithm. Furthermore, it addresses the technical challenges that hinder the widespread application of this algorithm in industrial inspection scenarios, such as the large number of model parameters and high memory consumption.
[0006] A first aspect of this invention provides a method for detecting defects in silk fabrics based on YOLOv8, comprising:
[0007] S1: Collect images of defects and images of the silk fabric without defects;
[0008] S2: Preprocess the defect image and the defect-free image;
[0009] S3: Construct an improved YOLOV8 model for detecting defects in silk fabrics, wherein the silk fabric defect detection model includes a GhostHGNetv2 feature extraction network, a Slim-Neck feature fusion network, and a shared detail enhancement detection head SDEH;
[0010] S4: Train the silk fabric defect detection model based on the preprocessed defect images and defect-free images;
[0011] S5: Acquire an image of the silk fabric to be detected;
[0012] S6: Input the image of the silk fabric to be detected into the trained silk fabric defect detection model, and output the defect detection result of the silk fabric.
[0013] A second aspect of this invention provides a YOLOv8-based defect detection system for silk fabrics, comprising: a processor and a memory;
[0014] The memory stores programs or instructions that can run on the processor, which, when executed by the processor, implement the steps of the YOLOV8-based silk fabric defect detection method as described in the first aspect.
[0015] A third aspect of the present invention provides a readable storage medium storing a program or instructions that, when executed by a processor, implement the steps of the YOLOv8-based silk fabric defect detection method described in the first aspect.
[0016] The beneficial effects of the technical solutions provided in the embodiments of the present invention include at least the following:
[0017] In this embodiment of the invention, GhostHGNetv2 is used to replace the traditional backbone network. A lightweight convolutional method is employed to reduce the number of parameters and computational cost. The Slim-Neck algorithm is introduced to optimize the feature fusion network, reducing memory consumption. Simultaneously, a shared detail enhancement detection head reduces convolutional computation and improves the fusion capability of multi-scale features. The entire process ensures high accuracy while improving inference speed and computational efficiency, meeting the real-time and resource efficiency requirements of industrial environments. Attached Figure Description
[0018] The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Throughout the drawings, the same reference numerals denote the same parts. Obviously, the drawings described below are merely some embodiments of the present invention, and those skilled in the art can obtain other drawings based on these drawings without any creative effort.
[0019] Figure 1 This is a schematic flowchart of a method for detecting defects in silk fabrics based on YOLOv8 provided in an embodiment of the present invention;
[0020] Figure 2 This is a network architecture diagram of a YOLOv8-based silk fabric defect detection system provided in an embodiment of the present invention;
[0021] Figure 3 This is a GSConv structure diagram provided in an embodiment of the present invention;
[0022] Figure 4 This is a structural diagram of a GS bottleneck and VoVGSCSP provided in an embodiment of the present invention;
[0023] Figure 5 This is a comparison diagram of the original YOLOv8 neck structure and the Slim-Neck structure provided in an embodiment of the present invention;
[0024] Figure 6 This is a structural diagram of a shared detail enhancement detection head provided in an embodiment of the present invention;
[0025] Figure 7 This is a schematic diagram of the structure of a YOLOV8-based defect detection system for silk fabrics provided in an embodiment of the present invention. Detailed Implementation
[0026] To enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. It should be understood that these descriptions are merely exemplary and are not intended to limit the scope of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0027] The following description, in conjunction with the accompanying drawings, details the YOLOv8-based defect detection method for silk fabrics provided by the present invention through specific embodiments and application scenarios.
[0028] Reference manual attached Figure 1 The diagram shows a flowchart of a YOLOv8-based defect detection method for silk fabrics provided by an embodiment of the present invention.
[0029] Reference manual attached Figure 2 The diagram shows a network architecture of a YOLOv8-based silk fabric defect detection system provided by an embodiment of the present invention.
[0030] Reference manual attached Figure 3 The diagram shows a GSConv structure provided by an embodiment of the invention.
[0031] Reference manual attached Figure 4 The diagram shows a structural diagram of a GS bottleneck and VoVGSCSP provided in an embodiment of the present invention.
[0032] Reference manual attached Figure 5 The diagram shows a comparison between the original YOLOv8 neck structure and the Slim-Neck structure provided in an embodiment of the present invention.
[0033] Reference manual attached Figure 6 The diagram shows a structure of a shared detail enhancement detection head provided in an embodiment of the present invention.
[0034] This invention provides a method for detecting defects in silk fabrics based on YOLOv8, which may include the following steps:
[0035] S1: Collect images of defects and no defects in silk fabrics.
[0036] Specifically, the original pixel size was 6000×4000. During data acquisition, both defect-free and defective samples were captured simultaneously. Different defects have different names depending on the fabric type. To facilitate model learning, defects with similar visual features and those with the same definition were uniformly categorized into four textures (herringbone twill, star pattern twill, checkered plain weave, and solid color linen) and six types of defects (weft shrinkage, holes, knots, stains, broken yarns, and loose threads) within the self-built dataset.
[0037] In this embodiment of the invention, data including defective and defect-free images is first obtained by capturing original images (6000×4000 pixels in size). To facilitate model learning, the dataset is categorized into four fabric texture types (such as herringbone, star, checkered, and plain weave fabrics) and six defect types (such as weft shrinkage, holes, and knots). This data provides rich input samples for model training, enabling the model to identify various fabrics and defects.
[0038] S2: Preprocess the defective and defect-free images.
[0039] In one possible implementation, S2 specifically includes:
[0040] S201: Perform rotation correction processing on defective and defect-free images.
[0041] S202: Retain the portion of the defect image containing defect features after rotation correction, remove background clutter and edge interference, and form the target defect image.
[0042] S203: Select Labelimg as the annotation tool, use YOLO data format labels to annotate flawless images and images with target defects, and generate a training set.
[0043] LabelImg is an open-source image annotation tool widely used in image processing and computer vision tasks, especially in object detection model training. It helps users manually annotate the bounding boxes of target objects in images and save this annotation information for use in training machine learning models, particularly for object detection tasks in deep learning.
[0044] In one possible implementation, all images in the training set are uniformly formatted to a size of 1024×1024 pixels and a color depth of 24 bits.
[0045] Specifically, the acquired raw fabric defect images were rotated and corrected. Regions of interest were selected, retaining only the portions containing defect features. Background clutter and edge interference were removed to reduce noise. Labelimg was chosen as the object detection data annotation tool, using YOLO data format labels, saved as txt files, containing the type and location of defects. All images in the dataset were uniformly resized to 1024×1024 pixels with a color depth of 24 bits.
[0046] In this embodiment of the invention, preprocessing ensures the consistency of input images during training, improves training efficiency, ensures that the model can run smoothly under the specified format, reduces the waste of computing resources, and at the same time ensures the full expression of image details.
[0047] S3: Construct an improved YOLOV8 model for detecting defects in silk fabrics. The silk fabric defect detection model includes a GhostHGNetv2 feature extraction network, a Slim-Neck feature fusion network, and a shared detail enhancement detection head (SDEH).
[0048] YOLOv8 is the latest version based on the YOLO (You Only Look Once) architecture, specifically designed for real-time object detection tasks. YOLO is a fast and efficient object detection algorithm, originally proposed by Joseph Redmon. YOLOv8 represents the latest evolution and improvement of this algorithm, further enhancing detection accuracy and speed, and is widely used in image processing, video surveillance, autonomous driving, and other fields.
[0049] In one possible implementation, the improved YOLOV8 fabric defect detection model includes an input terminal, a backbone network, a neck network, and a detection head.
[0050] It's important to note that the input end is the entry point for the entire model, responsible for receiving and preprocessing the raw image before it enters subsequent processing modules. The backbone network is the core of the object detection model, responsible for extracting useful features from the input image, with the goal of extracting low-level to high-level features. The neck network, located between the backbone network and the detection head, acts as a connector and optimizes the features. The main task of the neck network is to further process the features extracted by the backbone network, adapting them to the requirements of the detection task. The detection head is the final part of the object detection model, responsible for predicting the final object category, location, and confidence score from the feature maps processed by the backbone and neck networks.
[0051] The backbone network is designed with GhostHGNetv2 as the feature extraction network to reduce the number of parameters and improve the target detection capability.
[0052] It should be noted that the GSS-YOLOv8 model includes an input, a backbone network, a neck network, and a detection head. The original backbone network is replaced by GhostHGNetv2 as the feature extraction network of the model. In the feature fusion part, the lightweight convolutional GSConv is used to replace the original convolutional kernel, and a Slim-Neck feature fusion network is introduced. A shared detail enhancement detection head is designed. By sharing convolutional parameters, the amount of convolutional computation of feature maps of different scales during the detection process is reduced, thereby reducing the number of parameters of the detection head.
[0053] In one possible implementation, the GhostHGNetV2 feature extraction network includes an HGStem module and a Ghost_HGBlock module. The workflow of the GhostHGNetV2 feature extraction network specifically includes:
[0054] The HGStem module performs initial preprocessing on the input image, extracts the basic features of the image, and generates the first feature map.
[0055] The second feature map is generated by compressing the number of channels in the first feature map using a 1×1 standard convolution in the Ghost_HGBlock module.
[0056] High-level features are extracted from the second feature map using depthwise separable convolution in the Ghost_HGBlock module, generating the Ghost feature map.
[0057] Specifically, GhostHGNetv2 is used to replace the original backbone network for feature extraction in the model. Depthwise separable convolutions and Ghost_HGBlock are used to replace the standard convolutions and C2f modules in the original YOLOv8 backbone network, respectively, to extract more feature information from the input feature map with fewer parameters. These features are sent to the SPPF module to prepare for feature fusion in the neck network.
[0058] In one possible implementation, standard convolution is replaced by depthwise separable convolution, where the parameter ratio of the depthwise separable convolution satisfies:
[0059]
[0060] Where DWConv represents the number of parameters in the depthwise separable convolution, Conv represents the number of parameters in the standard convolution, c represents the number of channels in the input feature map, k represents the size of the convolution kernel, and m represents the number of channels in the output feature map.
[0061] The Ghost feature map and the feature map of the input image are fused to obtain a fused feature map.
[0062] The neck network is designed with a Slim-Neck feature fusion network. By introducing GSConv lightweight convolution, GS Bottleneck and VoVGSCSP modules into the Slim-Neck feature fusion network, the computational cost and memory usage are reduced, while ensuring high-precision detection capability.
[0063] In one possible implementation, the Slim-Neck feature fusion network includes a GSConv convolutional module, a GSBottleneck module, and a VoVGSCSP module. The workflow of the Slim-Neck feature fusion network specifically includes:
[0064] Standard convolution is performed using the GSConv lightweight convolution module to obtain convolutional feature maps.
[0065] By concatenating the feature maps of standard convolution and depthwise separable convolution on different channels, a concatenated feature map is obtained.
[0066] A shuffle operation is performed on the spliced feature map to rearrange the features of the standard convolution and depthwise separable convolution, and to distribute the features of the standard convolution evenly into the output channel of the depthwise separable convolution.
[0067] The GSBottleneck module is used to compress the feature map after the shuffle operation.
[0068] The VoVGSCSP module aggregates compressed features at different scales to output the final target feature map.
[0069] Specifically, GSConv uses a hybrid convolution that combines standard convolution, depthwise convolution, and shuffle convolution. Slim-Neck builds upon GSConv by introducing GS Bottleneck to further reduce the computational cost of the model. In addition, an efficient cross-stage partial network (CSP) module, VoVGSCSP, is designed using a one-time aggregation strategy to reduce computational complexity and inference time while maintaining accuracy.
[0070] The detection head is designed with a shared detail enhancement detection head (SDEH), which reduces the amount of convolution computation between feature maps of different scales by sharing convolution parameters, thereby enhancing the fusion capability of multi-scale feature maps.
[0071] It should be noted that the architecture of the Slim-Neck feature fusion network is that the VoVGSCSP module and the GSConv module replace the C2f and standard convolution in the original YOLOv8 neck structure, respectively, while keeping the original FPN-PAN structure unchanged.
[0072] In one possible implementation, the workflow of the Shared Detail Enhancement Detection Head (SDEH) specifically includes:
[0073] On the three different scale feature maps P3, P4 and P5 output by the neck network, Group Normalization is used instead of traditional Batch Normalization to divide the input feature map into multiple groups for normalization.
[0074] By introducing detail-enhancing convolutions to construct shared convolutional layers, convolutional weights are shared among feature maps of different scales. This fuses semantic and contextual information contained in feature maps captured by three different scale detection heads to generate prediction boxes and classification targets.
[0075] By using reparameterization techniques, the convolution kernels are readjusted so that convolution operations can be merged and executed in parallel to obtain the output feature map.
[0076] In one possible implementation, the formula for the reparameterization technique is as follows:
[0077]
[0078] Among them, F out This represents the output feature map, DEConv() represents the detail enhancement convolution, and F... in Indicates the input features, * indicates the convolution operation, and K i Let K represent the i-th convolutional kernel, where i = 1, 2, ..., 5 represent the kernels of VC, CDC, ADC, HDC, and VDC, respectively. cvt This indicates the converted kernel.
[0079] In this embodiment of the invention, the shared detail-enhanced detection head includes three feature maps of different scales (P3, P4, and P5) output by the neck network. The Batch Normalization (BN) method in the convolution is replaced with Group Normalization (GN), solving the problem of increased GPU memory due to storing the mean and variance in BN. This makes the model more accurate and accelerates the speed of gradient descent to find the optimal solution, thus speeding up the model's convergence. Detail-enhanced convolutions are introduced to construct shared convolutional layers, fusing semantic and contextual information from the feature maps captured by the three different-scale detection heads to generate prediction boxes and classification targets. By sharing the weight parameters of the convolutional layers, the efficiency and accuracy of the model are improved. Through the use of reparameterization techniques, DEConv extracts richer features while maintaining the same parameter size, without increasing additional computation and storage during the inference stage.
[0080] S4: Train the silk fabric defect detection model based on the preprocessed defect images and defect-free images.
[0081] It should be noted that the preprocessed image data is input into the training model and trained using a standard object detection training process. The model is trained using both defective and defect-free images, learning how to identify and distinguish different defects, progressively optimizing the loss function to improve detection accuracy. During training, standard classification losses (such as cross-entropy loss) and regression losses (such as IoU loss) are used to optimize the model, ensuring it can accurately predict the location and category of the target. After training, a set of different validation datasets is used to evaluate the model's performance, typically using metrics such as accuracy, recall, and mAP to quantify the model's detection effectiveness.
[0082] S5: Acquire an image of the silk fabric to be detected.
[0083] S6: Input the image of the silk fabric to be detected into the trained silk fabric defect detection model, and output the defect detection results of the silk fabric.
[0084] Specifically, the model detection results include: defect type, defect quantity, and defect size.
[0085] In this embodiment of the invention, by outputting defect types, defect quantities, and defect sizes, the model provides more comprehensive and accurate information for production and quality management. This not only enhances the automation level of the production process but also provides strong support for subsequent quality optimization, problem tracking, and real-time adjustments, helping to improve overall product quality and production efficiency.
[0086] The beneficial effects of the technical solutions provided in the embodiments of the present invention include at least the following:
[0087] In this embodiment of the invention, GhostHGNetv2 is used to replace the traditional backbone network. A lightweight convolutional method reduces the number of parameters and computational cost, and the Slim-Neck optimization network is introduced to reduce memory consumption. Simultaneously, a shared detail enhancement detection head reduces convolutional computation and improves the fusion capability of multi-scale features. The entire process ensures high accuracy while improving inference speed and computational efficiency, meeting the real-time and resource efficiency requirements of industrial environments.
[0088] Reference manual attached Figure 7 The diagram shows a schematic of the structure of a YOLOV8-based defect detection system for silk fabrics provided in an embodiment of the present invention.
[0089] This invention provides a YOLOv8-based defect detection system 20 for silk fabrics, comprising: a processor 201 and a memory 202;
[0090] The memory 202 stores programs or instructions that can run on the processor 201. When the program or instructions are executed by the processor 201, they implement the steps of the above-described YOLOV8-based silk fabric defect detection method and achieve the same technical effect. To avoid repetition, the present invention will not elaborate further.
[0091] It should be understood that the processor 201 in this embodiment of the invention may be a central processing unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0092] It should also be understood that the memory 202 in the embodiments of the present invention can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate synchronous DRAM (DDR SDRAM), enhanced synchronous DRAM (ESDRAM), synchronous linked DRAM (SLDRAM), and direct rambus RAM (DR RAM).
[0093] The above embodiments can be implemented, in whole or in part, by software, hardware (such as circuits), firmware, or any other combination thereof. When implemented using software, the above embodiments can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more sets of available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium. A semiconductor medium can be a solid-state drive.
[0094] It should be understood that, in various embodiments of the present invention, the order of the above-mentioned process numbers does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0095] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0096] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the devices, apparatuses, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0097] In the several embodiments provided by this invention, it should be understood that the disclosed devices, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0098] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0099] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0100] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0101] This invention provides a readable storage medium comprising: storing a program or instructions on the readable storage medium, wherein when the program or instructions are executed by a processor, the program or instructions implement the steps of the above-described YOLOV8-based silk fabric defect detection method and achieve the same technical effect. To avoid repetition, this invention will not elaborate further.
[0102] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the embodiments of the present invention, and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the protection scope of the present invention.
Claims
1. A method for detecting defects in silk fabrics based on YOLOv8, characterized in that, include: S1: Collect images of defects and images of the silk fabric without defects; S2: Preprocess the defect image and the defect-free image; S3: Construct an improved YOLOV8 model for detecting defects in silk fabrics, wherein the silk fabric defect detection model includes a GhostHGNetv2 feature extraction network, a Slim-Neck feature fusion network, and a shared detail enhancement detection head SDEH; S4: Train the silk fabric defect detection model based on the preprocessed defect images and defect-free images; S5: Acquire an image of the silk fabric to be detected; S6: Input the image of the silk fabric to be detected into the trained silk fabric defect detection model, and output the defect detection result of the silk fabric.
2. The method for detecting defects in silk fabrics based on YOLOv8 according to claim 1, characterized in that, S2 specifically includes: S201: Perform rotational correction processing on the defective image and the defect-free image; S202: Retain the portion of the defect image containing defect features after rotation correction, remove background clutter and edge interference, and form the target defect image; S203: Select Labelimg as the annotation tool, use YOLO data format labels to annotate the flawless image and the target flaw image, and generate a training set.
3. The method for detecting defects in silk fabrics based on YOLOv8 according to claim 2, characterized in that, All images in the training set were uniformly formatted to a size of 1024×1024 pixels and a color depth of 24 bits.
4. The method for detecting defects in silk fabrics based on YOLOv8 according to claim 1, characterized in that, The improved YOLOV8 fabric defect detection model includes an input terminal, a backbone network, a neck network, and a detection head. The backbone network is designed with GhostHGNetv2 as a feature extraction network to reduce the number of parameters and improve the target detection capability. The neck network is designed with the Slim-Neck feature fusion network. By introducing GSConv lightweight convolution, GS Bottleneck and VoVGSCSP modules into the Slim-Neck feature fusion network, the computational load and memory usage are reduced, while ensuring high-precision detection capability. The detection head is designed with the Shared Detail Enhancement Detection Head (SDEH), which reduces the amount of convolution computation between feature maps of different scales by sharing convolution parameters, thereby enhancing the fusion capability of multi-scale feature maps.
5. The method for detecting defects in silk fabrics based on YOLOv8 according to claim 4, characterized in that, The GhostHGNetV2 feature extraction network includes the HGStem module and the Ghost_HGBlock module. The specific workflow of the GhostHGNetV2 feature extraction network includes: The HGStem module performs initial preprocessing on the input image, extracts the basic features of the image, and generates a first feature map. The number of channels in the first feature map is compressed using the 1×1 standard convolution in the Ghost_HGBlock module to generate the second feature map; High-level features are extracted from the second feature map through the depthwise separable convolution in the Ghost_HGBlock module to generate the Ghost feature map; The Ghost feature map and the feature map of the input image are fused to obtain a fused feature map.
6. The method for detecting defects in silk fabrics based on YOLOv8 according to claim 5, characterized in that, By replacing the standard convolution with the depthwise separable convolution, the ratio of the number of parameters of the depthwise separable convolution satisfies: Where DWConv represents the number of parameters in the depthwise separable convolution, Conv represents the number of parameters in the standard convolution, c represents the number of channels in the input feature map, k represents the size of the convolution kernel, and m represents the number of channels in the output feature map.
7. The method for detecting defects in silk fabrics based on YOLOv8 according to claim 4, characterized in that, The Slim-Neck feature fusion network includes a GSConv convolutional module, a GSBottleneck module, and a VoVGSCSP module; the workflow of the Slim-Neck feature fusion network specifically includes: Standard convolution is performed using the GSConv lightweight convolution module; By concatenating the feature maps of standard convolution and depthwise separable convolution on different channels, a concatenated feature map is obtained; A shuffle operation is performed on the stitched feature map to rearrange the features of the standard convolution and depthwise separable convolution, and to evenly distribute the features of the standard convolution into the output channel of the depthwise separable convolution. The GSBottleneck module is used to compress the feature map after the shuffle operation; The VoVGSCSP module aggregates compressed features at different scales to output the final target feature map.
8. The method for detecting defects in silk fabrics based on YOLOv8 according to claim 4, characterized in that, The workflow of the Shared Detail Enhancement Detection Head (SDEH) specifically includes: On the three different scale feature maps P3, P4 and P5 output by the neck network, Group Normalization is used instead of traditional Batch Normalization to divide the input feature maps into multiple groups for normalization. By introducing detail enhancement convolution to construct a shared convolutional layer, the convolutional weights are shared among feature maps of different scales. The semantic and contextual information contained in the feature maps captured by the three detection heads of different scales are fused to generate prediction boxes and classification targets. By using reparameterization techniques, the convolution kernels are readjusted so that convolution operations can be merged and executed in parallel to obtain the output feature map.
9. The method for detecting defects in silk fabrics based on YOLOv8 according to claim 8, characterized in that, The specific formula for the reparameterization technique is as follows: Among them, F out This represents the output feature map, DEConv() represents the detail enhancement convolution, and F... in Indicates the input features, * indicates the convolution operation, and K i Let K represent the i-th convolutional kernel, where i = 1, 2, ..., 5 represent the kernels of VC, CDC, ADC, HDC, and VDC, respectively. cvt This indicates the converted kernel.
10. A defect detection system for silk fabrics based on YOLOv8, characterized in that, include: Processor and memory; The memory stores programs or instructions that can run on the processor, which, when executed by the processor, implement the steps of the YOLOV8-based silk fabric defect detection method as described in any one of claims 1 to 9.